/* Understudy: design tokens, layout and components. Light and dark from the same tokens. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --border: #e4e7ec;
  --border-strong: #d0d5dd;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #ffffff;
  --success: #067647;
  --success-soft: #ecfdf3;
  --success-border: #abefc6;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --warning-border: #fedf89;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;
  --chart-bar: #4f46e5;
  --chart-grid: #eaecf0;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 20px 24px -4px rgba(16, 24, 40, 0.1), 0 8px 8px -4px rgba(16, 24, 40, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 248px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13;
    --surface: #161a21;
    --surface-2: #1b2029;
    --surface-3: #232935;
    --border: #2a303c;
    --border-strong: #3a4252;
    --text: #f2f4f7;
    --text-2: #d0d5dd;
    --muted: #98a2b3;
    --accent: #7c7ff2;
    --accent-hover: #9a9cf6;
    --accent-soft: #232650;
    --accent-text: #0d0f13;
    --success: #47cd89;
    --success-soft: #0e2a1c;
    --success-border: #1b5e3b;
    --warning: #fdb022;
    --warning-soft: #2e2208;
    --warning-border: #5c4310;
    --danger: #f97066;
    --danger-soft: #34140f;
    --danger-border: #6b221a;
    --chart-bar: #7c7ff2;
    --chart-grid: #262c37;
    --shadow-xs: none;
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; color: var(--text); }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1rem; font-weight: 620; }
h3 { font-size: 0.9375rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
code {
  font: 0.82em/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
  background: var(--surface-3);
  padding: 0.12em 0.4em;
  border-radius: 5px;
  color: var(--text-2);
}
.muted, .hint { color: var(--muted); }
.hint { font-size: 0.8125rem; }
.small { font-size: 0.8125rem; }
.num { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout primitives ---------- */

.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 10px; }
.stack-lg { display: grid; gap: 24px; min-width: 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1 1 auto; min-width: 0; }
input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
.grow { flex: 1; min-width: 220px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
@media (max-width: 1080px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- brand ---------- */

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 0.9375rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.brand-stack { display: grid; line-height: 1.2; }
.brand-stack small { font-size: 0.75rem; font-weight: 500; color: var(--muted); }
.brand-logo {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
}
img.brand-logo { background: none; border-radius: 8px; }
.brand-tag {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 7px;
}

/* ---------- admin shell: sidebar + main ---------- */

.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 0 8px; }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-weight: 550;
}
.nav a svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav a[aria-current="page"] svg { color: var(--accent); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--border); }
.sidebar-foot .who { min-width: 0; flex: 1; }
.sidebar-foot .who strong { display: block; font-size: 0.875rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .who span { font-size: 0.75rem; color: var(--muted); }
.sidebar-foot form { margin: 0; }

.main { min-width: 0; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 28px 32px 20px;
}
.page-head .sub { color: var(--muted); margin-top: 4px; max-width: 720px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.content { padding: 0 32px 48px; display: grid; gap: 24px; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: 8px 12px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { padding: 0; }
  .nav { grid-auto-flow: column; justify-content: start; order: 3; width: 100%; overflow-x: auto; }
  .nav a { padding: 6px 10px; font-size: 0.8125rem; }
  .nav-label { display: none; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .sidebar-foot .who { display: none; }
  .page-head { padding: 20px 16px 14px; }
  .content { padding: 0 16px 32px; gap: 16px; }
}

/* ---------- member top bar ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar-user .name { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-user form { margin: 0; }
.container { max-width: 1160px; margin: 0 auto; padding: 0 24px 48px; }
.container .page-head { padding: 28px 0 20px; }
@media (max-width: 760px) {
  .topbar { padding: 10px 16px; }
  .topbar-user .name { display: none; }
  .container { padding: 0 16px 32px; }
  .container .page-head { padding: 20px 0 14px; }
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head .card-sub { color: var(--muted); font-size: 0.8125rem; margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.card-foot.sticky { position: sticky; bottom: 0; z-index: 2; }

/* ---------- KPIs ---------- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { padding: 18px 20px; display: grid; gap: 6px; }
.kpi-label { font-size: 0.8125rem; color: var(--muted); font-weight: 550; }
.kpi-value { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-meta { font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-note { font-size: 0.75rem; color: var(--warning); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.875rem; }
.table th {
  text-align: left; font-weight: 600; font-size: 0.75rem; letter-spacing: 0.02em; color: var(--muted);
  background: var(--surface-2); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table .cell-sub { display: block; font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.table tr.is-on td:first-child { box-shadow: inset 3px 0 0 var(--success); }

/* Tables become stacked cards on narrow screens. */
@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { border-bottom: 1px solid var(--border); padding: 10px 0; }
  .table.responsive tbody tr:last-child { border-bottom: 0; }
  .table.responsive td { border: 0; padding: 6px 16px; text-align: left; }
  .table.responsive td.num { text-align: left; }
  .table.responsive td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 0.75rem; font-weight: 550; margin-bottom: 2px; }
  .table.responsive td[data-label=""]::before { content: none; }
  .table.responsive td.lead { display: block; text-align: left; }
  .table.responsive td.lead::before { content: none; }
  .table.responsive tbody tr:hover td { background: transparent; }
  .table tr.is-on td:first-child { box-shadow: none; }
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-size: 0.75rem; font-weight: 550; line-height: 1.5;
  padding: 1px 9px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.badge.plain::before { content: none; }
.badge-success { color: var(--success); background: var(--success-soft); border-color: var(--success-border); }
.badge-accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.badge-warning { color: var(--warning); background: var(--warning-soft); border-color: var(--warning-border); }
.badge-danger { color: var(--danger); background: var(--danger-soft); border-color: var(--danger-border); }
.badge-neutral { color: var(--muted); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  font: inherit; font-size: 0.875rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-text); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 0.8125rem; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 0.9375rem; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }
.btn-slack { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-slack:hover { background: var(--surface-2); }

/* ---------- forms ---------- */

label, .field { display: grid; gap: 6px; font-size: 0.8125rem; font-weight: 550; color: var(--text-2); }
input, textarea, select {
  font: inherit; font-size: 0.875rem; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 12px; width: 100%; min-height: 36px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.8; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select-sm { min-height: 30px; padding: 4px 28px 4px 10px; font-size: 0.8125rem; width: auto; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: 0.8125rem; font-weight: 550; color: var(--text-2); padding: 0; margin-bottom: 8px; }
.field-hint, label .hint { font-weight: 400; }

.choice {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-weight: 400;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.choice:hover { background: var(--surface-2); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input, .checkbox input { width: 16px; height: 16px; min-height: 0; margin-top: 2px; accent-color: var(--accent); flex: none; }
.choice strong { display: block; color: var(--text); font-weight: 600; font-size: 0.875rem; }
.choice .hint { display: block; margin-top: 2px; }
.checkbox { display: flex; align-items: flex-start; gap: 10px; font-weight: 400; color: var(--text-2); font-size: 0.875rem; cursor: pointer; }

/* Settings sections: description on the left, fields on the right. */
.section { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; padding: 24px 20px; }
.section + .section { border-top: 1px solid var(--border); }
.section-title h2 { font-size: 0.9375rem; }
.section-title p { color: var(--muted); font-size: 0.8125rem; margin-top: 4px; }
@media (max-width: 900px) { .section { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 20px 16px; } }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.form-grid .align-end { align-self: end; padding-bottom: 10px; }
@media (max-width: 760px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.status-text { font-size: 0.8125rem; color: var(--muted); }
.status-error { color: var(--danger); }
.status-ok { color: var(--success); }

/* ---------- switch ---------- */

.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background 0.2s ease; }
.switch .slider::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25); transition: transform 0.2s ease;
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .slider { opacity: 0.6; }
.switch-lg { width: 52px; height: 28px; }
.switch-lg .slider::before { width: 22px; height: 22px; }
.switch-lg input:checked + .slider::before { transform: translateX(24px); }

/* ---------- avatars ---------- */

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none; object-fit: cover;
  display: inline-grid; place-items: center; font-size: 0.75rem; font-weight: 650; letter-spacing: 0.02em;
  color: #fff; background: var(--muted); user-select: none;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.6875rem; }
.avatar-lg { width: 40px; height: 40px; font-size: 0.875rem; }
.av-0 { background: #4f46e5; } .av-1 { background: #0e7490; } .av-2 { background: #b42318; } .av-3 { background: #067647; }
.av-4 { background: #9e4a03; } .av-5 { background: #6941c6; } .av-6 { background: #c11574; } .av-7 { background: #475467; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person-text { min-width: 0; }
.person-text strong { display: block; color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-text span { display: block; font-size: 0.8125rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- alerts, empty states, toasts ---------- */

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.875rem; border: 1px solid; }
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.alert-info { background: var(--accent-soft); color: var(--text-2); border-color: transparent; }
.alert-warning { background: var(--warning-soft); color: var(--text-2); border-color: var(--warning-border); }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.empty .import-progress { margin: 6px 0 2px; color: var(--text); font-variant-numeric: tabular-nums; }
.empty .hint { margin: 0 0 12px; }

.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 50; }
.toast {
  min-width: 240px; max-width: 380px; padding: 12px 14px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 0.875rem; box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- dialogs (modal and side drawer) ---------- */

dialog {
  border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
}
dialog::backdrop { background: rgba(13, 15, 19, 0.5); }
dialog.drawer {
  margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(600px, 100vw);
  border-radius: 0; border-width: 0 0 0 1px; display: none; flex-direction: column;
}
dialog.drawer[open] { display: flex; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 24px 16px; border-bottom: 1px solid var(--border); }
.dialog-head p { color: var(--muted); font-size: 0.8125rem; margin-top: 4px; }
.dialog-body { padding: 20px 24px; overflow-y: auto; display: grid; gap: 16px; flex: 1; align-content: start; }
.dialog-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.dialog-foot .status-text { margin-right: auto; }

/* ---------- auth pages ---------- */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-inner { width: 100%; max-width: 420px; display: grid; gap: 24px; }
.auth-inner > .brand { justify-content: center; }
.auth-card { padding: 32px; display: grid; gap: 20px; }
.auth-card h1 { font-size: 1.375rem; }
.auth-card .lede { color: var(--muted); margin-top: 6px; }
.auth-foot { text-align: center; font-size: 0.8125rem; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.78rem; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.identity { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }

/* ---------- member dashboard ---------- */

.away-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 24px; }
.away-hero-main { display: flex; align-items: center; gap: 16px; min-width: 0; }
.away-icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted); transition: background 0.2s ease, color 0.2s ease;
}
.away-icon svg { width: 22px; height: 22px; }
.away-hero h2 { font-size: 1.0625rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.away-hero .away-status { color: var(--muted); margin-top: 2px; }
.away-hero.is-on { border-color: var(--success-border); }
.away-hero.is-on .away-icon { background: var(--success-soft); color: var(--success); }
.changed-by { font-size: 0.8125rem; color: var(--muted); margin-top: 4px; }

.convo { display: grid; gap: 6px; padding: 14px 20px; }
.convo + .convo { border-top: 1px solid var(--border); }
.convo-meta { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--muted); }
.bubble { padding: 8px 12px; border-radius: 12px; font-size: 0.875rem; white-space: pre-wrap; overflow-wrap: anywhere; max-width: 92%; }
.bubble-in { background: var(--surface-3); color: var(--text); justify-self: start; border-bottom-left-radius: 4px; }
.bubble-out { background: var(--accent-soft); color: var(--text); justify-self: end; border-bottom-right-radius: 4px; }
.preview-out { margin-top: 4px; }

/* ---------- chart ---------- */

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .bar { fill: var(--chart-bar); }
.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border-strong); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .bar-hit { fill: transparent; outline: none; }
.chart .bar-hit.is-active, .chart .bar-hit:focus-visible { fill: var(--text); fill-opacity: 0.05; }
.chart-tip {
  position: absolute; top: 0; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
  background: var(--text); color: var(--bg); font-size: 0.78rem; padding: 5px 9px; border-radius: 7px; box-shadow: var(--shadow-md);
}
.table-view { margin-top: 12px; }
.table-view summary { cursor: pointer; color: var(--muted); font-size: 0.8125rem; width: max-content; }
.table-view[open] summary { margin-bottom: 10px; }

/* ---------- activity feed ---------- */

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 12px 20px; align-items: flex-start; }
.feed li + li { border-top: 1px solid var(--border); }
.feed .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--border-strong); }
.feed .dot.on { background: var(--success); }
.feed .feed-text { flex: 1; min-width: 0; font-size: 0.875rem; }
.feed .feed-time { font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.feed.scroll { max-height: 460px; overflow-y: auto; }

/* ---------- story: characters ---------- */

.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; padding: 20px; }
.char-card { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); align-content: start; }
.char-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.char-card.is-off { opacity: 0.75; }
.char-desc { color: var(--text-2); font-size: 0.8125rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 3.6em; }
.char-desc.empty-desc { color: var(--muted); font-style: italic; }
.char-tags { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- story: studio ---------- */

.studio { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 1180px) { .studio { grid-template-columns: minmax(0, 1fr); } }
.transcript { list-style: none; margin: 0; padding: 8px 0; min-height: 420px; max-height: 640px; overflow-y: auto; }
.transcript .msg { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding: 8px 20px; }
.transcript .msg:hover { background: var(--surface-2); }
.transcript .msg .avatar { width: 36px; height: 36px; }
.transcript .msg-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.transcript .msg-head strong { font-weight: 650; }
.transcript .msg-head .time { font-size: 0.75rem; color: var(--muted); }
.transcript .msg-text { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--text); }
.transcript .note { padding: 8px 20px; }
.transcript .note span {
  display: inline-flex; gap: 6px; font-size: 0.8125rem; color: var(--warning);
  background: var(--warning-soft); border: 1px dashed var(--warning-border); border-radius: 8px; padding: 6px 10px;
}
.transcript .empty { padding: 48px 20px; }
.timer { font-size: 2rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.meter-row { display: grid; gap: 6px; }
.meter-row .row-between { font-size: 0.8125rem; color: var(--muted); }
progress.meter { appearance: none; width: 100%; height: 8px; border: 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
progress.meter::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
progress.meter::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
progress.meter::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
progress.meter.warn::-webkit-progress-value { background: var(--warning); }
progress.meter.warn::-moz-progress-bar { background: var(--warning); }
.writer-list { display: grid; gap: 4px; }
.writer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.writer + .writer { border-top: 1px solid var(--border); }
.writer .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.writer .who .role { font-size: 0.78rem; color: var(--muted); display: block; }
.chapter { white-space: pre-wrap; line-height: 1.75; font-size: 0.9375rem; max-width: 72ch; }
@media (max-width: 760px) {
  .away-hero { padding: 16px; gap: 12px; }
  .away-icon { display: none; }
}

/* ---------- imported history in the studio ---------- */

.transcript .divider { display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.transcript .divider::before, .transcript .divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.transcript .msg.is-history .msg-text { color: var(--text-2); }
