/* GiftMatch console: "the gift tag". Cream paper on a kraft desk, deep green ink, one coral ribbon.
   Tokens keep the names used across the workspace (--bg --surface --ink --muted --line --brand --ok --warn --bad).
   Colours as in docs/BRAND.md. Light and dark; colour is never the only signal (labels carry an icon and a word). */
:root {
  color-scheme: light;
  --bg: #fbf6ee; --surface: #fffdf8; --surface-2: #f5ecdd; --desk: #ecdcc3;
  --ink: #0f3d3a; --ink-2: #365653; --muted: #5a6f6c; --faint: #86958f;
  --line: #e4d8c4; --line-2: #cdbb9f;
  --kraft: #d9b88f; --kraft-2: #c9a574; --string: #8a6a43;
  --brand: #ff5a4d; --brand-ink: #c2372b; --on-brand: #0b2e2c;
  --ok: #1f7a4d; --warn: #9a5b07; --bad: #b3261e;
  --ok-bg: #e3f3ea; --warn-bg: #fbeed2; --bad-bg: #fbe3df;
  --ev-observed: #2a5f94; --ev-possible: #8a5a12; --ev-user_confirmed: #1f7a4d; --ev-not_verifiable: #5a6a68;
  --ev-observed-bg: #e3edf8; --ev-possible-bg: #fbf0d8; --ev-user_confirmed-bg: #e3f3ea; --ev-not_verifiable-bg: #ecefee;
  --shadow: 0 1px 0 rgba(15,61,58,.06), 0 8px 22px -10px rgba(74,50,20,.28);
  --grain: rgba(15,61,58,.045);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px; --r-sm: 6px; --focus: #0f3d3a;
}
:root[data-theme="dark"] { color-scheme: dark; --bg: #0e1f1e; --surface: #152a28; --surface-2: #1b3330; --desk: #0a1716;
  --ink: #f3ecdf; --ink-2: #d3cdbf; --muted: #a5b6b1; --faint: #7d908b; --line: #264240; --line-2: #3a5b57;
  --kraft: #a8855c; --kraft-2: #8a6a43; --string: #c9a574; --brand: #ff6f62; --brand-ink: #ff8f84; --on-brand: #0b2e2c;
  --ok: #6fd6a0; --warn: #f0b45a; --bad: #ff8a80; --ok-bg: #173a2b; --warn-bg: #3d2f12; --bad-bg: #44201d;
  --ev-observed: #8bb9ea; --ev-possible: #e8b95f; --ev-user_confirmed: #6fd6a0; --ev-not_verifiable: #b4c2bf;
  --ev-observed-bg: #172b40; --ev-possible-bg: #3a2d12; --ev-user_confirmed-bg: #173a2b; --ev-not_verifiable-bg: #22312f;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 10px 24px -10px rgba(0,0,0,.6); --grain: rgba(243,236,223,.035); --focus: #f3ecdf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark; --bg: #0e1f1e; --surface: #152a28; --surface-2: #1b3330; --desk: #0a1716;
  --ink: #f3ecdf; --ink-2: #d3cdbf; --muted: #a5b6b1; --faint: #7d908b; --line: #264240; --line-2: #3a5b57;
  --kraft: #a8855c; --kraft-2: #8a6a43; --string: #c9a574; --brand: #ff6f62; --brand-ink: #ff8f84; --on-brand: #0b2e2c;
  --ok: #6fd6a0; --warn: #f0b45a; --bad: #ff8a80; --ok-bg: #173a2b; --warn-bg: #3d2f12; --bad-bg: #44201d;
  --ev-observed: #8bb9ea; --ev-possible: #e8b95f; --ev-user_confirmed: #6fd6a0; --ev-not_verifiable: #b4c2bf;
  --ev-observed-bg: #172b40; --ev-possible-bg: #3a2d12; --ev-user_confirmed-bg: #173a2b; --ev-not_verifiable-bg: #22312f;
  --shadow: 0 1px 0 rgba(0,0,0,.4), 0 10px 24px -10px rgba(0,0,0,.6); --grain: rgba(243,236,223,.035); --focus: #f3ecdf; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100vh; }
/* paper grain, CSS only */
body.paper::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(var(--grain) 1px, transparent 1.3px), radial-gradient(var(--grain) 1px, transparent 1.3px);
  background-size: 6px 6px, 9px 9px; background-position: 0 0, 3px 4px; }
body.paper > .desk, body.paper > .lp, body.paper > .pubbar, body.paper > .doc, body.paper > .pubfoot, body.paper > .err-page { position: relative; z-index: 1; }

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; line-height: 1.15; margin: 0; color: var(--ink); }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); } h2 { font-size: 1.35rem; } h3 { font-size: 1.08rem; }
p { margin: 0; } a { color: var(--ink); text-underline-offset: 3px; } a:hover { color: var(--brand-ink); }
em { font-style: italic; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 55%, transparent); border-radius: 4px; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 6px; } .skip-link:focus { top: 8px; }
.i { width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: .86rem; } .sub { color: var(--muted); font-size: .88rem; }
.eyebrow { display: inline-block; font: 700 .72rem/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--brand-ink); }
.stack { display: grid; gap: 22px; } .stack.sm { gap: 12px; } .row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; } .row.between { justify-content: space-between; } .grow { flex: 1 1 0; min-width: 0; }
.nowrap { white-space: nowrap; } [hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* ---- shell: kraft desk, paper sheet, folder-index tabs ---- */
.desk { min-height: 100vh; background: var(--desk); padding: 0 clamp(0px, 2vw, 24px) 24px; display: flex; flex-direction: column; }
.deskbar { display: flex; align-items: flex-end; gap: 18px; max-width: 1180px; width: 100%; margin: 0 auto; padding: 14px 6px 0; }
.brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); align-self: center; }
.brand:hover { color: var(--ink); }
.brand-mark img { display: block; border-radius: 22%; }
.wm { font: 600 1.28rem/1 var(--serif); letter-spacing: -.02em; } .wm em { font-style: italic; color: var(--brand-ink); }
.tabs { display: flex; gap: 3px; align-items: flex-end; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; padding-left: 8px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 9px 14px 8px; border-radius: 9px 9px 0 0; font-size: .9rem; font-weight: 600; color: var(--ink-2); text-decoration: none; background: color-mix(in srgb, var(--kraft) 38%, var(--desk)); border: 1px solid transparent; border-bottom: 0; white-space: nowrap; min-height: 40px; display: inline-flex; align-items: center; transform: translateY(2px); transition: transform .15s; }
.tabs a:hover { transform: translateY(0); color: var(--ink); }
.tabs a[aria-current="page"] { background: var(--bg); color: var(--ink); border-color: var(--line-2); transform: translateY(1px); padding-bottom: 10px; }
.deskbar-actions { display: flex; align-items: center; gap: 10px; align-self: center; }
.sheet { background: var(--bg); max-width: 1180px; width: 100%; margin: 0 auto; flex: 1; border: 1px solid var(--line-2); border-radius: 0 var(--r) var(--r) var(--r); padding: clamp(18px, 3vw, 34px); box-shadow: var(--shadow); outline: none; min-width: 0; }
#app > * + * { margin-top: 22px; }
#app:not(.settled) > * { animation: rise .35s ease both; } @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.foot { max-width: 1180px; width: 100%; margin: 14px auto 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: .82rem; color: var(--muted); justify-content: center; }
.foot a { color: var(--muted); }
.pubfoot { padding: 24px 16px 30px; margin: 0 auto; }
.wallet-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-size: .84rem; font-weight: 700; text-decoration: none; min-height: 36px; }
.wallet-chip.low { border-color: var(--warn); color: var(--warn); } .wl { font-weight: 500; }
.user-menu { position: relative; }
.avatar { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 700 .85rem var(--sans); cursor: pointer; }
.pop { position: absolute; right: 0; top: 46px; z-index: 30; min-width: 220px; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); box-shadow: var(--shadow); padding: 6px; display: grid; }
.pop .who { padding: 8px 10px; display: grid; } .pop .who span { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.pop a, .pop button, .sheet-pop a, .sheet-pop button { display: flex; align-items: center; gap: 10px; padding: 10px; min-height: 44px; border: 0; background: none; color: var(--ink); text-decoration: none; font: 500 .95rem var(--sans); border-radius: 6px; cursor: pointer; text-align: left; width: 100%; }
.pop a:hover, .pop button:hover, .sheet-pop a:hover, .sheet-pop button:hover { background: var(--surface-2); }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.tabbar, .more-sheet { display: none; }

/* ---- controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 999px; border: 1.5px solid var(--ink); background: transparent; color: var(--ink); font: 700 .95rem var(--sans); text-decoration: none; cursor: pointer; transition: background .15s, transform .15s; }
.btn:hover { background: color-mix(in srgb, var(--ink) 9%, transparent); color: var(--ink); }
.btn.cta, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.cta:hover, .btn.primary:hover { background: color-mix(in srgb, var(--brand) 86%, #fff); color: var(--on-brand); }
.btn.sm { min-height: 40px; padding: 6px 14px; font-size: .88rem; } .btn.lg { min-height: 54px; padding: 14px 28px; font-size: 1.08rem; }
.btn.ghost { border-color: transparent; } .btn.danger { border-color: var(--bad); color: var(--bad); } .btn.danger.solid { background: var(--bad); color: #fff; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; } .btn[aria-busy="true"]::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid var(--on-brand); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--ink); cursor: pointer; } .icon-btn:hover { background: var(--surface-2); }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-ink); font: 600 inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; min-height: 28px; }
.field { display: grid; gap: 6px; } .field > label, .lbl { font-weight: 700; font-size: .85rem; color: var(--ink-2); }
.hint { color: var(--muted); font-size: .82rem; }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--line-2); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: 1rem var(--sans); }
textarea.input { min-height: 88px; resize: vertical; }
.input:focus-visible { outline-offset: 0; }
.err { color: var(--bad); font-weight: 600; min-height: 1em; }
.field.bad .input { border-color: var(--bad); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; } .check input { width: 20px; height: 20px; accent-color: var(--ink); }
.seg { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.toggle { position: relative; } .toggle input { position: absolute; opacity: 0; inset: 0; cursor: pointer; width: 100%; height: 100%; margin: 0; }
.toggle span { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 8px 16px; border: 1.5px solid var(--line-2); border-radius: 999px; background: var(--surface); font-weight: 600; font-size: .92rem; }
.toggle input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toggle input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand) 55%, transparent); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 999px; border: 1.5px solid var(--line-2); background: var(--surface); font-size: .9rem; font-weight: 600; max-width: 100%; min-height: 36px; }
.chip.unsure { border-style: dashed; border-color: var(--warn); background: var(--warn-bg); }
.chip button { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; } .chip button:hover { background: var(--surface-2); color: var(--ink); }
.chip .t { overflow-wrap: anywhere; }
.chip-soft { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: .76rem; font-weight: 700; }
.chip-suggest { padding: 6px 12px; min-height: 36px; border-radius: 999px; border: 1.5px dashed var(--line-2); background: transparent; color: var(--ink-2); font: 600 .88rem var(--sans); cursor: pointer; } .chip-suggest:hover { background: var(--surface-2); border-style: solid; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* evidence labels: icon + word + a distinct border style */
.ev { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 8px; border-radius: 6px; font-size: .76rem; font-weight: 800; letter-spacing: .01em; white-space: nowrap; border: 1.5px solid currentColor; }
.ev .i { width: 14px; height: 14px; }
.ev[data-l="observed"] { color: var(--ev-observed); background: var(--ev-observed-bg); border-style: solid; }
.ev[data-l="user_confirmed"] { color: var(--ev-user_confirmed); background: var(--ev-user_confirmed-bg); border-style: double; border-width: 3px; padding: 1px 9px 1px 6px; }
.ev[data-l="possible"] { color: var(--ev-possible); background: var(--ev-possible-bg); border-style: dashed; }
.ev[data-l="not_verifiable"] { color: var(--ev-not_verifiable); background: repeating-linear-gradient(135deg, var(--ev-not_verifiable-bg) 0 5px, transparent 5px 9px); border-style: dotted; }

/* surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: clamp(16px, 2.4vw, 24px); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card.flat { background: transparent; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.page-head p { color: var(--muted); max-width: 60ch; margin-top: 6px; }
.crumbs { display: flex; gap: 8px; color: var(--muted); font-size: .86rem; margin-bottom: 8px; } .crumbs a { color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--kraft); }
.kpi b { display: block; font: 600 1.9rem/1.1 var(--serif); } .kpi span { color: var(--muted); font-size: .84rem; }
.banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--line-2); background: var(--surface); margin-bottom: 18px; }
.banner.warn { background: var(--warn-bg); border-color: var(--warn); } .banner.bad { background: var(--bad-bg); border-color: var(--bad); }
.empty { text-align: center; padding: 34px 16px; display: grid; gap: 10px; justify-items: center; border: 2px dashed var(--line-2); border-radius: var(--r); }
.empty .big { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); } .empty .big .i { width: 26px; height: 26px; }
.empty p { color: var(--muted); max-width: 46ch; }
.skel { background: linear-gradient(100deg, var(--surface-2) 30%, var(--line) 50%, var(--surface-2) 70%) 0 0 / 200% 100%; border-radius: var(--r); animation: shimmer 1.4s linear infinite; }
.skel.line { height: 16px; border-radius: 6px; } .skel.chart { height: 180px; } .skel.kpi-s { height: 78px; } .skel.tagk { height: 260px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; } th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; } th { font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
td.r, th.r { text-align: right; }
.secret { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1.5px dashed var(--line-2); border-radius: var(--r-sm); font-family: var(--mono); word-break: break-all; background: var(--surface-2); }

/* dialogs, toasts */
.scrim { position: fixed; inset: 0; z-index: 70; background: rgba(8,22,21,.55); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.dialog { width: min(520px, 100%); background: var(--surface); border: 1px solid var(--line-2); border-radius: 14px; padding: 22px; box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); max-height: calc(100vh - 32px); overflow-y: auto; }
.dialog.wide { width: min(940px, 100%); } .dialog .actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--ink); color: var(--bg); box-shadow: var(--shadow); }
.toast a { color: inherit; font-weight: 700; } .toast .body { flex: 1; } .toast.ok { border-left: 5px solid var(--ok); } .toast.bad { border-left: 5px solid var(--bad); } .toast.warn { border-left: 5px solid var(--warn); }
.toast .x { background: none; border: 0; color: inherit; cursor: pointer; width: 28px; height: 28px; }
:root[data-theme="dark"] .toast { background: #f3ecdf; color: #0e1f1e; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast { background: #f3ecdf; color: #0e1f1e; } }
.err-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; } .err-in { display: grid; gap: 14px; max-width: 460px; justify-items: start; }

@media (max-width: 1100px) { .deskbar { flex-wrap: wrap; } .tabs { order: 3; flex-basis: 100%; padding-left: 0; } .sheet { border-radius: var(--r); } }
@media (max-width: 860px) {
  .desk { padding: 0 0 calc(86px + env(safe-area-inset-bottom)); background: var(--bg); }
  .deskbar { padding: 10px 14px; align-items: center; } .tabs, .top-cta { display: none; }
  .deskbar-actions { margin-left: auto; }
  .sheet { border: 0; border-radius: 0; box-shadow: none; padding: 16px 16px 28px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface); border-top: 1px solid var(--line-2); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: flex-end; }
  .tabbar a, .tabbar button { flex: 1; display: grid; justify-items: center; gap: 2px; padding: 6px 2px; min-height: 52px; color: var(--muted); font: 600 .68rem var(--sans); text-decoration: none; background: none; border: 0; cursor: pointer; }
  .tabbar a[aria-current="page"], .tabbar button.current { color: var(--ink); } .tabbar a[aria-current="page"] .i { stroke-width: 2.4; }
  .tabbar .tab-plan { color: var(--ink); } .tab-plan .knot { display: grid; place-items: center; width: 52px; height: 52px; margin-top: -26px; border-radius: 50%; background: var(--brand); color: var(--on-brand); border: 4px solid var(--surface); box-shadow: var(--shadow); } .tab-plan .knot .i { width: 24px; height: 24px; }
  .more-sheet { position: fixed; inset: 0; z-index: 50; background: rgba(8,22,21,.5); align-items: flex-end; }
  .more-sheet.open { display: flex; }
  .sheet-pop { width: 100%; background: var(--surface); border-radius: 16px 16px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); display: grid; gap: 2px; }
  .wallet-chip .wl { display: none; }
  .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; } }
@media print { .deskbar, .tabbar, .foot, .banner, .no-print, .toasts { display: none !important; } .desk, .sheet, body { background: #fff !important; box-shadow: none !important; border: 0 !important; } body.paper::before { display: none; } }
.toggle input:checked + span::before { content: "\2713"; font-weight: 800; }
