/* Design tokens. Light = warm paper + ink, dark = ink + paper, one accent (vermilion). */
:root {
  color-scheme: light dark;

  --bg: light-dark(#f4f0e6, #12110d);
  --surface: light-dark(#fbf8f1, #1a1914);
  --surface-2: light-dark(#ebe6d8, #23211b);
  --ink: light-dark(#16140e, #efebe0);
  --muted: light-dark(#5b5547, #a8a190);
  --line: light-dark(rgb(22 20 14 / .16), rgb(239 235 224 / .16));
  --line-strong: light-dark(rgb(22 20 14 / .52), rgb(239 235 224 / .42));
  --accent: light-dark(#b83208, #ff7a4d);
  --on-accent: light-dark(#ffffff, #1b0d06);
  --accent-soft: light-dark(rgb(184 50 8 / .09), rgb(255 122 77 / .13));
  --good: light-dark(#14633a, #6bd69a);
  --good-soft: light-dark(rgb(20 99 58 / .1), rgb(107 214 154 / .13));
  --warn: light-dark(#7d5200, #f2c14e);
  --warn-soft: light-dark(rgb(125 82 0 / .1), rgb(242 193 78 / .13));
  --bad: light-dark(#a3201a, #ff8f86);
  --bad-soft: light-dark(rgb(163 32 26 / .09), rgb(255 143 134 / .13));

  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --gutter: clamp(1.1rem, 4.2vw, 2.5rem);
  --maxw: 72rem;
  --shadow: 0 1px 0 light-dark(rgb(22 20 14 / .05), rgb(0 0 0 / .3)),
            0 22px 40px -28px light-dark(rgb(22 20 14 / .45), rgb(0 0 0 / .8));
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

/* Reset, typography and the few shared components (buttons, pills, form controls). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 5.5rem; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--ink);
  font: 1.0625rem/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 {
  margin: 0; font-family: var(--font-serif); font-weight: 400;
  line-height: 1.08; letter-spacing: -.015em; text-wrap: balance;
}
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: .08em; text-underline-offset: .22em; }
a:hover { text-decoration-thickness: .17em; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--on-accent); }

.container { width: min(100% - 2 * var(--gutter), var(--maxw)); margin-inline: auto; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: var(--gutter); top: -4rem; z-index: 100;
  background: var(--ink); color: var(--bg); padding: .7rem 1rem; border-radius: 8px; text-decoration: none; font-weight: 600;
}
.skip:focus { top: .75rem; }
.eyebrow { font: 600 .74rem/1.3 var(--font-mono); letter-spacing: .13em; text-transform: uppercase; color: var(--muted); }
.mono { font-family: var(--font-mono); }

/* buttons */
.btn {
  --btn-bg: transparent; --btn-fg: var(--ink); --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
  min-height: 3rem; padding: .7rem 1.3rem; border-radius: 999px;
  border: 1.5px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font: 600 .98rem/1.1 var(--font-sans); text-decoration: none; text-align: center;
  transition: transform .18s ease, background-color .18s ease, border-color .18s ease, filter .18s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--ink); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--on-accent); --btn-bd: var(--accent); }
.btn--primary:hover { border-color: var(--accent); filter: brightness(1.07); }
.btn--sm { min-height: 2.75rem; padding: .5rem 1.05rem; font-size: .92rem; }
.btn--lg { min-height: 3.4rem; padding: .9rem 1.7rem; font-size: 1.04rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn .arr { transition: transform .18s ease; }
.btn:hover .arr { transform: translateX(3px); }

.pill {
  display: inline-flex; align-items: center; gap: .5rem; padding: .38rem .75rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  font: 600 .7rem/1 var(--font-mono); letter-spacing: .09em; text-transform: uppercase; color: var(--ink);
}
.pill .dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); }

/* form controls (used by the demos) */
.field { display: grid; gap: .35rem; }
.field > label, .field > .label, legend.label { font-weight: 600; font-size: .92rem; }
.hint { color: var(--muted); font-size: .86rem; font-weight: 400; }
.input, .select, .textarea {
  width: 100%; min-height: 2.9rem; padding: .6rem .8rem;
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea { min-height: 6rem; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink); }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--ink); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.error-text { color: var(--bad); font-size: .88rem; font-weight: 600; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Shared chrome for the interactive demos. */
.demo-bar { border-bottom: 1px solid var(--line); background: color-mix(in oklab, var(--bg) 92%, transparent); }
.demo-bar__in { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.2rem; min-height: 3.6rem; padding-block: .4rem; }
.demo-bar .back { display: inline-flex; align-items: center; min-height: 2.75rem; text-decoration: none; font-weight: 600; font-size: .95rem; margin-right: auto; }
.demo-bar .back:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.demo-note { color: var(--muted); font-size: .86rem; }
.demo-main { padding-block: clamp(1.75rem, 5vw, 3.5rem) 1rem; }
.demo-intro { max-width: 46rem; margin-bottom: clamp(1.5rem, 4vw, 2.4rem); }
.demo-intro h1 { margin-top: .8rem; font-size: clamp(2.2rem, 1.2rem + 3.8vw, 3.9rem); letter-spacing: -.025em; line-height: 1.02; }
.demo-intro h1 em { font-style: italic; color: var(--accent); }
.demo-intro p:not(.eyebrow) { margin-top: 1rem; color: color-mix(in oklab, var(--ink) 80%, var(--bg)); font-size: 1.1rem; max-width: 40rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1rem, 2.5vw, 1.5rem); }
.panel h2 { font-size: clamp(1.4rem, 1.1rem + 1vw, 1.9rem); letter-spacing: -.015em; }
.panel__eyebrow, .panel .panel__eyebrow { font: 600 .72rem/1.3 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.stack { display: grid; gap: 1rem; }

.seg { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span {
  display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 1.05rem; border-radius: 999px;
  border: 1.5px solid var(--line-strong); font-weight: 600; font-size: .95rem; background: var(--bg); transition: background-color .15s, border-color .15s, color .15s;
}
.seg input:hover + span { border-color: var(--ink); }
.seg input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.explain { margin-top: clamp(2.5rem, 6vw, 4rem); }
.explain h2 { font-size: clamp(1.7rem, 1.2rem + 1.6vw, 2.4rem); letter-spacing: -.02em; }
.explain__grid { display: grid; gap: 1.5rem 2rem; margin-top: 1.5rem; }
@media (min-width: 48rem) { .explain__grid { grid-template-columns: repeat(2, 1fr); } }
.explain__grid h3 { font: 600 1.02rem/1.3 var(--font-sans); letter-spacing: 0; }
.explain__grid p { margin-top: .35rem; color: var(--muted); }
.explain__grid li { padding-top: 1rem; border-top: 1px solid var(--line-strong); }

.demo-cta {
  margin-top: clamp(2.5rem, 6vw, 4.5rem); padding: clamp(1.4rem, 4vw, 2.4rem); border: 1px solid var(--line-strong); border-radius: var(--radius);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1.2rem 2rem; background: var(--surface);
}
.demo-cta h2 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); letter-spacing: -.02em; }
.demo-cta p { margin-top: .4rem; color: var(--muted); max-width: 32rem; }
.demo-footer { margin-top: clamp(2.5rem, 6vw, 4rem); padding-block: 1.6rem 2.2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.demo-footer__in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem 2rem; }


[hidden] { display: none !important; }

/* ---------- layout ---------- */
.mc__controls { display: grid; gap: 1.1rem 1.6rem; margin-bottom: 1.5rem; align-items: end; }
@media (min-width: 56rem) { .mc__controls { grid-template-columns: auto minmax(0, 1fr) auto; } }
.mc__controls .field { margin: 0; }
.mc__controls legend { padding: 0; margin-bottom: .35rem; }
.mc__actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.mc__stage { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 58rem) { .mc__stage { grid-template-columns: 21.5rem minmax(0, 1fr); gap: 2.5rem; } }
.side { display: grid; gap: 1rem; }

/* ---------- phone (fixed palette: it is a device, not part of the page theme) ---------- */
.phone {
  --p-bg: #f3f1ec; --p-ink: #16140e; --p-muted: #5b5547; --p-bot: #e4e1d9; --p-you: #b83208;
  --p-line: rgb(22 20 14 / .14); --p-frame: light-dark(#1a1812, #4a463b);
  position: relative; width: min(21.5rem, 100%); height: clamp(36rem, 80vh, 42rem); margin-inline: auto; padding: .55rem;
  border-radius: 2.9rem; background: var(--p-frame); color: var(--p-ink);
  box-shadow: var(--shadow), inset 0 0 0 1px rgb(255 255 255 / .12);
  display: flex; flex-direction: column; overflow: hidden;
}
.phone::before { content: ""; position: absolute; inset: .55rem; border-radius: 2.35rem; background: var(--p-bg); z-index: 0; }
.phone[data-screen="home"]::before { background: #1c1b17; }
.phone[data-screen="call"]::before { background: #26241f; }
.phone__island { position: absolute; z-index: 5; top: 1.1rem; left: 50%; transform: translateX(-50%); width: 5.4rem; height: 1.45rem; border-radius: 999px; background: #0b0a08; }
.phone__status { position: relative; z-index: 4; display: flex; justify-content: space-between; align-items: center; padding: 1.15rem 1.9rem .2rem; font: 600 .8rem/1 var(--font-sans); }
.phone__icons { display: inline-flex; align-items: center; gap: .35rem; }
.phone[data-screen="home"] .phone__status, .phone[data-screen="call"] .phone__status { color: #f5f2ea; }
.scr { position: relative; z-index: 2; flex: 1; min-height: 0; display: flex; flex-direction: column; margin: 0 .55rem .55rem; border-radius: 0 0 2.35rem 2.35rem; overflow: hidden; }

/* home / lock screen */
.scr--home { align-items: center; justify-content: center; text-align: center; gap: .5rem; padding: 1rem 1.4rem; color: #f5f2ea; }
.home__time { font: 200 4.6rem/1 var(--font-sans); letter-spacing: -.03em; margin-top: -1rem; }
.home__date { font-size: 1.02rem; color: #cfcabd; margin-bottom: 2.2rem; }
.call-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .7rem; width: 100%; max-width: 17rem; min-height: 3.4rem; padding: .7rem 1.2rem;
  border: 0; border-radius: 999px; background: #17723c; color: #fff; font: 700 1rem/1.2 var(--font-sans); transition: transform .15s ease, filter .15s ease;
}
.call-btn:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.call-btn:disabled { opacity: .5; cursor: default; }
.call-btn span span { overflow-wrap: anywhere; }
.home__hint { max-width: 15rem; font-size: .9rem; color: #cfcabd; margin-top: .6rem; }

/* calling screen */
.scr--call { align-items: center; justify-content: center; text-align: center; gap: .55rem; padding: 1rem; color: #f5f2ea; }
.rings { position: absolute; top: 50%; left: 50%; width: 9rem; height: 9rem; transform: translate(-50%, -78%); pointer-events: none; }
.rings i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgb(255 255 255 / .28); animation: ring 2s ease-out infinite; }
.rings i:nth-child(2) { animation-delay: 1s; }
@keyframes ring { from { transform: scale(.7); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }
.call__name { font: 400 1.5rem/1.2 var(--font-serif); max-width: 15rem; overflow-wrap: anywhere; }
.call__state { color: #cfcabd; font-size: 1rem; }
.avatar { display: grid; place-items: center; border-radius: 50%; background: var(--p-you); color: #fff; font: 700 1rem/1 var(--font-sans); letter-spacing: .02em; flex: none; }
.avatar--lg { width: 5.2rem; height: 5.2rem; font-size: 1.7rem; position: relative; z-index: 1; margin-bottom: .4rem; }
.avatar--sm { width: 2.5rem; height: 2.5rem; font-size: .9rem; }

/* messages */
.scr--msgs { background: var(--p-bg); }
.m-head { display: flex; align-items: center; gap: .7rem; padding: .7rem 1rem; border-bottom: 1px solid var(--p-line); background: #faf9f6; }
.m-name { font-weight: 700; font-size: .95rem; line-height: 1.2; overflow-wrap: anywhere; }
.m-sub { font-size: .76rem; color: var(--p-muted); }
.m-log { flex: 1; min-height: 0; overflow-y: auto; padding: .8rem .85rem; display: flex; flex-direction: column; gap: .45rem; overscroll-behavior: contain; }
.msg { max-width: 84%; padding: .55rem .8rem .5rem; border-radius: 1.1rem; font-size: .93rem; line-height: 1.38; overflow-wrap: anywhere; animation: pop .26s ease both; }
.msg p { margin: 0; }
.msg time { display: block; margin-top: .2rem; font-size: .68rem; }
.msg--bot { align-self: flex-start; background: var(--p-bot); border-bottom-left-radius: .3rem; }
.msg--bot time { color: var(--p-muted); }
.msg--you { align-self: flex-end; background: var(--p-you); color: #fff; border-bottom-right-radius: .3rem; }
.msg--you time { color: rgb(255 255 255 / .9); text-align: right; }
.msg--typing { display: inline-flex; gap: .28rem; padding: .75rem .9rem; }
.msg--typing span { width: .45rem; height: .45rem; border-radius: 50%; background: #8a8474; animation: bounce 1.1s ease-in-out infinite; }
.msg--typing span:nth-child(2) { animation-delay: .15s; }
.msg--typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .55; } 30% { transform: translateY(-4px); opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.m-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .35rem .85rem .5rem; }
.chip {
  min-height: 2.5rem; padding: 0 .9rem; border-radius: 999px; border: 1.5px solid var(--p-you); background: #fff; color: var(--p-you);
  font: 600 .88rem/1.1 var(--font-sans); transition: background-color .15s, color .15s;
}
.chip:hover { background: var(--p-you); color: #fff; }
.chip:focus-visible, .m-send:focus-visible, .m-field:focus-visible { outline: 3px solid var(--p-you); outline-offset: 2px; }
.phone.is-locked .chip { pointer-events: none; opacity: .65; }
.m-input { display: flex; gap: .5rem; padding: .5rem .75rem .95rem; border-top: 1px solid var(--p-line); background: #faf9f6; }
.m-field { flex: 1; min-width: 0; min-height: 2.6rem; padding: 0 .95rem; border-radius: 999px; border: 1.5px solid rgb(22 20 14 / .3); background: #fff; color: #16140e; }
.m-field::placeholder { color: #5b5547; opacity: 1; }
.m-field:disabled { background: #efede7; }
.m-send { display: grid; place-items: center; flex: none; width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; background: var(--p-you); color: #fff; }
.m-send:disabled { opacity: .4; cursor: default; }

/* ---------- side panels ---------- */
.panel__eyebrow { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.tl li { display: grid; grid-template-columns: 1.3rem 1fr auto; gap: .75rem; align-items: center; padding: .62rem 0; border-top: 1px solid var(--line); }
.tl li:first-child { border-top: 0; }
.tl .mark { width: 1.05rem; height: 1.05rem; border-radius: 50%; border: 2px solid var(--line-strong); transition: all .25s ease; }
.tl li[data-state="active"] .mark { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.tl li[data-state="done"] .mark { background: var(--good); border-color: var(--good); }
.tl li[data-state="pending"] .tl__t { color: var(--muted); }
.tl li[data-state="active"] .tl__t { font-weight: 650; }
.tl time { font: 500 .78rem/1 var(--font-mono); color: var(--muted); min-width: 4.8rem; text-align: right; }
.badge { display: inline-block; padding: .22rem .55rem; border-radius: 999px; background: var(--bad-soft); color: var(--bad); font: 700 .68rem/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.lead { display: grid; gap: 0; }
.lead > div { display: grid; grid-template-columns: 6.2rem 1fr; gap: .8rem; padding: .55rem 0; border-top: 1px solid var(--line); }
.lead > div:first-child { border-top: 0; }
.lead dt { font: 600 .72rem/1.6 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lead dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.lead dd.is-empty { color: var(--muted); font-weight: 400; }

.owner { min-height: 7rem; display: grid; align-items: stretch; }
.owner__ghost { display: grid; place-items: center; text-align: center; padding: 1.2rem; border: 1.5px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); font-size: .95rem; }
.owner__card { padding: 1rem 1.15rem 1.1rem; border-radius: 1.3rem; background: light-dark(#e9e6df, #2a2822); border: 1px solid var(--line); box-shadow: var(--shadow); }
.owner__card.pop { animation: slide .5s cubic-bezier(.2, .9, .3, 1) both; }
@keyframes slide { from { opacity: 0; transform: translateY(-14px) scale(.97); } to { opacity: 1; transform: none; } }
.owner__app { display: flex; justify-content: space-between; font: 600 .72rem/1 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .6rem; }
.owner__title { font-weight: 700; }
.owner__body { margin-top: .25rem; color: color-mix(in oklab, var(--ink) 85%, var(--bg)); overflow-wrap: anywhere; }

/* ---------- calculator ---------- */
.calc { margin-top: clamp(1.5rem, 4vw, 2.5rem); }
.calc__intro { margin-top: .5rem; color: var(--muted); max-width: 38rem; }
.calc__grid { display: grid; gap: 1.2rem 2rem; margin-top: 1.4rem; }
@media (min-width: 44rem) { .calc__grid { grid-template-columns: repeat(2, 1fr); } }
.rng { display: grid; grid-template-columns: minmax(0, 1fr) 3.4rem; gap: .9rem; align-items: center; }
.rng input[type="range"] { width: 100%; min-height: 2.75rem; accent-color: var(--accent); }
.rng output { font: 600 1.05rem/1 var(--font-mono); text-align: right; }
.money { position: relative; }
.money span { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); font-weight: 600; color: var(--muted); }
.money .input { padding-left: 1.7rem; font: 600 1.05rem/1 var(--font-mono); }
.calc__out { display: grid; gap: 1rem; margin-top: 1.6rem; padding-top: 1.4rem; border-top: 1px solid var(--line-strong); }
@media (min-width: 44rem) { .calc__out { grid-template-columns: 1fr 1fr 1.4fr; align-items: end; } }
.calc__out .k { display: block; font: 600 .72rem/1.4 var(--font-mono); letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.calc__out strong { display: block; margin-top: .25rem; font: 400 clamp(1.9rem, 1.3rem + 2vw, 2.7rem)/1 var(--font-serif); letter-spacing: -.02em; }
.calc__big strong { font-size: clamp(2.6rem, 1.6rem + 3.4vw, 4.2rem); color: var(--accent); }
.calc .fine { margin-top: 1.2rem; }
.explain__note { margin-top: 1.4rem; max-width: 44rem; }
