:root {
  --ivory: #f8f5ef;
  --paper: #fffdf9;
  --linen: #efe9df;
  --line: #e2dacd;
  --gold: #a8875a;        /* champagne gold for rules and accents */
  --gold-ink: #7a5f3a;    /* gold dark enough for text (AA on ivory) */
  --gold-soft: #f1e8da;
  --charcoal: #2b2926;
  --ink-2: #4f4a44;
  --taupe: #6f665d;       /* muted taupe, AA for small text */
  --sage: #5f7360;
  --rose: #9a4f45;
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  --nav-h: 68px;
  --ease: 180ms ease;
  color-scheme: light;
}
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html[data-text="large"] { font-size: 18px; }
html[data-text="xl"] { font-size: 20px; }
html[data-motion="reduced"] *, html[data-motion="reduced"] *::before { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

* { box-sizing: border-box; }
body { margin: 0; background: var(--ivory); color: var(--charcoal); font: 1rem/1.55 var(--sans); min-height: 100vh; }
a { color: var(--gold-ink); }
h1, h2, h3, .serif { font-family: var(--serif); font-weight: 400; letter-spacing: 0.005em; margin: 0; }
h1 { font-size: 2.1rem; line-height: 1.15; }
h2 { font-size: 1.45rem; line-height: 1.25; }
h3 { font-size: 1.12rem; line-height: 1.3; }
p { margin: 0.35rem 0; }
small, .muted { color: var(--taupe); }
.muted { font-size: 0.92rem; }
.eyebrow { font: 600 0.72rem/1.2 var(--sans); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold-ink); }
:focus-visible { outline: 2px solid var(--gold-ink); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- layout ---------- */
.shell { max-width: 680px; margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 8px 0 22px; }
.top .date { color: var(--taupe); font-size: 0.92rem; margin-top: 4px; }
.brand { font-family: var(--serif); font-size: 1.15rem; color: var(--gold-ink); text-decoration: none; }
.stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 420px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- nav ---------- */
.nav { position: fixed; inset: auto 0 0 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 253, 249, 0.96); border-top: 1px solid var(--line); display: flex; justify-content: center; z-index: 20; backdrop-filter: blur(8px); }
.nav a { flex: 1; max-width: 136px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-decoration: none; color: var(--taupe); font-size: 0.74rem; letter-spacing: 0.04em; }
.nav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.4; }
.nav a[aria-current="page"] { color: var(--charcoal); }
.nav a[aria-current="page"]::after { content: ""; width: 18px; height: 2px; background: var(--gold); border-radius: 2px; }

/* ---------- cards ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.hero { padding: 22px; border-color: var(--gold); background: linear-gradient(180deg, #fffdf9, #fbf6ee); }
.card.soft { background: var(--linen); border-color: transparent; }
.card > .eyebrow + * { margin-top: 8px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.hero-title { font-family: var(--serif); font-size: 1.6rem; line-height: 1.25; margin: 6px 0 4px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.empty { color: var(--taupe); font-style: italic; }
.disclaimer { font-size: 0.82rem; color: var(--taupe); margin-top: 18px; }

/* ---------- buttons & inputs ---------- */
button, .btn { font: 500 0.95rem/1 var(--sans); border-radius: 999px; border: 1px solid var(--charcoal); background: var(--charcoal); color: var(--ivory);
  padding: 12px 18px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background var(--ease), color var(--ease); }
button:hover, .btn:hover { background: #45413c; }
button.ghost, .btn.ghost { background: transparent; color: var(--charcoal); border-color: var(--line); }
button.ghost:hover, .btn.ghost:hover { border-color: var(--gold); background: var(--gold-soft); }
button.gold, .btn.gold { background: var(--gold-ink); border-color: var(--gold-ink); }
button.link { background: none; border: 0; color: var(--gold-ink); padding: 6px 4px; min-height: 0; text-decoration: underline; text-underline-offset: 3px; }
button.danger { background: var(--rose); border-color: var(--rose); }
button.small, .btn.small { padding: 8px 12px; min-height: 36px; font-size: 0.85rem; }
button:disabled { opacity: 0.5; cursor: default; }
.icon-btn { width: 40px; min-height: 40px; height: 40px; padding: 0; background: transparent; color: var(--taupe); border-color: transparent; }
.icon-btn:hover { background: var(--linen); color: var(--charcoal); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

label.field { display: block; }
label.field > span { display: block; font-size: 0.86rem; color: var(--ink-2); margin-bottom: 6px; }
input, select, textarea { width: 100%; font: 1rem/1.4 var(--sans); color: var(--charcoal); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 44px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px var(--gold-soft); }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--gold-ink); flex: none; }
.check { display: flex; align-items: center; gap: 10px; }
form.stack > * + * { margin-top: 14px; }
.error { color: var(--rose); font-size: 0.92rem; }

/* chips / choices */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--paper); color: var(--ink-2); border-radius: 999px; padding: 8px 14px; min-height: 38px; font-size: 0.9rem; }
.chip:hover { background: var(--gold-soft); color: var(--charcoal); }
.chip[aria-pressed="true"] { background: var(--charcoal); color: var(--ivory); border-color: var(--charcoal); }
.tag { display: inline-block; font-size: 0.76rem; color: var(--gold-ink); background: var(--gold-soft); border-radius: 999px; padding: 2px 9px; }
.tag.grey { color: var(--taupe); background: var(--linen); }
.choice-grid { display: grid; gap: 10px; }
.choice-grid button { justify-content: flex-start; background: var(--paper); color: var(--charcoal); border-color: var(--line); border-radius: 12px; padding: 16px; font-size: 1.02rem; }
.choice-grid button:hover, .choice-grid button[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 0.92rem; color: var(--ink-2); }
.switch input { appearance: none; width: 44px; height: 26px; min-height: 0; border-radius: 999px; background: var(--line); border: 0; padding: 0; position: relative; transition: background var(--ease); }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform var(--ease); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.switch input:checked { background: var(--gold-ink); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .title { display: block; color: var(--charcoal); text-decoration: none; }
.list .meta { display: block; font-size: 0.82rem; color: var(--taupe); margin-top: 2px; }
.list li.done .title { color: var(--taupe); text-decoration: line-through; text-decoration-color: var(--gold); }
.time { font-variant-numeric: tabular-nums; color: var(--gold-ink); font-size: 0.86rem; width: 48px; flex: none; }
.timeline li.fixed { background: var(--linen); margin: 4px -10px; padding: 10px; border-radius: 10px; border: 0; }
.timeline li.break .title { font-style: italic; color: var(--sage); }
details summary { cursor: pointer; color: var(--gold-ink); font-size: 0.92rem; padding: 6px 0; }

/* ---------- wardrobe ---------- */
.wgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.witem { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; text-align: left; padding: 0; color: var(--charcoal); min-height: 0; font-weight: 400; }
.witem:hover { background: var(--paper); border-color: var(--gold); }
.witem .ph { aspect-ratio: 4 / 5; background: var(--linen); display: flex; align-items: center; justify-content: center; color: var(--gold-ink); font-family: var(--serif); font-size: 1.6rem; width: 100%; }
.witem img, .piece img { width: 100%; height: 100%; object-fit: cover; display: block; }
.witem .wb { padding: 10px 12px; width: 100%; }
.witem.unowned { border-style: dashed; }
.pieces { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.piece { text-align: center; font-size: 0.82rem; color: var(--ink-2); }
.piece .ph { aspect-ratio: 4 / 5; background: var(--linen); border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; margin-bottom: 6px; color: var(--gold-ink); font-family: var(--serif); }

/* ---------- check-in / flows ---------- */
.flow { min-height: 70vh; display: flex; flex-direction: column; }
.flow .q { font-family: var(--serif); font-size: 1.7rem; line-height: 1.25; margin: 18px 0 22px; }
.flow .foot { margin-top: auto; padding-top: 24px; display: flex; justify-content: space-between; gap: 10px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--gold); }

/* ---------- focus ---------- */
.focus { position: fixed; inset: 0; background: var(--ivory); z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 28px; text-align: center; overflow: auto; }
.focus h1 { max-width: 560px; }
.focus .step { margin-top: 12px; color: var(--ink-2); font-size: 1.1rem; }
.ring { width: 220px; height: 220px; margin: 28px auto 10px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset 1s linear; }
.ring .clock { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 2.4rem var(--serif); font-variant-numeric: tabular-nums; }
.focus .close { position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; }

/* ---------- sheet (dialog) ---------- */
dialog.sheet { border: 0; border-radius: 18px 18px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); width: 100%; max-width: 680px; margin: auto auto 0; max-height: 92vh; background: var(--paper); color: var(--charcoal); }
@media (min-width: 700px) { dialog.sheet { border-radius: 18px; margin: auto; } }
dialog.sheet::backdrop { background: rgba(43, 41, 38, 0.38); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

/* ---------- misc ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--charcoal); color: var(--ivory);
  padding: 11px 18px; border-radius: 999px; font-size: 0.92rem; opacity: 0; pointer-events: none; transition: opacity var(--ease), transform var(--ease); z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.auth { max-width: 420px; margin: 0 auto; padding: 12vh 22px 40px; }
.auth h1 { font-size: 3rem; }
.auth .tagline { font-family: var(--serif); font-size: 1.2rem; color: var(--ink-2); margin: 6px 0 30px; }
.bar { height: 8px; background: var(--linen); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font-size: 0.78rem; color: var(--taupe); }
.week .e { width: 14px; height: 14px; border-radius: 50%; margin: 6px auto; background: var(--line); }
.week .e.low { background: #d9c7ae; } .week .e.normal { background: var(--gold); } .week .e.high { background: var(--gold-ink); }
.code { font: 1.05rem/1.6 ui-monospace, Menlo, monospace; letter-spacing: 0.08em; background: var(--linen); padding: 10px 12px; border-radius: 10px; word-break: break-all; }
.hub a.card { display: block; text-decoration: none; color: inherit; }
.hub a.card:hover { border-color: var(--gold); }
.loading { padding: 40px 0; text-align: center; color: var(--taupe); font-family: var(--serif); }
button, .btn { white-space: nowrap; }
.card > input + input { margin-top: 10px; }
.card > input:first-of-type { margin-top: 6px; }
.card > label.field { margin-top: 12px; }
