/* Clawd 控制台 —— 样式。颜色全部走 :root 上的 token，深色在下面两处覆盖（跟随系统 / 手动）。 */

:root {
  color-scheme: light;
  --bg: #F5F3EE;
  --bg-elev: #FAF9F6;
  --surface: #FFFFFF;
  --surface-2: #F8F6F2;
  --sunken: #EEEBE4;
  --seg-on: #FFFFFF;
  --border: #E6E1D7;
  --border-strong: #D3CCBF;
  --text: #1F1E1C;
  --text-2: #5B5750;
  --text-3: #8A857C;
  --accent: #D97757;
  --accent-hover: #CB6849;
  --accent-soft: #FAE8E0;
  --accent-ring: rgba(217, 119, 87, .28);
  --accent-ink: #B4532F;
  --on-accent: #FFFFFF;
  --ok: #2B7A4B;      --ok-soft: #E1F2E7;
  --bad: #BF3A2C;     --bad-soft: #FCE5E1;
  --warn: #946100;    --warn-soft: #FBEFD2;
  --info: #2D62B3;    --info-soft: #E3ECFA;
  --neutral-soft: #EDEAE4;
  --switch-off: #D6D0C5;
  --inverse: #262421;
  --inverse-text: #F4F1EC;
  --overlay: rgba(24, 22, 19, .45);
  --shadow-sm: 0 1px 2px rgba(40, 32, 20, .05);
  --shadow: 0 1px 2px rgba(40, 32, 20, .04), 0 6px 20px rgba(40, 32, 20, .06);
  --shadow-lg: 0 18px 50px rgba(30, 24, 16, .22);
  --log-bg: #1D1C1A;
  --log-text: #E7E2DA;
  --log-border: #2E2C29;
  --crab-eye: #2A1E18;
  --avatar-l: 38%;

  --radius: 16px;
  --radius-sm: 11px;
  --radius-xs: 8px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Noto Sans Mono CJK SC", monospace;
  --sidebar-w: 236px;
  --tabbar-h: 58px;
  --topbar-h: 52px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #181715;
    --bg-elev: #1C1B19;
    --surface: #23221F;
    --surface-2: #2A2825;
    --sunken: #151412;
    --seg-on: #3A3733;
    --border: #34312D;
    --border-strong: #47433D;
    --text: #F1EEE9;
    --text-2: #BEB8AE;
    --text-3: #8C867C;
    --accent: #DE7F5F;
    --accent-hover: #E68D6E;
    --accent-soft: rgba(222, 127, 95, .16);
    --accent-ring: rgba(222, 127, 95, .35);
    --accent-ink: #F0A086;
    --on-accent: #FFFFFF;
    --ok: #7FD09C;      --ok-soft: rgba(90, 190, 125, .15);
    --bad: #F38B80;     --bad-soft: rgba(235, 90, 75, .16);
    --warn: #EBC167;    --warn-soft: rgba(230, 175, 50, .15);
    --info: #8FB5F3;    --info-soft: rgba(90, 145, 235, .16);
    --neutral-soft: #2F2D2A;
    --switch-off: #4A4640;
    --inverse: #F1EEE9;
    --inverse-text: #1E1D1B;
    --overlay: rgba(0, 0, 0, .58);
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, .02);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
    --log-bg: #121110;
    --log-text: #E7E2DA;
    --log-border: #2A2826;
    --crab-eye: #1A1311;
    --avatar-l: 74%;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #181715;
  --bg-elev: #1C1B19;
  --surface: #23221F;
  --surface-2: #2A2825;
  --sunken: #151412;
  --seg-on: #3A3733;
  --border: #34312D;
  --border-strong: #47433D;
  --text: #F1EEE9;
  --text-2: #BEB8AE;
  --text-3: #8C867C;
  --accent: #DE7F5F;
  --accent-hover: #E68D6E;
  --accent-soft: rgba(222, 127, 95, .16);
  --accent-ring: rgba(222, 127, 95, .35);
  --accent-ink: #F0A086;
  --on-accent: #FFFFFF;
  --ok: #7FD09C;      --ok-soft: rgba(90, 190, 125, .15);
  --bad: #F38B80;     --bad-soft: rgba(235, 90, 75, .16);
  --warn: #EBC167;    --warn-soft: rgba(230, 175, 50, .15);
  --info: #8FB5F3;    --info-soft: rgba(90, 145, 235, .16);
  --neutral-soft: #2F2D2A;
  --switch-off: #4A4640;
  --inverse: #F1EEE9;
  --inverse-text: #1E1D1B;
  --overlay: rgba(0, 0, 0, .58);
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, .02);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55);
  --log-bg: #121110;
  --log-text: #E7E2DA;
  --log-border: #2A2826;
  --crab-eye: #1A1311;
  --avatar-l: 74%;
}

/* ---------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
html:has(dialog[open]) { overflow: hidden; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
img, video { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-ring); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--text-3); }
.dim-text { color: var(--text-2); }
.nowrap { white-space: nowrap; }
.num-tab { font-variant-numeric: tabular-nums; }
.ic { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.ic-sm { width: 15px; height: 15px; }
.ic-lg { width: 22px; height: 22px; }
.spacer { flex: 1; }
.stack-sm > * + * { margin-top: 8px; }
.stack > * + * { margin-top: 14px; }
.stack-lg > * + * { margin-top: 22px; }
.hstack { display: flex; align-items: center; gap: 8px; min-width: 0; }
.wrap { flex-wrap: wrap; }
.break { overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- crab */

.crab { display: inline-block; flex: none; image-rendering: pixelated; }
.crab .eye { fill: var(--crab-eye); transform-box: fill-box; transform-origin: center; animation: crab-blink 6s infinite; }
.crab.sleep .eye { animation: none; transform: scaleY(.34) translateY(2px); }
.crab.busy { animation: crab-bob .5s var(--ease) infinite alternate; }
.crab.wave .arm-r { transform-box: fill-box; transform-origin: left bottom; animation: crab-wave 1.2s ease-in-out infinite; }
@keyframes crab-blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.15); } }
@keyframes crab-bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes crab-wave { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-1px); } }

/* ---------------------------------------------------------------- shell */

.shell { min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 16px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: .01em; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; color: var(--text-3); font-size: 12px; }
.topbar .pills { display: flex; gap: 6px; min-width: 0; overflow: hidden; }
.main { width: 100%; max-width: 1180px; margin: 0 auto; padding: 8px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px); min-width: 0; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 4px env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.6) blur(18px);
  backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--border);
}
.tab {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 600; color: var(--text-3); background: none; border: 0; cursor: pointer; padding: 0;
  transition: color .15s;
}
.tab:hover { text-decoration: none; color: var(--text-2); }
.tab .ic { width: 23px; height: 23px; transition: transform .2s var(--ease); }
.tab[aria-current="page"] { color: var(--accent-ink); }
.tab[aria-current="page"] .ic { transform: translateY(-1px); }
.tab .count, .nav-item .count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums;
}
.tab .count { position: absolute; top: 5px; left: calc(50% + 5px); box-shadow: 0 0 0 2px var(--surface); }
.tab .live-dot, .nav-item .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
.tab .live-dot { position: absolute; top: 9px; left: calc(50% + 9px); box-shadow: 0 0 0 2px var(--surface); }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: 20px 12px 16px; border-right: 1px solid var(--border); background: var(--bg-elev);
  }
  .sidebar .brand { padding: 2px 10px 18px; font-size: 17px; }
  .main { padding: 30px 40px 72px; }
}
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px;
  color: var(--text-2); font-weight: 600; font-size: 14.5px; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sunken); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item .label { flex: 1; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--border); }
.sidebar-status { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; font-size: 12.5px; color: var(--text-3); }
.sidebar-status .hstack { gap: 7px; }
.sidebar-tools { display: flex; gap: 4px; }
.sdot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--border-strong); }
.sdot.ok { background: var(--ok); } .sdot.bad { background: var(--bad); } .sdot.warn { background: var(--warn); } .sdot.progress { background: var(--accent); }

.alerts { display: flex; flex-direction: column; gap: 10px; margin: 0 0 14px; }
.alerts:empty { display: none; }
.alert {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bad-soft); color: var(--bad); font-size: 14px; font-weight: 550;
  border: 1px solid color-mix(in srgb, var(--bad) 22%, transparent);
  animation: fade-up .25s var(--ease);
}
.alert.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.alert.info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }
.alert .text { flex: 1; min-width: 0; }
.alert .btn { flex: none; }

.page { animation: page-in .28s var(--ease); min-width: 0; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-ring); } 70% { box-shadow: 0 0 0 6px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.page-head { display: flex; align-items: flex-end; gap: 12px; margin: 8px 0 18px; flex-wrap: wrap; }
.page-head .titles { flex: 1 1 220px; min-width: 0; }
.page-head h1 { font-size: 26px; line-height: 1.2; font-weight: 750; letter-spacing: -.01em; }
.page-head .sub { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.back:hover { color: var(--text); text-decoration: none; }
@media (min-width: 900px) { .page-head h1 { font-size: 28px; } }

.section-title { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; color: var(--text-3); letter-spacing: .04em; margin: 26px 2px 10px; }
.section-title .spacer + a, .section-title a { font-weight: 600; letter-spacing: 0; }

/* ---------------------------------------------------------------- layout helpers */

.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.grid-tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2 { grid-column: span 2; }
}
@media (min-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 22px; align-items: start; }
  .split > .side { position: sticky; top: 24px; grid-column: 2; grid-row: 1; }
  .split > .main-area { grid-column: 1; grid-row: 1; }
}
.split > * + * { margin-top: 0; }
@media (max-width: 1099px) { .split > * + * { margin-top: 14px; } }

/* ---------------------------------------------------------------- card */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card.tinted { background: var(--surface-2); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-width: 0; }
.card-head .title { font-size: 15.5px; font-weight: 700; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.card-head .title .ic { color: var(--text-3); }
.card-foot { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.card-sub { color: var(--text-3); font-size: 13px; }
a.card { color: inherit; display: block; transition: border-color .15s, transform .15s; }
a.card:hover { text-decoration: none; border-color: var(--border-strong); }
@media (min-width: 900px) { .card { padding: 18px 20px; } }

details.panel { padding: 0; }
details.panel > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius);
  user-select: none; -webkit-user-select: none;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary .ic-chev { transition: transform .2s var(--ease); color: var(--text-3); }
details.panel[open] > summary .ic-chev { transform: rotate(90deg); }
details.panel[open] > summary { border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
details.panel > summary .sum-title { font-weight: 700; font-size: 15.5px; }
details.panel > summary .sum-sub { color: var(--text-3); font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.panel > summary .sum-text { flex: 1; min-width: 0; }
details.panel .panel-body > .row:first-child { border-top: 0; }

/* ---------------------------------------------------------------- settings rows */

.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; min-height: 58px; min-width: 0; transition: opacity .2s; }
.row + .row, .rows > .row + .row { border-top: 1px solid var(--border); }
.row-text { flex: 1; min-width: 0; }
.row-label { display: block; font-weight: 600; font-size: 14.5px; line-height: 1.35; cursor: default; }
label.row-label[for] { cursor: pointer; }
.row-hint { color: var(--text-3); font-size: 12.5px; line-height: 1.45; margin-top: 3px; }
.row-error { color: var(--bad); font-size: 12.5px; margin-top: 4px; font-weight: 550; }
.row-warn { color: var(--warn); font-size: 12.5px; margin-top: 4px; font-weight: 550; }
.row-control { flex: none; display: flex; align-items: center; gap: 8px; min-width: 0; }
.row.stack { flex-direction: column; align-items: stretch; gap: 10px; }
.row.stack .row-control { width: 100%; flex-wrap: wrap; }
.row.dim .row-label, .row.dim .row-control { opacity: .5; }
.row.actions-row { flex-wrap: wrap; gap: 8px; }
.row-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub .lbl { font-size: 13px; color: var(--text-2); }
.row-sub .pair { display: inline-flex; align-items: center; gap: 8px; }
@media (min-width: 900px) { .row { padding: 14px 20px; } }

/* ---------------------------------------------------------------- inputs */

.input, .select, .textarea {
  font: inherit; font-size: 15px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border-strong); border-radius: var(--radius-xs); padding: 8px 11px; min-height: 40px; width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s; min-width: 0;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: .9; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: .6; cursor: not-allowed; }
.textarea { resize: vertical; line-height: 1.55; min-height: 84px; }
.num { width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.time { width: 110px; font-variant-numeric: tabular-nums; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.select.auto { width: auto; max-width: 100%; }
.unit { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field .hint { color: var(--text-3); font-size: 12.5px; }
.field-row { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 600px) { .field-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.counter { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--bad); font-weight: 600; }
.input-wrap { position: relative; display: flex; align-items: center; width: 100%; }
.input-wrap > .ic { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.input-wrap > .input { padding-left: 36px; }
.input-wrap > .btn-inside { position: absolute; right: 4px; }
@media (max-width: 899px) { .input, .select, .textarea { font-size: 16px; } }

input[type="checkbox"].check { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; margin: 0; flex: none; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 15px; border-radius: 11px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 14.5px; font-weight: 600; line-height: 1;
  cursor: pointer; white-space: nowrap; user-select: none; -webkit-user-select: none; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, transform .1s, opacity .15s, box-shadow .15s;
  position: relative; min-width: 0;
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); text-decoration: none; }
.btn:active { transform: scale(.975); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(180, 80, 40, .25); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.btn-soft:hover { background: var(--accent-soft); border-color: var(--accent-ring); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 32%, var(--border)); background: var(--surface); }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--bad) 88%, #000); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--sunken); border-color: transparent; color: var(--text); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13.5px; border-radius: 9px; gap: 5px; }
.btn-sm .ic { width: 16px; height: 16px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 16px; border-radius: 13px; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-block { width: 100%; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading > * { visibility: hidden; }
.btn.loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--text-3) var(--text-3) var(--text-3) transparent; animation: spin .7s linear infinite;
}
.btn-primary.loading::after, .btn-danger-solid.loading::after { border-color: #fff #fff #fff transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }
@media (max-width: 599px) { .btn-row.fill > .btn { flex: 1 1 auto; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; flex: none; }

.link-btn { background: none; border: 0; padding: 0; color: var(--accent-ink); font-weight: 600; cursor: pointer; font-size: inherit; }
.link-btn:hover { text-decoration: underline; text-underline-offset: 3px; }

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

.switch {
  --w: 48px; --h: 28px;
  position: relative; flex: none; width: var(--w); height: var(--h); border-radius: 999px; border: 0; padding: 0;
  background: var(--switch-off); cursor: pointer; transition: background .22s var(--ease), opacity .2s;
}
.switch-knob {
  position: absolute; top: 3px; left: 3px; width: calc(var(--h) - 6px); height: calc(var(--h) - 6px); border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25), 0 0 0 .5px rgba(0, 0, 0, .04);
  transition: transform .24s var(--ease);
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(calc(var(--w) - var(--h))); }
.switch.busy { opacity: .65; pointer-events: none; }
.switch:disabled { opacity: .4; cursor: not-allowed; }
.switch:focus-visible { outline-offset: 3px; border-radius: 999px; }
.switch-lg { --w: 62px; --h: 36px; }

/* ---------------------------------------------------------------- segmented */

.seg { display: inline-flex; background: var(--sunken); border-radius: 11px; padding: 3px; gap: 2px; max-width: 100%; }
.seg button {
  flex: 1 1 auto; border: 0; background: transparent; font-size: 13.5px; font-weight: 600; color: var(--text-2);
  padding: 0 12px; min-height: 32px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background .18s, color .18s, box-shadow .18s; min-width: 0;
}
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"], .seg button[aria-selected="true"], .seg button[aria-pressed="true"] {
  background: var(--seg-on); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .1), 0 0 0 .5px var(--border);
}
.seg button.hot[aria-checked="true"] { color: var(--accent-ink); }
.seg.full { display: flex; width: 100%; }
.seg.scroll { overflow-x: auto; scrollbar-width: none; max-width: 100%; }
.seg.scroll::-webkit-scrollbar { display: none; }
.seg .n { font-size: 11.5px; color: var(--text-3); margin-left: 4px; font-variant-numeric: tabular-nums; }
.seg button[aria-selected="true"] .n { color: var(--accent-ink); }

.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days button {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 650; font-size: 14px; color: var(--text-2); cursor: pointer; transition: all .15s;
}
.days button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------------------------------------------------------------- badges & chips */

.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 23px; padding: 0 9px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap; line-height: 1; flex: none;
  background: var(--neutral-soft); color: var(--text-2);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.t-ok { background: var(--ok-soft); color: var(--ok); }
.t-bad { background: var(--bad-soft); color: var(--bad); }
.t-warn { background: var(--warn-soft); color: var(--warn); }
.t-info { background: var(--info-soft); color: var(--info); }
.t-progress { background: var(--accent-soft); color: var(--accent-ink); }
.t-progress.dot::before { animation: pulse 1.6s infinite; }
.t-neutral { background: var(--neutral-soft); color: var(--text-2); }
.t-muted { background: transparent; color: var(--text-3); box-shadow: inset 0 0 0 1px var(--border-strong); }
.badge.sm { height: 20px; padding: 0 7px; font-size: 11.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px;
  background: var(--sunken); color: var(--text-2); max-width: 100%; overflow-wrap: anywhere; line-height: 1.4;
}
.chip.accent { background: var(--accent-soft); color: var(--accent-ink); }
.chip button { border: 0; background: none; padding: 0; margin-right: -3px; cursor: pointer; color: inherit; opacity: .7; display: inline-flex; }
.chip button:hover { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 650; white-space: nowrap; border: 0; cursor: pointer;
}
.pill:hover { text-decoration: none; filter: brightness(.97); }

/* ---------------------------------------------------------------- lists */

.list { display: flex; flex-direction: column; }
.list > .item + .item { border-top: 1px solid var(--border); }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-width: 0; color: inherit;
  transition: background .15s;
}
a.item:hover, button.item:hover, .item.linked:hover { background: var(--surface-2); text-decoration: none; }
.item.linked { position: relative; }
.item .stretch { color: inherit; }
.item .stretch:hover { text-decoration: none; }
.item .stretch::after { content: ""; position: absolute; inset: 0; }
.item .stretch:focus-visible { outline: none; }
.item.linked:has(.stretch:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 10px; }
.item.linked .side-col { position: relative; z-index: 1; }
button.item { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; font: inherit; }
.item .main-col { flex: 1; min-width: 0; }
.item .t1 { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; min-width: 0; }
.item .t1 .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.item .t2 { color: var(--text-3); font-size: 12.5px; margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.item .t3 { color: var(--text-2); font-size: 13px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .side-col { flex: none; display: flex; align-items: center; gap: 8px; }
.item .ic-chev { color: var(--text-3); }
@media (max-width: 480px) { .hide-sm { display: none !important; } }
.sep-dot::before { content: "·"; margin-right: 6px; color: var(--border-strong); }
@media (min-width: 900px) { .item { padding: 12px 20px; } }

.load-more { display: flex; justify-content: center; padding: 14px; }
.list-foot { text-align: center; color: var(--text-3); font-size: 12.5px; padding: 12px; }

/* ---------------------------------------------------------------- stat tiles */

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2);
  border: 1px solid var(--border); color: inherit; min-width: 0;
}
a.stat:hover { text-decoration: none; border-color: var(--border-strong); }
.stat .v { font-size: 21px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .k { font-size: 12px; color: var(--text-3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.hot { background: var(--accent-soft); border-color: transparent; }
.stat.hot .v, .stat.hot .k { color: var(--accent-ink); }
.kv { margin: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--text-3); white-space: nowrap; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.meta-line { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--text-3); font-size: 13px; align-items: center; }
.meta-line > span { display: inline-flex; align-items: center; gap: 5px; }

/* ---------------------------------------------------------------- overview */

.hero {
  display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: 20px;
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%);
  border: 1px solid var(--border); position: relative; overflow: hidden;
}
.hero.paused { background: linear-gradient(135deg, var(--warn-soft), var(--surface) 70%); }
.hero .crab-wrap { width: 58px; height: 58px; border-radius: 16px; background: var(--surface); display: grid; place-items: center; flex: none; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.hero .hero-text { flex: 1; min-width: 0; }
.hero .hero-k { font-size: 12.5px; color: var(--text-3); font-weight: 650; letter-spacing: .03em; }
.hero h2 { font-size: 20px; font-weight: 750; line-height: 1.3; margin-top: 1px; }
.hero .hero-hint { font-size: 13px; color: var(--text-2); margin-top: 4px; }
@media (max-width: 420px) { .hero { padding: 16px 14px; gap: 12px; } .hero .crab-wrap { width: 48px; height: 48px; } .hero h2 { font-size: 18px; } }

.svc-card .card-head { margin-bottom: 10px; }
.svc-line { display: flex; align-items: baseline; gap: 10px; font-size: 14px; padding: 5px 0; min-width: 0; }
.svc-line .k { color: var(--text-3); flex: none; width: 64px; font-size: 13px; }
.svc-line .v { flex: 1; min-width: 0; overflow-wrap: anywhere; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.svc-line .v.ellipsis { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini { display: flex; flex-direction: column; gap: 8px; }
.mini .who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.mini .who .name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--accent-soft); color: var(--accent-ink); object-fit: cover; overflow: hidden;
}
.avatar.hue { background: hsl(var(--h) 70% 50% / .16); color: hsl(var(--h) 60% var(--avatar-l)); }
.avatar.lg { width: 54px; height: 54px; font-size: 21px; }
.sys-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 720px) { .sys-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.sys-grid .stat .v { font-size: 18px; }

.danger-zone { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: var(--radius); border: 1px dashed color-mix(in srgb, var(--bad) 40%, var(--border)); flex-wrap: wrap; }
.danger-zone .text { flex: 1 1 220px; min-width: 0; }
.danger-zone .t { font-weight: 700; }
.danger-zone .h { color: var(--text-3); font-size: 13px; margin-top: 2px; }

/* ---------------------------------------------------------------- empty / skeleton */

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 34px 20px; color: var(--text-3); }
.empty .crab { margin-bottom: 6px; }
.empty .et { font-weight: 700; color: var(--text-2); font-size: 15px; }
.empty .ed { font-size: 13.5px; max-width: 340px; }
.empty .btn { margin-top: 8px; }
.sk { border-radius: 7px; height: 13px; background: var(--sunken); position: relative; overflow: hidden; }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 55%, transparent), transparent);
  animation: shimmer 1.3s infinite;
}
.sk.h { height: 20px; width: 40%; }
.sk.w60 { width: 60%; } .sk.w80 { width: 80%; } .sk.w30 { width: 30%; }
.sk-card { display: flex; flex-direction: column; gap: 10px; }
@keyframes shimmer { to { transform: translateX(100%); } }

.boot { min-height: 100vh; display: grid; place-items: center; }
.boot .inner { display: flex; flex-direction: column; align-items: center; gap: 14px; color: var(--text-3); font-size: 14px; }

/* ---------------------------------------------------------------- toast */

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 200;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: min(92vw, 440px);
  /* 用 popover 进顶层，打开的对话框也盖不住 toast；这里清掉浏览器给 [popover] 的默认样式 */
  top: auto; right: auto; height: auto; margin: 0; padding: 0; border: 0; background: none; overflow: visible; color: inherit;
}
@media (min-width: 900px) { .toasts { left: calc(50% + var(--sidebar-w) / 2); bottom: 26px; } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: 100%;
  background: var(--inverse); color: var(--inverse-text); padding: 10px 14px; border-radius: 13px;
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 550; animation: toast-in .24s var(--ease);
}
.toast .msg { min-width: 0; overflow-wrap: anywhere; }
.toast .ic { color: #6CCB8C; }
.toast.error .ic { color: #FF8D80; }
.toast.info .ic { color: var(--accent); }
.toast.out { animation: toast-out .2s forwards; }
.toast-action { flex: none; border: 0; background: none; color: var(--accent); font-weight: 700; cursor: pointer; padding: 2px 4px; font-size: 14px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ---------------------------------------------------------------- dialog */

dialog.dlg {
  border: 0; padding: 0; background: var(--surface); color: var(--text); border-radius: 20px; box-shadow: var(--shadow-lg);
  width: min(460px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 48px);
  display: flex; flex-direction: column; overflow: hidden;
}
dialog.dlg:not([open]) { display: none; }
dialog.dlg.wide { width: min(760px, calc(100vw - 32px)); }
dialog.dlg[open] { animation: dlg-in .24s var(--ease); }
dialog.dlg::backdrop { background: var(--overlay); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade .2s; }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 8px; }
.dlg-head .dlg-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-ink); }
.dlg-head .dlg-ic.danger { background: var(--bad-soft); color: var(--bad); }
.dlg-head h2 { font-size: 17px; font-weight: 750; line-height: 1.35; flex: 1; min-width: 0; padding-top: 7px; }
.dlg-head .btn-icon { margin: -2px -6px 0 0; }
.dlg-body { padding: 6px 20px 16px; overflow: auto; color: var(--text-2); font-size: 14.5px; min-height: 0; flex: 1; }
.dlg-body p + p { margin-top: 8px; }
.dlg-body strong { color: var(--text); }
.dlg-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px 18px; border-top: 1px solid transparent; flex-wrap: wrap; }
.dlg-quote { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@media (max-width: 599px) {
  dialog.dlg { width: 100%; max-height: calc(100dvh - 24px); margin: auto 0 0; border-radius: 22px 22px 0 0; padding-bottom: env(safe-area-inset-bottom); }
  dialog.dlg.wide { width: 100%; }
  dialog.dlg[open] { animation: sheet-in .3s var(--ease); }
  .dlg-foot .btn { flex: 1 0 0; min-width: max-content; }
  .dlg-head { padding-top: 22px; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

.sheet-nav { display: flex; flex-direction: column; gap: 4px; }
.sheet-nav .nav-item { padding: 13px 12px; font-size: 16px; }

/* ---------------------------------------------------------------- login */

.login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; animation: page-in .4s var(--ease); }
.login-card .logo { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 6px; text-align: center; }
.login-card .logo .crab-wrap { width: 84px; height: 84px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; box-shadow: var(--shadow); }
.login-card h1 { font-size: 24px; font-weight: 800; }
.login-card .sub { color: var(--text-3); font-size: 13.5px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card .err { color: var(--bad); font-size: 13.5px; font-weight: 550; min-height: 1em; }
.login-card .foot { color: var(--text-3); font-size: 12.5px; text-align: center; line-height: 1.6; }

/* ---------------------------------------------------------------- replies */

.side-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "panel" "list" "try"; align-items: start; }
.side-layout > * { min-width: 0; }
.area-panel { grid-area: panel; } .area-list { grid-area: list; } .area-try { grid-area: try; }
@media (min-width: 1100px) {
  .side-layout { grid-template-columns: minmax(0, 1fr) 380px; grid-template-areas: "list panel" "list try"; grid-template-rows: auto 1fr; gap: 16px 22px; }
}

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; min-width: 0; }
.toolbar .grow { flex: 1 1 200px; min-width: 0; }
.tabs-wrap { margin: 0 0 12px; min-width: 0; }
.bulkbar {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 14px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); margin-bottom: 12px; flex-wrap: wrap;
}
.bulkbar label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.bulkbar .spacer { min-width: 4px; }
.cards { display: flex; flex-direction: column; gap: 12px; }

.rcard { padding: 0; overflow: hidden; transition: opacity .25s, transform .25s, max-height .3s; }
.rcard.leaving { opacity: 0; transform: translateX(24px) scale(.98); }
.rcard.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.rcard-top { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; color: var(--text-3); min-width: 0; }
.rcard-top .video { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text-2); }
.rcard-body { padding: 13px 14px 14px; display: flex; flex-direction: column; gap: 11px; min-width: 0; }
.who { display: flex; align-items: center; gap: 9px; min-width: 0; flex-wrap: wrap; }
.who .nick { font-weight: 700; font-size: 14.5px; overflow-wrap: anywhere; }
.who .meta { color: var(--text-3); font-size: 12.5px; display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.likes { display: inline-flex; align-items: center; gap: 3px; color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.likes .ic { width: 14px; height: 14px; }
.comment { font-size: 16px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.notes { display: flex; flex-wrap: wrap; gap: 6px; }
.thread { border-left: 2px solid var(--border-strong); padding: 2px 0 2px 11px; display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; color: var(--text-2); }
.thread .t-who { font-weight: 650; color: var(--text-2); }
.thread .me .t-who { color: var(--accent-ink); }
.thread .more-btn { align-self: flex-start; }
.thread-label { font-size: 12px; color: var(--text-3); font-weight: 650; display: flex; align-items: center; gap: 6px; }
.draft { border-radius: 13px; background: var(--accent-soft); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.draft-head { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--accent-ink); }
.draft-head .crab { margin-right: 1px; }
.draft textarea {
  border: 1px solid transparent; background: var(--surface); border-radius: 9px; resize: none; min-height: 44px; padding: 8px 10px;
  font: inherit; font-size: 15.5px; color: var(--text); line-height: 1.5; width: 100%; overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.draft textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.draft .final { font-size: 15.5px; color: var(--text); overflow-wrap: anywhere; white-space: pre-wrap; }
.draft-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.draft-foot .edited { color: var(--accent-ink); font-weight: 650; }
.reason { font-size: 12.5px; color: var(--text-3); display: flex; flex-direction: column; gap: 3px; }
.reason b { color: var(--text-2); font-weight: 650; }
.rcard-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rcard-actions .spacer { min-width: 0; }
.err-box { padding: 9px 11px; border-radius: 10px; background: var(--bad-soft); color: var(--bad); font-size: 13px; overflow-wrap: anywhere; }
.warn-box { padding: 9px 11px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 13px; overflow-wrap: anywhere; }
.info-box { padding: 10px 12px; border-radius: 10px; background: var(--info-soft); color: var(--info); font-size: 13px; overflow-wrap: anywhere; }

.bubble-row { display: flex; gap: 10px; align-items: flex-start; }
.bubble-row .crab-av { width: 36px; height: 36px; border-radius: 12px; background: var(--accent-soft); display: grid; place-items: center; flex: none; }
.bubble { padding: 10px 13px; border-radius: 4px 15px 15px 15px; background: var(--surface-2); border: 1px solid var(--border); font-size: 15.5px; overflow-wrap: anywhere; min-width: 0; }
.bubble.accent { background: var(--accent-soft); border-color: transparent; color: var(--text); }

/* ---------------------------------------------------------------- episodes */

.ep-day {
  width: 52px; height: 52px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; justify-content: center; flex: none; line-height: 1;
}
.ep-day .d1 { font-size: 10px; font-weight: 750; color: var(--text-3); letter-spacing: .06em; }
.ep-day .d2 { font-size: 19px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }
.ep-day.active { background: var(--accent-soft); border-color: transparent; }
.ep-day.active .d1, .ep-day.active .d2 { color: var(--accent-ink); }

.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.step { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.step-bar { height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; position: relative; }
.step-bar > i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent); border-radius: 3px; transition: width .5s var(--ease); }
.step.done .step-bar > i { width: 100%; background: var(--ok); }
.step.active .step-bar > i { width: 100%; }
.step.active.indet .step-bar > i {
  width: 100%;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 8px, color-mix(in srgb, var(--accent) 60%, transparent) 8px 16px);
  background-size: 22.6px 100%; animation: stripes .8s linear infinite;
}
.step.waiting .step-bar > i { width: 100%; background: var(--warn); }
.step.failed .step-bar > i { width: 100%; background: var(--bad); }
.step-label { font-size: 13px; font-weight: 700; color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.step.done .step-label { color: var(--text-2); }
.step.active .step-label { color: var(--accent-ink); }
.step.waiting .step-label { color: var(--warn); }
.step.failed .step-label { color: var(--bad); }
.step-sub { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
@keyframes stripes { to { background-position: 22.6px 0; } }
.callout { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 600; font-size: 14px; margin-top: 14px; }
.callout.info { background: var(--info-soft); color: var(--info); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }
.callout.bad { background: var(--bad-soft); color: var(--bad); }
.callout .text { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.media { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .media { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.video-box { background: #000; border-radius: 14px; overflow: hidden; display: grid; place-items: center; aspect-ratio: 9 / 16; width: min(100%, calc(72vh * 9 / 16)); margin: 0 auto; }
.video-box video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.ph {
  border-radius: 14px; border: 1.5px dashed var(--border-strong); display: grid; place-items: center; text-align: center;
  color: var(--text-3); font-size: 13px; padding: 20px; background: var(--surface-2); min-height: 120px;
}
.ph.tall { aspect-ratio: 9 / 16; width: min(100%, calc(60vh * 9 / 16)); margin: 0 auto; }
.thumbs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-content: start; }
.thumb { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.thumb .lbl { font-size: 12.5px; font-weight: 650; color: var(--text-3); }
.thumb img { width: 100%; border-radius: 10px; border: 1px solid var(--border); display: block; background: var(--surface-2); }
.thumb a { display: block; }
.thumb.full { grid-column: 1 / -1; }

.pick { display: flex; flex-direction: column; gap: 10px; }
.order {
  padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); position: relative;
}
.order .q { font-size: 18px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; color: var(--text); }
.order .by { font-size: 13px; color: var(--accent-ink); margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 600; }
.cand { display: flex; align-items: center; gap: 10px; padding: 10px 0; min-width: 0; }
.cand + .cand { border-top: 1px solid var(--border); }
.cand .ct { flex: 1; min-width: 0; }
.cand .ct .tx { font-size: 14.5px; overflow-wrap: anywhere; }
.cand .ct .mt { font-size: 12.5px; color: var(--text-3); display: flex; gap: 8px; align-items: center; margin-top: 2px; flex-wrap: wrap; }
.cand.done .tx { color: var(--text-3); }

.scenes { width: 100%; border-collapse: collapse; font-size: 14px; }
.scenes th { text-align: left; font-size: 12px; color: var(--text-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.scenes td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.scenes tr:last-child td { border-bottom: 0; }
.scenes .n { color: var(--text-3); font-variant-numeric: tabular-nums; width: 28px; }
.scene-cards { display: none; flex-direction: column; gap: 10px; }
.scene-card { border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px; display: flex; flex-direction: column; gap: 5px; background: var(--surface-2); }
.scene-card .sc-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }
.scene-card .cap { font-weight: 700; font-size: 15px; }
.scene-card .sub { color: var(--text-2); font-size: 13.5px; }
.scene-card .say { font-size: 13.5px; color: var(--accent-ink); }
@media (max-width: 719px) { .scenes { display: none; } .scene-cards { display: flex; } }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px 8px; min-height: 42px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs); background: var(--surface-2); cursor: text; }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); background: var(--surface); }
.tag-input input { border: 0; outline: 0; background: transparent; font: inherit; color: var(--text); flex: 1 1 90px; min-width: 60px; padding: 4px 2px; }
.save-state { font-size: 12.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; }
.save-state.dirty { color: var(--warn); }
.save-state.err { color: var(--bad); }
.action-bar { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- log viewer */

.log { background: var(--log-bg); color: var(--log-text); border-radius: 14px; overflow: hidden; border: 1px solid var(--log-border); position: relative; min-width: 0; }
.log-bar { display: flex; align-items: center; gap: 6px; padding: 7px 8px 7px 12px; border-bottom: 1px solid var(--log-border); font-size: 12.5px; color: #A8A197; flex-wrap: wrap; }
.log-bar .state { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; margin-right: auto; }
.log-bar .state .d { width: 7px; height: 7px; border-radius: 50%; background: #6A645B; }
.log-bar .state.live .d { background: var(--accent); animation: pulse 1.6s infinite; }
.log-bar button {
  border: 0; background: transparent; color: #CFC8BD; font-size: 12.5px; font-weight: 600; padding: 5px 8px; border-radius: 7px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
}
.log-bar button:hover { background: rgba(255, 255, 255, .07); }
.log-bar button[aria-pressed="true"] { color: var(--accent); }
.log-body {
  height: 440px; max-height: 64vh; overflow: auto; padding: 10px 12px 14px; font: 12.5px/1.6 var(--mono);
  white-space: pre-wrap; overflow-wrap: anywhere; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
}
.log.short .log-body { height: 280px; }
.log.nowrap .log-body { white-space: pre; overflow-wrap: normal; }
.log-body .ln-ev { color: #E9A68A; }
.log-body .ln-res { color: #96D9AC; font-weight: 600; }
.log-body .ln-err { color: #FF9E92; }
.log-body .ln-note { color: #8C857B; font-style: italic; }
.log-body .tail { opacity: .8; }
.log-empty { color: #8C857B; }
.log-follow {
  position: absolute; right: 12px; bottom: 12px; border: 0; border-radius: 999px; padding: 7px 12px; font-size: 12.5px; font-weight: 700;
  background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  animation: fade-up .2s var(--ease);
}

/* ---------------------------------------------------------------- jobs */

.job-ic {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--sunken); color: var(--text-2);
}
.job-ic.running { background: var(--accent-soft); color: var(--accent-ink); }
.job-ic.failed { background: var(--bad-soft); color: var(--bad); }
.job-ic.success { background: var(--ok-soft); color: var(--ok); }
.summary-line { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-line.err { color: var(--bad); }
.summary-box { display: flex; flex-wrap: wrap; gap: 8px; }
.summary-box .stat { flex: 1 1 54px; padding: 8px 10px; }
.summary-box .stat .v { font-size: 18px; }
.pre {
  font: 12.5px/1.55 var(--mono); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 260px; overflow: auto; margin: 0; color: var(--text-2);
}

/* ---------------------------------------------------------------- kb */

.kb-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.kb-tools .status { font-size: 12.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 6px; margin-right: auto; }
.kb-tools .status.dirty { color: var(--warn); font-weight: 600; }
.kb-editor {
  width: 100%; min-height: 420px; height: calc(100dvh - 300px); resize: vertical; font: 14px/1.7 var(--mono); padding: 16px 18px;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); tab-size: 2;
}
.kb-editor:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
@media (max-width: 899px) { .kb-editor { font-size: 14px; padding: 12px 13px; height: calc(100dvh - 330px); } }
.kb-preview { min-height: 420px; }
.kb-banner { margin-bottom: 12px; }
.bk-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; }
.bk-item + .bk-item { border-top: 1px solid var(--border); }
.bk-item .nm { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.bk-item .mt { color: var(--text-3); font-size: 12.5px; }

.md { font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; color: var(--text); }
.md h1, .md h2, .md h3, .md h4 { line-height: 1.35; margin: 1.3em 0 .5em; font-weight: 750; }
.md h1 { font-size: 22px; } .md h2 { font-size: 18px; padding-bottom: 6px; border-bottom: 1px solid var(--border); } .md h3 { font-size: 16px; } .md h4 { font-size: 15px; }
.md > :first-child { margin-top: 0; }
.md p, .md ul, .md ol, .md blockquote, .md pre { margin: 0 0 .8em; }
.md ul, .md ol { padding-left: 1.4em; }
.md li + li { margin-top: .25em; }
.md li > ul, .md li > ol { margin: .3em 0 0; }
.md code { font-family: var(--mono); font-size: .88em; background: var(--sunken); padding: .1em .4em; border-radius: 5px; }
.md pre { background: var(--sunken); border-radius: 10px; padding: 12px 14px; overflow: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md strong { font-weight: 700; }
.md del { color: var(--text-3); }

/* ---------------------------------------------------------------- users */

.utl { display: flex; flex-direction: column; gap: 10px; }
.utl .day { align-self: center; font-size: 12px; color: var(--text-3); font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--sunken); margin: 8px 0 2px; }
.msg { display: flex; flex-direction: column; gap: 3px; max-width: min(86%, 560px); }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg .b { padding: 9px 13px; border-radius: 15px 15px 15px 5px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14.5px; overflow-wrap: anywhere; white-space: pre-wrap; }
.msg.me .b { border-radius: 15px 15px 5px 15px; background: var(--accent-soft); border-color: transparent; }
.msg .m { font-size: 11.5px; color: var(--text-3); padding: 0 4px; overflow-wrap: anywhere; }
.note-row { display: flex; gap: 8px; align-items: center; }
.note-row + .note-row { margin-top: 8px; }
.note-row .input { flex: 1; }

/* ---------------------------------------------------------------- qr */

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.qr-frame {
  width: 236px; height: 236px; max-width: 100%; border-radius: 18px; background: #fff; border: 1px solid var(--border);
  display: grid; place-items: center; overflow: hidden; position: relative; padding: 10px;
}
.qr-frame img { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; }
.qr-frame .over { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 255, 255, .92); color: #2B7A4B; font-weight: 700; }
.qr-state { font-weight: 650; color: var(--text); font-size: 15px; display: flex; align-items: center; gap: 8px; }
.qr-tip { font-size: 12.5px; color: var(--text-3); max-width: 320px; }

/* ---------------------------------------------------------------- misc */

.kbd { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); color: var(--text-3); background: var(--surface-2); }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.secret-state { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.steps-list { margin: 0; padding-left: 1.2em; color: var(--text-2); font-size: 14px; }
.steps-list li + li { margin-top: 6px; }
.fade-in { animation: fade-up .25s var(--ease); }
.collapse-out { overflow: hidden; transition: max-height .28s var(--ease), opacity .2s, margin .28s, padding .28s; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
