:root {
  --bg: #121516; --surface: #181C1D; --raised: #22272A; --sheet: #1D2223; --line: #252A2B; --line2: #30373A; --line3: #353B3D;
  --text: #F2F2EF; --text2: #A6ABA9; --text3: #8C918F; --muted: #C9CCCA;
  --coral: #FB6F64; --coral-text: #FF7B70; --coral-bg: #3A2223; --coral-line: #5A2E2C;
  --sage: #8FBA94; --sage-bg: #1E2A22; --on-coral: #1A1414;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif; }
body { min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }

.screen { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-top) + 16px) 16px calc(var(--safe-bottom) + 32px); display: flex; flex-direction: column; gap: 12px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; position: relative; }
.back { height: 44px; display: inline-flex; align-items: center; gap: 6px; margin-left: -6px; padding: 0 6px; font-size: 17px; color: var(--muted); background: none; border: 0; }
h1 { margin: 0; font-weight: 800; font-size: 34px; letter-spacing: -0.02em; line-height: 1.1; }
h2 { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text3); }
.sub { font-size: 15px; color: var(--text2); margin-top: -4px; }
.small { font-size: 12px; color: var(--text3); line-height: 17px; }

.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line); background: transparent; display: inline-flex; align-items: center; justify-content: center; }
.chip { height: 40px; display: inline-flex; align-items: center; gap: 8px; padding: 0 12px 0 5px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.avatars { display: flex; }
.avatar { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-left: -8px; }
.avatar:first-child { margin-left: 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); display: inline-block; }
.dot.off { background: var(--text3); }

.menu { position: absolute; right: 0; top: 52px; z-index: 10; width: 268px; padding: 6px; border-radius: 16px; background: var(--sheet); border: 1px solid var(--line2); box-shadow: 0 18px 40px rgba(0,0,0,.5); display: flex; flex-direction: column; }
.menu a, .menu button { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 52px; padding: 8px 12px; border-radius: 10px; text-align: left; background: none; border: 0; }
.menu a:hover, .menu button:hover { background: var(--raised); }
.menu b { font-size: 16px; font-weight: 600; }
.menu span { font-size: 13px; color: var(--text2); }

.search { height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.search input { flex: 1; border: 0; background: transparent; font-size: 16px; outline: none; min-width: 0; }
.search input::placeholder { color: var(--text3); }

.seg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 3px; border-radius: 13px; background: var(--surface); border: 1px solid var(--line); }
.seg button { height: 36px; border: 0; border-radius: 10px; background: transparent; color: var(--text2); font-size: 14px; font-weight: 600; }
.seg button[aria-pressed="true"] { background: #2C3234; color: var(--text); }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.row { width: 100%; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 56px; padding: 6px 14px 6px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; }
.row.big { grid-template-columns: 48px minmax(0, 1fr) auto; min-height: 64px; padding: 8px 12px 8px 8px; border-radius: 16px; }
.row.pending { border-color: var(--muted); }
.thumb { width: 44px; height: 44px; object-fit: contain; display: block; }
.row.big .thumb { width: 48px; height: 48px; }
.ph { width: 44px; height: 44px; border-radius: 12px; background: var(--raised); display: flex; align-items: center; justify-content: center; color: #6B7173; }
.row.big .ph { width: 48px; height: 48px; }
.name { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.big .name { font-size: 16px; }
.meta { font-size: 12px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.when { font-size: 11px; color: var(--text3); white-space: nowrap; }
.when.fresh { color: var(--sage); } .when.never { color: var(--muted); } .when.pending { color: var(--text); }

.sq { display: flex; gap: 2px; }
.sq i { width: 10px; height: 10px; border-radius: 2px; display: block; background: var(--sage); }
.sq i.e { background: transparent; border: 1.5px solid var(--coral); }
.sq i.n { background: transparent; border: 1.5px solid var(--line3); }
.sq.l i { width: 12px; height: 12px; }
.key { display: flex; gap: 14px; align-items: center; padding: 10px 4px; font-size: 11px; color: var(--text3); }
.key i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: -1px; background: var(--sage); }
.key i.e { background: transparent; border: 1.5px solid var(--coral); }

.banner { position: sticky; top: 0; z-index: 5; margin: calc(-16px - var(--safe-top)) -16px 0; padding: calc(var(--safe-top) + 12px) 16px 10px; background: var(--raised); border-bottom: 1px solid var(--line2); display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.banner b { font-size: 14px; display: block; }
.banner span { font-size: 12px; color: var(--text2); }

.btn { height: 50px; border-radius: 14px; border: 0; background: var(--coral); color: var(--on-coral); font-size: 16px; font-weight: 700; padding: 0 18px; display: inline-flex; align-items: center; justify-content: center; }
.btn.light { background: var(--text); color: var(--bg); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line3); font-weight: 600; }
.btn.small { height: 40px; font-size: 15px; border-radius: 12px; padding: 0 16px; }
.btn.done { background: var(--sage-bg); color: var(--sage); }
.btn:disabled { opacity: .5; }
.card { border-radius: 16px; background: var(--surface); border: 1px solid var(--line); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.card.stack { padding: 0 12px 0 14px; gap: 0; }
.field { height: 48px; width: 100%; border-radius: 12px; background: var(--raised); border: 1px solid var(--line2); padding: 0 14px; font-size: 16px; }
.field::placeholder { color: var(--text3); }
label.lbl { font-size: 13px; font-weight: 600; color: var(--text3); }
.code { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.code input { height: 54px; text-align: center; font-size: 22px; font-weight: 800; text-transform: uppercase; border-radius: 12px; background: var(--raised); border: 1px solid var(--line2); }
.err { color: var(--coral-text); font-size: 14px; }

.mrow { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 58px; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; padding: 0; }
.mrow:last-child { border-bottom: 0; }
.mrow .av { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; }
.tag { height: 26px; display: inline-flex; align-items: center; padding: 0 10px; border-radius: 13px; font-size: 12px; font-weight: 700; border: 1px solid var(--line3); color: var(--muted); }
.tag.solid { background: var(--text); color: var(--bg); border-color: var(--text); }

#overlay:empty { display: none; }
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(5,7,8,.6); display: flex; flex-direction: column; justify-content: flex-end; animation: fade .15s ease-out; }
.scrim > .close-area { flex: 1; }
.sheet { max-width: 560px; width: 100%; margin: 0 auto; border-radius: 24px 24px 0 0; background: var(--sheet); border-top: 1px solid var(--line2); padding: 8px 16px calc(var(--safe-bottom) + 24px); display: flex; flex-direction: column; gap: 14px; animation: up .2s ease-out; }
.grab { align-self: center; width: 40px; height: 5px; border-radius: 3px; background: #3A4143; }
.big-stepper { display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; align-items: center; padding: 6px 0; }
.big-stepper button { width: 64px; height: 64px; border-radius: 32px; border: 1px solid var(--line3); background: var(--raised); font-size: 28px; }
.big-stepper .n { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.big-stepper .n b { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stepper { display: flex; align-items: center; border-radius: 12px; background: var(--raised); border: 1px solid var(--line2); }
.stepper button { width: 40px; height: 44px; border: 0; background: transparent; font-size: 20px; }
.stepper b { min-width: 30px; text-align: center; font-size: 17px; font-variant-numeric: tabular-nums; }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; min-height: 58px; border-bottom: 1px solid var(--line); }
.qr { align-self: center; width: 232px; height: 232px; border-radius: 20px; background: #F2F2EF; display: flex; align-items: center; justify-content: center; }
.qr svg { width: 200px; height: 200px; }
.bigcode { text-align: center; font-size: 34px; font-weight: 800; letter-spacing: .12em; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 13px; word-break: break-all; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 20px); transform: translateX(-50%); z-index: 60; background: #2C3234; border: 1px solid #3A4143; border-radius: 14px; padding: 10px 16px; font-size: 14px; max-width: 90vw; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .scrim, .sheet { animation: none; } }
