:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --line: #e7e5e4;
  --text: #141414;
  --muted: #78716c;
  --ink: #141414;
  --ink-text: #fafaf9;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c;
    --surface: #131314;
    --line: #242427;
    --text: #ececec;
    --muted: #8b8b92;
    --ink: #ececec;
    --ink-text: #0b0b0c;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.shell {
  max-width: 560px;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  margin-bottom: 36px;
}
.mark { font-weight: 650; letter-spacing: -0.01em; font-size: 17px; }

.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status[data-state="wait"] i { background: var(--warn); }
.status[data-state="relay"] i,
.status[data-state="direct"] i { background: var(--ok); }
.status b { font-weight: 500; }

h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.025em; font-weight: 650; margin: 0 0 10px; }
.lede { margin: 0 0 28px; color: var(--muted); max-width: 44ch; }
.label { font-size: 12px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }

.code-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.code-main { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.code {
  all: unset;
  cursor: pointer;
  font: 600 38px/1.1 var(--mono);
  letter-spacing: 0.08em;
  padding: 2px 0;
  border-radius: 6px;
}
.code:focus-visible { outline: 2px solid var(--text); outline-offset: 4px; }
.hint { font-size: 13px; color: var(--muted); }
.qr { width: 96px; height: 96px; flex: none; color: var(--text); }
.qr svg { display: block; width: 100%; height: 100%; }

.note { margin: 0 0 16px; padding: 10px 14px; font-size: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }

.join { margin-top: 28px; display: flex; flex-direction: column; gap: 8px; }
.join-row, .text-row { display: flex; gap: 8px; }

input[type="text"], input:not([type]) {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px; /* stops iOS zoom */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s;
}
#joinInput { font-family: var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
input::placeholder { color: var(--muted); opacity: .7; text-transform: none; letter-spacing: 0; }
input:focus { border-color: var(--text); }

.btn {
  height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--ink-text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(0.98); }
.btn.quiet {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
}
.btn.quiet:hover { background: var(--surface); opacity: 1; }
.link {
  all: unset;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link:hover { color: var(--text); }

.error { margin: 0; font-size: 13px; color: var(--bad); }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 168px;
  padding: 24px;
  text-align: center;
  background: var(--surface);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop strong { font-weight: 600; font-size: 16px; }
.drop span { color: var(--muted); font-size: 14px; }
.drop:hover, .drop.over { border-color: var(--text); }

.text-row { margin-top: 12px; }

.tray { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 24px; padding: 10px 10px 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.tray .btn { height: 36px; padding: 0 14px; font-size: 14px; white-space: nowrap; }
.tray + .list { margin-top: 8px; }

.list { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
}
.item .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { grid-column: 1; font-size: 13px; color: var(--muted); }
.item .actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.item .bar { grid-column: 1 / -1; height: 2px; margin-top: 8px; background: var(--line); border-radius: 2px; overflow: hidden; }
.item .bar > div { height: 100%; width: 0; background: var(--text); transition: width .12s linear; }
.item[data-state="done"] .bar,
.item[data-state="text"] .bar { display: none; }
.item[data-state="failed"] .meta,
.item[data-state="declined"] .meta { color: var(--bad); }
.item .body { grid-column: 1; white-space: pre-wrap; overflow-wrap: anywhere; }
.item .body a { color: inherit; }

.session-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 32px; font-size: 13px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.toggle input { width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; }
.foot-actions { display: inline-flex; gap: 16px; }
.fine { margin: 14px 0 0; font-size: 12px; color: var(--muted); }

@media (max-width: 440px) {
  h1 { font-size: 24px; }
  .code { font-size: 30px; }
  .qr { width: 80px; height: 80px; }
  .code-card { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
