/* Dark-first; light values follow the phone's setting. The QR card always stays white for scanning. */
:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --surface-2: #242833;
  --line: #2c313d;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #7c5cff;
  --accent-text: #a48dff;
  --danger: #f87171;
  --shadow: rgba(0, 0, 0, .45);
  --radius: 18px;
  color-scheme: dark;
}
/* Light: follows the phone unless the user picked a theme (data-theme on <html>). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f5f8;
    --surface: #ffffff;
    --surface-2: #eceaf3;
    --line: #dfdce8;
    --text: #17151f;
    --muted: #6b6880;
    --accent: #6d4dff;
    --accent-text: #5b3df0;
    --danger: #dc2626;
    --shadow: rgba(40, 30, 90, .14);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
    --bg: #f5f5f8;
    --surface: #ffffff;
    --surface-2: #eceaf3;
    --line: #dfdce8;
    --text: #17151f;
    --muted: #6b6880;
    --accent: #6d4dff;
    --accent-text: #5b3df0;
    --danger: #dc2626;
    --shadow: rgba(40, 30, 90, .14);
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px calc(32px + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}

button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, .file-btn:focus-within {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
[hidden] { display: none !important; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0 12px;
}
.logo { font-size: 24px; letter-spacing: -0.02em; font-weight: 800; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }

.ghost {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: 15px;
}
.primary {
  background: var(--accent); color: #fff;
  border: 0; border-radius: 14px;
  padding: 14px 20px; font-size: 16px; font-weight: 600;
}
.primary.small { padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.wide { width: 100%; }
.link {
  display: block; width: 100%;
  margin-top: 8px; padding: 12px;
  background: none; border: 0;
  color: var(--muted); font-size: 15px;
}
.lead { color: var(--muted); font-size: 17px; line-height: 1.45; margin: 0 0 20px; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.45; margin: 4px 0 18px; }
h3.sub { font-size: 14px; font-weight: 600; color: var(--muted); margin: 26px 0 12px; }

/* Segmented control: profile switch and settings tabs */
.switch {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 4px; margin-bottom: 16px;
}
.switch button {
  border: 0; background: none; color: var(--muted);
  padding: 10px 4px; border-radius: 10px;
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.switch button.on { background: var(--accent); color: #fff; }
.switch.tabs button { font-size: 13px; padding: 9px 2px; }
/* More than three profiles: scroll sideways instead of squeezing the labels. */
.switch.scroll { grid-auto-columns: minmax(max(96px, calc((100% - 8px) / var(--n, 2))), 1fr); overflow-x: auto; scrollbar-width: none; }
.switch.scroll::-webkit-scrollbar { display: none; }

/* Tiles: max 2 per row, big centred icon */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile {
  --c: var(--accent);
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(90% 90% at 50% 38%, color-mix(in srgb, var(--c) 30%, transparent), transparent 70%),
    var(--surface);
  color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 16px 8px; text-align: center;
  transition: transform .12s ease;
}
.tile:active { transform: scale(.96); }

.tile-icon {
  width: 44px; height: 44px; flex: none;
  border-radius: 12px;
  background: var(--c, var(--accent));
  display: grid; place-items: center;
  color: var(--fg, #fff);
}
.tile-icon svg { width: 24px; height: 24px; }
.tile .tile-icon {
  width: 46%; height: auto; aspect-ratio: 1; border-radius: 28%;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--c) 40%, transparent);
}
.tile .tile-icon svg { width: 56%; height: 56%; }
.tile-label {
  font-weight: 600; font-size: 16px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Filled brand logos look heavier than line icons; size them down slightly. */
.tile-icon svg.brand { width: 20px; height: 20px; }
.tile .tile-icon svg.brand { width: 48%; height: 48%; }

.empty { text-align: center; padding: 40px 0; color: var(--muted); display: grid; gap: 12px; justify-items: center; }
.empty p { margin: 0; }

/* Install banner */
.banner {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 8px 12px 12px; margin-bottom: 16px;
  box-shadow: 0 8px 24px var(--shadow);
}
.banner-icon { width: 44px; height: 44px; border-radius: 11px; }
.banner-text { display: grid; gap: 2px; font-size: 13px; color: var(--muted); line-height: 1.35; }
.banner-text strong { color: var(--text); font-size: 14px; }
.banner-close {
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: none; color: var(--muted); font-size: 14px;
}

/* Forms */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--muted); margin-bottom: 6px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 25%, transparent); }
.field input, .field select {
  width: 100%;
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 13px 14px;
  font-size: 16px; /* prevents zoom on iOS */
}
.field input:focus, .field select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.field.invalid input { border-color: var(--danger); }
.field > label { display: block; }
.field > label > span {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--muted); margin-bottom: 6px;
}
.field-tools { display: flex; gap: 8px; margin-top: 8px; }
.tool {
  background: none; border: 1px solid var(--line); color: var(--accent-text);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 600;
}
.help-box {
  margin-top: 8px; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border: 1px solid var(--line);
  display: grid; gap: 10px; justify-items: start;
}
.help-box p { margin: 0; font-size: 14px; line-height: 1.45; }
.small-link { text-decoration: none; font-size: 14px; font-weight: 600; padding: 7px 14px; border-radius: 10px; }
.err { display: block; color: var(--danger); font-size: 13px; margin-top: 6px; }
.err:empty { display: none; }

.check { display: flex; align-items: center; gap: 10px; margin: -4px 0 16px; color: var(--muted); font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* iOS-style switches */
.switch-input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  width: 46px; height: 28px; border-radius: 14px;
  background: var(--surface-2); position: relative; cursor: pointer;
  transition: background .15s;
}
.switch-input::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s;
}
.switch-input:checked { background: var(--accent); }
.switch-input:checked::after { transform: translateX(18px); }

.toggles { display: grid; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.toggle-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.toggle-row:last-child { border-bottom: 0; }
.toggle-row .tile-icon { width: 34px; height: 34px; border-radius: 9px; }
.toggle-row .tile-icon svg { width: 19px; height: 19px; }
.toggle-row .tile-icon svg.brand { width: 16px; height: 16px; }
.toggle-text { display: grid; min-width: 0; }
.toggle-text b { font-weight: 600; font-size: 15px; }
.toggle-text small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle-text small.dim { opacity: .6; font-style: italic; }

.stack { display: grid; gap: 10px; }
.stack .ghost { border-radius: 14px; padding: 14px 16px; text-align: left; }
.file-btn { display: block; cursor: pointer; position: relative; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.save-bar {
  position: sticky; bottom: 0;
  padding: 14px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  margin-top: 12px;
}
.save-bar .err { margin: 0 0 10px; text-align: center; }

/* QR view */
.qr-view {
  --c: var(--accent);
  position: fixed; inset: 0;
  background: linear-gradient(180deg, var(--c) 0%, color-mix(in srgb, var(--c) 60%, #000) 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(56px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  z-index: 10;
  transition: background .25s ease;
}
.close {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 16px;
  width: 40px; height: 40px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.25); color: #fff; font-size: 18px;
}
.qr-card {
  background: #fff; color: #111;
  border-radius: 28px; padding: 24px;
  width: min(100%, 380px); text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.qr-icon {
  width: 52px; height: 52px; margin: -50px auto 8px;
  border-radius: 16px; background: var(--c); color: #fff;
  display: grid; place-items: center; border: 4px solid #fff;
}
.qr-icon svg { width: 26px; height: 26px; }
.qr-icon svg.brand { width: 22px; height: 22px; }
.qr-badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: #6b7280; background: #f1f2f5; border-radius: 999px; padding: 3px 9px; margin-bottom: 6px;
}
.qr-card h2 { margin: 0; font-size: 22px; }
.qr-sub { margin: 4px 0 14px; color: #6b7280; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qr-code {
  display: block; width: 100%; padding: 0; border: 0; background: none;
  border-radius: 12px; cursor: pointer; transition: transform .12s ease;
}
.qr-code:active { transform: scale(.97); }
.qr-code:focus-visible { outline: 3px solid var(--c); outline-offset: 4px; }
.qr-code svg { width: 100%; height: auto; display: block; }
.qr-hint { margin: 8px 0 0; font-size: 13px; color: #6b7280; }
.qr-name { margin: 12px 0 0; font-weight: 700; font-size: 18px; }
.qr-name:empty { display: none; }
.qr-nav { display: flex; align-items: center; gap: 16px; margin-top: 24px; }
.qr-nav button {
  width: 48px; height: 48px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.2); color: #fff; font-size: 28px; line-height: 1;
}
.qr-nav button[hidden] { visibility: hidden; display: block !important; }
.dots { display: flex; gap: 6px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.4); }
.dots i.on { background: #fff; }

/* Bottom sheet */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); color: var(--text);
  width: min(100%, 560px);
  border-radius: 22px 22px 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 90dvh; overflow-y: auto;
}
.sheet h2 { margin: 0 0 10px; font-size: 21px; }
.sheet-text { color: var(--muted); line-height: 1.45; margin: 0 0 16px; }
.sheet-note { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 12px 0 0; }
.sheet-qr { background: #fff; border-radius: 18px; padding: 14px; max-width: 300px; margin: 0 auto; }
.sheet-qr svg { width: 100%; height: auto; display: block; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.sheet-actions > * { flex: 1; border-radius: 14px; padding: 14px; }
.ios-steps { margin: 4px 0 0; padding-left: 22px; display: grid; gap: 12px; line-height: 1.45; }
.share-glyph {
  display: inline-block; width: 18px; height: 20px; vertical-align: -4px;
  background: var(--accent-text);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 22' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 13V2M5 5.5 9 1.5l4 4M5.5 8.5H3.5a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 3.5 20.5h11a1.5 1.5 0 0 0 1.5-1.5v-9a1.5 1.5 0 0 0-1.5-1.5h-2'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 22' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 13V2M5 5.5 9 1.5l4 4M5.5 8.5H3.5a1.5 1.5 0 0 0-1.5 1.5v9A1.5 1.5 0 0 0 3.5 20.5h11a1.5 1.5 0 0 0 1.5-1.5v-9a1.5 1.5 0 0 0-1.5-1.5h-2'/%3E%3C/svg%3E") center / contain no-repeat;
}

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30;
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 24px var(--shadow);
  max-width: calc(100% - 32px);
}

/* Onboarding */
.onboard h2 { font-size: 28px; letter-spacing: -0.02em; margin: 20px 0 8px; text-wrap: balance; }
.ob-progress { display: flex; gap: 6px; }
.ob-progress i { flex: 1; height: 4px; border-radius: 2px; background: var(--surface-2); transition: background .2s; }
.ob-progress i.on { background: var(--accent); }
.ob-hero { width: 96px; height: 96px; margin: 40px 0 8px; border-radius: 24px; display: block; }
.ob-import { margin-bottom: 18px; padding: 13px 16px; border-radius: 14px; }
.ob-actions { display: flex; gap: 12px; margin-top: 24px; }
.ob-actions .ghost { border-radius: 14px; padding: 14px 20px; }
.ob-actions .primary { flex: 1; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  --c: var(--accent);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px 9px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 15px; transition: background .15s, border-color .15s;
}
.chip svg { width: 20px; height: 20px; }
.chip svg.brand { width: 17px; height: 17px; }
.chip[aria-pressed="true"] { background: var(--c); border-color: var(--c); color: #fff; }

.split-head, .split-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 72px 72px; align-items: center; justify-items: center;
}
.split-head { font-size: 13px; font-weight: 600; color: var(--muted); padding: 0 14px 8px; }
.split { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; }
.split-row { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.split-row:last-child { border-bottom: 0; }
.split-name { justify-self: start; display: flex; align-items: center; gap: 12px; font-weight: 600; min-width: 0; }
.split-name .tile-icon { width: 34px; height: 34px; border-radius: 9px; }
.split-name .tile-icon svg { width: 19px; height: 19px; }
.split-name .tile-icon svg.brand { width: 16px; height: 16px; }

.preview { display: grid; gap: 12px; margin: 8px 0 20px; }
.preview-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; align-items: center;
  text-align: left; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  transition: border-color .15s, transform .12s;
}
.preview-row:hover { border-color: var(--accent); }
.preview-row:active { transform: scale(.98); }
.preview-row b { font-size: 16px; }
.preview-row > span { grid-column: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.preview-row .chev { grid-column: 2; grid-row: 1 / span 2; font-style: normal; font-size: 28px; color: var(--accent); line-height: 1; }
.preview .tile-icon { width: 40px; height: 40px; border-radius: 11px; }
.preview .tile-icon svg.brand { width: 18px; height: 18px; }

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

/* Premium */
.pro {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: .06em;
  color: #fff; background: linear-gradient(135deg, #9b7bff, #5a36f2);
  border-radius: 6px; padding: 2px 5px; margin-left: 4px; vertical-align: 1px;
}
.premium-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 22px; display: grid; gap: 12px; margin-bottom: 20px;
}
.premium-card.active { background: linear-gradient(135deg, color-mix(in srgb, #9b7bff 18%, var(--surface)), var(--surface)); }
.premium-card h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.premium-card .badge { justify-self: start; font-size: 11px; font-weight: 800; letter-spacing: .08em; color: #fff; background: linear-gradient(135deg, #9b7bff, #5a36f2); border-radius: 999px; padding: 4px 10px; }
.price { margin: 0; font-size: 17px; font-weight: 600; color: var(--accent-text); }
.check-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.check-list li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 8px; line-height: 1.4; }
.check-list li::before { content: "✓"; color: var(--accent-text); font-weight: 800; }
.consent { margin: 4px 0 0; align-items: flex-start; font-size: 14px; }
.consent input { margin-top: 2px; flex: none; }
.code-row { display: flex; gap: 8px; align-items: center; }
.code-row input { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 12px 14px; font: 600 16px ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; }
.code-row .ghost { border-radius: 12px; padding: 12px 16px; }
.code-row code { flex: 1; font: 600 17px ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .06em; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.field .label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field-note { display: block; color: var(--muted); font-size: 13px; margin-top: 6px; }

/* Photo */
.photo-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: center; margin-bottom: 18px; }
.avatar { width: 72px; height: 72px; border-radius: 50%; overflow: hidden; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar svg { width: 34px; height: 34px; }
.photo-actions { display: grid; gap: 2px; }
.photo-actions small { color: var(--muted); font-size: 13px; }

/* Custom links */
.link-rows { display: grid; gap: 12px; margin-bottom: 12px; }
.link-row { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 14px 10px; display: grid; }
.link-row .field { margin-bottom: 10px; }
.link-row [data-remove] { justify-self: start; }
.add-btn { border-radius: 14px; padding: 13px 16px; }
.add-btn:disabled { opacity: .5; }
.tool.danger, .ghost.danger, .danger-text { color: var(--danger); }
.danger-text { text-align: left; padding-left: 0; }

/* Profiles in settings */
.profile-chips { margin-bottom: 16px; }
.profile-chips .chip { padding: 8px 14px; }
.profile-chips .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.add, .chip.more { border-style: dashed; color: var(--accent-text); }

/* QR view extras */
.qr-person { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; }
.qr-person .qr-name { margin: 0; }
.qr-person img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.nfc-btn {
  margin-top: 14px; border: 0; border-radius: 999px; padding: 10px 18px;
  background: rgba(255,255,255,.2); color: #fff; font-size: 14px; font-weight: 600;
}

.primary:disabled { opacity: .55; cursor: default; }

.toggle-row.unfilled .tile-icon { opacity: .45; }
.toggle-row.unfilled b { color: var(--muted); }
.switch-input:disabled { opacity: .45; cursor: default; }
.profile-panel .toggles + .field { margin-top: 20px; }
.receipt-btn { border-radius: 14px; padding: 13px 16px; margin-top: 4px; }

/* Top bar actions */
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { position: relative; width: 40px; height: 40px; padding: 0; display: grid; place-items: center; }
.icon-btn svg { width: 20px; height: 20px; }
.dot-new { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #ef4444; border: 2px solid var(--bg); }

/* Achievements */
.view-title { font-size: 28px; letter-spacing: -0.02em; margin: 8px 0 16px; }
.invite-card { background: linear-gradient(135deg, color-mix(in srgb, #9b7bff 16%, var(--surface)), var(--surface)); border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: grid; gap: 12px; }
.invite-card h3 { margin: 0; font-size: 20px; }
.invite-card .hint { margin: 0; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.level { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px; display: grid; justify-items: center; gap: 4px; text-align: center; opacity: .55; }
.level.reached { opacity: 1; }
.level-medal { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.level-medal svg { width: 24px; height: 24px; }
.level.bronze .level-medal { background: linear-gradient(135deg, #d9a066, #a0643a); }
.level.silver .level-medal { background: linear-gradient(135deg, #d8dde6, #8f98a8); }
.level.gold .level-medal { background: linear-gradient(135deg, #ffd66b, #d19a00); }
.level b { font-size: 15px; }
.level small { font-size: 12px; color: var(--muted); }
.progress { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #9b7bff, #5a36f2); border-radius: 5px; transition: width .4s ease; }
.progress-text { margin: -4px 0 0; font-size: 14px; font-weight: 600; }

.badge-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.badge { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 8px; display: grid; justify-items: center; gap: 4px; text-align: center; }
.badge-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.badge-icon svg { width: 26px; height: 26px; }
.badge.earned .badge-icon { background: var(--c); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 40%, transparent); }
.badge b { font-size: 13px; line-height: 1.2; }
.badge small { font-size: 11px; color: var(--muted); line-height: 1.3; }
.badge:not(.earned) b { color: var(--muted); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 4px; min-width: 0; }
.stat.wide { grid-column: 1 / -1; }
.stat span { font-size: 13px; color: var(--muted); }
.stat b { font-size: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat small { font-size: 13px; color: var(--muted); }
.split-bar { height: 10px; border-radius: 5px; background: #14b8a6; overflow: hidden; margin-top: 4px; }
.split-bar i { display: block; height: 100%; background: #0a66c2; }

.invite-teaser { display: grid; gap: 6px; justify-items: start; background: var(--surface); border: 1px dashed var(--accent); border-radius: 16px; padding: 14px 16px; margin-bottom: 8px; }
.invite-teaser span { color: var(--muted); font-size: 14px; }
.invite-teaser .ghost { margin-top: 4px; border-radius: 12px; }
.invite-card .stack .ghost { text-align: center; border-radius: 14px; }

/* Year in connections */
.year-card {
  width: 100%; text-align: left; border: 0; color: #fff; margin-bottom: 16px;
  background: linear-gradient(135deg, #9b7bff, #3b1fbf); border-radius: 20px; padding: 18px 20px;
  display: grid; gap: 4px; box-shadow: 0 12px 30px rgba(59, 31, 191, .3);
}
.year-card b { font-size: 22px; letter-spacing: -0.01em; }
.year-card .year-kicker, .year-view .year-kicker { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.year-open { font-size: 14px; font-weight: 600; opacity: .9; }
.year-view {
  position: fixed; inset: 0; z-index: 12; color: #fff;
  background: linear-gradient(160deg, #9b7bff, #3b1fbf 70%);
  padding: calc(64px + env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; overflow-y: auto;
}
.year-inner { flex: 1; display: grid; align-content: start; gap: 14px; max-width: 520px; width: 100%; margin: 0 auto; }
.year-inner h2 { margin: 0; font-size: 34px; letter-spacing: -0.02em; line-height: 1.1; }
.year-big b { display: block; font-size: 110px; line-height: 1; font-weight: 800; letter-spacing: -0.04em; }
.year-big span { font-size: 20px; opacity: .85; }
.year-top { display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,.14); border-radius: 18px; padding: 14px; }
.year-top .tile-icon { width: 52px; height: 52px; border-radius: 14px; }
.year-top > span:last-child { display: grid; font-size: 14px; opacity: .9; }
.year-top b { font-size: 22px; }
.year-rows { display: grid; gap: 10px; margin: 4px 0 0; }
.year-rows div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid rgba(255,255,255,.18); padding-bottom: 10px; }
.year-rows dt { opacity: .8; }
.year-rows dd { margin: 0; font-weight: 700; text-align: right; }
.year-share { margin: 20px auto 0; width: 100%; max-width: 520px; border: 0; border-radius: 14px; padding: 15px; background: #fff; color: #3b1fbf; font-size: 16px; font-weight: 700; }

/* QR style picker */
.style-box { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.style-preview { background: #fff; border-radius: 12px; padding: 6px; }
.style-preview svg { width: 100%; height: auto; display: block; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); background: var(--sw); box-shadow: 0 0 0 1px var(--line); position: relative; }
.swatch.on { box-shadow: 0 0 0 2px var(--accent); }
.swatch.locked { opacity: .35; }
.swatch.locked::after { content: ""; position: absolute; inset: 9px; background: #fff; -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1v11H6V10zm2 0h6V7a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center/contain no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10V7a5 5 0 0 1 10 0v3h1v11H6V10zm2 0h6V7a3 3 0 0 0-6 0z'/%3E%3C/svg%3E") center/contain no-repeat; }
.style-toggles { display: grid; gap: 4px; }
.toggle-row.small { padding: 6px 0; border: 0; grid-template-columns: minmax(0, 1fr) auto; }
.toggle-row.small small { white-space: normal; }
@media (max-width: 360px) { .style-box { grid-template-columns: 1fr; } .style-preview { max-width: 160px; } }
