/* Shared components: type, surfaces, buttons, badges, forms, sheets,
   feedback. Status is always colour plus an icon plus a word, never colour
   alone. Loaded after tokens.css, before a surface's own stylesheet. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--brand); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.ic { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.ic.lg { width: 34px; height: 34px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.fine { font-size: 13px; color: var(--muted); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 14px; }
.stack > * { min-width: 0; }            /* long names truncate instead of widening the page */
.ok { color: var(--ok); } .warn { color: var(--warn); }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- type ---------- */
.sec { font-size: 15px; font-weight: 700; margin: 10px 2px 8px; display: flex; align-items: center; gap: 7px; }
.sec.flush { margin: 0; }
.day { font-size: 13px; font-weight: 600; color: var(--muted); margin: 14px 2px 7px; }
.sub { font-size: 15px; font-weight: 700; margin: 18px 0 6px; }
.lead { font-size: 17px; color: var(--ink-2); }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 10px; }
.card.flush { padding: 0; overflow: hidden; }
.card.quiet { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); box-shadow: none; color: var(--ink-2); }
.card.empty { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 30px 20px; color: var(--ink-2); }
.card.dev { border-style: dashed; background: var(--surface-2); box-shadow: none; }
.card.dev p { margin: 6px 0 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-ink); font-size: 16px; font-weight: 650;
  cursor: pointer; text-decoration: none; transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: scale(.985); }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { display: flex; width: 100%; }
.btn.big { min-height: 56px; font-size: 17px; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.ghost { background: transparent; color: var(--brand); }
.btn + .btn { margin-top: 8px; }
.linkish { background: none; border: 0; color: var(--brand); padding: 0; cursor: pointer; text-decoration: underline; font-size: inherit; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; padding: 5px 11px;
  font-size: 13px; font-weight: 650; border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.chip .ic { width: 15px; height: 15px; }
.chip.demo { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.streak { background: var(--ok-bg); color: var(--ok); border-color: transparent; cursor: default; }
.tag { font-size: 12px; font-weight: 650; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); padding: 1px 7px; border-radius: 6px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 11px 5px 8px;
  font-size: 14px; font-weight: 650; border: 0;
}
.badge .ic { width: 17px; height: 17px; }
.badge.as-btn { width: 100%; justify-content: center; min-height: 44px; cursor: pointer; margin-top: 12px; }
.tone-ok { --t: var(--ok); --tbg: var(--ok-bg); --ts: var(--ok-strong); }
.tone-warn { --t: var(--warn); --tbg: var(--warn-bg); --ts: var(--warn-strong); }
.tone-bad { --t: var(--bad); --tbg: var(--bad-bg); --ts: var(--bad-strong); }
.tone-neutral { --t: var(--ink-2); --tbg: var(--surface-2); --ts: var(--muted); }
.badge[class*="tone-"], .dot[class*="tone-"] { background: var(--tbg); color: var(--t); }

/* ---------- lists ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }
.plain { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 8px; color: var(--ink-2); }
.pick { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.pick-row { width: 100%; text-align: left; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 600; }
.pick-row.on { border-color: var(--brand); background: var(--brand-tint); }

/* ---------- sheets ---------- */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 560px; max-height: 92dvh;
  background: var(--surface); color: var(--ink); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-lg);
  overflow: auto; overscroll-behavior: contain; animation: up .26s cubic-bezier(.2, .8, .2, 1);
}
dialog.sheet::backdrop { background: rgba(8, 10, 14, .45); animation: fade .2s ease; }
@media (min-width: 640px) {
  dialog.sheet { margin: auto; border-radius: 22px; max-width: 460px; max-height: 88vh; animation: pop .2s ease; }
  .sheet-grip { display: none; }
}
.sheet-grip { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 9px auto 0; }
.sheet-x { position: absolute; top: 12px; right: 12px; width: 38px; height: 38px; border-radius: 50%; border: 0;
  background: var(--surface-2); display: grid; place-items: center; cursor: pointer; color: var(--muted); z-index: 2; }
.sheet-x .ic { width: 18px; height: 18px; }
.sheet-body { padding: 20px 20px calc(22px + env(safe-area-inset-bottom)); }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.step { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 12px 4px 4px; }
.step.left, .result.left { justify-items: stretch; text-align: left; }
.step h2, .result h2 { text-wrap: balance; font-size: 22px; line-height: 1.25; letter-spacing: -.01em; }
.step p { color: var(--ink-2); }
.step .btn { margin-top: 6px; }
.step .btn + .btn { margin-top: 0; }
.step label { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-top: 6px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; min-height: 48px;
}
textarea { resize: vertical; min-height: 84px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two > div { display: grid; gap: 6px; }
.how { text-align: left; padding-left: 22px; display: grid; gap: 8px; color: var(--ink-2); margin: 4px 0; }

.hero-ic { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand); margin-bottom: 4px; }
.hero-ic .ic { width: 36px; height: 36px; stroke-width: 2.2; }
.hero-ic.warn { background: var(--warn-bg); color: var(--warn); }
.hero-ic[class*="tone-"] { background: var(--tbg); color: var(--t); }
.result { display: grid; justify-items: center; text-align: center; gap: 8px; padding-top: 10px; }
.result .hero-ic { animation: pop .3s ease; }
.result .lead { font-size: 16.5px; }
.result.left .badge { justify-self: start; margin-bottom: 4px; }
.result .actions { width: 100%; margin-top: 10px; }

.pulse { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; color: var(--brand);
  background: var(--brand-tint); position: relative; margin: 8px 0 6px; }
.pulse .ic { width: 34px; height: 34px; }
.pulse::before, .pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--brand); opacity: 0; animation: ring 1.8s ease-out infinite; }
.pulse::after { animation-delay: .9s; }
@keyframes ring { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(1.8); opacity: 0; } }

.checks { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 9px; text-align: left; width: 100%; }
.checks li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; color: var(--ink-2); }
.checks li .ic { width: 18px; height: 18px; margin-top: 2px; }
.checks li.ok .ic { color: var(--ok-strong); }
.checks li.no .ic { color: var(--bad-strong); }
.checks li.info .ic { color: var(--muted); }

.callout { display: flex; gap: 9px; align-items: flex-start; text-align: left; width: 100%;
  background: var(--surface-2); border-radius: 12px; padding: 11px 13px; font-size: 15px; color: var(--ink-2); margin-top: 6px; }
.callout .ic { margin-top: 1px; }
.callout.warn { background: var(--warn-bg); color: var(--warn); }
.callout.ok { background: var(--ok-bg); color: var(--ok); }

.review { width: 100%; border-radius: 12px; padding: 12px 14px; margin-top: 8px; background: var(--tbg); color: var(--ink); }
.review p { margin: 6px 0; color: var(--ink-2); }
.mynote { background: var(--surface-2); border-radius: 12px; padding: 11px 13px; margin-top: 8px; }
.mynote p { color: var(--ink-2); margin-bottom: 4px; }
.note-form { display: grid; gap: 8px; width: 100%; text-align: left; margin-top: 14px; }
.note-form label { font-size: 14px; font-weight: 600; color: var(--ink-2); }

/* ---------- loading, toast ---------- */
.sk { border-radius: 10px; background: linear-gradient(90deg, var(--line) 0 40%, var(--surface-2) 50%, var(--line) 60% 100%);
  background-size: 300% 100%; animation: shimmer 1.3s linear infinite; }
.sk-title { height: 30px; width: 60%; margin: 12px 0 4px; }
.sk-card { height: 170px; background: linear-gradient(90deg, var(--surface) 0 40%, var(--surface-2) 50%, var(--surface) 60% 100%);
  background-size: 300% 100%; animation: shimmer 1.3s linear infinite; }
.sk-card.short { height: 110px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .22s ease;
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 15px;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast { display: flex; align-items: center; gap: 14px; }
.toast.has-action.show { pointer-events: auto; }
.toast button { background: none; border: 0; color: var(--brand-tint); font-weight: 750; cursor: pointer; padding: 4px 2px; text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
