:root {
  color-scheme: light;
  font: 15px/1.45 Inter, system-ui, sans-serif;
  color: #1a1a1a;
  background: #fafaf8;
  --surface-default: #fafaf8;
  --surface-raised: #fff;
  --surface-visibility: #ecebe6;
  --text-primary: #1a1a1a;
  --text-secondary: #5c5c5c;
  --text-tertiary: #6b6b6b;
  --action-primary: #2c3a55;
  --border-subtle: #deddd8;
  --border-input: #bdbdb7;
  --ink: var(--text-primary);
  --muted: var(--text-secondary);
  --accent: var(--action-primary);
  --line: var(--border-subtle);
  --paper: var(--surface-raised);
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --radius-control: 8px;
  --radius-card: 12px;
  --radius-pill: 26px;
  --screen-gutter: 20px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--surface-default); color: var(--text-primary); }
main { width: min(100%, 940px); margin: auto; padding: max(24px, env(safe-area-inset-top)) 22px max(32px, env(safe-area-inset-bottom)); }
header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
header select { width: auto; min-height: 44px; margin: 0; padding: 5px 9px; }
h1, h2 { font-family: Georgia, serif; font-weight: 500; line-height: 1.1; }
h1 { font-size: clamp(2.5rem, 8vw, 4rem); margin: 0; letter-spacing: -.045em; }
h2 { font-size: 1.9rem; margin: 0 0 20px; }
.hint, label span, #empty { color: var(--muted); }
#new { margin-top: 24px; }
#collection { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 245px), 1fr)); gap: 14px; margin-top: 24px; }
.card { display: flex; flex-direction: column; align-items: start; min-width: 0; background: var(--paper); padding: 19px; border: 1px solid var(--line); border-radius: 12px; }
.card[data-direction="offer"] { background: #eeebf7; }
.card h2 { font: 600 1.08rem/1.4 system-ui, sans-serif; margin: 7px 0 16px; overflow-wrap: anywhere; white-space: pre-wrap; }
.card .meta { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.card .actions { margin-top: auto; justify-content: start; }
button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 44px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); cursor: pointer; }
.primary { background: var(--accent); border-color: var(--accent); color: white; }
:focus-visible { outline: 3px solid #765db6; outline-offset: 3px; }
dialog { width: min(520px, calc(100% - 24px)); padding: 22px; max-height: 90vh; max-height: 90dvh; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: var(--paper); overflow-y: auto; }
dialog::backdrop { background: #27263880; }
label { display: block; margin: 12px 0; font-weight: 550; }
label[hidden] { display: none; }
input, select, textarea { display: block; width: 100%; margin-top: 5px; padding: 9px; background: white; border: 1px solid var(--line); border-radius: 6px; font-weight: 400; }
textarea { resize: vertical; }
.actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; margin-top: 20px; }
.message { white-space: pre-wrap; overflow-wrap: anywhere; background: #eeebf7; padding: 14px; border-radius: 8px; }

/* Figma Components & Tokens (0:1). These primitives are shared by every new screen. */
.meo-screen {
  width: min(100%, 440px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--surface-default);
  color: var(--text-primary);
}
.meo-screen-content { padding: max(var(--space-6), env(safe-area-inset-top)) var(--screen-gutter) calc(96px + env(safe-area-inset-bottom)); }
.meo-title { margin: 0; font: 600 26px/1.2 'Source Serif 4', Georgia, serif; letter-spacing: -.01em; }
.meo-eyebrow { color: var(--text-secondary); font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; }
.meo-button-primary {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--action-primary);
  color: white;
  font-size: 16px;
  font-weight: 650;
  text-decoration: none;
}
.meo-button-text { border: 0; background: transparent; text-decoration: underline; }
.visibility-band { display: grid; gap: var(--space-1); padding: var(--space-3) var(--screen-gutter); background: var(--surface-visibility); }
.visibility-band strong { color: var(--text-secondary); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.state-message { display: grid; align-content: center; gap: var(--space-3); min-height: 45vh; text-align: center; }
.state-message > * { margin: 0; }
.state-message p { color: var(--text-secondary); }
.meo-card { border: 1.5px solid var(--text-primary); border-radius: var(--radius-card); background: var(--surface-raised); padding: var(--space-4); }
.meo-tabbar {
  position: fixed;
  z-index: 20;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 440px);
  margin: 0 auto;
  padding: var(--space-2) var(--space-2) max(var(--space-2), env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-default);
}
.meo-tabbar button { min-width: 0; border: 0; background: transparent; color: var(--text-secondary); font-size: 11px; }
.meo-tabbar button[aria-current="page"] { color: var(--text-primary); font-weight: 700; }
.contact-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border-subtle); }
.contact-row-avatar { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--border-subtle); font-weight: 650; }
.contact-row-copy { min-width: 0; }
.contact-row-copy > * { margin: 0; overflow-wrap: anywhere; }
.contact-row-copy small { color: var(--text-secondary); }
.app-screen { min-height: 100vh; min-height: 100dvh; }
.app-screen .meo-title { font-size: 26px; }
.app-screen .state-message h2 { font: 600 22px/1.25 'Source Serif 4', Georgia, serif; }

@media (min-width: 700px) {
  #app-shell { border-inline: 1px solid var(--border-subtle); }
}

#onboarding-shell { display: flex; flex-direction: column; }
.onboarding-stage { display: flex; flex: 1; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.onboarding-body, .onboarding-form { display: flex; flex: 1; flex-direction: column; gap: var(--space-4); padding: max(var(--space-6), env(safe-area-inset-top)) var(--screen-gutter) var(--space-6); }
.onboarding-welcome-body { justify-content: center; }
.onboarding-brand { margin: 0; color: var(--action-primary); font: 700 14px/1 'JetBrains Mono', monospace; letter-spacing: .18em; }
.onboarding-copy, .field-help { margin: 0; color: var(--text-secondary); }
.onboarding-footer { display: grid; gap: var(--space-2); padding: var(--space-3) var(--screen-gutter) max(var(--space-7), env(safe-area-inset-bottom)); }
.onboarding-form label { margin: 0; }
.onboarding-form input { min-height: 48px; margin-top: var(--space-1); border-color: var(--border-input); border-radius: var(--radius-control); background: var(--surface-raised); padding: 10px 12px; }
.onboarding-form > .meo-button-primary { margin-top: auto; }
.consent-row { display: flex; align-items: flex-start; gap: var(--space-2); font-size: 13px; font-weight: 400; }
.consent-row input { flex: 0 0 auto; width: 20px; min-height: 20px; margin: 1px 0 0; }
.consent-row a { color: var(--action-primary); }
.onboarding-back { align-self: start; min-height: 36px; border: 0; background: transparent; padding: 0; }
.onboarding-error { min-height: 1.45em; margin: 0; color: #8b1e1e; }
.setting-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--space-3); padding-block: var(--space-3); border-block: 1px solid var(--border-subtle); }
.setting-row span, .setting-row small { display: block; }
.setting-row input { width: auto; min-height: auto; margin: 0; }
.setting-row em { grid-column: 1 / -1; color: var(--text-secondary); font-size: 13px; font-style: normal; }
.onboarding-qr { display: block; width: 200px; height: 200px; margin: var(--space-6) auto; border: 1.5px solid var(--text-primary); border-radius: var(--radius-control); background: white; object-fit: contain; }
.invite-link-row { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.invite-link-row input { min-width: 0; margin: 0; font-family: 'JetBrains Mono', monospace; }
.invite-link-row button { flex: 0 0 auto; }
.me-profile-header { display: flex; align-items: center; gap: var(--space-4); }
.me-profile-header .contact-row-avatar { width: 56px; height: 56px; }
.me-profile-header p { margin: var(--space-1) 0 0; color: var(--text-secondary); }
.me-data-section { margin-top: 48px; }
.me-data-section h2 { margin: var(--space-2) 0 var(--space-1); font: 500 22px/1.3 Inter, sans-serif; }
.me-data-section p:not(.meo-eyebrow) { color: var(--text-secondary); }
#app-logout { margin-top: 48px; }
.danger-action { color: #8b1e1e; }
#open-delete-account { display: block; margin-top: var(--space-4); }
#delete-account-error { min-height: 1.45em; color: #8b1e1e; }
.people-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.people-heading .meo-button-primary { width: auto; min-height: 44px; padding-inline: var(--space-4); font-size: 14px; }
.people-search { margin: var(--space-6) 0; }
.people-search input { min-height: 44px; border-color: var(--border-input); border-radius: var(--radius-pill); background: var(--surface-raised); padding-inline: var(--space-4); }
#screen-people section + section { margin-top: var(--space-6); }
#screen-people .meo-eyebrow { margin: 0 0 var(--space-2); }
#people-status { color: var(--text-secondary); }
.privacy-page { width: min(100%, 720px); }
.privacy-page h1 { font-size: clamp(2.3rem, 8vw, 3.5rem); }
.privacy-page h2 { margin-top: 36px; font-size: 1.45rem; }
.privacy-version { padding: var(--space-3); border: 1px solid var(--text-primary); border-radius: var(--radius-control); background: var(--surface-visibility); }
.privacy-page li + li { margin-top: var(--space-2); }

.collection-tools { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.collection-tools input { flex: 1; min-width: 0; min-height: 44px; margin: 0; }
.collection-tools button { flex-shrink: 0; }

[hidden] { display: none !important; }
.collection-tools { flex-wrap: wrap; }
.collection-tools input { min-width: min(100%, 150px); }
#contact-list { display: grid; gap: 8px; margin-top: 16px; }
#contact-list button { text-align: start; overflow-wrap: anywhere; }
#contact-heading { margin-top: 18px; overflow-wrap: anywhere; }
button[aria-pressed="true"] { border-color: currentColor; }
#network-dialog section { margin-block: 12px; }
#invite-qr { display: block; max-width: 100%; height: auto; margin: 10px auto; image-rendering: pixelated; }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: auto; margin: 0; }
#network-links > article { border-top: 1px solid var(--line); padding-block: 10px; overflow-wrap: anywhere; }
#network-links button { margin-inline-end: 8px; }

#network-dialog.flow-dialog {
  --surface-default: #fafaf8;
  --surface-raised: #fff;
  --surface-visibility: #ecebe6;
  --text-primary: #1a1a1a;
  --text-secondary: #5c5c5c;
  --action-primary: #2c3a55;
  --border-input: #bdbdb7;
  --gutter: 20px;
  --radius-input: 8px;
  --radius-pill: 26px;
  --primary-height: 52px;
  width: min(100%, 440px);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  max-width: none;
  max-height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--surface-default);
  color: var(--text-primary);
  font: 15px/1.45 Inter, system-ui, sans-serif;
}
#network-dialog.flow-dialog > :not(#invite-flow):not(#network-status) { display: none; }
.flow-dialog #network-status:empty { display: none; }
.flow-dialog #network-status { padding-inline: var(--gutter); }
#network-dialog #invite-flow, #network-dialog .flow-stage { margin: 0; }
#invite-flow { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.flow-top { padding: max(20px, env(safe-area-inset-top)) var(--gutter) 8px; }
.flow-stage { flex: 1; display: flex; flex-direction: column; }
.flow-body { flex: 1; display: flex; flex-direction: column; gap: 16px; padding: 16px var(--gutter); }
.flow-body > *, .flow-stage p { margin: 0; }
.flow-stage h2 { font: 600 26px/1.25 'Source Serif 4', Georgia, serif; overflow-wrap: anywhere; }
html[lang="zh-CN"] .flow-dialog, html[lang="zh-CN"] .flow-stage h2 { font-family: 'Noto Sans SC', 'PingFang SC', system-ui, sans-serif; }
.flow-caption { font-size: 13px; line-height: 1.4; color: var(--text-secondary); }
.flow-eyebrow, .flow-band strong, .flow-list strong { display: block; color: var(--text-secondary); font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.flow-band { display: grid; gap: 4px; background: var(--surface-visibility); padding: 12px var(--gutter); font-size: 13px; }
.flow-stage footer { display: grid; justify-items: stretch; gap: 8px; text-align: center; padding: 12px var(--gutter) max(28px, env(safe-area-inset-bottom)); }
#invite-flow button { border: 0; background: transparent; padding: 0; }
#invite-flow .primary { color: white; min-height: var(--primary-height); border-radius: var(--radius-pill); background: var(--action-primary); font-weight: 600; font-size: 16px; }
#invite-flow #invite-qr { width: 200px; height: 200px; object-fit: contain; background: white; border: 1.5px solid var(--text-primary); border-radius: 8px; }
.flow-link { display: flex; gap: 12px; border: 1px solid var(--border-input); border-radius: var(--radius-input); background: var(--surface-raised); padding: 0 12px; }
.flow-link input { flex: 1 1 0; width: 0; min-width: 0; margin: 0; border: 0; padding: 0; font: 14px 'JetBrains Mono', monospace; }
#invite-flow .flow-link button, #invite-flow .flow-underlined { text-decoration: underline; }
#invite-flow .flow-underlined { align-self: start; font-size: 13px; }
.flow-card, .flow-list { border: 1.5px solid var(--text-primary); border-radius: var(--radius-input); padding: 12px 16px; }
.flow-profile-heading, .flow-card { display: flex; align-items: center; gap: 12px; overflow-wrap: anywhere; }
.flow-avatar { flex: 0 0 auto; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: #ddddd7; font-weight: 600; }
.flow-profile-heading .flow-avatar { width: 56px; height: 56px; }
.flow-list ul { padding-inline-start: 18px; margin: 6px 0 0; }
.flow-list li + li { margin-top: 6px; }
.flow-private { border-style: dashed; border-color: var(--text-secondary); }
.flow-state { justify-content: center; }
#invite-flow label { margin: 0; }
#attach-options { margin: 0; border: 0; padding: 0; }
#attach-list label { display: flex; gap: 12px; align-items: start; padding: 12px 0; border-bottom: 1px solid #ddddd7; }
#attach-list input { appearance: none; flex: 0 0 22px; width: 22px; height: 22px; margin: 0; padding: 0; border: 0; background: url('./assets/radio-unselected.svg') center / auto no-repeat; }
#attach-list input:checked { background-image: url('./assets/radio-selected.svg'); }
#attach-list small { display: block; }

/* Stage titles receive focus for announcements. Keep the visible ring on controls. */
.flow-stage h2[tabindex="-1"]:focus { outline: none; }
.flow-list ul { list-style: none; padding-inline-start: 0; }
.flow-list li { display: flex; gap: 8px; }
.flow-list li::before { content: "+"; color: var(--text-secondary); }
.flow-private li::before { content: "−"; }
#attach-list label > span { color: var(--text-primary); font-size: 15px; font-weight: 400; }
#attach-list small { color: var(--text-secondary); font-size: 13px; }
#invite-flow .flow-link button { flex: 0 0 auto; }
