/* Portal layer on top of gap-ui.css. Only what the portal adds; tokens come from gap-ui. */

/* ---------- Shell ---------- */
.side { flex-direction: column; gap: 2px; }
@media (min-width: 861px) { .side { display: flex; } }
.brand-link { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 700; letter-spacing: -0.02em; font-size: var(--t-md); }
.brand-link img { border-radius: 8px; }
.side .brand-link { padding: 4px var(--s3) var(--s5); }
.side-app { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; align-items: center; margin: 0 0 var(--s4); padding: 10px var(--s3); border-radius: 12px; background: var(--bg); }
.side-app > div { min-width: 0; }
.side-app .item-title { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; word-break: break-word; }
.side a.nav svg, .side .nav-btn svg { width: 20px; height: 20px; flex: none; }
.side .nav-btn { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 9px var(--s3); border: 0; border-radius: 10px; background: none; font: 500 var(--t-body)/1.47 var(--font); color: var(--ink-2); cursor: pointer; text-align: left; letter-spacing: -0.012em; }
.side a.nav:hover, .side .nav-btn:hover { background: var(--bg); }
.page-title { font-size: var(--t-2xl); }
.main-body { display: block; }
.topbar .select { width: auto; }
@media (max-width: 860px) {
  .topbar { position: sticky; top: 0; z-index: 30; margin: calc(-1 * max(var(--s5), env(safe-area-inset-top))) calc(-1 * var(--s4)) var(--s5); padding: max(var(--s3), env(safe-area-inset-top)) var(--s4) var(--s3); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); }
  .page-title { font-size: var(--t-xl); }
}

/* ---------- Sign in ---------- */
.auth { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: var(--s8); padding: var(--s10) var(--s4); }
.auth-card { width: min(420px, calc(100vw - 32px)); background: var(--surface); border-radius: 20px; padding: var(--s8) var(--s6); box-shadow: 0 0 0 1px var(--sep), var(--shadow-float); }
.auth-card .btn svg { width: 18px; height: 18px; }
.or { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s3); align-items: center; color: var(--ink-3); font-size: var(--t-sm); }
.or::before, .or::after { content: ""; border-top: 1px solid var(--sep); }

/* ---------- Onboarding ---------- */
.onb { width: min(100% - 32px, 560px); margin-inline: auto; padding: var(--s6) 0 var(--s16); }
.onb-wide { width: min(100% - 32px, 720px); }
.onb-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s4); }
.onb .steps { margin-bottom: var(--s10); }
.onb-body { display: block; }
.price { font: 700 var(--t-lg)/1 var(--font-round); letter-spacing: -0.02em; white-space: nowrap; }
.price .small { font-family: var(--font); font-weight: 500; }
.howto { margin-inline: 0; margin-bottom: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: var(--s4); }
.howto li { counter-increment: step; display: grid; grid-template-columns: 28px 1fr; gap: var(--s3); font-size: var(--t-md); line-height: 1.5; color: var(--ink-2); }
.howto li::before { content: counter(step); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg); font: 700 var(--t-sm)/1 var(--font-round); }
.howto strong { color: var(--ink); }
.drop { display: flex; align-items: center; justify-content: center; min-height: 72px; padding: var(--s4); border-radius: var(--r-field); border: 1.5px dashed var(--sep-strong); background: var(--surface); color: var(--ink-2); font-size: var(--t-md); text-align: center; cursor: pointer; }
.drop:hover, .drop:focus-within { border-color: var(--ink); color: var(--ink); }
.drop:focus-within { box-shadow: 0 0 0 3px var(--measure); }
.security { font-size: var(--t-md); }
.security summary { cursor: pointer; font-weight: 600; }
.security ul { margin: var(--s3) 0 0; padding-left: 18px; display: grid; gap: 6px; }
.progress #pmsg { font-weight: 600; }
.spin { display: inline-block; flex: none; }

/* Switches and radios, iOS style */
.toggle { appearance: none; position: relative; width: 51px; height: 31px; border-radius: 999px; background: rgba(120, 120, 128, 0.32); cursor: pointer; flex: none; margin: 0; transition: background 0.2s var(--ease); }
.toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.2s var(--ease); }
.toggle:checked { background: var(--up); }
.toggle:checked::after { transform: translateX(20px); }
.toggle:disabled { opacity: 0.4; cursor: not-allowed; }
.radio { appearance: none; width: 22px; height: 22px; margin: 2px 0 0; border-radius: 50%; border: 1.5px solid var(--sep-strong); background: var(--surface); cursor: pointer; align-self: start; }
.radio:checked { border: 7px solid var(--ink); }

/* ---------- Free look ---------- */
.wedge { display: grid; grid-template-columns: auto 1fr; gap: var(--s6); align-items: center; padding: var(--s5) var(--s6) var(--s5) var(--s5); border-radius: var(--r-group); background: var(--measure-soft); position: relative; }
.wedge::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 2px; background: var(--measure); }
.wedge-rank { display: grid; gap: 4px; padding-left: var(--s2); }
.wedge-rank .small { color: var(--measure-ink); font-weight: 600; }
.wedge .rank { font-size: clamp(3rem, 9vw, 4.5rem); color: var(--ink); }
.wedge p { font-size: var(--t-md); line-height: 1.5; }
@media (max-width: 520px) { .wedge { grid-template-columns: 1fr; gap: var(--s3); } }

/* ---------- Dashboard ---------- */
.brief { padding: var(--s6); border-radius: var(--r-group); background: var(--surface); box-shadow: 0 0 0 1px var(--sep); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; border-radius: var(--r-group); overflow: hidden; background: var(--sep); box-shadow: 0 0 0 1px var(--sep); }
.stats .stat { background: var(--surface); padding: var(--s4) var(--s5); }
.stats .stat span { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.rank-cell { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .chip-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill); background: var(--surface); box-shadow: inset 0 0 0 1px var(--sep); font-size: var(--t-md); color: var(--ink); }
.chip b { font-family: var(--font-round); }
.chip-btn { appearance: none; border: 0; cursor: pointer; font-family: var(--font); color: var(--ink-3); text-decoration: line-through; }
.chip-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); box-shadow: none; text-decoration: none; }
.btn-x { appearance: none; border: 0; background: none; width: 32px; height: 32px; border-radius: 50%; color: var(--ink-3); font-size: 20px; line-height: 1; cursor: pointer; }
.btn-x:hover { background: var(--surface-2); color: var(--ink); }
@media (max-width: 560px) { .hide-sm { display: none; } }

/* Moves and reply cards */
.move { overflow: visible; }
.move-body { padding: var(--s5); }
.move-actions { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--sep); background: var(--surface-2); border-radius: 0 0 var(--r-group) var(--r-group); }
.move .textarea:not(.code) { font-family: var(--font); font-size: var(--t-md); line-height: 1.45; min-height: 96px; }
.textarea.code { font-size: var(--t-sm); background: var(--surface-2); }
.diff { display: grid; gap: 4px; }
.diff-now, .diff-was { padding: 10px 12px; border-radius: 10px; font-size: var(--t-md); word-break: break-word; }
.diff-now { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--sep); }
.diff.changed .diff-now { background: var(--measure-soft); box-shadow: inset 3px 0 0 var(--measure); }
.diff-was { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--sep-strong); }

/* AI Search */
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--sep); overflow: hidden; }
.meter span { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.bars { display: flex; align-items: flex-end; gap: var(--s3); height: 96px; margin-top: var(--s5); }
.bar { flex: 1; display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; max-width: 64px; }
.bar span { align-self: end; background: var(--ink); border-radius: 6px 6px 2px 2px; min-height: 4px; }
.bar:last-child span { background: var(--measure); }
.bar small { font-size: var(--t-xs); color: var(--ink-3); text-align: center; }
details.item { display: block; }
details.item summary { display: flex; justify-content: space-between; gap: var(--s3); align-items: center; cursor: pointer; list-style: none; }
details.item summary::-webkit-details-marker { display: none; }
details.item[open] summary .item-title { text-decoration: underline; text-decoration-color: var(--measure); text-decoration-thickness: 3px; text-underline-offset: 4px; }

/* Toast sits above the tab bar on phones */
@media (max-width: 860px) { .toast { bottom: calc(88px + env(safe-area-inset-bottom)) !important; } }

/* Plan rows: price beside the text on wide screens, under it on phones */
.plan-ai, .plan-pick { grid-template-columns: auto 1fr auto; }
@media (max-width: 520px) {
  .plan-item { grid-template-columns: 1fr !important; }
  .plan-ai, .plan-pick { grid-template-columns: auto 1fr !important; }
  .plan-ai .price, .plan-pick .price { grid-column: 2; }
}
.conn-item { grid-template-columns: 1fr auto; }
@media (max-width: 560px) { .conn-item { grid-template-columns: 1fr; } .conn-item .row-wrap { justify-content: flex-start !important; } }
.look-card .h2 { margin: 0 0 var(--s3); }
.locked { position: relative; }
.locked .blur { filter: blur(5px); user-select: none; pointer-events: none; }
.locked .unlock { position: absolute; inset: 0; display: grid; place-items: center; }
.progress-steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; font-size: var(--t-md); }
.progress-steps li { display: flex; gap: 10px; align-items: center; color: var(--ink-3); }
.progress-steps li.on { color: var(--ink); font-weight: 600; }
.progress-steps li.done { color: var(--ink-2); }
.progress-steps li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--sep-strong); flex: none; }
.progress-steps li.on::before { border-color: var(--ink); border-right-color: transparent; animation: gap-spin 0.8s linear infinite; }
.progress-steps li.done::before { background: var(--up); border-color: var(--up); }

.firstlook > summary { list-style: none; cursor: pointer; }
.firstlook > summary::-webkit-details-marker { display: none; }

/* ===================== Dashboard v2 =====================
   Bright canvas, crisp white panels, one loud thing: the yellow gap to #1. */
.shell { background: var(--bg); }
.main { max-width: 1240px; margin-inline: auto; padding-inline: clamp(var(--s4), 4vw, var(--s12)); }
@media (min-width: 861px) { .topbar { margin-bottom: var(--s5); } }
:root { --panel-r: 20px; --panel-shadow: 0 1px 2px rgba(28, 28, 30, 0.04), 0 8px 24px -12px rgba(28, 28, 30, 0.12); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --panel-shadow: 0 0 0 1px var(--sep); } }

.dash { display: grid; gap: var(--s6); }
.panel { background: var(--surface); border-radius: var(--panel-r); box-shadow: var(--panel-shadow); padding: var(--s6); min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.panel-head h3 { margin: 0; font-size: var(--t-lg); font-weight: 650; letter-spacing: -0.02em; }
.panel-head a { font-size: var(--t-md); color: var(--ink-2); text-decoration: none; }
.panel-head a:hover { color: var(--ink); text-decoration: underline; }
.panel-foot { margin: var(--s4) 0 0; font-size: var(--t-sm); color: var(--ink-3); line-height: 1.45; }
.pill { min-width: 26px; height: 26px; padding: 0 8px; display: inline-grid; place-items: center; border-radius: 999px; background: var(--measure); color: #1c1c1e; font: 700 var(--t-sm)/1 var(--font-round); }
.empty.compact { padding: var(--s6) var(--s2); }

/* Hero: the week in one sentence, beside the search to win */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s6); align-items: stretch; background: var(--surface); border-radius: 24px; box-shadow: var(--panel-shadow); padding: var(--s8); }
.eyebrow { margin: 0 0 var(--s3); font-size: var(--t-sm); font-weight: 600; color: var(--ink-3); }
.hero-title { margin: 0; font-size: clamp(1.75rem, 3.2vw, 2.5rem); line-height: 1.1; font-weight: 700; letter-spacing: -0.035em; text-wrap: balance; max-width: 22ch; }
.hero-sub { margin: var(--s3) 0 0; font-size: var(--t-body); line-height: 1.5; color: var(--ink-2); max-width: 56ch; }
.hero-steps { margin-top: var(--s6); grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); column-gap: var(--s6); }
.hero-wedge { display: grid; align-content: start; gap: 6px; padding: var(--s5); border-radius: 18px; background: var(--measure-soft); text-decoration: none; color: var(--ink); position: relative; overflow: hidden; }
.hero-wedge:hover { text-decoration: none; box-shadow: inset 0 0 0 2px var(--measure); }
.wedge-label { font-size: var(--t-sm); font-weight: 600; color: var(--measure-ink); }
.wedge-term { font-size: var(--t-lg); font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; }
.wedge-big { font: 700 clamp(3.5rem, 7vw, 5rem)/0.95 var(--font-round); letter-spacing: -0.05em; margin-top: var(--s2); }
.wedge-big sup { font-size: 0.42em; vertical-align: 0.95em; margin-right: 2px; letter-spacing: 0; }
.wedge-ruler { display: block; height: 8px; border-radius: 4px; background: var(--measure); margin-top: var(--s3); overflow: hidden; }
.wedge-ruler span { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.wedge-ends { display: flex; justify-content: space-between; font-size: var(--t-xs); color: var(--measure-ink); opacity: 0.8; }
.wedge-foot { font-size: var(--t-sm); color: var(--measure-ink); font-weight: 600; }
@media (max-width: 960px) { .hero { grid-template-columns: 1fr; padding: var(--s6); } }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); }
.kpi { position: relative; display: grid; gap: 4px; align-content: start; background: var(--surface); border-radius: 16px; box-shadow: var(--panel-shadow); padding: var(--s5) var(--s5) var(--s4); min-height: 120px; overflow: hidden; }
.kpi-top { display: flex; align-items: center; gap: var(--s2); }
.kpi b { font: 700 var(--t-2xl)/1.05 var(--font-round); letter-spacing: -0.035em; }
.kpi > span { font-size: var(--t-sm); color: var(--ink-3); line-height: 1.35; max-width: 22ch; }
.kpi-line { position: absolute; left: var(--s5); right: var(--s5); bottom: var(--s3); height: 28px; color: var(--ink); opacity: 0.22; max-width: none !important; }
.kpi:has(.spark) { padding-bottom: 48px; }
.spark { width: 100%; height: 100%; display: block; }
@media (max-width: 960px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Two columns */
.dash-cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: var(--s6); align-items: start; }
.dash-side { display: grid; gap: var(--s6); }
@media (max-width: 1060px) { .dash-cols { grid-template-columns: 1fr; } }

/* Gap bars: each search on a log track from #1 to 200+ */
.gap-scale, .gap-row { display: grid; grid-template-columns: minmax(120px, 1.1fr) minmax(0, 1.6fr) 96px; gap: var(--s4); align-items: center; }
.gap-scale { font-size: var(--t-xs); color: var(--ink-3); padding-bottom: var(--s3); }
.gap-ticks { position: relative; height: 14px; }
.gap-ticks i { position: absolute; top: 0; font-style: normal; transform: translateX(-50%); white-space: nowrap; }
.gap-ticks i:first-child { transform: none; }
.gap-ticks i:last-child { transform: translateX(-100%); }
.gap-row { padding: 11px 0; border-top: 1px solid var(--sep); }
.gap-term { font-size: var(--t-md); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gap-track { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--sep); }
.gap-fill { position: absolute; top: 0; bottom: 0; right: 0; border-radius: 5px; background: var(--measure); }
.gap-dot { position: absolute; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--surface); box-shadow: 0 0 0 3px var(--ink), 0 2px 6px rgba(0, 0, 0, 0.2); }
.gap-dot.top { box-shadow: 0 0 0 3px var(--up), 0 2px 6px rgba(0, 0, 0, 0.2); }
.gap-rank { justify-self: end; }
@media (max-width: 560px) {
  .gap-row { grid-template-columns: 1fr auto; row-gap: 8px; }
  .gap-track { grid-column: 1 / -1; grid-row: 2; }
  .gap-scale { display: none; }
}

/* Waiting on you */
.actions { display: grid; gap: var(--s2); }
.action { display: grid; gap: 3px; padding: var(--s4); border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--sep); text-decoration: none; color: var(--ink); transition: box-shadow 0.15s var(--ease), transform 0.15s var(--ease); }
.action:hover { text-decoration: none; box-shadow: inset 0 0 0 1.5px var(--ink); }
.action-kind { font-size: var(--t-xs); font-weight: 700; color: var(--ink-3); }
.action-kind.paste { color: var(--measure-ink); }
.action.warn { background: var(--down-soft); }
.action-title { font-size: var(--t-md); font-weight: 650; line-height: 1.3; letter-spacing: -0.01em; }
.action-sub { font-size: var(--t-sm); color: var(--ink-3); line-height: 1.4; }

/* Activity timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; }
.timeline li { display: grid; grid-template-columns: 1fr auto; gap: var(--s3); padding: 10px 0 10px 18px; position: relative; font-size: var(--t-md); line-height: 1.4; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--sep-strong); }
.timeline li::after { content: ""; position: absolute; left: 3px; top: 28px; bottom: -6px; width: 1px; background: var(--sep); }
.timeline li:last-child::after { display: none; }
.timeline li:first-child::before { background: var(--measure); }
.timeline time { font-size: var(--t-sm); color: var(--ink-3); white-space: nowrap; }

.panel.firstlook > summary { margin: 0; cursor: pointer; list-style: none; }
.panel.firstlook > summary::-webkit-details-marker { display: none; }

/* Manual delivery */
.choice-note { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4); border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--sep); font-size: var(--t-md); line-height: 1.45; }
.choice-note > div { flex: 1 1 280px; }
.paste-field { display: grid; gap: 6px; }
.paste-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s2); align-items: stretch; }
.paste-row .diff-now { margin: 0; }
