:root {
  --page: #f4f1ea;
  --card: #ffffff;
  --ink: #1d2420;
  --ink-2: #5c6660;
  --hairline: #ddd7c9;
  --teal: #2f7a5c;
  --teal-soft: #a9cdb6;
  --red: #c0392b;
  --dark: #20251f;
  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--page); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.45; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px 12px 48px; }
.card { background: var(--card); border-radius: 16px; padding: 22px 18px 28px; box-shadow: 0 1px 4px rgba(30,40,35,0.06); }
@media (min-width: 640px) { .card { padding: 30px 32px 36px; } .wrap { padding-top: 28px; } }

.display { font-family: var(--font-display); font-size: 30px; line-height: 1.15; letter-spacing: -0.02em; margin: 4px 0 10px; }
.intro { color: var(--ink); font-size: 15px; line-height: 1.5; margin: 0 0 14px; }
.header-fact { font-family: var(--font-display); font-size: 17px; margin: 0 0 8px; }
.header-fact.known { color: var(--teal); }
.header-fact.unknown { color: var(--red); }
.caption { color: var(--ink-2); font-size: 13px; line-height: 1.4; margin: 8px 0 0; }
.closing { color: var(--ink-2); font-size: 13px; text-align: center; margin: 22px 0 0; }

/* Buttons */
.btn { font: inherit; font-size: 15px; font-weight: 600; border-radius: 10px; padding: 10px 16px; min-height: 44px; cursor: pointer; border: 1px solid var(--hairline); background: #fff; color: var(--ink); transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
.btn.primary { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn.secondary { background: #fff; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:not(:disabled):active { transform: scale(0.98); }
button.tapped { background-color: var(--teal) !important; color: #fff !important; border-color: var(--teal) !important; }

/* Choice rows */
.choice-block { margin: 14px 0 6px; }
.choice-label { display: block; color: var(--ink-2); font-size: 12px; margin-bottom: 6px; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-row button { font: inherit; font-size: 14px; font-weight: 600; border: 1px solid var(--hairline); background: #fff; border-radius: 8px; padding: 9px 14px; min-height: 44px; cursor: pointer; color: var(--ink); transition: background-color .15s ease, color .15s ease; }
.choice-row button.selected { background: var(--teal-soft); border-color: var(--teal-soft); color: #17352a; }

/* Verdict */
.verdict { border: 1px solid var(--hairline); border-radius: 8px; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; margin: 14px 0 4px; }
.verdict-word { font-family: var(--font-display); font-size: 28px; line-height: 1.2; letter-spacing: -0.025em; }
.verdict-word.deal { color: var(--teal); }
.verdict-word.nodeal { color: var(--red); }
.verdict-word.idle { color: var(--ink-2); }
.verdict-why { color: var(--ink-2); font-size: 14px; line-height: 20px; }
.verdict-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 24px; }
@media (min-width: 640px) { .verdict-grid { grid-template-columns: repeat(4, 1fr); } }
.verdict-cell .v-label { display: block; color: var(--ink-2); font-size: 12px; line-height: 18px; }
.verdict-cell .v-value { display: block; font-weight: 600; font-size: 16px; line-height: 22px; }
.verdict-cell .v-value.known { color: var(--teal); }
.verdict-cell .v-value.bad { color: var(--red); }
.verdict.glow-deal { border: 1px solid var(--teal); box-shadow: 0 0 0 1px var(--teal), 0 6px 28px rgba(47,122,92,0.35); }
.verdict.glow-nodeal { border: 1px solid var(--red); box-shadow: 0 0 0 1px var(--red), 0 6px 28px rgba(192,57,43,0.30); }

/* Groups + fields */
.group { margin-top: 22px; display: flex; flex-direction: column; gap: 12px; }
.group-label { font-family: var(--font-display); font-size: 21px; margin: 0; letter-spacing: -0.01em; }
.f-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
@media (min-width: 640px) { .f-grid { grid-template-columns: repeat(3, 1fr); } }
.f-grid.one { grid-template-columns: 1fr; }
label.f, .f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.f-label { color: var(--ink-2); font-size: 12px; line-height: 16px; }
.f-box { display: flex; align-items: baseline; border: 1px solid var(--hairline); border-radius: 4px; padding: 0 10px; min-height: 44px; background: var(--page); }
.f-box:focus-within { border-color: var(--teal); }
.f-affix { color: var(--ink-2); font-size: 14px; }
.f-box input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; padding: 10px 2px; }
.f-hint { color: var(--ink-2); font-size: 12px; line-height: 16px; }
.f-box.f-static { background: transparent; border-style: dashed; }
.f-static-val { font-weight: 600; font-size: 16px; padding: 10px 2px; color: var(--ink); }
.slider-f { margin-bottom: 4px; }
.slider { width: 100%; accent-color: var(--teal); height: 32px; }

/* Research paste */
.research-block { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--hairline); display: flex; flex-direction: column; gap: 8px; }
.research-paste { width: 100%; border: 0; background: transparent; font: inherit; resize: vertical; min-height: 60px; outline: none; }

/* Comps */
.comp-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.comp-row { display: grid; grid-template-columns: 1.4fr 1fr 0.7fr 0.8fr 0.8fr 0.9fr; gap: 10px; align-items: end; }
.comp-psf { color: var(--ink-2); font-size: 13px; line-height: 44px; white-space: nowrap; }
@media (max-width: 560px) {
  .comp-row { grid-template-columns: 1fr 1fr; }
  .comp-psf { line-height: 18px; }
}
.comp-head { display: grid; grid-template-columns: 1.4fr 1fr 0.7fr 0.8fr 0.8fr 0.9fr; gap: 10px; color: var(--ink-2); font-size: 12px; }
@media (max-width: 560px) { .comp-head { display: none; } }
.comp-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.comp-psf-wrap { display: flex; align-items: center; gap: 4px; }

/* Rooms */
.room { border: 1px solid var(--hairline); border-radius: 8px; background: #fff; }
.room + .room { margin-top: 8px; }
.room summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 12px 14px; font-weight: 600; min-height: 44px; box-sizing: border-box; }
.room summary::-webkit-details-marker { display: none; }
.room summary::after { content: ''; width: 8px; height: 8px; border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2); transform: rotate(45deg); transition: transform 0.15s; }
.room[open] summary::after { transform: rotate(225deg); }
.room-sub { margin-left: auto; color: var(--ink-2); font-weight: 400; }
.room-sub.has { color: var(--teal); font-weight: 600; }
.room-body { padding: 2px 14px 14px; }
.room-static-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 2px; font-weight: 600; min-height: 44px; box-sizing: border-box; }
.room-static-hint { color: var(--ink-2); font-size: 12px; line-height: 16px; padding: 0 14px 12px; }
.custom-items { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.custom-row { display: flex; gap: 8px; align-items: flex-start; }
.custom-row .f { margin: 0; }
.custom-name { flex: 1.4; min-width: 0; }
.custom-cost { flex: 1; min-width: 0; }
.custom-del { flex: none; width: 34px; height: 34px; margin-top: 1px; border: 1px solid var(--hairline); border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 18px; line-height: 1; cursor: pointer; }
.custom-del:hover { color: var(--red); border-color: var(--red); }

/* Analyses */
.analyses-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.home-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.home-card { border: 1px solid var(--hairline); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.home-card:active { border-color: var(--teal); }
.home-top { display: flex; align-items: center; gap: 8px; }
.home-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.home-chip { flex: none; font-size: 11px; font-weight: 700; line-height: 1; padding: 4px 8px; border-radius: 999px; border: 1px solid currentColor; }
.home-chip.deal { color: var(--teal); }
.home-chip.nodeal { color: var(--red); }
.home-chip.idle { color: var(--ink-2); }
.home-stats { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; }
.home-stats b { color: var(--ink); font-weight: 600; }
.home-strat { flex: none; font-size: 11px; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.saved-date { color: var(--ink-2); font-size: 12px; }

/* Callout */
.callout { margin-top: 22px; border: 1px solid var(--hairline); border-left: 3px solid var(--teal); border-radius: 8px; padding: 12px 14px; color: var(--ink-2); font-size: 13.5px; line-height: 1.5; }

/* Brand + strategy visual */
.brand-tag { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 12px; }
.brand-tag img { height: 30px; width: auto; border-radius: 7px; display: block; }
.brand-tag span { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; opacity: 0.72; }
.strategy-visual { position: relative; border-radius: 18px; overflow: hidden; margin: 6px 0 2px; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; box-shadow: 0 2px 10px rgba(30,50,40,0.12); }
.strategy-visual img.sv-cur { display: block; width: 100%; height: auto; animation: sv-in 0.5s ease both; }
.strategy-visual img.sv-prev { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
@keyframes sv-in { from { opacity: 0; transform: scale(1.02); } to { opacity: 1; transform: scale(1); } }
.strategy-visual.boing img.sv-cur { animation: sv-boing 0.55s ease; }
@keyframes sv-boing { 0% { transform: scale(1); } 30% { transform: scale(1.05) rotate(-1.2deg); } 60% { transform: scale(0.98) rotate(1deg); } 100% { transform: scale(1); } }
.strategy-visual.celebrating img.sv-cur { animation: sv-party 0.7s ease; }
@keyframes sv-party { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }

/* Full-screen verdict effects (standalone app = top document, fixed covers the screen) */
.confetti-bit { position: absolute; top: -14px; border-radius: 2px; opacity: 0; }
.confetti-bit.c0 { background: #2f7a5c; }
.confetti-bit.c1 { background: #f2b134; }
.confetti-bit.c2 { background: #e07a4f; }
.confetti-bit.c3 { background: #7fb685; }
.confetti-bit.c4 { background: #f7ead1; }
.fx-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden; }
.fx-confetti .confetti-bit { animation: confetti-fall-screen 2.4s ease-in forwards; }
@keyframes confetti-fall-screen {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translateY(110vh) rotate(400deg); opacity: 0; }
}
.fx-redflash { position: fixed; inset: 0; pointer-events: none; z-index: 9998; background: rgba(196,45,45,0.30); animation: fx-redflash 0.85s ease-out forwards; }
@keyframes fx-redflash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- auth & sync ---------- */
.auth-bar { display: flex; justify-content: flex-end; align-items: center; gap: 10px; min-height: 28px; margin-bottom: 8px; }
.auth-link { background: none; border: none; color: #2f7a5c; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 4px 2px; text-decoration: underline; text-underline-offset: 3px; }
.auth-email { font-size: 13px; color: #5c5648; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal { position: fixed; inset: 0; background: rgba(43, 38, 28, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.modal[hidden] { display: none; }
.modal-card { background: #fdfbf6; border-radius: 14px; box-shadow: 0 12px 40px rgba(43, 38, 28, 0.25); max-width: 400px; width: 100%; padding: 24px 22px; position: relative; }
.modal-close { position: absolute; top: 10px; right: 12px; background: none; border: none; font-size: 26px; line-height: 1; color: #8a8271; cursor: pointer; }
.modal-title { font-size: 22px; margin: 0 0 8px; }
.modal-divider { display: flex; align-items: center; gap: 12px; color: #8a8271; font-size: 13px; margin: 14px 0; }
.modal-divider::before, .modal-divider::after { content: ''; flex: 1; border-top: 1px solid #ddd5c4; }
.google-wrap { margin: 14px 0 0; }
.google-wrap #google-btn { display: flex; justify-content: center; min-height: 44px; }
.modal-label { display: block; font-size: 13px; font-weight: 600; color: #5c5648; margin: 12px 0 4px; }
.modal-input { width: 100%; box-sizing: border-box; padding: 10px 12px; font: inherit; border: 1px solid #d8d0be; border-radius: 8px; background: #fff; }
.modal-input:focus { outline: 2px solid #2f7a5c; outline-offset: 1px; }
.modal-btn { width: 100%; margin-top: 12px; }
.auth-note { font-size: 14px; margin: 12px 0 0; color: #2f7a5c; }
.auth-note.error { color: #b3402e; }
