:root {
  color-scheme: dark;
  --bg: #061718;
  --bg-elevated: #0a2222;
  --surface: #0d2929;
  --surface-2: #123535;
  --surface-3: #17423f;
  --text: #f4fbf8;
  --text-soft: #d7e8e3;
  --muted: #acc8c1;
  --border: #2c5954;
  --border-strong: #3b746d;
  --accent: #3ee6ad;
  --accent-hover: #78f0c8;
  --accent-ink: #03241b;
  --accent-soft: #103f35;
  --gold: #f3cf72;
  --gold-soft: #41351b;
  --danger: #ff858d;
  --danger-soft: #4a1f25;
  --warning: #ffd56a;
  --warning-soft: #45381b;
  --info: #82c8ff;
  --info-soft: #17364d;
  --shadow: 0 18px 60px rgba(0, 0, 0, .28);
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, .2);
  --radius: 18px;
  --radius-sm: 12px;
  --sidebar-width: 280px;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f8f6;
  --bg-elevated: #e9f3f0;
  --surface: #ffffff;
  --surface-2: #eef7f4;
  --surface-3: #dfeeea;
  --text: #102421;
  --text-soft: #28443e;
  --muted: #506b65;
  --border: #c4d9d3;
  --border-strong: #91b5ac;
  --accent: #006a52;
  --accent-hover: #004f3d;
  --accent-ink: #ffffff;
  --accent-soft: #d9f2e9;
  --gold: #805d00;
  --gold-soft: #fff2cc;
  --danger: #a4202c;
  --danger-soft: #fde8ea;
  --warning: #755500;
  --warning-soft: #fff3ca;
  --info: #005d99;
  --info-soft: #e3f2fd;
  --shadow: 0 18px 50px rgba(19, 57, 48, .12);
  --shadow-sm: 0 8px 24px rgba(19, 57, 48, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
button, a { -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.07; letter-spacing: -.045em; }
h2 { font-size: clamp(1.35rem, 2.4vw, 2rem); line-height: 1.18; letter-spacing: -.025em; }
h3 { font-size: 1.08rem; line-height: 1.3; }
p { color: var(--text-soft); }
small, .muted { color: var(--muted); }

.skip-link { position: fixed; top: -100px; left: 1rem; z-index: 9999; background: var(--accent); color: var(--accent-ink); padding: .8rem 1rem; border-radius: 8px; font-weight: 800; }
.skip-link:focus { top: 1rem; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.app-shell.public-shell { grid-template-columns: minmax(0, 1fr); }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; overflow-y: auto; background: linear-gradient(180deg, var(--surface), var(--bg-elevated)); border-right: 1px solid var(--border); padding: 1.1rem; z-index: 60; }
.page-frame { grid-column: 2; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.public-shell .page-frame { grid-column: 1; }
.brand { display: flex; align-items: center; gap: .8rem; color: var(--text); text-decoration: none; padding: .6rem; border-radius: 14px; }
.brand:hover { color: var(--text); background: var(--surface-2); }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; border-radius: 14px; background: linear-gradient(135deg, var(--accent), var(--gold)); color: var(--accent-ink); font-size: 1.35rem; box-shadow: var(--shadow-sm); }
.brand span:last-child { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: .98rem; line-height: 1.2; }
.brand small { margin-top: .2rem; font-size: .72rem; }
.brand.compact { padding: 0; }
.nav-list { display: flex; flex-direction: column; gap: .25rem; margin-top: 1.4rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; min-height: 44px; padding: .67rem .75rem; border-radius: 11px; color: var(--text-soft); text-decoration: none; font-size: .92rem; font-weight: 650; border: 1px solid transparent; }
.nav-item span { width: 1.3rem; text-align: center; }
.nav-item:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); border-color: var(--border-strong); box-shadow: inset 3px 0 0 var(--accent); }
.nav-section { margin: 1rem .75rem .3rem; font-size: .68rem; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.sidebar-footer { margin-top: auto; padding: 1rem .6rem .2rem; border-top: 1px solid var(--border); display: grid; gap: .55rem; }
.sidebar-footer a { color: var(--muted); font-size: .8rem; text-decoration: none; }
.sidebar-footer a:hover { color: var(--text); }

/* An opaque sticky header keeps scrolled headings and cards from showing
   through the navigation layer. */
.topbar { min-height: 72px; position: sticky; top: 0; z-index: 50; isolation: isolate; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem clamp(1rem, 3vw, 2.2rem); background: var(--bg); border-bottom: 1px solid var(--border); box-shadow: 0 10px 24px color-mix(in srgb, var(--bg) 28%, transparent); }
.topbar-left, .topbar-actions { display: flex; align-items: center; gap: .75rem; }
.topbar-actions { justify-content: flex-end; }
.theme-toggle, .icon-button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 40px; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); cursor: pointer; font-weight: 700; }
.theme-toggle:hover, .icon-button:hover { border-color: var(--accent); background: var(--surface-2); }
.user-chip { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.user-chip > span:last-child { display: flex; flex-direction: column; max-width: 180px; min-width: 0; }
.user-chip strong, .user-chip small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border-strong); font-weight: 900; }
.inline-form { display: inline; margin: 0; }
.main-content { width: min(1500px, 100%); margin: 0 auto; flex: 1; padding: clamp(1.2rem, 3.5vw, 2.5rem); }
.footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.2rem clamp(1rem, 3vw, 2.2rem); border-top: 1px solid var(--border); color: var(--muted); font-size: .75rem; }

.button { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 42px; padding: .66rem 1rem; border-radius: 11px; border: 1px solid transparent; text-decoration: none; font-weight: 800; line-height: 1.1; cursor: pointer; transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease; }
.button:hover { transform: translateY(-1px); text-decoration: none; }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 75%, white); outline-offset: 2px; }
.button.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 20%, transparent); }
.button.primary:hover { background: var(--accent-hover); color: var(--accent-ink); }
.button.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.button.secondary:hover { border-color: var(--accent); background: var(--surface-3); }
.button.ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.button.ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.button.danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.button.small { min-height: 36px; padding: .5rem .72rem; font-size: .82rem; }
.button.large { min-height: 50px; padding: .85rem 1.25rem; }
.button.full { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }

.alert { display: flex; align-items: flex-start; gap: .65rem; margin-bottom: 1.2rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
.alert.success { border-color: var(--accent); background: var(--accent-soft); }
.alert.danger { border-color: var(--danger); background: var(--danger-soft); }
.alert.warning { border-color: var(--warning); background: var(--warning-soft); }
.alert.info { border-color: var(--info); background: var(--info-soft); }

.eyebrow { display: inline-block; margin-bottom: .45rem; color: var(--accent); font-weight: 850; font-size: .72rem; letter-spacing: .09em; text-transform: uppercase; }
.accent-text { color: var(--accent); }
.lead { font-size: clamp(1.05rem, 1.7vw, 1.25rem); max-width: 780px; }
.lead-sm { font-size: 1.05rem; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1.3rem; margin-bottom: 1.5rem; }
.page-heading h1 { margin-bottom: .55rem; font-size: clamp(2rem, 3.8vw, 3rem); }
.page-heading p { max-width: 820px; margin-bottom: 0; }
.section-heading { max-width: 820px; margin: 0 auto 1.7rem; text-align: center; }
.section-heading.left { margin-left: 0; text-align: left; }
.section-block { padding: clamp(2.5rem, 6vw, 5rem) 0; }
.panel, .narrow-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: clamp(1rem, 2.5vw, 1.5rem); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.panel-head h2 { margin-bottom: 0; }
.narrow-page { max-width: 600px; margin: 3rem auto; }
.narrow-card { max-width: 720px; margin: 0 auto; }
.center { text-align: center; }

.hero { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(360px, .95fr); align-items: center; gap: clamp(2rem, 6vw, 5rem); min-height: 650px; padding: clamp(1.5rem, 5vw, 4.5rem) 0; }
.main-content.public-page { padding-top: clamp(.75rem, 1vw, 1rem); }
.public-hero { align-items: start; padding-top: clamp(.5rem, .75vw, .75rem); }
.public-hero .hero-visual { place-items: start center; padding-top: .55rem; }
.public-hero h1 { max-width: 850px; font-size: clamp(2.6rem, 6vw, 5.3rem); }
.hero-copy .button-row { margin: 1.5rem 0; }
.trust-row { display: flex; flex-wrap: wrap; gap: .7rem 1.2rem; color: var(--muted); font-size: .82rem; font-weight: 650; }
.hero-visual { position: relative; min-height: 480px; display: grid; place-items: center; }
/* Keep the portfolio surface level so its upper-right status badge aligns
   precisely with the page header and card edges. */
.visual-card { width: min(100%, 510px); background: linear-gradient(155deg, var(--surface-2), var(--surface)); border: 1px solid var(--border-strong); border-radius: 28px; padding: 1.4rem; box-shadow: var(--shadow); }
.visual-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.visual-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .45rem; margin-left: auto; }
.status-pill { display: inline-flex; align-items: center; width: fit-content; padding: .3rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid var(--border-strong); font-size: .72rem; font-weight: 850; }
.status-pill.negative { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.score-ring { width: 132px; height: 132px; margin: 2rem auto; border-radius: 50%; display: grid; place-items: center; align-content: center; background: radial-gradient(circle, var(--surface) 58%, transparent 60%), conic-gradient(var(--accent) 0 87%, var(--surface-3) 87% 100%); }
.score-ring span { font-size: 2.25rem; line-height: 1; font-weight: 900; }
.score-ring small { margin-top: .25rem; }
.score-ring.large { width: 180px; height: 180px; background: radial-gradient(circle, var(--surface) 58%, transparent 60%), conic-gradient(var(--accent) 0 78%, var(--surface-3) 78% 100%); }
.score-ring.large span { font-size: 3rem; }
.mini-bars { display: grid; gap: .55rem; }
.mini-bars i { display: block; width: var(--w); height: 9px; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--gold)); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-top: 1.2rem; }
.metric-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-grid > div { min-width: 0; padding: .85rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.metric-grid small, .metric-grid strong { display: block; }
.metric-grid strong { margin-top: .25rem; font-size: 1.1rem; word-break: break-word; }
.floating-card { position: absolute; padding: .7rem .9rem; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); font-size: .82rem; font-weight: 800; }
.fc-one { top: 9%; left: -2%; transform: rotate(-3deg); }
.fc-two { right: -2%; bottom: 12%; transform: rotate(3deg); }
.fc-three { left: 5%; bottom: 2%; }
.stats-band { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.stats-band div { padding: 1.2rem; text-align: center; border-right: 1px solid var(--border); }
.stats-band div:last-child { border-right: 0; }
.stats-band strong, .stats-band span { display: block; }
.stats-band strong { font-size: 1.65rem; color: var(--accent); }
.stats-band span { color: var(--muted); font-size: .8rem; }
.feature-grid, .action-grid, .case-grid, .plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.feature-card, .action-card, .case-card, .plan-card { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow-sm); }
.feature-card { transition: transform .2s ease, border-color .2s ease; }
.feature-card:hover { transform: translateY(-4px); border-color: var(--accent); }
.feature-icon { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 15px; margin-bottom: 1rem; background: var(--accent-soft); border: 1px solid var(--border-strong); font-size: 1.45rem; }
.cta-panel { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: clamp(1.5rem, 4vw, 2.7rem); background: linear-gradient(135deg, var(--accent-soft), var(--surface)); border: 1px solid var(--border-strong); border-radius: 24px; }
.cta-panel h2 { max-width: 800px; }

.auth-layout { display: grid; grid-template-columns: 1fr minmax(360px, 520px); align-items: center; gap: clamp(2rem, 7vw, 6rem); min-height: calc(100vh - 190px); }
.auth-story { padding: 2rem 0; }
.auth-story h1 { max-width: 760px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: clamp(1.25rem, 4vw, 2rem); box-shadow: var(--shadow); }
.card-heading { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.3rem; }
.card-heading .feature-icon { margin: 0; flex: 0 0 50px; }
.card-heading h1, .card-heading h2, .card-heading p { margin-bottom: .2rem; }
.quote-card, .example-box { margin-top: 1.4rem; padding: 1.2rem; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--gold); border-radius: 12px; color: var(--text-soft); }
.stack-form { display: grid; gap: 1rem; }
.stack-form.compact-form { margin-top: .85rem; gap: .7rem; }
label { display: grid; gap: .38rem; color: var(--text); font-weight: 750; font-size: .86rem; }
label small { font-weight: 500; }
input, select, textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--bg-elevated); color: var(--text); padding: .72rem .82rem; line-height: 1.35; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
textarea { resize: vertical; min-height: 90px; }
select { cursor: pointer; }
input[type="range"] { padding: 0; accent-color: var(--accent); }
output { color: var(--accent); font-weight: 900; }
.checkbox-row { display: flex; grid-template-columns: auto 1fr; align-items: flex-start; gap: .65rem; font-weight: 550; }
.checkbox-row input { width: 18px; height: 18px; flex: 0 0 18px; margin-top: .15rem; accent-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-note, .notice-banner, .insight-box, .source-note, .dev-notice { padding: .85rem 1rem; border-radius: 11px; background: var(--info-soft); border: 1px solid var(--info); color: var(--text-soft); font-size: .84rem; }
.notice-banner { margin-bottom: 1.2rem; }
.insight-box { margin-top: 1rem; background: var(--accent-soft); border-color: var(--border-strong); }
.dev-notice { display: grid; gap: .4rem; margin-top: 1rem; border-style: dashed; }
.form-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .8rem; margin-top: 1rem; font-size: .84rem; }
.check-list { padding: 0; list-style: none; display: grid; gap: .6rem; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-card { display: flex; align-items: center; gap: .9rem; padding: 1.15rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat-card > span { display: grid; place-items: center; width: 45px; height: 45px; flex: 0 0 45px; border-radius: 13px; background: var(--accent-soft); font-size: 1.25rem; }
.stat-card small, .stat-card strong { display: block; }
.stat-card strong { font-size: 1.6rem; }
.quick-actions { margin: 1.5rem 0; }
.action-card { display: block; color: var(--text); text-decoration: none; transition: transform .2s ease, border-color .2s ease; }
.action-card:hover { color: var(--text); transform: translateY(-3px); border-color: var(--accent); }
.action-card > span { font-size: 1.7rem; }
.action-card b { color: var(--accent); font-size: .84rem; }
.admin-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-layout { align-items: start; }
.insight-panel { position: sticky; top: 94px; }
.list-stack { display: grid; }
.list-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; padding: .8rem 0; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: 0; }
.list-row small, .list-row strong { display: block; }
.list-row time { color: var(--muted); font-size: .75rem; }
.list-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); }
.timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: .8rem; }
.timeline li { display: flex; gap: .8rem; }
.timeline li > span { display: grid; place-items: center; width: 30px; height: 30px; flex: 0 0 30px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.timeline small, .timeline strong { display: block; }

.factor-list { display: grid; gap: .35rem; }
.factor-list > div { display: flex; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.factor-list > div:last-child { border-bottom: 0; }
.factor-list > div > span { font-size: 1.25rem; }
.factor-list small, .factor-list strong { display: block; }
.summary-strip { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.2rem; }
.summary-strip span, .count-badge, .code-chip { display: inline-flex; align-items: center; padding: .42rem .7rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); font-size: .78rem; font-weight: 750; }
.idea-list { display: grid; gap: 1.2rem; }
.idea-card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: clamp(1rem, 3vw, 1.6rem); box-shadow: var(--shadow-sm); }
.idea-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.idea-title { display: flex; gap: 1rem; }
.idea-emoji { font-size: 2.2rem; }
.fit-score { display: grid; place-items: center; min-width: 90px; padding: .8rem; border-radius: 15px; background: var(--accent-soft); border: 1px solid var(--border-strong); text-align: center; }
.fit-score strong { font-size: 1.8rem; }
.fit-score small { font-size: .68rem; }
.idea-details { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1rem; margin: 1rem 0; }
.idea-details > div { padding: 1rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
details { margin: 1rem 0; padding: .8rem 1rem; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-elevated); }
summary { cursor: pointer; color: var(--text); font-weight: 800; }
.score-bars { display: grid; gap: .65rem; margin-top: 1rem; }
.score-bars > div { display: grid; grid-template-columns: minmax(130px, 1fr) minmax(140px, 3fr) 44px; align-items: center; gap: .7rem; }
progress { width: 100%; height: 10px; accent-color: var(--accent); }

.table-wrap, .scenario-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.scenario-table-wrap { margin: 1rem 0; }
.data-table { width: 100%; border-collapse: collapse; min-width: 680px; background: var(--surface); }
.data-table th, .data-table td { padding: .78rem .85rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table th { background: var(--surface-2); color: var(--text); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
.data-table td { color: var(--text-soft); font-size: .86rem; }
.data-table tr:last-child td { border-bottom: 0; }
.result-panel { min-height: 420px; }
.scenario-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.scenario-card { padding: 1rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.scenario-card.base { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.scenario-card.optimistic { border-color: var(--gold); }
.scenario-label { display: inline-block; margin-bottom: .7rem; font-weight: 850; color: var(--accent); }
.scenario-card > strong { display: block; font-size: 1.7rem; }
.scenario-card > small { display: block; margin-bottom: 1rem; }
dl { margin: 0; }
dl div { display: flex; justify-content: space-between; gap: .6rem; padding: .38rem 0; border-bottom: 1px solid var(--border); font-size: .78rem; }
dl div:last-child { border-bottom: 0; }
dt { color: var(--muted); }
dd { margin: 0; font-weight: 750; color: var(--text); }
.result-hero { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; padding: 1.2rem; border-radius: 15px; background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); border: 1px solid var(--border-strong); }
.result-hero > strong { font-size: clamp(2.2rem, 5vw, 3.7rem); }
.formula-box { margin-top: 1rem; padding: 1rem; border-radius: 12px; background: var(--bg-elevated); border: 1px solid var(--border); }
.formula-box strong, .formula-box code { display: block; }
.formula-box code { margin-top: .5rem; color: var(--gold); white-space: normal; }
.range-grid { display: grid; gap: .95rem; }
.range-label { grid-template-columns: minmax(140px, 1fr) minmax(150px, 2fr) 40px; align-items: center; }
.score-hero { text-align: center; }

.filter-panel { margin-bottom: 1rem; }
.filter-form { display: grid; grid-template-columns: 2fr 1fr 1.4fr 1fr auto auto; align-items: end; gap: .75rem; }
.case-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.case-card, .plan-card { display: flex; flex-direction: column; }
.case-card h2, .plan-card h2 { font-size: 1.22rem; }
.case-card p, .plan-card p { flex: 1; }
.case-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; color: var(--muted); font-size: .75rem; }
.difficulty { display: inline-flex; padding: .25rem .5rem; border-radius: 999px; border: 1px solid var(--border); font-size: .7rem; font-weight: 800; }
.difficulty.beginner { color: var(--accent); background: var(--accent-soft); }
.difficulty.intermediate { color: var(--warning); background: var(--warning-soft); }
.difficulty.advanced { color: var(--danger); background: var(--danger-soft); }
.case-location { margin: .7rem 0; color: var(--muted); font-size: .8rem; }
.case-actions { display: flex; gap: .6rem; margin-top: auto; }
.case-actions form { flex: 1; }
.case-actions .button { width: 100%; }
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1rem; }
.pagination > div { display: flex; gap: .5rem; }
.case-detail-layout { grid-template-columns: minmax(0, 1.35fr) minmax(330px, .65fr); align-items: start; }
.numbered-list { display: grid; gap: .55rem; padding-left: 1.3rem; }
.metric-list { display: grid; }
.metric-list > div { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.metric-list span { color: var(--muted); font-size: .82rem; }
.block-gap { margin-top: 1.5rem; }
.source-note { margin-top: 1rem; }
.plan-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.plan-footer { display: flex; justify-content: space-between; align-items: center; gap: .7rem; margin-top: auto; }
.plan-form { display: grid; gap: 1rem; }
.plan-form .panel label + label { margin-top: 1rem; }
.json-view { max-height: 360px; overflow: auto; padding: 1rem; border-radius: 12px; background: var(--bg-elevated); color: var(--gold); border: 1px solid var(--border); font-size: .78rem; }
.sticky-actions { position: sticky; bottom: .8rem; z-index: 20; display: flex; flex-wrap: wrap; gap: .65rem; align-items: center; padding: .8rem; border: 1px solid var(--border-strong); border-radius: 15px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); box-shadow: var(--shadow); }
.experiment-list { display: grid; gap: .8rem; max-height: 900px; overflow-y: auto; padding-right: .2rem; }
.experiment-card { padding: 1rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; }

.admin-list { display: grid; gap: .8rem; }
.admin-edit-row { display: grid; gap: .8rem; }
.row-between, .row-end { display: flex; align-items: center; gap: .8rem; }
.row-between { justify-content: space-between; }
.row-end { justify-content: flex-end; }
.code-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; border-radius: 8px; }
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; }

.guide-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 1rem; align-items: start; }
.guide-nav { position: sticky; top: 94px; display: grid; gap: .45rem; padding: 1rem; }
.guide-nav a { padding: .45rem .55rem; color: var(--text-soft); text-decoration: none; border-radius: 8px; }
.guide-nav a:hover { background: var(--surface-2); color: var(--text); }
.guide-content { display: grid; gap: 1rem; }
.guide-section { scroll-margin-top: 95px; }
.guide-tip { padding: .9rem; border-left: 4px solid var(--accent); background: var(--accent-soft); border-radius: 8px; }
.step-list { padding: 0; list-style: none; display: grid; gap: 1rem; }
.step-list li { display: flex; gap: .8rem; }
.step-list li > span { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 900; }
.legal-document { max-width: 920px; }
.legal-document h2 { margin-top: 1.6rem; font-size: 1.25rem; }
.access-card { display: flex; gap: 1rem; margin-bottom: 1.3rem; }
.access-card .feature-icon { margin: 0; }
.success-mark { display: grid; place-items: center; width: 76px; height: 76px; margin: 0 auto 1rem; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 2.2rem; font-weight: 900; }
.empty-state { display: grid; place-items: center; text-align: center; padding: 2rem; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.empty-state.tall { min-height: 360px; }
.empty-state.compact { padding: 1rem; }
.empty-state > span { font-size: 2rem; }
.empty-state p { max-width: 560px; }

.mobile-only { display: none; }

@media (max-width: 1180px) {
  .feature-grid, .case-grid, .plan-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-grid.five { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-form { grid-template-columns: repeat(3, 1fr); }
  .filter-form label:first-child { grid-column: span 2; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .page-frame { grid-column: 1; }
  .sidebar { transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero-visual { min-height: 430px; }
  .auth-layout { grid-template-columns: 1fr; min-height: auto; }
  .auth-story { padding-bottom: 0; }
  .two-column, .case-detail-layout { grid-template-columns: 1fr; }
  .insight-panel { position: static; }
  .scenario-cards { grid-template-columns: 1fr; }
  .idea-details { grid-template-columns: 1fr; }
  .guide-layout { grid-template-columns: 1fr; }
  .guide-nav { position: static; grid-template-columns: repeat(3, 1fr); }
  .topbar { min-height: 64px; }
}

@media (max-width: 720px) {
  .main-content { padding: 1rem; }
  .topbar { padding: .65rem 1rem; }
  .theme-toggle span:last-child { display: none; }
  .user-chip > span:last-child { display: none; }
  .topbar-actions { gap: .45rem; }
  .topbar-actions .button { padding-inline: .65rem; }
  .page-heading { flex-direction: column; }
  .public-hero h1 { font-size: 2.7rem; }
  .main-content.public-page { padding-top: .75rem; }
  .public-hero { padding-top: .75rem; }
  .hero-visual { display: none; }
  .stats-band { grid-template-columns: repeat(2, 1fr); }
  .stats-band div:nth-child(2) { border-right: 0; }
  .stats-band div:nth-child(-n+2) { border-bottom: 1px solid var(--border); }
  .feature-grid, .action-grid, .case-grid, .plan-grid, .stat-grid, .stat-grid.five { grid-template-columns: 1fr; }
  .metric-grid, .metric-grid.five { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .filter-form { grid-template-columns: 1fr; }
  .filter-form label:first-child { grid-column: auto; }
  .idea-top, .idea-title { flex-direction: column; }
  .fit-score { width: 100%; }
  .range-label { grid-template-columns: 1fr 44px; }
  .range-label input { grid-column: 1 / -1; grid-row: 2; }
  .score-bars > div { grid-template-columns: 1fr 40px; }
  .score-bars progress { grid-column: 1 / -1; grid-row: 2; }
  .cta-panel, .footer, .pagination, .row-between { flex-direction: column; align-items: flex-start; }
  .guide-nav { grid-template-columns: repeat(2, 1fr); }
  .floating-card { display: none; }
}

@media (max-width: 420px) {
  .brand.compact small { display: none; }
  .brand.compact .brand-mark { width: 38px; height: 38px; flex-basis: 38px; }
  .metric-grid, .metric-grid.five { grid-template-columns: 1fr; }
  .guide-nav { grid-template-columns: 1fr; }
  .case-actions { flex-direction: column; }
}

@media print {
  :root, html[data-theme="light"] { --bg: #fff; --surface: #fff; --surface-2: #f4f4f4; --text: #000; --text-soft: #222; --muted: #444; --border: #bbb; --accent: #005743; }
  .sidebar, .topbar, .footer, .button, .sticky-actions, .guide-nav { display: none !important; }
  .app-shell, .page-frame { display: block; }
  .main-content { max-width: none; padding: 0; }
  .panel, .idea-card { box-shadow: none; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}

/* Premium responsive-layout hardening (v3.0)
   Account controls deliberately change structure on narrow screens instead
   of competing for the same top-right space. */
.brand,
.topbar-left,
.topbar-actions,
.public-actions,
.public-account-actions,
.panel,
.auth-card,
.feature-card,
.action-card,
.case-card,
.plan-card { min-width: 0; }

.topbar-left { flex: 1 1 auto; }
.topbar-actions { flex: 0 0 auto; max-width: 100%; }
.brand.compact { max-width: 100%; }
.brand.compact strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.public-topbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; justify-content: stretch; }
.public-topbar .topbar-left { grid-column: 1; }
.public-topbar .public-actions { grid-column: 2; }
.public-topbar .public-account-actions { grid-column: 3; }
.public-actions { position: relative; flex-wrap: nowrap; }
.public-account-actions { display: flex; align-items: center; gap: .75rem; }
.public-action-link { white-space: nowrap; }
.public-menu-toggle { display: none; }

/* Authentication pages begin just below the header. Removing the old
   viewport centering also prevents a blank band above the sign-in card. */
.main-content.auth-page {
  padding-top: clamp(.25rem, .5vw, .5rem);
  padding-bottom: clamp(1.5rem, 3vw, 2.5rem);
}
.auth-page .auth-layout {
  align-items: start;
  min-height: 0;
  padding-top: 0;
  gap: clamp(1.5rem, 5vw, 4.5rem);
}
.auth-page .auth-story { padding: 0; }
.auth-page .narrow-page { margin-top: clamp(.35rem, 1vw, .8rem); }

/* Long content must wrap inside its own component rather than widening or
   colliding with neighboring controls. */
.panel-head,
.row-between,
.row-end,
.plan-footer,
.access-card,
.card-heading,
.visual-head,
.case-actions { flex-wrap: wrap; }
.panel-head > *,
.row-between > *,
.row-end > *,
.plan-footer > *,
.card-heading > div,
.user-chip > span:last-child,
.stat-card > div,
.list-row > *,
.case-actions > *,
.case-meta > * { min-width: 0; }
.card-heading h1,
.card-heading h2,
.page-heading h1,
.case-card h2,
.plan-card h2,
.list-row strong,
.metric-list strong,
.metric-list span,
dl dt,
dl dd,
.status-pill,
.data-table td,
.data-table th,
.code-chip,
.json-view,
.alert,
.form-note,
.notice-banner,
.insight-box,
.source-note,
.dev-notice,
.button { overflow-wrap: anywhere; }
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }

/* User-managed titles, labels, and values need a shrinkable text column.
   These rows appear throughout dashboards, cases, plans, and calculations. */
.list-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.metric-list > div,
dl div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.metric-list strong,
dl dd { max-width: 100%; text-align: right; }
.visual-head { gap: .65rem; }
.status-pill { max-width: 100%; }

@media (max-width: 960px) {
  .auth-page .auth-layout { gap: 1.35rem; }
  .auth-page .auth-story h1 { max-width: 19ch; }
}

@media (max-width: 720px) {
  /* One compact row: brand on the left; theme and account menu on the right. */
  .public-topbar {
    min-height: 64px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    column-gap: .65rem;
    row-gap: .5rem;
    padding: .6rem .85rem;
  }
  .public-topbar .topbar-left { grid-column: 1; width: auto; min-width: 0; }
  .public-topbar .brand.compact { width: auto; min-width: 0; }
  .public-topbar .brand.compact .brand-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    border-radius: 12px;
  }
  .public-topbar .brand.compact strong { font-size: .94rem; }
  .public-topbar .brand.compact small { display: block; font-size: .68rem; }
  .public-topbar .public-actions { grid-column: 2; margin-left: auto; gap: .45rem; }
  .public-topbar .theme-toggle,
  .public-topbar .public-menu-toggle {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
  }
  .public-topbar .theme-toggle span:last-child { display: none; }
  .public-menu-toggle { display: inline-flex; }
  .public-topbar .public-account-actions {
    display: none;
    grid-column: 1 / -1;
    width: 100%;
    padding: .55rem 0 .15rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: .55rem;
    border-top: 1px solid var(--border);
  }
  .public-topbar .public-account-actions.open { display: grid; }
  .public-topbar .public-account-actions .button { width: 100%; min-height: 44px; }
  .public-topbar .public-account-actions .button:only-child { grid-column: 1 / -1; }

  .main-content.auth-page { padding-top: .35rem; }
  .auth-page .auth-layout { gap: 1.2rem; }
  .auth-page .auth-story { padding-top: 0; }
  .auth-page .auth-story h1 { font-size: clamp(2rem, 9.5vw, 2.65rem); }
  .auth-card { border-radius: 20px; }
  .form-links { align-items: flex-start; }
  .plan-footer { align-items: flex-start; }

  .button-row,
  .row-end,
  .sticky-actions { max-width: 100%; }
}

@media (max-width: 520px) {
  .public-topbar .brand.compact small { display: none; }
  .public-topbar .brand.compact strong { font-size: .9rem; }
  .auth-page .auth-card { padding: 1.15rem; }
  .card-heading { align-items: flex-start; gap: .8rem; }
  .card-heading .feature-icon { width: 46px; height: 46px; flex-basis: 46px; }
  .form-links { flex-direction: column; gap: .55rem; }
  .access-card { flex-direction: column; }
  .list-row { grid-template-columns: auto minmax(0, 1fr); }
  .list-row time { grid-column: 2; }
  .pagination > div,
  .button-row { width: 100%; }
}

@media (max-width: 360px) {
  .public-topbar { padding-inline: .65rem; gap: .45rem; }
  .public-topbar .brand.compact { gap: .55rem; }
  .public-topbar .brand.compact .brand-mark {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }
  .public-topbar .brand.compact strong { font-size: .84rem; }
  .public-topbar .theme-toggle,
  .public-topbar .public-menu-toggle {
    width: 39px;
    min-width: 39px;
    height: 39px;
    min-height: 39px;
  }
  .main-content,
  .main-content.auth-page { padding-inline: .75rem; }
}

/* Reduced-motion users receive instant, stable controls. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
