/* ── Reference style · dark sidebar + light stage, minimal ─────
   极深炭黑侧栏 + 米白主区，细发丝边框，衬线标题，无装饰。
──────────────────────────────────────────────────────────────── */
:root {
  /* Sidebar (dark) */
  --side: #17150f;
  --side-2: #1f1c14;
  --side-hover: #26221a;
  --side-line: rgba(235, 220, 190, 0.08);
  --side-line-strong: rgba(235, 220, 190, 0.16);
  --side-text: #e8dfc9;
  --side-dim: #8d8471;
  --side-mute: #5a5344;

  /* Content (light) */
  --paper: #faf6ec;
  --paper-2: #f3eedd;
  --paper-line: rgba(35, 29, 17, 0.09);
  --paper-line-strong: rgba(35, 29, 17, 0.16);
  --ink: #1f1b12;
  --ink-2: #57503f;
  --ink-3: #8b8270;
  --ink-4: #b5ac99;

  /* Accent (used sparingly) */
  --accent: #7d7dff;
  --accent-dim: rgba(125, 125, 255, 0.08);
  --accent-line: rgba(125, 125, 255, 0.3);

  --rose: #a83232;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-xs: 5px;

  --sidebar-w: 256px;
  --font-display: 'Fraunces', 'Songti SC', 'STSong', Georgia, serif;
  --font-body: 'Inter', 'PingFang SC', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  background: var(--paper);
}

#app {
  height: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

input,
textarea,
select {
  outline: none;
}

::selection {
  background: rgba(124, 90, 30, 0.18);
}

/* ── Setup ───────────────────────────────────────────────────── */
.setup {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--paper);
  overflow: auto;
}

.setup-card {
  width: min(480px, 100%);
  background: var(--paper);
  border: 1px solid var(--paper-line-strong);
  border-radius: var(--radius);
  padding: 44px 40px 32px;
}

.setup-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-3);
  border: 1px solid var(--paper-line);
  padding: 5px 11px;
  border-radius: 999px;
  margin-bottom: 22px;
}

.setup-badge .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.setup h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-variation-settings: 'opsz' 144;
  font-size: clamp(32px, 5vw, 40px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0 0 14px;
  color: var(--ink);
}

.setup h1 span {
  font-style: italic;
  color: var(--accent);
  font-weight: 300;
}

.setup-lead {
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.65;
  margin: 0 0 30px;
}

.setup-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-2);
}

.field label em {
  font-style: normal;
  color: var(--ink-3);
  font-weight: 400;
  margin-left: 6px;
}

.field input,
.field select {
  width: 100%;
  background: #fff;
  border: 1px solid var(--paper-line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field input::placeholder {
  color: var(--ink-4);
}

.field-hint {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.5;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}

.preset-chip {
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--paper-line-strong);
  color: var(--ink-2);
  transition: all 0.15s;
}

.preset-chip:hover,
.preset-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.setup-actions {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 500;
  font-size: 14.5px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  letter-spacing: 0.01em;
}

.btn-primary:hover:not(:disabled) {
  background: #000;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px;
  border-radius: var(--radius-xs);
  transition: all 0.15s;
}

.btn-ghost:hover {
  color: var(--ink);
  background: var(--paper-2);
}

.setup-error {
  background: rgba(168, 50, 50, 0.06);
  border: 1px solid rgba(168, 50, 50, 0.25);
  color: var(--rose);
  font-size: 13.5px;
  padding: 11px 13px;
  border-radius: var(--radius-xs);
  line-height: 1.5;
}

.setup-foot {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--paper-line);
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.55;
  text-align: center;
}

/* ── Shell ───────────────────────────────────────────────────── */
.shell {
  height: 100%;
  display: flex;
  --sidebar-w: 264px;
  --chat-w: min(48%, 720px);
  --handle-w: 5px;
  transition: none;
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  transition: opacity 0.25s var(--ease), flex-basis 0.3s var(--ease);
}

.shell.sidebar-collapsed .sidebar {
  flex-basis: 0;
}

.chat-panel {
  flex: 0 0 var(--chat-w);
  min-width: 280px;
}

.split-handle {
  flex: 0 0 var(--handle-w);
  cursor: col-resize;
  background: transparent;
  transition: background 0.15s;
  position: relative;
}

.split-handle::before {
  content: '';
  position: absolute;
  inset: 0 2px;
  background: var(--paper-line);
  transition: background 0.15s;
}

.split-handle:hover::before,
.split-handle.dragging::before {
  background: var(--accent);
}

.canvas-panel {
  flex: 1 1 auto;
  min-width: 320px;
}

.shell.sidebar-collapsed {
  /* no-op now — sidebar flex-basis handles it */
}

/* ── Sidebar (dark) ──────────────────────────────────────────── */
.sidebar {
  background: var(--side);
  color: var(--side-text);
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.25s var(--ease);
}

.shell.sidebar-collapsed .sidebar {
  opacity: 0;
  pointer-events: none;
}

.sidebar-head {
  padding: 18px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-bottom: 1px solid var(--side-line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--side-line-strong);
  display: block;
  flex-shrink: 0;
  object-fit: cover;
}

.brand-text {
  min-width: 0;
}

.brand-text strong {
  display: block;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--side-text);
}

.brand-text span {
  display: block;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--side-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.btn-new {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--side-line-strong);
  color: var(--side-text);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s;
}

.btn-new:hover {
  background: var(--side-hover);
  border-color: var(--side-dim);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--side-mute);
  padding: 10px 10px 6px;
}

.conv-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: start;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  transition: background 0.12s;
  position: relative;
  cursor: pointer;
  border-left: 2px solid transparent;
}

.conv-item:hover {
  background: var(--side-hover);
}

.conv-item.active {
  background: var(--side-hover);
  border-left-color: var(--side-text);
}

.conv-item.active .conv-title {
  color: var(--side-text);
}

.conv-title {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--side-text);
}

.conv-meta {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--side-mute);
  margin-top: 3px;
  letter-spacing: 0.04em;
}

.conv-del {
  opacity: 0;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: var(--side-mute);
  display: grid;
  place-items: center;
  transition: all 0.12s;
}

.conv-item:hover .conv-del,
.conv-item:focus-within .conv-del {
  opacity: 1;
}

.conv-del:hover {
  background: rgba(168, 50, 50, 0.2);
  color: var(--rose);
}

.sidebar-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--side-mute);
  font-size: 13px;
  line-height: 1.55;
}

.sidebar-foot {
  border-top: 1px solid var(--side-line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.side-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  color: var(--side-dim);
  font-size: 13px;
  font-weight: 400;
  transition: all 0.12s;
}

.side-action:hover {
  background: var(--side-hover);
  color: var(--side-text);
}

.side-action svg {
  flex-shrink: 0;
  opacity: 0.7;
}

/* ── Chat panel (light) ──────────────────────────────────────── */
.chat-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
  border-right: 1px solid var(--paper-line);
  overflow: hidden;
  position: relative;
}

.chat-top {
  height: 52px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--paper-line);
  flex-shrink: 0;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  border: 1px solid transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--paper-2);
  color: var(--ink);
  border-color: var(--paper-line);
}

.chat-top-title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.chat-top-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  white-space: nowrap;
  text-transform: uppercase;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 26px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scroll-behavior: smooth;
}

.msg {
  max-width: min(640px, 100%);
  animation: msg-in 0.3s var(--ease) both;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg.user {
  align-self: flex-end;
  max-width: min(520px, 92%);
}

.msg.assistant {
  align-self: flex-start;
  max-width: min(640px, 100%);
  width: auto;
}

.msg-role {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg.user .msg-role {
  justify-content: flex-end;
  color: var(--ink-3);
}

.msg.assistant .msg-role {
  color: var(--accent);
}

.msg-role .live {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.msg-role .live::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .msg-bubble {
  background: var(--ink);
  color: var(--paper);
  border-bottom-right-radius: 4px;
  box-shadow: 0 6px 18px rgba(31, 27, 18, 0.12);
}

.msg.assistant .msg-bubble {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--paper-line);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 10px rgba(31, 27, 18, 0.03);
}

.msg-bubble p {
  margin: 0 0 0.8em;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-2);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--paper-line);
}

.msg.user .msg-bubble code {
  background: rgba(255, 255, 255, 0.12);
  color: var(--paper);
  border-color: rgba(255, 255, 255, 0.1);
}

.msg-bubble pre {
  background: var(--paper-2);
  border: 1px solid var(--paper-line-strong);
  color: var(--ink);
  border-radius: var(--radius-xs);
  padding: 13px 16px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  margin: 0.8em 0;
}

.msg-bubble pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
}

.msg-bubble ul,
.msg-bubble ol {
  margin: 0.4em 0;
  padding-left: 1.4em;
}

/* Welcome */
.welcome {
  margin: auto 0;
  max-width: 440px;
  align-self: center;
  text-align: left;
  padding: 40px 16px 60px;
}

.welcome-orb {
  display: none;
}

.welcome h2 {
  font-family: var(--font-display);
  font-weight: 400;
  font-variation-settings: 'opsz' 144;
  font-size: 34px;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  color: var(--ink);
  line-height: 1.15;
}

.welcome h2 em {
  font-style: italic;
  color: var(--accent);
  font-weight: 300;
}

.welcome p {
  color: var(--ink-2);
  font-size: 14.5px;
  line-height: 1.65;
  margin: 0 0 26px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.suggestion {
  font-size: 13px;
  font-weight: 400;
  padding: 7px 13px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--paper-line-strong);
  color: var(--ink-2);
  transition: all 0.15s;
}

.suggestion:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Composer */
.composer-wrap {
  padding: 14px 18px 18px;
  flex-shrink: 0;
  border-top: 1px solid var(--paper-line);
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: end;
  background: #fff;
  border: 1px solid var(--paper-line-strong);
  border-radius: var(--radius);
  padding: 10px 10px 10px 16px;
  transition: all 0.15s;
}

/* Attachment chips above composer */
.composer-attachments {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.att-chip {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  overflow: visible;
  border: 1px solid var(--paper-line-strong);
  background: var(--paper-2);
}

.att-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.att-file-icon {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}

.att-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  cursor: pointer;
  border: 1.5px solid var(--paper);
  opacity: 0;
  transition: opacity 0.15s;
}

.att-chip:hover .att-del {
  opacity: 1;
}

.attach-btn {
  align-self: end;
}

/* Attachments inside user messages */
.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.msg-att-img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.msg-att-file {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--paper);
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.composer textarea {
  resize: none;
  border: none;
  background: transparent;
  min-height: 24px;
  max-height: 160px;
  line-height: 1.6;
  font-size: 14.5px;
  padding: 4px 0;
  field-sizing: content;
  color: var(--ink);
}

.composer textarea::placeholder {
  color: var(--ink-4);
}

.composer textarea:disabled {
  opacity: 0.5;
}

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.15s;
}

.send-btn:hover:not(:disabled) {
  background: #000;
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.composer-hint {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding: 0 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  color: var(--ink-3);
}

/* ── Canvas panel ────────────────────────────────────────────── */
.canvas-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper-2);
  overflow: hidden;
  position: relative;
}

.canvas-top {
  height: 52px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--paper-line);
  flex-shrink: 0;
}

.canvas-top h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  flex: 1;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.canvas-top h2::before {
  content: '幕布';
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.22em;
  color: var(--ink-3);
  text-transform: uppercase;
  padding: 3px 7px;
  border: 1px solid var(--paper-line-strong);
  border-radius: 3px;
  transform: translateY(-2px);
}

.canvas-status {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* Canvas history tabs — minimal prev/title/next + counter */
.canvas-tabs {
  display: flex;
  gap: 2px;
  align-items: center;
  flex: 0 1 auto;
  margin-left: auto;
  margin-right: 10px;
  min-width: 0;
}

.canvas-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: min(420px, 46vw);
}

.canvas-nav-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  border: 1px solid transparent;
  transition: all 0.15s;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  background: transparent;
}

.canvas-nav-btn:hover:not(:disabled) {
  color: var(--ink);
  background: var(--paper-2);
  border-color: var(--paper-line);
}

.canvas-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.canvas-nav-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  min-width: 0;
  text-align: center;
}

.canvas-nav-count {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  white-space: nowrap;
  padding-left: 4px;
  flex-shrink: 0;
}

.canvas-current {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  min-width: 0;
}

/* Highlight pulse on the assistant message that produced the active canvas */
.msg-highlight .msg-bubble {
  animation: msg-highlight 1.2s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes msg-highlight {
  0%,
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
  30% {
    box-shadow: 0 0 0 3px var(--accent-dim);
  }
}

.canvas-status.live {
  color: var(--accent);
}

.canvas-status.live::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.canvas-stage {
  flex: 1;
  overflow: auto;
  padding: 22px;
  position: relative;
}

.stage-surface {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  border: 1px solid var(--paper-line);
  position: relative;
  overflow: hidden;
}

.stage-inner {
  position: relative;
  z-index: 1;
  min-height: calc(100vh - 140px);
  padding: 32px 32px 40px;
}

.stage-empty {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 40px 24px;
  color: var(--ink-3);
}

.stage-empty .frame {
  width: 70px;
  height: 54px;
  margin: 0 auto 20px;
  border: 1.5px solid var(--ink-4);
  border-radius: 6px;
  position: relative;
}

.stage-empty .frame::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 26px;
  height: 10px;
  border: 1.5px solid var(--ink-4);
  border-top: none;
  transform: translateX(-50%);
  border-radius: 0 0 3px 3px;
}

.stage-empty h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--ink);
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

.stage-empty h3 em {
  font-style: italic;
  color: var(--accent);
}

.stage-empty p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  max-width: 320px;
}

/* Canvas content */
.cv-header {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--paper-line);
}

/* ── Cinematic canvas loading: pure ink dot + rings, no gradients ── */
.cv-loading {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 200px);
  padding: 40px;
}

.cv-loading-scene {
  position: relative;
  display: grid;
  place-items: center;
  text-align: center;
}

/* Central mark: solid ink dot + two expanding hairline rings */
.loading-mark {
  position: relative;
  width: 88px;
  height: 88px;
  margin-bottom: 32px;
  display: grid;
  place-items: center;
}

.mark-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  animation: dot-throb 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.mark-ring {
  position: absolute;
  inset: 0;
  border: 1px solid var(--ink);
  border-radius: 50%;
  opacity: 0;
  animation: ring-out 1.6s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

.mark-ring.ring-2 {
  animation-delay: 0.8s;
}

@keyframes dot-throb {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
}

@keyframes ring-out {
  0% { transform: scale(0.3); opacity: 0.8; }
  100% { transform: scale(1); opacity: 0; }
}

/* Loading text */
.loading-text {
  position: relative;
}

.loading-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 12px;
}

.loading-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.loading-title span {
  display: inline-block;
  animation: ch-breathe 2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.06s);
}

@keyframes ch-breathe {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Thin progress hairline that fills left→right */
.loading-bar {
  margin-top: 22px;
  width: 200px;
  height: 1px;
  background: var(--paper-line-strong);
  position: relative;
  overflow: hidden;
  margin-left: auto;
  margin-right: auto;
}

.loading-bar i {
  position: absolute;
  inset: 0;
  background: var(--ink);
  transform-origin: 0 50%;
  animation: bar-fill 2.2s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

@keyframes bar-fill {
  0% { transform: scaleX(0); transform-origin: 0 50%; }
  50% { transform: scaleX(1); transform-origin: 0 50%; }
  51% { transform-origin: 100% 50%; }
  100% { transform: scaleX(0); transform-origin: 100% 50%; }
}

/* ── Shatter transition (when stream completes) ──────────────── */
.cv-loading-scene.shattering {
  pointer-events: none;
}

.cv-loading-scene.shattering .mark-dot {
  animation: dot-shatter 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.cv-loading-scene.shattering .mark-ring {
  animation: ring-shatter 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.cv-loading-scene.shattering .loading-kicker {
  animation: fade-up-out 0.6s ease-out forwards;
}

.cv-loading-scene.shattering .loading-title span {
  animation: ch-shatter 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  animation-delay: calc(var(--i) * 0.04s);
}

.cv-loading-scene.shattering .loading-bar {
  animation: bar-shatter 0.7s ease-out forwards;
}

@keyframes dot-shatter {
  0% { transform: scale(1); opacity: 1; }
  30% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(0) translateY(-30px); opacity: 0; }
}

@keyframes ring-shatter {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.4); opacity: 0; }
}

@keyframes ch-shatter {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); filter: blur(0); }
  100% {
    opacity: 0;
    transform: translateY(calc(-40px - var(--i) * 4px)) rotate(calc(var(--i) * 6deg - 12deg));
    filter: blur(3px);
  }
}

@keyframes fade-up-out {
  0% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-12px); }
}

@keyframes bar-shatter {
  0% { opacity: 1; transform: scaleX(1); }
  100% { opacity: 0; transform: scaleX(0); }
}

/* ── Sweep reveal: content unveiled left→right by a light band ── */
.cv-reveal {
  position: relative;
  animation: cv-reveal-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.cv-reveal::before {
  content: '';
  position: absolute;
  inset: -20px -32px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(125, 125, 255, 0.12) 48%,
    rgba(125, 125, 255, 0.22) 50%,
    rgba(125, 125, 255, 0.12) 52%,
    transparent 100%);
  transform: translateX(-100%);
  animation: sweep-band 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
  z-index: 2;
}

@keyframes sweep-band {
  0% { transform: translateX(-100%); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateX(100%); opacity: 0; }
}

@keyframes cv-reveal-in {
  0% { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: none; }
}

.cv-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
  font-weight: 500;
  display: inline-block;
}

.cv-title {
  font-family: var(--font-display);
  font-size: clamp(26px, 3.5vw, 34px);
  font-weight: 400;
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.025em;
  line-height: 1.15;
  margin: 0;
  color: var(--ink);
}

.cv-markdown {
  font-size: 15.5px;
  line-height: 1.8;
  color: var(--ink-2);
}

/* Longform (novels / essays / articles) — reader-grade typography */
.cv-longform {
  max-width: 66ch;
  margin: 0 auto;
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.95;
  color: var(--ink);
  font-weight: 400;
  letter-spacing: 0.005em;
}

.cv-longform p {
  margin: 0 0 1.4em;
  text-align: justify;
  text-justify: inter-ideograph;
  hanging-punctuation: first allow-end;
}

/* Drop cap on first paragraph */
.cv-longform > p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 4.2em;
  float: left;
  line-height: 0.85;
  padding: 0.08em 0.12em 0 0;
  color: var(--accent);
  font-weight: 400;
}

/* First paragraph slightly larger as lede */
.cv-longform > p:first-of-type {
  font-size: 1.08em;
  color: var(--ink);
}

.cv-longform h1,
.cv-longform h2,
.cv-longform h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--ink);
  margin: 2.2em 0 0.8em;
  font-weight: 500;
  text-align: center;
}

.cv-longform h1 {
  font-size: 1.65em;
}
.cv-longform h2 {
  font-size: 1.3em;
}
.cv-longform h3 {
  font-size: 1.1em;
  font-variant: small-caps;
  letter-spacing: 0.05em;
  color: var(--ink-2);
}

/* Section divider for longform breaks (*** or ---) */
.cv-longform hr {
  border: none;
  text-align: center;
  margin: 2.5em auto;
  width: auto;
}

.cv-longform hr::before {
  content: '❦';
  color: var(--ink-3);
  font-size: 1.1em;
  letter-spacing: 1em;
  padding-left: 1em;
}

.cv-longform blockquote {
  margin: 1.6em 2em;
  padding: 0;
  border: none;
  color: var(--ink-2);
  font-style: italic;
  font-size: 1.02em;
  line-height: 1.8;
  text-align: center;
}

.cv-longform blockquote::before,
.cv-longform blockquote::after {
  content: '';
  display: block;
  width: 40px;
  height: 1px;
  background: var(--paper-line-strong);
  margin: 0 auto;
}

.cv-longform blockquote::before {
  margin-bottom: 1.2em;
}

.cv-longform blockquote::after {
  margin-top: 1.2em;
}

.cv-longform em,
.cv-longform i {
  font-style: italic;
}

.cv-longform strong,
.cv-longform b {
  font-weight: 600;
  color: var(--ink);
}

.cv-longform code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--paper-2);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--paper-line);
}

.cv-longform pre {
  background: var(--side);
  color: var(--side-text);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  margin: 1.6em 0;
}

.cv-longform pre code {
  background: none;
  padding: 0;
  color: inherit;
  border: none;
}

.cv-longform ul,
.cv-longform ol {
  margin: 0.8em 0 1.4em;
  padding-left: 1.5em;
}

.cv-longform li {
  margin: 0.5em 0;
}

.cv-longform table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.6em 0;
  font-size: 0.9em;
}

.cv-longform th,
.cv-longform td {
  border: 1px solid var(--paper-line);
  padding: 10px 13px;
  text-align: left;
}

.cv-longform th {
  background: var(--paper-2);
  font-weight: 600;
  color: var(--ink);
}

.cv-markdown h1,
.cv-markdown h2,
.cv-markdown h3 {
  font-family: var(--font-display);
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: var(--ink);
  margin: 1.4em 0 0.55em;
  font-weight: 500;
}

.cv-markdown h1 {
  font-size: 1.7em;
}
.cv-markdown h2 {
  font-size: 1.35em;
}
.cv-markdown h3 {
  font-size: 1.15em;
}

.cv-markdown p {
  margin: 0 0 1em;
}

.cv-markdown blockquote {
  margin: 1.2em 0;
  padding: 4px 0 4px 18px;
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
  font-style: italic;
  font-family: var(--font-display);
  font-size: 1.05em;
}

.cv-markdown code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--paper-2);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--paper-line);
}

.cv-markdown pre {
  background: var(--side);
  color: var(--side-text);
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  margin: 1em 0;
}

.cv-markdown pre code {
  background: none;
  padding: 0;
  color: inherit;
  border: none;
}

.cv-markdown ul,
.cv-markdown ol {
  margin: 0.6em 0 1em;
  padding-left: 1.4em;
}

.cv-markdown li {
  margin: 0.3em 0;
}

.cv-markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 14px;
}

.cv-markdown th,
.cv-markdown td {
  border: 1px solid var(--paper-line);
  padding: 9px 12px;
  text-align: left;
}

.cv-markdown th {
  background: var(--paper-2);
  font-weight: 600;
  color: var(--ink);
}

/* Clock */
.cv-clock {
  display: grid;
  place-items: center;
  min-height: 400px;
  gap: 28px;
}

.clock-face {
  width: min(280px, 70vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--paper);
  border: 1px solid var(--paper-line-strong);
  position: relative;
}

.clock-face .mark {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 1.5px;
  height: 10px;
  background: var(--ink);
  opacity: 0.3;
  transform-origin: center 128px;
}

.clock-face .mark.hour {
  height: 18px;
  width: 2px;
  top: 9px;
  opacity: 0.9;
  transform-origin: center 131px;
}

.clock-hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: bottom center;
  background: var(--ink);
  border-radius: 2px;
}

.clock-hand.hour {
  width: 4px;
  height: 27%;
  margin-left: -2px;
}

.clock-hand.minute {
  width: 2.5px;
  height: 39%;
  margin-left: -1.25px;
}

.clock-hand.second {
  width: 1px;
  height: 44%;
  margin-left: -0.5px;
  background: var(--accent);
}

.clock-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 3px var(--paper);
  z-index: 2;
}

.clock-digital {
  font-family: var(--font-display);
  font-size: clamp(38px, 6vw, 54px);
  font-weight: 400;
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.clock-date {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: -16px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
}

/* Cards */
.cv-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.cv-card {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 18px;
  transition: border-color 0.15s;
}

.cv-card:hover {
  border-color: var(--paper-line-strong);
}

.cv-card .label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 10px;
}

.cv-card .value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 400;
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--ink);
}

.cv-card .desc {
  font-size: 13px;
  color: var(--ink-2);
  margin-top: 7px;
  line-height: 1.55;
}

/* Steps */
.cv-steps {
  display: grid;
  gap: 0;
  counter-reset: step;
}

.cv-step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--paper-line);
  counter-increment: step;
}

.cv-step:last-child {
  border-bottom: none;
}

.cv-step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  display: grid;
  place-items: center;
  font-variation-settings: 'opsz' 144;
}

.cv-step h4 {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.cv-step p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.6;
}

/* Quote */
.cv-quote {
  min-height: 320px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 32px;
}

.cv-quote blockquote {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(26px, 3.5vw, 36px);
  font-weight: 400;
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.02em;
  line-height: 1.4;
  max-width: 26ch;
  color: var(--ink);
}

.cv-quote blockquote::before {
  content: '“';
  display: block;
  font-size: 80px;
  line-height: 0.7;
  color: var(--accent);
  margin-bottom: 16px;
  font-weight: 300;
}

.cv-quote cite {
  display: block;
  margin-top: 20px;
  font-style: normal;
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
}

/* Code */
.cv-code {
  background: var(--side);
  color: var(--side-text);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin: -4px;
}

.cv-code-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--side-line);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--side-dim);
}

.cv-code-bar .dots {
  display: flex;
  gap: 6px;
  margin-right: 8px;
}

.cv-code-bar .dots i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--side-hover);
  display: block;
}

.cv-code-bar .dots i:nth-child(1) {
  background: var(--rose);
}
.cv-code-bar .dots i:nth-child(2) {
  background: var(--side-dim);
}
.cv-code-bar .dots i:nth-child(3) {
  background: var(--side-text);
}

.cv-code pre {
  margin: 0;
  padding: 18px 20px 22px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre;
}

/* Table */
.cv-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--paper-line);
  background: var(--paper);
}

.cv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.cv-table th {
  text-align: left;
  padding: 12px 16px;
  background: var(--paper-2);
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid var(--paper-line);
  white-space: nowrap;
  font-size: 13px;
}

.cv-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--paper-line);
  color: var(--ink-2);
}

.cv-table tr:last-child td {
  border-bottom: none;
}

.cv-table tr:hover td {
  background: var(--paper-2);
}

/* HTML sandbox */
.cv-html-frame {
  width: 100%;
  min-height: 80px;
  border: none;
  background: transparent;
  display: block;
}

/* List */
.cv-list {
  display: grid;
  gap: 8px;
}

.cv-list-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-xs);
  transition: border-color 0.15s;
}

.cv-list-item:hover {
  border-color: var(--paper-line-strong);
}

.cv-list-item .idx {
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  padding: 2px 8px;
  border: 1px solid var(--accent-line);
  border-radius: 5px;
  font-variation-settings: 'opsz' 144;
}

.cv-list-item strong {
  display: block;
  font-size: 14.5px;
  margin-bottom: 3px;
  color: var(--ink);
}

.cv-list-item span {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
}

/* Hero */
.cv-hero {
  display: grid;
  place-items: center;
  text-align: center;
  min-height: 320px;
  gap: 12px;
}

.cv-hero .big {
  font-family: var(--font-display);
  font-size: clamp(56px, 11vw, 88px);
  font-weight: 400;
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--ink);
}

.cv-hero .sub {
  font-size: 16px;
  color: var(--ink-2);
}

.cv-hero .meta {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.cv-hero .pill {
  font-size: 12px;
  font-weight: 400;
  padding: 5px 11px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--paper-line-strong);
  color: var(--ink-2);
}

/* Chart */
.cv-chart {
  display: grid;
  gap: 14px;
  padding: 10px 0;
}

.cv-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 52px;
  gap: 14px;
  align-items: center;
  font-size: 13.5px;
}

.cv-bar-row .name {
  text-align: right;
  color: var(--ink-2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cv-bar-track {
  height: 12px;
  background: var(--paper-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--paper-line);
}

.cv-bar-fill {
  height: 100%;
  background: var(--ink);
  border-radius: 999px;
  transition: width 0.6s var(--ease);
}

.cv-bar-row .val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 500;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--paper);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 400;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s var(--ease);
  max-width: min(440px, 90vw);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Scrollbars */
.messages::-webkit-scrollbar,
.sidebar-list::-webkit-scrollbar,
.canvas-stage::-webkit-scrollbar {
  width: 8px;
}
.messages::-webkit-scrollbar-thumb,
.sidebar-list::-webkit-scrollbar-thumb,
.canvas-stage::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 999px;
}
.sidebar-list::-webkit-scrollbar-thumb {
  background: var(--side-hover);
}

/* Responsive */
@media (max-width: 1024px) {
  .shell {
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: 1fr 1fr;
  }
  .shell.sidebar-collapsed {
    grid-template-columns: 0 1fr;
  }
  .canvas-panel {
    grid-column: 1 / -1;
    border-top: 1px solid var(--paper-line);
  }
}

@media (max-width: 680px) {
  .shell,
  .shell.sidebar-collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 88vw);
    z-index: 50;
    transform: translateX(-100%);
    transition:
      transform 0.3s var(--ease),
      opacity 0.25s;
    opacity: 1;
    pointer-events: auto;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.3);
  }
  .shell:not(.sidebar-collapsed) .sidebar {
    transform: translateX(0);
  }
  .shell.sidebar-collapsed .sidebar {
    opacity: 1;
  }
  .canvas-panel {
    min-height: 45vh;
  }
  .stage-inner {
    padding: 22px 18px 30px;
  }
  .messages {
    padding: 20px 16px 12px;
  }
  .composer-wrap {
    padding: 12px 14px 16px;
  }
}

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

/* ── 显 · Auth ──────────────────────────────────────────────── */
.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background: var(--side-bg, #16140f);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--paper, #faf6ec);
  border: 1px solid rgba(31, 27, 18, 0.08);
  border-radius: 18px;
  padding: 32px 28px 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.auth-brand h1 {
  margin: 0;
  font-family: Fraunces, serif;
  font-size: 28px;
  font-weight: 500;
  color: #1f1b12;
  letter-spacing: -0.02em;
}

.auth-mark {
  width: 42px;
  height: 42px;
  display: block;
  flex-shrink: 0;
  border-radius: 10px;
  object-fit: cover;
}

.auth-lead {
  margin: 4px 0 0;
  color: #8b8270;
  font-size: 13px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(31, 27, 18, 0.05);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 18px;
}

.auth-tab {
  border: 0;
  background: transparent;
  color: #8b8270;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.auth-tab.active {
  background: #fff;
  color: #1f1b12;
  box-shadow: 0 1px 3px rgba(31, 27, 18, 0.08);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-error {
  background: rgba(180, 40, 40, 0.08);
  color: #9a2b2b;
  border: 1px solid rgba(180, 40, 40, 0.16);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  white-space: pre-wrap;
}

.side-quota {
  color: var(--side-mute, #8b8270);
  font-size: 12px;
  padding: 4px 10px 10px;
}

a.side-action {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 显 · Admin ─────────────────────────────────────────────── */
.admin-body {
  background: #16140f;
  min-height: 100vh;
  color: #1f1b12;
  font-family: Inter, system-ui, sans-serif;
}

.admin-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 18px 48px;
}

.admin-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
  margin-bottom: 18px;
  color: #faf6ec;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
}

.admin-brand strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.admin-brand span {
  display: block;
  font-size: 12px;
  color: rgba(250, 246, 236, 0.55);
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.admin-tabs button {
  border: 1px solid rgba(250, 246, 236, 0.12);
  background: transparent;
  color: rgba(250, 246, 236, 0.7);
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.admin-tabs button.active {
  background: #7d7dff;
  border-color: #7d7dff;
  color: #fff;
}

.admin-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-actions .btn-ghost,
.admin-actions a.btn-ghost {
  color: rgba(250, 246, 236, 0.75);
  border: 1px solid rgba(250, 246, 236, 0.14);
  background: transparent;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
}

.admin-main {
  display: grid;
  gap: 16px;
}

.admin-card {
  background: #faf6ec;
  border-radius: 16px;
  padding: 20px 20px 16px;
  border: 1px solid rgba(31, 27, 18, 0.06);
}

.admin-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.admin-card-head h2 {
  margin: 0;
  font-family: Fraunces, serif;
  font-size: 22px;
  font-weight: 500;
}

.admin-card .muted,
.admin-hint {
  color: #8b8270;
  font-size: 12px;
}

.admin-hint {
  margin: 14px 0 0;
  line-height: 1.55;
}

.admin-table-wrap {
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(31, 27, 18, 0.08);
  vertical-align: top;
}

.admin-table th {
  color: #8b8270;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.admin-table.compact th,
.admin-table.compact td {
  padding: 7px 6px;
}

.admin-table .mono,
.mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 12px;
}

.u-name {
  font-weight: 500;
  color: #1f1b12;
}

.admin-select,
.admin-input {
  font: inherit;
  font-size: 13px;
  border: 1px solid rgba(31, 27, 18, 0.12);
  background: #fff;
  border-radius: 8px;
  padding: 7px 9px;
  color: #1f1b12;
}

.admin-input.narrow {
  width: 96px;
}

.admin-form {
  display: grid;
  gap: 14px;
  max-width: 520px;
}

.btn-primary.sm {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 8px;
}

.pill {
  border: 0;
  border-radius: 999px;
  padding: 5px 10px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.pill.ok {
  background: rgba(40, 140, 80, 0.12);
  color: #1f6b3a;
}

.pill.off {
  background: rgba(160, 40, 40, 0.1);
  color: #8a2b2b;
}

.usage-days {
  display: grid;
  gap: 14px;
}

.usage-day {
  border: 1px solid rgba(31, 27, 18, 0.08);
  border-radius: 12px;
  padding: 12px 12px 8px;
  background: #fbf5e3;
}

.usage-day-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.admin-body .auth {
  background: transparent;
}

.admin-body .auth-card .btn-primary {
  display: inline-flex;
  text-decoration: none;
  justify-content: center;
}

.provider-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn-ghost.dark {
  border: 1px solid rgba(31, 27, 18, 0.14);
  background: transparent;
  color: #1f1b12;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-ghost.dark:hover {
  background: rgba(31, 27, 18, 0.04);
}

.btn-ghost.dark.sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-ghost.dark.danger {
  color: #8a2b2b;
  border-color: rgba(160, 40, 40, 0.22);
}

.provider-test-result {
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  background: rgba(31, 27, 18, 0.04);
  color: #57503f;
  white-space: pre-wrap;
}

.provider-test-result.ok {
  background: rgba(40, 140, 80, 0.1);
  color: #1f6b3a;
}

.provider-test-result.bad {
  background: rgba(160, 40, 40, 0.08);
  color: #8a2b2b;
}

.provider-history {
  display: grid;
  gap: 10px;
}

.provider-hist-item {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(31, 27, 18, 0.08);
  background: #fbf5e3;
}

.provider-hist-item.active {
  border-color: rgba(125, 125, 255, 0.45);
  box-shadow: inset 0 0 0 1px rgba(125, 125, 255, 0.18);
}

.provider-hist-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: #1f1b12;
  margin-bottom: 4px;
}

.provider-hist-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.provider-hist-actions .btn-primary.sm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
