:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f0eee9;
  --ink: #191b1f;
  --ink-2: #5d6067;
  --ink-3: #8b8e94;
  --line: #e3e0d9;
  --accent: #ec5f2e;
  --accent-soft: #fbe3d9;
  --accent-ink: #ffffff;
  --ok: #2f8f5b;
  --ok-soft: #dcefe3;
  --warn: #b7791f;
  --warn-soft: #f6ead2;
  --danger: #c8372b;
  --danger-soft: #f7dcd8;
  --track: #dedbd3;
  --shadow: 0 1px 2px rgba(25, 27, 31, 0.05), 0 4px 16px rgba(25, 27, 31, 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121316;
    --surface: #1b1d21;
    --surface-2: #24272c;
    --ink: #ecebe7;
    --ink-2: #a3a6ac;
    --ink-3: #74777e;
    --line: #2f3238;
    --accent: #f0703f;
    --accent-soft: #3a2219;
    --ok: #4cb67c;
    --ok-soft: #1c3125;
    --warn: #d9a23f;
    --warn-soft: #352a14;
    --danger: #e5584b;
    --danger-soft: #3a1d1a;
    --track: #34373d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex-shrink: 0; }
.wordmark { display: block; height: 16px; width: auto; color: var(--ink); }
.brand-sub { color: var(--ink-2); }
.brand-sub::before { content: "·"; margin-right: 8px; color: var(--ink-3); }
.who { display: flex; align-items: center; justify-content: flex-end; gap: 12px; font-size: 14px; min-width: 0; flex: 1 1 auto; }
.who-account { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-admin { color: var(--ink-2); white-space: nowrap; }
.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; }
.link:hover { text-decoration: underline; }
.nav-link { color: var(--accent); font-weight: 600; text-decoration: none; white-space: nowrap; }
.nav-link:hover { text-decoration: underline; }

.sign-in { display: grid; place-items: center; padding: 12vh 16px 40px; }
.sign-in-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}
.sign-in-card h1 { margin: 0 0 6px; font-size: 21px; }
.sign-in-card .btn { width: 100%; justify-content: center; margin-top: 6px; }

.muted { color: var(--ink-2); margin: 0 0 16px; }
.small { font-size: 13px; }
.error { color: var(--danger); font-weight: 600; font-size: 14px; margin: 0 0 12px; }
.sign-in-alt { margin: 16px 0 0; text-align: center; font-size: 14px; }
.sign-in-alt .link { white-space: normal; }
.danger { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line); }
.danger-link { color: var(--danger); }
.danger .muted { margin-top: 6px; font-size: 13px; }
#code { font-size: 22px; letter-spacing: 0.14em; font-variant-numeric: tabular-nums; }
.success { font-size: 18px; font-weight: 650; margin: 4px 0 6px; color: var(--ok); }

.field { display: block; margin: 0 0 14px; }
.field-label { display: block; color: var(--ink-2); font-size: 13px; margin-bottom: 5px; }
input[type="text"], input[type="password"], input[type="email"] {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
}
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 600; font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.12s, filter 0.12s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { border-color: var(--accent); filter: brightness(1.05); }
.btn-small { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; background: var(--surface); }
.btn-danger-quiet { color: var(--danger); }
.btn-danger-quiet:hover:not(:disabled) { border-color: var(--danger); }
.btn-danger-quiet.confirm { background: var(--danger); border-color: var(--danger); color: #fff; }
.plus { font-size: 18px; line-height: 1; margin-top: -2px; }

.main { max-width: 980px; margin: 0 auto; padding: 24px 24px 56px; }

.summary {
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 24px;
}
.quota { min-width: 220px; flex: 1; max-width: 420px; }
.quota-numbers { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.quota-used { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1; }
.quota-max { font-size: 18px; color: var(--ink-3); font-weight: 600; }
.quota-label { color: var(--ink-2); font-size: 13px; margin: 4px 0 10px; }
.meter { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.meter.full span { background: var(--danger); }

.block { margin-bottom: 28px; }
.block-title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 10px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
.block-hint { margin: -4px 0 12px; color: var(--ink-2); font-size: 13px; max-width: 70ch; }
.count { background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: 1px 8px; letter-spacing: 0; }
.empty { color: var(--ink-3); margin: 8px 2px; }

.list {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list:empty { display: none; }
.row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) minmax(150px, auto) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}
.row + .row { border-top: 1px solid var(--line); }
.row.suspended .row-main, .row.suspended .kind { opacity: 0.55; }

.kind {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--surface-2);
  display: grid; place-items: center;
}
.kind::before {
  content: ""; width: 20px; height: 20px; background: var(--ink-2);
  -webkit-mask: var(--glyph) center / contain no-repeat; mask: var(--glyph) center / contain no-repeat;
}
.kind.iphone { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M6.5 1h7A2.5 2.5 0 0 1 16 3.5v13a2.5 2.5 0 0 1-2.5 2.5h-7A2.5 2.5 0 0 1 4 16.5v-13A2.5 2.5 0 0 1 6.5 1zm0 1.6a.9.9 0 0 0-.9.9v13c0 .5.4.9.9.9h7c.5 0 .9-.4.9-.9v-13a.9.9 0 0 0-.9-.9h-1.2a.8.8 0 0 1-.8.7h-3a.8.8 0 0 1-.8-.7z'/%3E%3C/svg%3E"); }
.kind.computer { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3.5 3h13A1.5 1.5 0 0 1 18 4.5v9a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 2 13.5v-9A1.5 1.5 0 0 1 3.5 3zm.1 1.6v8.8h12.8V4.6zM1 16.5h18v.6a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1z'/%3E%3C/svg%3E"); }
.kind.pending { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M10 1.5a8.5 8.5 0 1 1 0 17 8.5 8.5 0 0 1 0-17zm0 1.6a6.9 6.9 0 1 0 0 13.8 6.9 6.9 0 0 0 0-13.8zM10.8 5v4.7l3 1.8-.8 1.4-3.8-2.3V5z'/%3E%3C/svg%3E"); background: var(--warn-soft); }
.kind.pending::before { background: var(--warn); }
.kind.invite { --glyph: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M2 2h7v7H2zm1.6 1.6v3.8h3.8V3.6zM11 2h7v7h-7zm1.6 1.6v3.8h3.8V3.6zM2 11h7v7H2zm1.6 1.6v3.8h3.8v-3.8zM11 11h2.5v2.5H11zm4.5 0H18v2.5h-2.5zM13 13.5h2.5V16H13zm-2 2.5h2v2h-2zm4.5 0H18v2h-2.5z'/%3E%3C/svg%3E"); background: var(--accent-soft); }
.kind.invite::before { background: var(--accent); }

.row-main { min-width: 0; }
.row-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { color: var(--ink-3); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1px; }
.fp { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }

.chip { flex: none; border-radius: 999px; padding: 1px 8px; font-size: 11.5px; font-weight: 700; }
.chip.status.active { display: none; }
.chip.status.suspended { background: var(--warn-soft); color: var(--warn); }

.row-state { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.presence { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); flex: none; }
.presence.online .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.presence.online { color: var(--ink); font-weight: 600; }
.studio { color: var(--ink-3); white-space: nowrap; }
.studio.recording { color: var(--accent); font-weight: 650; }
.studio.paused { color: var(--warn); font-weight: 650; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.journal { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.journal summary {
  cursor: pointer; padding: 12px 16px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2);
}
.journal-list { list-style: none; margin: 0; padding: 0 16px 12px; font-size: 13px; }
.journal-list li { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 5px 0; border-top: 1px solid var(--line); color: var(--ink-2); }
.journal-list time { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.journal-list b { color: var(--ink); font-weight: 600; }

.dialog {
  width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.dialog::backdrop { background: rgba(18, 19, 22, 0.45); backdrop-filter: blur(2px); }
.dialog-body { padding: 22px 22px 20px; }
.dialog h2 { margin: 0 0 16px; font-size: 19px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.qr-wrap { display: grid; place-items: center; background: #fff; border-radius: 14px; border: 1px solid var(--line); padding: 14px; }
.qr-wrap img { display: block; width: 256px; height: 256px; image-rendering: pixelated; }
.countdown { text-align: center; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; margin: 10px 0 4px; }
.countdown.expired { color: var(--danger); font-weight: 650; }
.steps { margin: 10px 0 8px; padding-left: 20px; font-size: 14px; }
.steps li + li { margin-top: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  z-index: 20; max-width: calc(100vw - 32px);
}
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 720px) {
  .bar { padding: 10px 16px; }
  .who-admin, .brand-sub { display: none; }
  .link { white-space: nowrap; }
  .main { padding: 16px 16px 40px; }
  .summary { padding: 16px; }
  .summary .btn { width: 100%; justify-content: center; }
  .row { grid-template-columns: 40px minmax(0, 1fr); }
  .row-state { grid-column: 2; }
  .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .journal-list li { grid-template-columns: 1fr; gap: 0; }
}
