/* Owner app. Every value comes from design/tokens.css (served as /app/tokens.css). */

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-text-size-adjust: 100%;
  /* Long words (names, emails) wrap instead of pushing the page sideways. */
  overflow-wrap: break-word;
}

.screen {
  min-height: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(var(--space-14) + env(safe-area-inset-top)) var(--margin)
           calc(var(--margin) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.screen > form { display: contents; }

h1 {
  margin: 0;
  font-size: var(--fs-title);
  line-height: var(--lh-title);
  font-weight: 700;
}

h1:focus { outline: none; }

p { margin: 0; }

.muted { color: var(--muted); }

.field { display: flex; flex-direction: column; gap: var(--space-2); }

label { font-size: var(--fs-small); color: var(--muted); }

input {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--line);
  border-radius: var(--r-input);
  min-height: var(--h-button);
  padding: 0 var(--space-4);
  width: 100%;
}

input:focus { outline: none; border-color: var(--accent); }

input.code { letter-spacing: 6px; font-weight: 600; }

/* The one big button, kept at the bottom as in the mocks. */
.actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
}

.links { display: flex; flex-direction: column; align-items: center; gap: var(--space-1); }

/* Peach: a note. */
.note {
  background: var(--p-peach);
  border-radius: var(--r-box);
  padding: var(--space-4) var(--space-6);
}

.error {
  border-left: 4px solid currentColor;
  padding-left: var(--space-4);
}

.error:empty { display: none; }

.google-slot:empty { display: none; }

/* The wordmark, navy on light and white on dark (design/brand). */
.brand img { display: block; height: 26px; width: auto; }
.brand .on-dark { display: none; }
:root[data-theme="dark"] .brand .on-light { display: none; }
:root[data-theme="dark"] .brand .on-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .on-light { display: none; }
  :root:not([data-theme="light"]) .brand .on-dark { display: block; }
}

/* ── First steps (setup.mjs; mocks/v1/FlowClaim, FlowImport, FlowFix, FlowLook) ── */

.step { color: var(--muted); font-size: var(--fs-small); margin-bottom: calc(-1 * var(--space-4)); }

/* "pagebeat.me/" inside the field, the owner's part after it. */
.prefixed {
  display: flex;
  align-items: center;
  border: 2px solid var(--line);
  border-radius: var(--r-input);
  min-height: var(--h-button);
  padding-left: var(--space-4);
  background: var(--bg);
}
.prefixed:focus-within { border-color: var(--accent); }
.prefix { color: var(--muted); white-space: nowrap; }
.prefixed input { border: 0; padding-left: 0; min-height: calc(var(--h-button) - 4px); font-weight: 600; }

.check { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-height: var(--tap-min); font-size: var(--fs-small); }
.check:empty { display: none; }
.check.ok { color: var(--ok); }
.check .link { min-height: var(--tap-min); }

/* The bar at the top of the chat-style steps. */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap-min); }
.avatar.small {
  width: var(--tap-min); height: var(--tap-min); border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.avatar.small.tone-blue { background: var(--p-blue); }

/* The owner's message, on the right as in the chat. */
.bubble.mine {
  align-self: flex-end;
  max-width: 80%;
  background: var(--surface);
  border-radius: var(--r-box);
  padding: var(--space-3) var(--space-4);
}

/* What the app says in the chat: body size, not a title. */
h1.said { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: 400; }

.module.lines, .module.fix { gap: var(--space-4); }
.module.fix .old { color: var(--muted); }
.module.fix .new { font-weight: 700; }

/* While it reads: grey bars in the shape of the lines. */
.skeleton { gap: var(--space-4); }
.skeleton span { display: block; height: 18px; border-radius: 9px; background: var(--line); opacity: 0.6; }
.skeleton span:nth-child(2) { width: 70%; }
.skeleton span:nth-child(3) { width: 80%; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton span { animation: pulse 1.4s var(--ease) infinite alternate; }
}
@keyframes pulse { to { opacity: 0.25; } }

/* A real file input behind the big button, so the label opens the picker. */
.file-pick { position: relative; cursor: pointer; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.file-pick:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 2px solid var(--line); border-radius: var(--r-input);
  padding: var(--space-3) var(--space-4); width: 100%; resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* Three looks as big radio cards; the chosen one has a blue border and a check. */
.looks { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.looks legend { padding: 0; margin-bottom: var(--space-2); }
.look {
  position: relative;
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3);
  border: 2px solid var(--line);
  border-radius: var(--r-box);
  cursor: pointer;
  color: var(--text);
  font-size: var(--fs-body);
}
.look input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.look:has(input:checked) { border-color: var(--accent); }
.look:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.look-thumb {
  flex: none; width: 74px; height: 92px; border-radius: 12px;
  background: var(--look);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; padding: 10px;
}
.look-thumb i { display: block; height: 6px; width: 36px; border-radius: 3px; background: #151515; }
.look-thumb i + i { width: 22px; opacity: 0.55; }
.look-thumb[data-theme="dark"] i { background: #F2F1EC; }
.look-name { flex: 1; font-weight: 600; font-size: var(--fs-h2); }
.look-check { color: var(--accent); visibility: hidden; }
.look:has(input:checked) .look-check { visibility: visible; }

.url { font-weight: 600; overflow-wrap: anywhere; }
.url a { color: var(--accent-text); }

/* In the chat-style steps the action follows the box, as in the mocks. */
.actions.inline { margin-top: 0; }

/* ── What people can see (FlowPrivacy.png) ──────────────────────────── */
.toggles { display: flex; flex-direction: column; }
.never-topics { margin: 0; font-size: var(--fs-body); font-weight: 600; color: var(--text); }
.module-link { display: flex; justify-content: center; }
.topic-list { list-style: none; margin: 0; padding: 0; }
.topic-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  min-height: var(--h-row);
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-body);
}
.topic-list .link { min-height: var(--tap-min); }

/* ── The app after the first steps (shell.mjs; FlowWeek, FlowPeople, FlowSearch …) ── */

/* The tabs (and on Home the ask bar) stay at the bottom; the page scrolls above them. */
.screen.tabbed { padding-bottom: calc(var(--h-tabs) + var(--margin) + env(safe-area-inset-bottom)); }
.screen.tabbed.with-ask { padding-bottom: calc(var(--h-tabs) + var(--h-ask) + 2 * var(--margin) + env(safe-area-inset-bottom)); }
.view { display: flex; flex-direction: column; gap: var(--gap); flex: 1; }
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 var(--margin);
  background: var(--bg);
}
.dock .askbar { margin-bottom: var(--space-2); }
.dock .tabs { margin: 0 calc(-1 * var(--margin)); }

.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }
.icon-button, .avatar-link {
  display: inline-grid; place-items: center;
  min-width: var(--tap-min); min-height: var(--tap-min);
  color: var(--text); text-decoration: none; border-radius: 50%;
}
.avatar-link .avatar { width: 40px; height: 40px; }

/* Home: the plain answer, then the rows (FlowWeek). */
.chat { display: flex; flex-direction: column; gap: var(--gap); }
.said-by-me {
  align-self: flex-end;
  max-width: 80%;
  background: var(--surface);
  border-radius: var(--r-box);
  padding: var(--space-3) var(--space-4);
}
.reply { display: flex; flex-direction: column; gap: var(--gap); }
.week { display: flex; flex-direction: column; }
.week-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: var(--space-4);
  min-height: 82px;
  border-bottom: 1px solid var(--line);
}
.week-n { font-size: var(--fs-number); font-weight: 700; color: var(--accent-text); line-height: 1; }
.pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  background: var(--bg);
  color: var(--text);
  font: inherit; font-size: var(--fs-small); font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.module .pill { align-self: flex-start; }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* Sources (blue) and questions (lilac) in the chat. */
.bars { display: flex; flex-direction: column; gap: var(--space-4); }
.bar-row { display: grid; grid-template-columns: 1fr auto; row-gap: var(--space-2); align-items: baseline; }
.bar-n { color: var(--muted); }
.bar-track { grid-column: 1 / -1; height: 10px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.bar { display: block; height: 100%; width: var(--w); min-width: 6px; border-radius: 6px; background: var(--accent); }
.counts { display: flex; flex-direction: column; }
.count-row { display: flex; align-items: baseline; gap: var(--space-6); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.count-row:last-child { border-bottom: 0; }
.count-n { min-width: 1.5em; font-size: 22px; font-weight: 700; color: var(--text); }

/* Search fields (FlowSearch, FlowPeople). */
.search-field {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--h-button);
  padding: 0 var(--space-4);
  border: 2px solid var(--line);
  border-radius: var(--r-input);
  color: var(--muted);
}
.search-field:focus-within { border-color: var(--accent); }
.search-field input { border: 0; padding: 0; min-height: calc(var(--h-button) - 4px); background: transparent; }
.search-field input::-webkit-search-cancel-button { display: none; }
.hint { color: var(--muted); font-size: var(--fs-small); margin-top: calc(-1 * var(--space-3)); }
.rows.boxed { background: var(--surface); border-radius: var(--r-box); padding: 0 var(--space-4); }
.group { margin: 0; font-size: var(--fs-small); color: var(--muted); font-weight: 600; }
.found { padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.empty { color: var(--muted); }

/* A person (FlowRequest, FlowContact). */
.person-head { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); text-align: center; }
.person-head h1 { margin-top: var(--space-2); }
.actions.stacked { margin-top: 0; align-items: stretch; }
.center { text-align: center; }
.small { font-size: var(--fs-small); }
.question { font-size: var(--fs-body); font-weight: 600; color: var(--text); }
.fact { color: var(--text); }

/* My card (FlowMyCard): the QR on white, whatever the theme, so any camera reads it. */
.my-card { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); text-align: center; }
.my-card .avatar.large { width: 96px; height: 96px; border-radius: 50%; object-fit: cover; }
.qr {
  width: min(100%, 300px);
  aspect-ratio: 1;
  padding: var(--space-6);
  border-radius: var(--r-box);
  background: #FFFFFF;
}
.qr svg { display: block; width: 100%; height: 100%; }

/* Send my card (FlowShare): rows with a blue icon. */
.sheet-rows { display: flex; flex-direction: column; }
.sheet-row {
  display: flex; align-items: center; gap: var(--space-4);
  min-height: var(--h-row);
  border: 0; border-bottom: 1px solid var(--line);
  background: none; color: var(--text);
  font: inherit; font-weight: 600; text-align: left;
  cursor: pointer;
}
.sheet-row .icon { color: var(--accent); flex: none; }
.sheet-note { color: var(--text); font-size: var(--fs-small); }
.sheet-note:empty { display: none; }

/* Scan a paper card (FlowScan): the camera, dark, with a frame to aim at. */
.scan { display: flex; flex-direction: column; gap: var(--gap); flex: 1; }
.scan-view {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--r-box);
  overflow: hidden;
  background: #1C1C1B;
}
.scan-view video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 30% 6%;
  border: 3px solid #FFFFFF;
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35);
}
.scan-hint { text-align: center; }
.file-link { position: relative; cursor: pointer; min-height: var(--tap-min); display: inline-flex; align-items: center; }
.found-card { display: flex; flex-direction: column; gap: var(--space-2); }
[hidden] { display: none !important; }

/* Sign-in from another device: the number to tap there. Recovery codes, once. */
.big-number { font-size: 56px; line-height: 1; font-weight: 700; text-align: center; letter-spacing: 4px; color: var(--accent-text); }
.codes { columns: 2; padding-left: var(--space-6); margin: 0; }
.codes code { font-size: var(--fs-body); font-family: ui-monospace, Menlo, monospace; }
.numbers .pill { min-width: 72px; font-size: 22px; }

/* How it's going (FlowRecap): the title with its period picker, the green answer block. */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.title-row h1 { margin: 0; }
.period { position: relative; display: inline-flex; }
.period select {
  appearance: none;
  min-height: 48px;
  padding: 0 calc(var(--space-4) + 20px) 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  background: var(--bg);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
}
.period::after {
  content: "";
  position: absolute; right: var(--space-4); top: 50%;
  border: 6px solid transparent; border-top: 8px solid var(--text); border-bottom: 0;
  transform: translateY(-25%);
  pointer-events: none;
}
.period select:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.answer-block { gap: var(--space-4); }
.answer-block .module-title { margin: 0; }
.answer-block p { margin: 0; }

/* The stamp card (FlowStampHome): a 5×2 grid, filled stamps in the accent. */
.play { display: flex; flex-direction: column; gap: var(--gap); }
.play:empty { display: none; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); }
.card-head .module-title { margin: 0; }
.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--space-3); }
.stamp {
  aspect-ratio: 1;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 2px dashed color-mix(in srgb, var(--muted) 55%, transparent);
  font-size: 22px; line-height: 1;
}
.stamp.on { border: 0; background: var(--accent); color: var(--on-accent, #FFFFFF); }
.choice-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.pill.wide { flex: 1 1 0; min-width: 88px; }

/* The spin (FlowStampSpin). The pastels mark the slices, as on the mock. */
.wheel-wrap { display: grid; place-items: center; }
.wheel { width: min(100%, 320px); height: auto; overflow: visible; }
#wheel-turn { transform-origin: 160px 160px; transform-box: view-box; }
.slice { stroke: var(--bg); stroke-width: 3; }
.slice.tone-blue { fill: var(--p-blue); }
.slice.tone-green { fill: var(--p-green); }
.slice.tone-peach { fill: var(--p-peach); }
.slice.tone-lilac { fill: var(--p-lilac); }
.slice-label { font: 700 30px/1 var(--font, inherit); fill: var(--text); }
.hub, .pointer { fill: var(--text); }
.prize { margin: 0; text-align: center; font-size: 48px; line-height: 1.1; color: var(--text); }
@media (prefers-reduced-motion: reduce) { #wheel-turn { transition: none !important; } }

/* Invite friends (FlowInvite): three steps toward Pro for life. */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); }
.step { height: 10px; border-radius: 6px; background: var(--bg); }
.step.on { background: var(--accent); }
.row.static { cursor: default; }

/* My plan (FlowPlans): two cards, the current one outlined in the accent. */
.plan-card { padding: var(--space-6); border-radius: var(--r-box); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: var(--space-2); }
.plan-card.on { box-shadow: inset 0 0 0 2px var(--accent); }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); }
.plan-head h2 { margin: 0; }
.plan-price { font-weight: 700; font-size: 20px; }
.plan-card p { margin: 0; }
.plan-yours { display: flex; align-items: center; gap: var(--space-2); color: var(--accent-text); font-weight: 600; }
.money-row { justify-content: space-between; }
.sheet-row[disabled], .sheet-row[aria-disabled="true"] { opacity: .6; cursor: default; }
