/* RevConduit web: shared components. Design system 1.0 (design/README.md, design/samples/v1/v1.css); colors as 0.3. Every value comes
   from tokens.css, a copy of design/tokens/tokens.css. */
@import url("tokens.css");
/* Web only: the blur behind the glass top bar. 1.0 has no token for it. */
:root { --glass-blur: blur(20px) saturate(180%); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--rule) transparent; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--type-body-size);
  line-height: var(--type-body-line);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--selection); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-inner-min); }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* Up/down colors: green good, red bad by default; settings can flip them (Marcus 10-29, 绿好红坏，可切换). */
/* Only the change figures swap; status dots (connected, expired) keep their meaning. Rules sit after .change below. */

.num { font-feature-settings: var(--font-numeric); font-variant-numeric: tabular-nums lining-nums; }
.t2 { color: var(--text-2); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Type ---------- */
.t-hero { font-family: var(--font-sans); font-size: var(--type-hero-size); line-height: var(--type-hero-line); font-weight: var(--type-hero-weight); letter-spacing: var(--type-hero-tracking); }
.t-metric, .t-metric-md, .t-metric-lg { font-family: var(--font-sans); font-size: var(--type-metric-size); line-height: var(--type-metric-line); font-weight: var(--type-metric-weight); letter-spacing: var(--type-metric-tracking); }
.t-value { font-size: var(--type-value-size); line-height: var(--type-value-line); font-weight: var(--type-value-weight); }
.t-title { font-family: var(--font-sans); font-size: var(--type-title-size); line-height: var(--type-title-line); font-weight: var(--type-title-weight); letter-spacing: var(--type-title-tracking); }
.t-heading { font-size: var(--type-section-size); line-height: var(--type-section-line); font-weight: var(--type-section-weight); letter-spacing: var(--type-section-tracking); }
.t-headline { font-size: var(--type-headline-size); line-height: var(--type-headline-line); font-weight: var(--type-headline-weight); }
.t-callout { font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); }
.t-label { font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); font-weight: var(--type-secondary-weight); }
.t-caption { font-size: var(--type-caption-size); line-height: var(--type-caption-line); font-weight: var(--type-caption-weight); }

/* ---------- Brand lockup: the S2 lockup file, one per theme (decision-144) ---------- */
.lockup { display: inline-flex; align-items: center; color: var(--text); text-decoration: none; }
.lockup img { display: block; height: 22px; width: auto; flex: none; }
.lockup:hover { text-decoration: none; }
.on-dark { display: none !important; }
:root[data-theme="dark"] .on-light { display: none !important; }
:root[data-theme="dark"] .on-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .on-light { display: none !important; }
  :root:not([data-theme="light"]) .on-dark { display: block !important; }
}

/* ---------- Glass top bar (navigation layer only) ---------- */
/* Pages draw the bar into <div id="bar">, a child of <body>. Sticky only holds inside the parent, so it's the parent that
   sticks: the bar (and on phones the subnav under it) stays at the top for the whole page. */
#bar { position: sticky; top: 0; z-index: 10; }
/* Whatever a link, an anchor or the keyboard scrolls to lands below the bar, not under it (WCAG 2.4.11). */
html { scroll-padding-top: 76px; }
/* Staging only (core.js envBar, decision-108): above everything, in the "late" color so it can't be missed. */
.env-bar {
  position: relative; z-index: 11;
  padding: 6px var(--space-4);
  background: var(--late); color: var(--on-ink);
  font-size: 13px; font-weight: 600; line-height: 18px; text-align: center;
}
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-edge);
}
.topbar-inner {
  max-width: calc(var(--size-page-max) + 2 * var(--space-8)); margin: 0 auto; height: 60px;
  padding: 0 var(--space-8);
  display: flex; align-items: center; gap: var(--space-8);
}
.nav { display: flex; gap: var(--space-1); }
.nav a {
  display: inline-flex; align-items: center; height: var(--size-control); padding: 0 14px; border-radius: var(--radius-pill); text-decoration: none;
  color: var(--text-2); font-size: var(--type-control-size); font-weight: 500;
}
.nav a:hover { color: var(--text); background: var(--fill); }
.nav a[aria-current="page"] { color: var(--text); background: var(--fill-strong); }
.topbar .spacer { flex: 1; }
.sync { display: flex; align-items: center; gap: var(--space-2); color: var(--text-2); font-size: var(--type-secondary-size); font-weight: 500; text-decoration: none; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--positive); flex: none; }
.dot.idle { background: var(--text-3); }
.dot.bad { background: var(--negative); }
.dot.late { background: var(--late); }
.avatar { width: var(--size-control); height: var(--size-control); border-radius: 50%; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--text-2); text-decoration: none; text-transform: uppercase; }
.avatar:hover { text-decoration: none; color: var(--text); }

/* ---------- Segmented control (glass, like iOS 26) ---------- */
.seg { display: inline-flex; padding: 3px; height: var(--size-control); border-radius: var(--radius-pill); background: var(--fill); }
.seg button {
  border: 0; background: transparent; cursor: pointer;
  min-width: 72px; height: 100%; padding: 0 14px; border-radius: var(--radius-pill);
  font-size: var(--type-control-size); font-weight: 500; color: var(--text-2);
  transition: background var(--motion-duration-fast) var(--motion-easing), color var(--motion-duration-fast) var(--motion-easing);
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--size-control); padding: 0 16px; border-radius: var(--radius-pill); border: 0; cursor: pointer;
  font-size: var(--type-control-size); font-weight: 600; white-space: nowrap; text-decoration: none;
  transition: background var(--motion-duration-fast) var(--motion-easing), opacity var(--motion-duration-fast) var(--motion-easing);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--ink); color: var(--on-ink); }
.btn-primary:hover { opacity: .86; }
.btn-secondary { background: var(--fill); color: var(--text); }
.btn-secondary:hover { background: var(--fill-strong); }
.btn-quiet { background: transparent; color: var(--text); padding: 0 10px; }
.btn-quiet:hover { background: var(--fill); }
.btn-danger { background: var(--negative); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-sm { height: 32px; padding: 0 14px; font-size: var(--type-secondary-size); }
.btn-lg { height: 44px; padding: 0 22px; font-size: var(--type-body-size); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .35; cursor: not-allowed; }
.btn .arrow { transition: transform var(--motion-duration-fast) var(--motion-easing); }
.btn:hover .arrow { transform: translateX(2px); }

/* ---------- Page ---------- */
.page { max-width: calc(var(--size-page-max) + 2 * var(--space-8)); margin: 0 auto; padding: var(--space-6) var(--space-8) var(--space-16); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); min-height: 40px; }
.section { margin-top: var(--space-12); }
.section-head { display: flex; align-items: baseline; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 1px solid var(--rule); }
.section-head .note { color: var(--text-2); font-size: var(--type-secondary-size); }
.section-head .right { margin-left: auto; }
.intro { max-width: 680px; margin: var(--space-6) 0 var(--space-4); }
.intro h1 { font-family: var(--font-sans); font-size: var(--type-title-size); line-height: var(--type-title-line); font-weight: var(--type-title-weight); letter-spacing: var(--type-title-tracking); }
.intro p { margin-top: var(--space-3); color: var(--text-2); }

/* ---------- Notice: one line, a dot, an action. Not a colored banner. ---------- */
.notice {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px 10px 10px 16px; border-radius: var(--radius-pill);
  box-shadow: inset 0 0 0 1px var(--rule);
  font-size: var(--type-secondary-size); line-height: var(--type-secondary-line);
}
.notice p { flex: 1; min-width: 0; }
.notice .dot { width: 8px; height: 8px; }
.notices { display: flex; flex-direction: column; gap: var(--space-2); }
.notices:not(:empty) { margin-bottom: var(--space-6); }

/* ---------- Change: arrow + signed percent in the meaning color. No pill. ---------- */
.change { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; white-space: nowrap; }
.change svg { flex: none; }
.change.pos { color: var(--positive); }
.change.neg { color: var(--negative); }
.change.flat { color: var(--text-2); }
.change .basis { color: var(--text-2); font-weight: 500; margin-left: 5px; }
:root[data-updown="red-up"] .change.pos { color: var(--negative); }
:root[data-updown="red-up"] .change.neg { color: var(--positive); }
.late { color: var(--late); font-weight: 600; }
.bad { color: var(--negative); font-weight: 600; }

/* ---------- Platform logo tile ---------- */
.logo { --s: var(--size-logo-tile); display: inline-grid; place-items: center; flex: none; width: var(--s); height: var(--s); border-radius: calc(var(--s) * var(--radius-tile-ratio)); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); font-size: 12px; font-weight: 700; color: var(--text-2); }
.logo svg { display: block; width: 58%; height: 58%; }
.logo img { display: block; width: 100%; height: 100%; border-radius: inherit; }
.logo.lg { --s: var(--size-logo-tile-lg); font-size: 15px; }
.logo.sm { --s: 22px; font-size: 10px; }
.logo.solid { box-shadow: none; }
.logo.solid svg { width: 86%; height: 86%; }

/* ---------- Rows (lists, the main container instead of cards) ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; align-items: center; column-gap: var(--space-4); padding: 14px 0; border-bottom: 1px solid var(--hairline); }
.row:last-child { border-bottom: 0; }
.row .name { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.row .name > div { min-width: 0; }
.row .name b { display: block; font-weight: 600; font-size: var(--type-headline-size); line-height: var(--type-headline-line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .name small { display: block; color: var(--text-2); font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { text-align: right; }
.row.is-stale .t-value, .row.is-stale .name b { color: var(--text-2); }

/* ---------- Charts ---------- */
.spark { display: block; overflow: visible; }
.spark .line { fill: none; stroke: var(--chart); stroke-width: var(--size-spark-stroke); stroke-linejoin: round; stroke-linecap: round; }
.spark .prev { fill: none; stroke: var(--chart-prev); stroke-width: 1.25; stroke-dasharray: 3 3; }
.spark .end { fill: var(--chart); }
.is-stale .spark .line { stroke: var(--text-3); }
.is-stale .spark .end { fill: var(--text-3); }

/* ---------- Forms ---------- */
.field label, .field .label { display: block; font-size: var(--type-secondary-size); font-weight: 600; margin-bottom: 5px; }
.input, .field input[type="text"], .field input[type="password"], .field select {
  width: 100%; height: var(--size-control); border-radius: var(--radius-field); border: 0; background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--rule); padding: 0 12px; font-size: var(--type-body-size);
}
.field select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 17px) 16px, calc(100% - 12px) 16px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
.input:focus, .field input:focus, .field select:focus { outline: none; box-shadow: inset 0 0 0 1.5px var(--ink); }
.field input::placeholder { color: var(--text-3); }
.field small { display: block; margin-top: 4px; color: var(--text-2); font-size: var(--type-caption-size); line-height: var(--type-caption-line); }
/* .sheet-body too: its rule for plain paragraphs would otherwise win and turn an error grey. */
.form-error, .sheet-body .form-error { color: var(--negative); font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); font-weight: 500; }
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--fill-strong); transition: background var(--motion-duration-fast) var(--motion-easing); pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform var(--motion-duration-fast) var(--motion-easing); }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(18px); background: var(--on-ink); }
.switch input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- Dialog ---------- */
dialog.sheet { border: 0; padding: 0; border-radius: var(--radius-dialog); background: var(--surface); color: var(--text); box-shadow: var(--shadow-overlay); width: min(460px, calc(100vw - 32px)); }
dialog.sheet::backdrop { background: rgba(0,0,0,.32); }
.sheet-body { padding: var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.sheet-body h2 { font-size: var(--type-section-size); line-height: var(--type-section-line); font-weight: var(--type-section-weight); letter-spacing: var(--type-section-tracking); }
.sheet-body p { color: var(--text-2); font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); }
.sheet-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }
/* Leaving the write page: Discard stands apart from the two ways of staying. */
.sheet-actions .discard { margin-right: auto; color: var(--negative); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); }
.check input { margin-top: 4px; accent-color: var(--ink); }

/* ---------- Plan chooser (core.js upgrade) ---------- */
dialog.plan-sheet { width: min(580px, calc(100vw - 32px)); }
.plan-sheet .seg { align-self: flex-start; }
/* The free trial's terms, by the button that starts it (trial.ts TRIAL_WORDS): larger than the notes, in full ink and
   bold, so they stand out from the grey around them (California §17601(a)(3)). Then the box that has to be ticked. */
.plan-sheet .plan-trial { color: var(--ink); font-weight: 600; font-size: var(--type-body-size); line-height: var(--type-body-line); }
.plan-sheet .plan-consent { color: var(--ink); }
.plan-opts { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.plan-opt { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; align-content: start; padding: var(--space-4); border-radius: var(--radius-field); box-shadow: inset 0 0 0 1px var(--hairline); cursor: pointer; }
.plan-opt:has(input:checked) { box-shadow: inset 0 0 0 2px var(--ink); }
.plan-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.plan-opt.is-current { cursor: default; }
.plan-opt input { grid-row: 1; align-self: start; margin: 4px 0 0; accent-color: var(--ink); }
.plan-opt > :not(input) { grid-column: 2; }
.po-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.po-head b { font-size: var(--type-headline-size); line-height: var(--type-headline-line); font-weight: 600; }
.po-tag { padding: 1px 8px; border-radius: var(--radius-pill); background: var(--fill); color: var(--text-2); font-size: var(--type-caption-size); line-height: var(--type-caption-line); }
.po-amount { flex-basis: 100%; display: flex; align-items: baseline; gap: 4px; }
.po-price { font-family: var(--font-numeric); font-size: var(--type-title-size); line-height: var(--type-title-line); font-weight: 600; }
.po-per, .po-equiv { color: var(--text-2); font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); }
.po-list { list-style: none; margin: var(--space-3) 0 0; padding: 0; display: grid; gap: 6px; color: var(--text-2); font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); }
.po-list li { position: relative; padding-left: 14px; }
.po-list li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }
@media (max-width: 560px) {
  .plan-opts { grid-template-columns: 1fr; }
}

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; max-width: min(560px, calc(100vw - 32px)); padding: 10px 18px; border-radius: var(--radius-pill); background: var(--ink); color: var(--on-ink); font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); box-shadow: var(--shadow-overlay); }

/* ---------- Loading and empty ---------- */
.loading { color: var(--text-3); padding: var(--space-8) 0; font-size: var(--type-secondary-size); }
.empty { color: var(--text-2); padding: var(--space-6) 0; font-size: var(--type-secondary-size); }
.fail { padding: var(--space-12) 0; max-width: 520px; }
.fail h1 { font-size: var(--type-title-size); line-height: var(--type-title-line); font-weight: var(--type-title-weight); letter-spacing: var(--type-title-tracking); }
.fail p { margin-top: var(--space-2); color: var(--text-2); }
.fail .btn { margin-top: var(--space-5); }

/* ---------- Footer ---------- */
.foot { border-top: 1px solid var(--hairline); margin-top: var(--space-16); }
.foot-inner { max-width: calc(var(--size-page-max) + 2 * var(--space-8)); margin: 0 auto; padding: var(--space-6) var(--space-8) var(--space-10); display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3) var(--space-6); font-size: var(--type-secondary-size); line-height: var(--type-secondary-line); color: var(--text-2); }
.foot-inner a { color: var(--text-2); text-decoration: none; }
.foot-inner a:hover { color: var(--text); }
.foot-inner .spacer { flex: 1; }
.lang-switch { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--radius-pill); background: var(--fill); }
.lang-switch button { border: 0; background: transparent; cursor: pointer; height: 28px; padding: 0 10px; border-radius: var(--radius-pill); font-size: var(--type-secondary-size); font-weight: 500; color: var(--text-2); }
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--hairline); }

@media (max-width: 760px) {
  .topbar-inner { padding: 0 var(--space-4); gap: var(--space-4); height: 52px; }
  .topbar .nav { display: none; }
  .sync span:last-child { display: none; }
  .page { padding: var(--space-4) var(--space-4) var(--space-12); }
  .foot-inner { padding: var(--space-5) var(--space-4) var(--space-8); }
  .btn { height: var(--size-touch); }
  .btn-sm { height: 36px; }
}
/* Phones: the nav moves to a bar under the top bar instead of disappearing. */
.subnav { display: none; }
@media (max-width: 760px) {
  .subnav { display: flex; gap: var(--space-1); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--hairline); background: var(--bg); overflow-x: auto; }
  .subnav a { display: inline-flex; align-items: center; height: var(--size-touch); padding: 0 14px; border-radius: var(--radius-pill); text-decoration: none; color: var(--text-2); font-size: var(--type-control-size); font-weight: 500; white-space: nowrap; }
  .subnav a[aria-current="page"] { color: var(--text); background: var(--fill-strong); }
  html:has(.subnav) { scroll-padding-top: 128px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* The brand tile is ink on light. On dark it lifts one step and gets a hairline so it does not vanish. */
:root[data-theme="dark"] { --brand-tile: #1C1C1E; --brand-tile-edge: rgba(255,255,255,0.14); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --brand-tile: #1C1C1E; --brand-tile-edge: rgba(255,255,255,0.14); } }
