:root {
  --ink: #25231f;
  --muted: #746f65;
  --paper: #f7f4ed;
  --paper-deep: #eee9df;
  --panel: #fbfaf6;
  --line: #d9d2c5;
  --accent: #8b3d2c;
  --accent-dark: #6e2e21;
  --green: #5e765c;
  --shadow: 0 18px 50px rgba(49, 42, 32, 0.12);
  --surface: #fffefa;
  --surface-soft: rgba(255,255,255,.48);
  --surface-strong: rgba(255,254,250,.94);
  --row-active: #ebe4d8;
  --surface-hover: #dfd6c7;
  --app-glow: rgba(255,255,255,.95);
  --toast-bg: #25231f;
  --toast-fg: #fffefa;
  --toast-error-bg: #6e2e21;
  --toast-error-fg: #fffefa;
  --font-latin: "SFMono-Regular", "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono";
  --font-cjk: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Heiti SC";
  --editor-font-size: 17px;
  --editor-line-height: 1.55;
  --left-panel-width: 280px;
  --ai-panel-width: 360px;
  font-family: var(--font-latin), var(--font-cjk), monospace, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}

.auth-pending .app-shell { pointer-events: none; user-select: none; }
.auth-loading { display: none; }
.auth-pending .auth-loading { position: fixed; inset: 0; z-index: 900; display: grid; place-items: center; pointer-events: none; }
.auth-loading::before { content: ""; width: 32px; height: 32px; border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent); border-top-color: var(--accent); border-radius: 50%; animation: auth-loading-spin .8s linear infinite; }
@keyframes auth-loading-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .auth-loading::before { animation-duration: 2s; } }
.login-route .auth-view.hidden { display: grid !important; }
.login-route .auth-loading { display: none; }
/* 会话恢复期间按 data-pending-view 预显示目标视图的骨架（自然 display 与各视图定义一致） */
[data-pending-view="shelf"] .auth-pending #shelf-view.hidden,
[data-pending-view="settings"] .auth-pending #settings-hub-view.hidden,
[data-pending-view="platform-ai"] .auth-pending #platform-ai-view.hidden,
[data-pending-view="module"] .auth-pending #module-view.hidden { display: block !important; }
[data-pending-view="welcome"] .auth-pending #welcome-view.hidden,
[data-pending-view="editor"] .auth-pending #editor-view.hidden { display: grid !important; }
/* 书架/设置/平台 AI 路由的骨架使用整宽布局，与 shelf-mode 一致 */
.pending-shelf-mode .auth-pending .app-shell { grid-template-columns: 1fr; }
.pending-shelf-mode .auth-pending .topbar { grid-template-columns: 280px 1fr auto; }
.pending-shelf-mode .auth-pending .left-panel, .pending-shelf-mode .auth-pending .ai-panel { display: none; }
.pending-shelf-mode .auth-pending .main-panel { grid-column: 1 / -1; }
.auth-view { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; align-content: safe center; padding: 24px; overflow-y: auto; overscroll-behavior: contain; background: radial-gradient(circle at 18% 16%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 34%), var(--paper); }
.auth-view.hidden { display: none; }
.auth-card { box-sizing: border-box; width: min(440px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 34px; }
.auth-brand div { display: grid; }
.auth-brand small { color: var(--muted); }
.auth-card h1 { margin: 8px 0; font-size: 30px; }
.auth-card > p { color: var(--muted); line-height: 1.6; }
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 24px 0 18px;
  padding: 3px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
  border-radius: 9px;
  background: var(--paper-deep);
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--surface) 65%, transparent);
}
.auth-tabs button {
  position: relative;
  z-index: 0;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.auth-tabs button + button::before {
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: -3px;
  width: 1px;
  background: var(--line);
  content: "";
}
.auth-tabs button:not([aria-selected="true"]):not(:disabled):hover { background: color-mix(in srgb, var(--surface) 62%, transparent); color: var(--ink); }
.auth-tabs button:disabled {
  cursor: not-allowed;
  color: color-mix(in srgb, var(--muted) 72%, transparent);
  opacity: .78;
}
.auth-tabs button[aria-selected="true"] {
  z-index: 1;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 58%, transparent), 0 2px 7px color-mix(in srgb, var(--accent) 18%, transparent);
  font-weight: 750;
}
.auth-tabs button[aria-selected="true"]::after {
  position: absolute;
  right: 24%;
  bottom: 5px;
  left: 24%;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
}
.auth-tabs button:focus-visible { z-index: 2; outline: 2px solid color-mix(in srgb, var(--accent) 82%, white); outline-offset: -2px; }
.auth-form { display: grid; gap: 16px; }
.auth-form label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.auth-form input {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-deep);
  font-size: 15px;
  line-height: 1.4;
}
.auth-form input:focus {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.password-field { position: relative; display: block; }
.password-field input { padding-right: 62px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  min-width: 36px;
  min-height: 30px;
  padding: 5px 7px;
  place-items: center;
  transform: translateY(-50%);
  border: 1px solid color-mix(in srgb, var(--line) 82%, transparent);
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}
.password-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.9; }
.password-toggle:hover { border-color: color-mix(in srgb, var(--accent) 52%, var(--line)); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.auth-form .primary-button {
  width: 100%;
  min-height: 46px;
  margin-top: 4px;
  padding: 12px 16px;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 600;
}
.auth-form small { color: var(--muted); line-height: 1.5; font-size: 12px; }
.auth-captcha { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.auth-captcha label { margin: 0; }
.auth-captcha-image {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 148px;
  min-height: 46px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper-deep);
  cursor: pointer;
}
.auth-captcha-image img { display: block; width: 148px; height: 48px; border-radius: 6px; }
.auth-captcha-image img[hidden], .auth-captcha-placeholder[hidden] { display: none; }
.auth-captcha-placeholder { color: var(--muted); font-size: 13px; padding: 0 14px; white-space: nowrap; }
.auth-captcha-hint { margin: -8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.auth-error { min-height: 20px; margin: 14px 0 0 !important; color: var(--accent-dark) !important; }

:root[data-theme="dark"] {
  --ink: #e8e2d8;
  --muted: #aaa398;
  --paper: #171714;
  --paper-deep: #26231f;
  --panel: #1d1c19;
  --line: #3f3a33;
  --accent: #bd6550;
  --accent-dark: #e08a72;
  --green: #89a985;
  --shadow: 0 18px 50px rgba(0,0,0,.38);
  --surface: #24221e;
  --surface-soft: rgba(48,45,39,.74);
  --surface-strong: rgba(38,35,30,.96);
  --row-active: #332d27;
  --surface-hover: #3a342d;
  --app-glow: rgba(98,82,66,.18);
  --toast-bg: #ece6dc;
  --toast-fg: #171714;
  --toast-error-bg: #e08a72;
  --toast-error-fg: #171714;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }

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

.app-shell {
  display: grid;
  grid-template-columns: var(--left-panel-width) minmax(480px, 1fr) var(--ai-panel-width);
  grid-template-rows: 64px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at 50% -20%, var(--app-glow), transparent 45%),
    var(--paper);
}

.topbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--left-panel-width) 1fr auto;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  z-index: 5;
}

.brand-block { display: flex; align-items: center; gap: 11px; padding: 0 20px; border: 0; background: transparent; text-align: left; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--accent); border-radius: 3px; font-weight: 700; }
.brand-block strong, .brand-block small { display: block; }
.brand-block strong { font-size: 16px; letter-spacing: .16em; }
.brand-block small { color: var(--muted); font-size: 10px; margin-top: 2px; }
.work-meta { font-size: 13px; color: var(--muted); padding-left: 26px; }
.top-actions { display: flex; justify-content: flex-end; gap: 10px; align-items: center; padding-right: 18px; }
.theme-toggle, .settings-button, .topbar-icon-button {
  display: grid;
  flex: 0 0 34px;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}
.theme-toggle:hover, .theme-toggle:focus-visible,
.settings-button:hover, .settings-button:focus-visible, .settings-button[aria-current="page"],
.topbar-icon-button:hover, .topbar-icon-button:focus-visible {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--paper-deep);
  outline: none;
}
.topbar-icon-button:disabled {
  cursor: not-allowed;
  opacity: .42;
  border-color: var(--line);
  color: var(--muted);
  background: transparent;
}
.theme-icon, .settings-icon, .topbar-icon {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun { display: block; }
.account-button { display: flex; align-items: center; gap: 7px; min-width: 0; height: 34px; padding: 3px 9px 3px 3px; border: 1px solid var(--line); border-radius: 18px; background: transparent; color: var(--text); }
.user-avatar { position: relative; display: inline-grid; flex: 0 0 auto; place-items: center; width: 36px; height: 36px; overflow: hidden; border-radius: 50%; background: var(--accent); color: white; font-size: 13px; font-weight: 650; line-height: 1; }
.user-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.user-avatar-fallback { display: grid; width: 100%; height: 100%; place-items: center; }
.account-button > .account-avatar { width: 26px; height: 26px; font-size: 11px; }
.account-button > span:last-child { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.account-menu { position: absolute; z-index: 80; top: 48px; right: 84px; display: grid; min-width: 180px; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow); }
.account-menu.hidden { display: none; }
.account-menu small { margin-bottom: 8px; color: var(--muted); }
.account-menu button { min-height: 30px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); text-align: left; font-size: 10px; }
.account-menu button:hover, .account-menu button:focus-visible { border-color: var(--accent); background: var(--paper-deep); color: var(--accent-dark); outline: none; }

.onboarding-dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.onboarding-dialog::backdrop { background: transparent; }
.onboarding-spotlight {
  position: absolute;
  z-index: 1;
  border: 2px solid color-mix(in srgb, var(--accent) 88%, white);
  border-radius: 10px;
  background: transparent;
  box-shadow: 0 0 0 9999px rgba(20,18,16,.7), 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent), 0 10px 28px rgba(0,0,0,.28);
  pointer-events: none;
  transition: left .22s ease, top .22s ease, width .22s ease, height .22s ease;
}
.onboarding-popover {
  --onboarding-arrow-offset: 40px;
  position: absolute;
  z-index: 2;
  display: grid;
  width: min(370px, calc(100vw - 28px));
  overflow: visible;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line));
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(20,18,16,.28);
  animation: onboarding-popover-in .18s ease both;
}
.onboarding-popover::before { position: absolute; width: 14px; height: 14px; background: var(--surface); content: ""; transform: rotate(45deg); }
.onboarding-popover[data-placement="right"]::before { top: calc(var(--onboarding-arrow-offset) - 7px); left: -8px; border-bottom: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line)); border-left: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line)); }
.onboarding-popover[data-placement="left"]::before { top: calc(var(--onboarding-arrow-offset) - 7px); right: -8px; border-top: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line)); border-right: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line)); }
.onboarding-popover[data-placement="bottom"]::before { top: -8px; left: calc(var(--onboarding-arrow-offset) - 7px); border-top: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line)); border-left: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line)); }
.onboarding-popover[data-placement="top"]::before { bottom: -8px; left: calc(var(--onboarding-arrow-offset) - 7px); border-right: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line)); border-bottom: 1px solid color-mix(in srgb, var(--accent) 36%, var(--line)); }
.onboarding-popover-header { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 18px 10px; border-bottom: 1px solid var(--line); }
.onboarding-popover-header > span { color: var(--accent-dark); font: 10px/1 var(--font-latin), monospace; letter-spacing: .08em; }
.onboarding-skip { min-height: 30px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 16px; background: transparent; color: var(--muted); font-size: 10px; }
.onboarding-skip:hover, .onboarding-skip:focus-visible { border-color: var(--accent); background: var(--paper-deep); color: var(--accent-dark); outline: none; }
.onboarding-popover-body { padding: 18px 20px 20px; }
.onboarding-popover-body h2 { margin: 7px 0 10px; font-size: 22px; font-weight: 620; line-height: 1.3; }
.onboarding-popover-body h2:focus { outline: none; }
.onboarding-popover-body p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.onboarding-popover-footer { display: flex; justify-content: space-between; gap: 10px; padding: 12px 18px 16px; border-top: 1px solid var(--line); }
.onboarding-popover-footer button { min-width: 94px; min-height: 36px; }
.onboarding-popover-footer button:disabled { cursor: default; opacity: .4; }
@keyframes onboarding-popover-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.left-panel, .ai-panel { position: relative; min-height: 0; background: var(--panel); }
.left-panel { border-right: 1px solid var(--line); padding: 18px 14px 16px; overflow-y: auto; }
.ai-panel { border-left: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px; min-width: 0; }
.panel-collapse-button { z-index: 8; flex: 0 0 auto; width: 24px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--muted); font-size: 18px; line-height: 1; }
.ai-heading #ai-panel-toggle { flex-basis: 30px; width: 30px; height: 30px; }
.panel-resize-handle { position: absolute; z-index: 7; top: 0; bottom: 0; width: 7px; cursor: col-resize; touch-action: none; }
.left-panel > .panel-resize-handle { right: 0; }.ai-panel > .panel-resize-handle { left: 0; }
.panel-resize-handle::after { content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 1px; background: transparent; transition: background .14s ease; }
.panel-resize-handle:hover::after, .panel-resize-handle:focus-visible::after, body.is-panel-resizing .panel-resize-handle::after { background: var(--accent); }
body.is-panel-resizing { cursor: col-resize; user-select: none; }
.app-shell.left-panel-collapsed { --left-panel-width: 42px !important; }.app-shell.ai-panel-collapsed { --ai-panel-width: 42px !important; }
.app-shell.left-panel-collapsed .left-panel, .app-shell.ai-panel-collapsed .ai-panel { padding: 0; overflow: hidden; }
.app-shell.left-panel-collapsed .left-panel > :not(.left-actions), .app-shell.ai-panel-collapsed .ai-panel > :not(.ai-heading) { display: none; }
.app-shell.left-panel-collapsed .left-actions, .app-shell.ai-panel-collapsed .ai-heading { display: flex; justify-content: center; padding: 8px 0; border: 0; }
.app-shell.left-panel-collapsed .left-actions > :not(.left-primary-actions), .app-shell.left-panel-collapsed .left-primary-actions > :not(.panel-collapse-button), .app-shell.ai-panel-collapsed .ai-heading > :not(.panel-collapse-button) { display: none; }
.app-shell.left-panel-collapsed .left-primary-actions { display: flex; justify-content: center; }
.app-shell.left-panel-collapsed .panel-heading { display: none; }
.app-shell.left-panel-collapsed .brand-block { padding: 0 4px; }.app-shell.left-panel-collapsed .brand-block > div { display: none; }
.main-panel { min-width: 0; min-height: 0; overflow: hidden; }
.app-shell.shelf-mode { grid-template-columns: 1fr; }
.app-shell.shelf-mode .topbar { grid-template-columns: 280px 1fr auto; }
.app-shell.shelf-mode .left-panel, .app-shell.shelf-mode .ai-panel { display: none; }
.app-shell.shelf-mode .save-state { display: none; }
.app-shell.shelf-mode .main-panel { grid-column: 1 / -1; }

.shelf-view { height: 100%; overflow-y: auto; padding: 48px clamp(32px, 7vw, 110px) 90px; }
.shelf-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; max-width: 1400px; margin: 0 auto 38px; }
.shelf-header h1 { margin: 0 0 10px; font-size: clamp(30px, 4vw, 52px); font-weight: 560; letter-spacing: -.04em; }
.shelf-header p { margin: 0; color: var(--muted); }
.settings-hub-header { align-items: center; }
.settings-hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; max-width: 1000px; margin: 0 auto; }
.settings-hub-card { display: grid; grid-template-columns: 48px minmax(0, 1fr); grid-template-rows: auto auto; gap: 4px 14px; align-items: center; min-height: 128px; padding: 22px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); text-align: left; }
.settings-hub-card:hover, .settings-hub-card:focus-visible { border-color: var(--accent); background: var(--paper-deep); box-shadow: var(--shadow); transform: translateY(-2px); }
.settings-hub-card:disabled { cursor: not-allowed; opacity: .42; box-shadow: none; transform: none; }
.settings-card-mark { display: grid; grid-row: 1 / 3; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 50%; color: var(--accent-dark); background: var(--surface); font-size: 14px; font-weight: 700; }
.settings-hub-card strong { align-self: end; font-size: 16px; }
.settings-hub-card small { align-self: start; color: var(--muted); font-size: 10px; line-height: 1.5; }
.settings-work-note { max-width: 1000px; margin: 18px auto 0; color: var(--muted); font-size: 11px; }
.access-dialog-body { display: grid; gap: 16px; padding: 18px 24px 22px; }
.access-list { display: grid; gap: 8px; max-height: min(52vh, 480px); overflow: auto; padding: 0; }
.access-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}
.access-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.access-avatar { width: 34px; height: 34px; font-size: 12px; }
.access-person-copy { display: grid; gap: 3px; min-width: 0; }
.access-row strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.access-row small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.access-row > span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}
.access-row select {
  min-width: 118px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
}
.access-row button {
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.access-row button:hover:not(:disabled), .access-row button:focus-visible:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
  outline: none;
}
.access-row button:disabled, .access-row select:disabled {
  cursor: not-allowed;
  opacity: .46;
}
.member-invite-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, .3fr) auto; align-items: end; gap: 10px; margin: 0; }
.member-invite-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.member-invite-form select {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}
.member-invite-form .primary-button { min-height: 38px; white-space: nowrap; }
.app-shell.view-only-mode:not(.shelf-mode) { grid-template-columns: var(--left-panel-width) minmax(480px, 1fr); }
.app-shell.view-only-mode:not(.shelf-mode) .ai-panel { display: none; }
.app-shell.view-only-mode:not(.shelf-mode) .left-primary-actions .file-button,
.app-shell.view-only-mode:not(.shelf-mode) #new-volume-button,
.app-shell.view-only-mode:not(.shelf-mode) #new-chapter-button,
.app-shell.view-only-mode:not(.shelf-mode) #module-create-button,
.app-shell.view-only-mode:not(.shelf-mode) [data-work-settings],
.app-shell.view-only-mode:not(.shelf-mode) [data-module="tasks"],
.app-shell.view-only-mode:not(.shelf-mode) [data-module="ai-settings"],
.app-shell.view-only-mode:not(.shelf-mode) #tidy-blank-lines-button,
.app-shell.view-only-mode:not(.shelf-mode) #save-button { display: none !important; }
.app-shell.view-only-mode:not(.shelf-mode) .left-primary-actions { justify-content: flex-end; }
.app-shell.view-only-mode:not(.shelf-mode) #chapter-title[readonly],
.app-shell.view-only-mode:not(.shelf-mode) #chapter-content[readonly] { cursor: default; }
body.work-viewer-mode [data-setting-status],
body.work-viewer-mode [data-edit-setting],
body.work-viewer-mode [data-edit-character],
body.work-viewer-mode [data-edit-race],
body.work-viewer-mode [data-edit-organization],
body.work-viewer-mode [data-edit-timeline-track],
body.work-viewer-mode [data-add-event-track],
body.work-viewer-mode [data-edit-event],
body.work-viewer-mode [data-split-event],
body.work-viewer-mode [data-event-select],
body.work-viewer-mode #create-timeline-track,
body.work-viewer-mode #merge-events,
body.work-viewer-mode [data-edit-foreshadow],
body.work-viewer-mode [data-edit-outline],
body.work-viewer-mode [data-edit-relationship],
body.work-viewer-mode [data-character-relationship-edit],
body.work-viewer-mode [data-character-relationship-create],
body.work-viewer-mode [data-review-id],
body.work-viewer-mode .task-auto-run-panel,
body.work-viewer-mode [data-run-task],
body.work-viewer-mode [data-cancel-task],
body.work-viewer-mode [data-restore-version],
body.work-viewer-mode [data-entity-version-restore],
body.work-viewer-mode [data-character-restore],
body.work-viewer-mode [data-item-list-add],
body.work-viewer-mode [data-item-list-remove],
body.work-viewer-mode [data-structured-list-add],
body.work-viewer-mode [data-structured-list-remove],
body.work-viewer-mode .character-editor-actions { display: none !important; }
.search-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin: 0; }
.search-form label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.search-form input {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}
.search-form .primary-button { min-height: 38px; white-space: nowrap; }
.search-results { display: grid; gap: 8px; max-height: min(52vh, 480px); overflow: auto; }
.search-results-empty, .search-results-status {
  margin: 0;
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.search-result {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  text-align: left;
}
.search-result:hover, .search-result:focus-visible {
  border-color: var(--accent);
  background: var(--paper-deep);
  outline: none;
}
.search-result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}
.search-result strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.work-access-field { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); }
.work-access-field > div { display: grid; gap: 4px; min-width: 0; }
.work-access-field strong { color: var(--ink); font-size: 12px; }
.work-access-field small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.work-access-field .ghost-button { flex: 0 0 auto; white-space: nowrap; }
.account-dialog { width: min(640px, 92vw); overflow: hidden; }
.account-settings-body { display: grid; gap: 16px; max-height: calc(88vh - 86px); overflow-y: auto; padding: 20px 24px 24px; }
.account-settings-section { padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.account-settings-section-header { display: grid; gap: 4px; }
.account-settings-section-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.account-settings-section-header p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.avatar-settings { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 5px 14px; align-items: center; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.profile-avatar-preview { grid-row: 1 / 3; width: 76px; height: 76px; border: 2px solid color-mix(in srgb, var(--line) 72%, transparent); font-size: 26px; }
.avatar-settings-copy { display: grid; gap: 5px; min-width: 0; }
.avatar-settings-copy strong { color: var(--ink); font-size: 12px; }
.avatar-settings-copy small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.avatar-settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.avatar-settings-actions button { min-height: 32px; padding: 6px 11px; font-size: 11px; }
.avatar-settings-actions button:disabled { cursor: wait; opacity: .5; }
.account-settings-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; margin-top: 16px; }
.account-settings-form label { display: grid; min-width: 0; gap: 6px; color: var(--muted); font-size: 11px; }
.account-settings-form input { width: 100%; min-height: 38px; padding: 9px 10px; background: var(--surface); font-size: 12px; }
.account-settings-form .primary-button { min-height: 38px; white-space: nowrap; }
.password-settings-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.api-key-settings { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-top: 16px; }
.api-key-settings > p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.6; }
.api-key-result { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.api-key-result.hidden { display: none; }
.api-key-result label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.api-key-result input { width: 100%; min-height: 38px; padding: 9px 10px; background: var(--surface); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 11px; }
.api-key-result button { min-height: 38px; }
.book-access-badge { display: inline-flex; width: fit-content; margin-top: 7px; padding: 2px 7px; border-radius: 10px; background: var(--paper-deep); color: var(--accent-dark); font-size: 9px; }
.book-shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(205px, 1fr)); gap: clamp(22px, 3vw, 38px); max-width: 1400px; margin: 0 auto; }
.book-card { position: relative; min-width: 0; border: 0; background: transparent; text-align: left; }
.book-open { width: 100%; padding: 0; border: 0; background: transparent; text-align: left; }
.book-cover { position: relative; display: grid; place-items: center; aspect-ratio: 3 / 4.25; overflow: hidden; border-radius: 8px 13px 13px 8px; background: linear-gradient(145deg, #a96350, #612d27); color: rgba(255,255,255,.9); box-shadow: 0 20px 34px rgba(62,39,29,.18), inset 9px 0 0 rgba(0,0,0,.08); transition: transform .2s ease, box-shadow .2s ease; }
.book-cover::after { content: ""; position: absolute; inset: 0 auto 0 9px; width: 1px; background: rgba(255,255,255,.2); }
.book-open:hover .book-cover, .book-open:focus-visible .book-cover { transform: translateY(-6px) rotateY(-2deg); box-shadow: 0 28px 44px rgba(62,39,29,.24), inset 9px 0 0 rgba(0,0,0,.08); }
.book-cover-fallback { font-size: clamp(46px, 6vw, 74px); font-weight: 700; opacity: .75; }
.book-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.book-info { display: grid; gap: 7px; padding: 15px 4px 0; padding-right: 40px; }
.book-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.book-info small, .book-info > span { color: var(--muted); font-size: 10px; }
.book-info > span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.4; }
.book-card-settings {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 1;
  min-height: 0;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.2;
  opacity: .28;
  transition: opacity .18s ease, color .18s ease, border-color .18s ease;
}
.book-card:hover .book-card-settings,
.book-card:focus-within .book-card-settings,
.book-card-settings:focus-visible {
  opacity: 1;
}
.book-card-settings:hover,
.book-card-settings:focus-visible {
  color: var(--ink);
  border-color: var(--accent);
}
.work-cover-field {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}
.work-cover-copy { grid-column: 2; display: grid; gap: 4px; min-width: 0; }
.work-cover-copy strong { color: var(--ink); font-size: 12px; }
.work-cover-copy small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.work-cover-preview {
  grid-row: 1 / 3;
  grid-column: 1;
  display: grid;
  place-items: center;
  width: 72px;
  aspect-ratio: 3 / 4.25;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-size: 9px;
  text-align: center;
}
.work-cover-preview.has-cover { border-style: solid; }
.work-cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.work-cover-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; }
.work-cover-actions .ghost-button { min-height: 32px; padding: 6px 11px; font-size: 11px; }
.book-add-card { display: grid; place-items: center; align-content: center; aspect-ratio: 3 / 4.25; min-height: 280px; border: 1px dashed #b8ad9c; border-radius: 8px; color: var(--muted); }
.book-add-card span { display: grid; place-items: center; width: 58px; height: 58px; margin-bottom: 15px; border: 1px solid var(--line); border-radius: 50%; font-size: 34px; color: var(--accent); }
.book-add-card strong { color: var(--ink); margin-bottom: 8px; }
.book-add-card small { max-width: 160px; text-align: center; line-height: 1.5; }
.book-add-card:hover { border-color: var(--accent); background: var(--surface-soft); }

select, input, textarea { border: 1px solid var(--line); background: var(--surface); border-radius: 5px; outline: none; }
select:focus, input:focus, textarea:focus { border-color: #a77768; box-shadow: 0 0 0 3px rgba(139,61,44,.08); }
.left-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin: 0 0 15px; }
.left-primary-actions { display: flex; grid-column: 1 / -1; width: 100%; align-items: center; gap: 8px; }
.left-primary-actions .file-button { flex: 1 1 auto; width: auto; min-width: 0; }
.left-primary-actions #left-panel-toggle { flex: 0 0 30px; width: 30px; height: 30px; }
.file-button, .secondary-button { display: grid; place-items: center; min-height: 30px; border: 1px solid var(--line); border-radius: 4px; font-size: 11px; background: transparent; }
.file-button { container-type: inline-size; overflow: hidden; white-space: nowrap; }
.import-file-label-compact, .import-file-label-short { display: none; }
@container (max-width: 120px) {
  .import-file-label-full { display: none; }
  .import-file-label-compact { display: inline; }
}
@container (max-width: 88px) {
  .import-file-label-compact { display: none; }
  .import-file-label-short { display: inline; }
}
.file-button input { display: none; }
.module-nav { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; padding: 8px 0 14px; border-bottom: 1px solid var(--line); }
.module-nav button { border: 0; background: transparent; text-align: left; padding: 7px 9px; color: var(--muted); font-size: 12px; border-radius: 3px; }
.module-nav button.active, .module-nav button:hover { background: var(--paper-deep); color: var(--ink); }
.module-nav .ai-analysis-entry { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent-dark); font-weight: 650; }
#module-more-button { grid-column: 1 / -1; color: var(--accent-dark); text-align: center; }
.panel-heading { display: flex; align-items: center; gap: 8px; padding: 15px 7px 9px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.panel-heading #chapter-count { margin-left: auto; }
.novel-tree { font-size: 13px; }
.empty-copy { color: var(--muted); padding: 14px 7px; line-height: 1.5; }
.volume-node { margin-bottom: 8px; }
.volume-title { display: flex; width: 100%; min-width: 0; align-items: center; justify-content: space-between; padding: 7px; border: 0; background: transparent; color: var(--muted); font-size: 11px; letter-spacing: .05em; text-align: left; }
.volume-title::before { content: ""; width: 4px; height: 4px; border: solid var(--muted); border-width: 0 1px 1px 0; transform: rotate(45deg); margin-right: 8px; }
.volume-node.is-collapsed .volume-title::before { transform: rotate(-45deg); }
.volume-title span:first-child { flex: 1; }
.volume-chapters { display: block; }
.volume-node.is-collapsed .volume-chapters { display: none; }
.chapter-node { display: grid; grid-template-columns: minmax(0, 1fr) max-content; gap: 8px; width: 100%; padding: 9px 10px 9px 20px; border: 0; background: transparent; border-radius: 4px; text-align: left; font-size: 12px; }
.chapter-node:hover, .chapter-node.active { background: var(--row-active); }
.chapter-node.active { color: var(--accent-dark); font-weight: 700; }
.chapter-node > span:first-child { min-width: 0; overflow-wrap: anywhere; line-height: 1.45; white-space: normal; }
.chapter-node-meta { display: flex; flex: none; align-items: center; gap: 5px; margin-left: auto; overflow: visible; white-space: nowrap; }
.chapter-node small { color: var(--muted); font-size: 9px; }
.chapter-type-badge { max-width: 58px; overflow: hidden; padding: 2px 5px; border-radius: 9px; background: rgba(139,61,44,.1); color: var(--accent-dark); font-size: 8px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }

.ghost-button, .primary-button { border-radius: 4px; padding: 8px 13px; font-size: 12px; }
.ghost-button { border: 1px solid var(--line); background: transparent; }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-dark); }
.full-button { width: 100%; padding: 10px; }
.save-state { color: var(--green); font-size: 11px; min-width: 44px; }

.welcome-view { height: 100%; display: grid; align-content: center; max-width: 850px; margin: 0 auto; padding: 50px; }
.eyebrow { display: block; color: var(--accent); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; margin-bottom: 8px; }
.welcome-view h1 { font-size: clamp(34px, 4vw, 58px); font-weight: 500; line-height: 1.26; margin: 0 0 24px; letter-spacing: -.03em; }
.welcome-view > p { max-width: 600px; color: var(--muted); line-height: 1.6; font-size: 15px; }
.welcome-view > .primary-button { width: fit-content; margin-top: 16px; padding: 12px 20px; }
.welcome-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 55px; background: var(--line); border: 1px solid var(--line); }
.welcome-grid article { background: var(--paper); padding: 18px; }
.welcome-grid b, .welcome-grid span { display: block; }
.welcome-grid b { font-size: 13px; margin-bottom: 8px; }
.welcome-grid span { color: var(--muted); font-size: 11px; line-height: 1.5; }

.hidden { display: none !important; }
.editor-view { container-name: editor-workspace; container-type: inline-size; display: grid; grid-template-rows: auto minmax(0, 1fr); height: 100%; }
.editor-toolbar { display: grid; grid-template-areas: "path path" "title actions"; grid-template-columns: minmax(0, 1fr) auto; align-items: flex-end; column-gap: 20px; row-gap: 6px; padding: 25px 7% 18px; border-bottom: 1px solid var(--line); }
#chapter-path { grid-area: path; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-title { grid-area: title; display: block; width: 100%; min-width: 0; border: 0; border-radius: 0; background: transparent; font-size: 27px; padding: 0; }
.chapter-title:focus { box-shadow: none; border-bottom: 1px solid var(--accent); }
.editor-actions { grid-area: actions; display: flex; align-items: center; gap: 10px; }
.chapter-stats { color: var(--muted); font-size: 11px; }
@container editor-workspace (max-width: 720px) {
  .editor-toolbar { grid-template-areas: "path" "title" "actions"; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-inline: 6%; }
  .chapter-title { min-height: 36px; }
  .editor-actions { justify-content: flex-end; flex-wrap: wrap; }
  .chapter-stats { display: none; }
}
.editor-body { display: flex; min-height: 0; flex-direction: column; }
.chapter-editor-frame { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); flex: 1 1 auto; width: 100%; min-height: 0; margin: 0; overflow: hidden; }
.chapter-line-numbers { position: relative; z-index: 2; grid-column: 1; grid-row: 1; min-height: 0; overflow: visible; border-right: 1px solid var(--line); background: linear-gradient(to right, transparent, rgba(143,132,116,.04)); color: var(--muted); font-family: var(--font-latin), monospace; font-size: clamp(11px, calc(var(--editor-font-size) * .72), 14px); line-height: 1.2; user-select: none; }
#chapter-line-numbers-inner { position: absolute; top: 32px; left: 0; right: 0; will-change: transform; }
.chapter-line-number { position: absolute; left: 0; box-sizing: border-box; display: flex; width: 100%; align-items: flex-start; justify-content: center; padding: 0 3px; border: 0; background: transparent; color: inherit; font: inherit; font-variant-numeric: tabular-nums; text-align: center; cursor: pointer; }
.chapter-line-number:hover { background: rgba(139,61,44,.08); color: var(--accent-dark); }
.chapter-line-number.is-line-selected { background: rgba(139,61,44,.16); color: var(--accent-dark); font-weight: 700; }
.chapter-line-number.is-line-selected::after { content: ""; position: absolute; top: 0; left: 100%; width: 100vw; height: 100%; background: rgba(139,61,44,.085); box-shadow: inset 3px 0 rgba(139,61,44,.28); pointer-events: none; }
.chapter-content { position: relative; z-index: 1; grid-column: 2; grid-row: 1; resize: none; width: 100%; height: 100%; min-height: 0; margin: 0; padding: 32px 36px 72px; border: 0; background: transparent; border-radius: 0; font-size: var(--editor-font-size); line-height: var(--editor-line-height); letter-spacing: .01em; overflow-wrap: break-word; }
.chapter-content:focus { box-shadow: none; }
.chapter-whitespace-overlay { position: relative; z-index: 2; grid-column: 2; grid-row: 1; width: 100%; height: 100%; overflow: hidden; opacity: 0; pointer-events: none; }
.chapter-whitespace-overlay.is-visible { opacity: 1; }
#chapter-whitespace-inner { box-sizing: border-box; min-height: 100%; color: transparent; white-space: pre-wrap; will-change: transform; }
.chapter-space-marker { position: relative; color: transparent; }
.chapter-space-marker::after { content: "·"; position: absolute; inset: 0; color: color-mix(in srgb, var(--muted) 62%, transparent); font-family: var(--font-latin), monospace; text-align: center; }
.chapter-space-marker.ideographic-space::after { content: "□"; color: color-mix(in srgb, var(--accent) 58%, transparent); font-size: .62em; line-height: 1.7; }
.chapter-space-marker.tab::after { content: "→"; color: color-mix(in srgb, var(--muted) 72%, transparent); font-size: .72em; line-height: 1.65; text-align: left; }
.chapter-line-measure { position: absolute; z-index: -1; top: 0; left: 38px; visibility: hidden; white-space: pre-wrap; overflow-wrap: break-word; pointer-events: none; }
.chapter-line-measure > div { display: block; }
.chapter-insight { margin: 14px 7% 0; padding: 13px 16px; border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface-soft); color: var(--muted); font-size: 11px; line-height: 1.5; }
.chapter-insight strong { color: var(--ink); margin-right: 8px; }

.module-view { height: 100%; overflow-y: auto; padding: 42px 6%; }
.module-header { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.module-header h1 { margin: 0 0 8px; font-weight: 500; font-size: 34px; }
.module-header p { margin: 0; color: var(--muted); font-size: 13px; }
.module-content { padding: 24px 0 80px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 13px; }
.record-card { position: relative; border: 1px solid var(--line); background: var(--surface-soft); padding: 18px; min-height: 130px; border-radius: 4px; }
.record-card h3 { font-size: 16px; margin: 5px 0 10px; font-weight: 600; }
.record-card p { color: var(--muted); font-size: 12px; line-height: 1.55; margin: 0; white-space: pre-wrap; }
.record-card small { color: var(--accent); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; }
.character-card { cursor: pointer; }
.character-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-actions { display: flex; gap: 6px; margin-top: 15px; }
.card-actions button { border: 1px solid var(--line); background: transparent; border-radius: 3px; font-size: 10px; padding: 5px 8px; }
.card-actions .primary-button { border-color: var(--accent); background: var(--accent); color: #fff; padding: 8px 13px; font-size: 12px; }
.card-actions .primary-button:hover, .card-actions .primary-button:focus-visible { background: var(--accent-dark); }
.provider-card-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.provider-card { min-width: 0; }
.provider-card p, .provider-card .model-pill { overflow-wrap: anywhere; word-break: break-word; }
.provider-models { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.provider-card .model-pill { max-width: 100%; margin: 0; border: 0; text-align: left; white-space: normal; cursor: pointer; }
.provider-card .model-pill:hover, .provider-card .model-pill:focus-visible { background: var(--surface-hover); color: var(--ink); }
.provider-card .card-actions { flex-wrap: wrap; }
.pill { display: inline-block; padding: 3px 7px; margin: 0 4px 4px 0; border-radius: 12px; background: var(--paper-deep); color: var(--muted); font-size: 9px; }
.organization-links { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; margin: 8px 0 6px; }.organization-links b { color: var(--muted); font-size: 9px; font-weight: 500; }.organization-links .pill { margin: 0; }.organization-empty { color: var(--muted); font-size: 9px; }.organization-pill { color: var(--accent-dark); background: rgba(139,61,44,.1); }.organization-settings { margin: 10px 0 6px; }.organization-members { margin-top: 9px !important; }.relationship-keyword { white-space: nowrap; }
.race-settings { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0 6px; }.race-settings .pill { margin: 0; }.race-members { margin-top: 9px !important; }
.config-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--line); }
.config-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.platform-system-prompt-section { margin-bottom: 36px; }
.task-auto-run-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
}
.task-auto-run-copy { display: grid; gap: 4px; }
.task-auto-run-copy strong { font-size: 13px; }
.task-auto-run-copy small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.task-auto-run-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
}
.task-auto-run-controls label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}
.task-auto-run-controls input[type="number"] {
  width: 88px;
  min-height: 32px;
  padding: 6px 8px;
  font-size: 12px;
}
.task-auto-run-controls .checkbox-field {
  align-self: center;
  margin: 0;
}
.task-auto-run-meta { margin: 0; color: var(--muted); font-size: 10px; }
.task-row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.task-detail { display: grid; gap: 12px; }
.task-detail p, .task-detail div { margin: 0; font-size: 12px; line-height: 1.55; }
.task-detail ul { margin: 6px 0 0; padding-left: 18px; }
.task-detail-result {
  max-height: 220px;
  overflow: auto;
  margin: 6px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-size: 10px;
  white-space: pre-wrap;
}
.config-section-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 14px; }
.config-section-header h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.config-section-header p { margin: 0; color: var(--muted); font-size: 11px; }
.ai-agent-tools { display: grid; gap: 8px; }
.ai-agent-tools label { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; align-items: start; color: var(--muted); font-size: 11px; line-height: 1.45; }
.ai-agent-tools input { width: auto; margin-top: 2px; }
.ai-agent-tools strong { color: var(--ink); font-size: 12px; font-weight: 600; }
.ai-agent-tools small { display: block; margin-top: 2px; font-size: 10px; }
.default-model-select { min-width: 260px; padding: 7px 9px; font-size: 11px; }
.empty-state { padding: 70px 30px; text-align: center; color: var(--muted); border: 1px dashed var(--line); }
.empty-state b { display: block; color: var(--ink); margin-bottom: 8px; }
.timeline-list { position: relative; margin-left: 15px; border-left: 1px solid var(--line); }
.timeline-item { position: relative; padding: 0 0 28px 25px; }
.timeline-item::before { content: ""; position: absolute; left: -5px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--paper); }
.timeline-item h3 { margin: 4px 0 7px; }
.timeline-item p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.table-list { width: 100%; border-collapse: collapse; font-size: 12px; }
.table-list th, .table-list td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table-list th { color: var(--muted); font-weight: 400; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.danger-text { color: var(--accent); }
.timeline-tools { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
.timeline-select { position: absolute; left: -33px; top: 0; }
.timeline-kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(290px, 340px); gap: 14px; align-items: start; overflow-x: auto; padding: 3px 2px 18px; scroll-snap-type: x proximity; }
.timeline-lane { display: flex; max-height: calc(100vh - 250px); min-height: 420px; flex-direction: column; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: color-mix(in srgb, var(--paper-deep) 42%, transparent); scroll-snap-align: start; }
.timeline-lane > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 14px 10px; border-bottom: 1px solid var(--line); }
.timeline-lane > header h3 { margin: 3px 0 0; font-size: 16px; }.timeline-lane > header small { color: var(--accent); font-size: 9px; }
.timeline-track-menu { border: 1px solid var(--line); border-radius: 3px; padding: 5px 7px; background: transparent; font-size: 9px; }
.timeline-track-actions { display: flex; gap: 5px; }
.timeline-track-description { min-height: 40px; margin: 0; padding: 9px 14px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.timeline-lane-events { display: grid; gap: 9px; align-content: start; flex: 1; overflow-y: auto; padding: 8px; }
.timeline-kanban-card { padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); box-shadow: 0 5px 16px rgba(49,42,32,.06); }
.timeline-kanban-card h4 { margin: 8px 0 6px; font-size: 14px; }.timeline-kanban-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }.timeline-kanban-card > span { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; }
.timeline-card-meta { display: flex; gap: 7px; align-items: center; }.timeline-card-meta small { color: var(--accent); font-size: 9px; }
.timeline-lane-empty { padding: 34px 12px; border: 1px dashed var(--line); color: var(--muted); text-align: center; font-size: 10px; }
.timeline-add-event { margin: 8px; padding: 8px; border: 1px dashed var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-size: 10px; }
.relationship-map-card { margin-bottom: 28px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.relationship-map-toolbar { display: flex; align-items: center; gap: 18px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.relationship-map-toolbar > div:first-child { display: grid; gap: 3px; }
.relationship-map-toolbar strong { font-size: 13px; }
.relationship-map-toolbar small { color: var(--muted); font-size: 9px; }
.relationship-map-toolbar .relationship-map-actions { display: flex; gap: 7px; margin-left: auto; }
.relationship-map-actions button { white-space: nowrap; }
.relationship-galaxy-button { display: inline-flex; align-items: center; gap: 6px; }
.relationship-galaxy-icon { width: 14px; height: 14px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.relationship-map-legend { display: flex; flex-wrap: wrap; gap: 10px; }
.relationship-map-legend span { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 9px; }
.relationship-map-legend i, .galaxy-legend i, .galaxy-detail li i { width: 8px; height: 8px; border-radius: 50%; background: #9aa5b5; }
.relationship-map-legend i.family, .galaxy-legend i.family, .galaxy-detail li i.family { background: #43e39a; }
.relationship-map-legend i.social, .galaxy-legend i.social, .galaxy-detail li i.social { background: #438cff; }
.relationship-map-legend i.emotional, .galaxy-legend i.emotional, .galaxy-detail li i.emotional { background: #ff5f69; }
.relationship-map-legend i.conflict, .galaxy-legend i.conflict, .galaxy-detail li i.conflict { background: #ffad42; }
.relationship-mindmap { position: relative; width: 100%; height: 490px; overflow: hidden; background: radial-gradient(circle at center, var(--surface), color-mix(in srgb, var(--paper-deep) 22%, transparent)); }
.relationship-mindmap-stage { position: absolute; inset: 0; width: 100%; height: 100%; transform-origin: 0 0; }
.relationship-mindmap svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.mind-edge-hit { fill: none; stroke: transparent; stroke-width: 16px; pointer-events: stroke; cursor: pointer; }
.mind-edge-hit:focus-visible { outline: none; stroke: rgba(139,61,44,.16); }
.mind-edge { fill: none; stroke-width: var(--edge-width); opacity: var(--edge-opacity); pointer-events: none; transition: opacity .15s ease, stroke-width .15s ease, filter .15s ease; }
.mind-edge.family { stroke: #3e9b73; }.mind-edge.social { stroke: #3c70a8; }.mind-edge.emotional { stroke: #af5263; }.mind-edge.conflict { stroke: #c37535; }.mind-edge.uncertain { stroke: #8a857b; stroke-dasharray: 3 5; }
.mind-edge.is-pending { stroke-dasharray: 7 5; }.mind-edge.is-dimmed { opacity: .08; }.mind-edge.is-highlighted { opacity: .92; stroke-width: 3; }
.mind-edge.is-edge-selected { opacity: 1; stroke-width: 4; filter: drop-shadow(0 0 3px rgba(139,61,44,.45)); }
.mind-edge-label { fill: var(--muted); font-size: 10px; paint-order: stroke; stroke: var(--paper); stroke-width: 4px; pointer-events: none; transition: opacity .15s ease, fill .15s ease; }
.mind-edge-label.is-secondary-label { opacity: 0; }.mind-edge-label.is-dimmed { opacity: .05; }.mind-edge-label.is-edge-selected { opacity: 1; fill: var(--ink); font-weight: 700; }
.relationship-map-card.is-expanded .mind-edge-label { font-size: 14px; stroke-width: 6px; }
.mind-node { position: absolute; width: 96px; min-height: 40px; transform: translate(-50%, -50%); padding: 7px 9px; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 6px 18px rgba(0,0,0,.14); font-size: 10px; cursor: grab; touch-action: none; z-index: 2; transition: opacity .15s ease, transform .15s ease, box-shadow .15s ease; }
.mind-node:hover, .mind-node:focus-visible, .mind-node.is-selected { transform: translate(-50%, -50%) scale(1.08); border-color: var(--accent); box-shadow: 0 8px 23px rgba(139,61,44,.16); }
.mind-node.is-locked { box-shadow: 0 0 0 2px rgba(94,118,92,.2), 0 6px 18px rgba(49,42,32,.1); }.mind-node.is-dimmed { opacity: .16; }
.mind-node.is-edge-endpoint { opacity: 1; transform: translate(-50%, -50%) scale(1.1); border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,61,44,.16), 0 9px 26px rgba(139,61,44,.2); }
.mind-node.is-dragging { cursor: grabbing; z-index: 4; transition: none; }
.mindmap-more { position: absolute; right: 14px; bottom: 12px; border: 1px solid var(--line); border-radius: 15px; padding: 6px 10px; background: var(--surface-strong); color: var(--muted); font-size: 9px; }
.mind-edge-detail { position: absolute; z-index: 5; left: 16px; right: 16px; bottom: 14px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-strong); box-shadow: var(--shadow); font-size: 11px; }
.mind-edge-detail b { white-space: nowrap; }.mind-edge-detail span { color: var(--muted); line-height: 1.55; }
.relationship-empty-note { margin-top: -12px; padding: 12px 14px; border: 1px dashed var(--line); color: var(--muted); font-size: 11px; }
.relationship-map-dialog { position: relative; width: min(1400px, 96vw); max-width: none; height: min(900px, 92vh); max-height: none; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); box-shadow: var(--shadow); }
.relationship-map-dialog::backdrop { background: rgba(34,30,25,.52); backdrop-filter: blur(3px); }
.relationship-map-floating-close { position: absolute; z-index: 6; top: 25px; right: 25px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: var(--surface-strong); color: var(--ink); font-size: 20px; }
.relationship-map-expanded-host { height: 100%; padding: 18px; }
.relationship-map-expanded-host .relationship-map-card { height: 100%; margin: 0; }
.relationship-map-expanded-host .relationship-map-toolbar { padding-right: 72px; }
.relationship-map-expanded-host .relationship-mindmap { height: calc(100% - 67px); min-height: 0; }
.relationship-network-card { border-color: #1c1c24; background: #12121a; box-shadow: none; }
.relationship-network-card .relationship-map-toolbar { min-height: 58px; border-color: #1c1c24; background: #12121a; color: #e8e8ef; }
.relationship-network-card .relationship-map-toolbar small { color: #7a7a88; }
.relationship-network-card .relationship-map-actions button { border-color: #2a2a36; background: transparent; color: #a8a8b4; }
.relationship-network-card .relationship-map-actions button:hover, .relationship-network-card .relationship-map-actions button:focus-visible { border-color: #4a4a58; background: #1a1a24; color: #f0f0f5; }
.relationship-network { height: min(68vh, 650px); min-height: 520px; contain: layout paint style; touch-action: none; cursor: grab; background: #12121a; }
.relationship-network.is-panning { cursor: grabbing; }
.relationship-network-stage { contain: layout paint style; will-change: transform; }
.relationship-network-stage.is-view-animating { transition: transform .34s cubic-bezier(.22,.78,.3,1); }
.relationship-network svg { overflow: visible; }
.relationship-network .mind-edge-hit {
  stroke-width: 14px;
  outline: none;
}
.relationship-network .mind-edge-hit:focus,
.relationship-network .mind-edge-hit:focus-visible {
  outline: none;
  stroke: transparent;
}
.relationship-network .mind-edge,
.relationship-network .obsidian-edge { stroke: rgba(255,255,255,.26); stroke-width: 1px; opacity: 1; transition: opacity .12s ease, stroke .12s ease; }
.relationship-network .mind-edge.family,
.relationship-network .mind-edge.social,
.relationship-network .mind-edge.emotional,
.relationship-network .mind-edge.conflict,
.relationship-network .mind-edge.uncertain { stroke: rgba(255,255,255,.26); stroke-dasharray: none; }
.relationship-network .mind-edge.is-pending { stroke: rgba(255,255,255,.18); stroke-dasharray: 4 6; }
.relationship-network .mind-edge.is-dimmed { opacity: .06; }
.relationship-network .mind-edge.is-highlighted { stroke: rgba(255,255,255,.72); stroke-width: 1.35px; opacity: 1; }
.relationship-network .mind-edge.is-edge-selected { stroke: rgba(220,220,235,.88); stroke-width: 1.6px; opacity: 1; }
.relationship-network .mind-edge-label {
  fill: rgba(230,230,240,.88);
  stroke: #12121a;
  stroke-width: 2.5px;
  font-size: 7px;
  font-weight: 400;
  letter-spacing: .01em;
  opacity: 1;
  paint-order: stroke;
}
.relationship-map-card.is-expanded .relationship-network .mind-edge-label {
  font-size: 8px;
  stroke-width: 3px;
}
.relationship-network .mind-node,
.relationship-network .obsidian-node {
  width: var(--node-size);
  height: var(--node-size);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--node-color, #8b9099);
  color: rgba(245,245,250,.88);
  box-shadow: 0 0 8px var(--node-glow, rgba(139,144,153,.42));
  font-family: "SF Pro Text", "Segoe UI", "Helvetica Neue", sans-serif;
  font-size: 9px;
  font-weight: 400;
  line-height: 1;
  transition: opacity .12s ease, transform .12s ease, box-shadow .12s ease;
  will-change: left, top;
}
.relationship-network .mind-node span {
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  display: block;
  width: max-content;
  max-width: 96px;
  overflow: hidden;
  transform: translateX(-50%);
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
  color: rgba(235,235,245,.78);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: .01em;
  text-shadow: 0 1px 2px rgba(0,0,0,.65);
}
.relationship-network .mind-node:hover,
.relationship-network .mind-node:focus-visible,
.relationship-network .mind-node.is-hovered {
  transform: translate(-50%, -50%) scale(1.28);
  outline: none;
  z-index: 6;
  box-shadow: 0 0 10px rgba(255,255,255,.5), 0 0 18px var(--node-glow, rgba(139,144,153,.55));
}
.relationship-network .mind-node:hover span,
.relationship-network .mind-node:focus-visible span,
.relationship-network .mind-node.is-hovered span,
.relationship-network .mind-node.is-selected span,
.relationship-network .mind-node.is-related span,
.relationship-network .mind-node.is-edge-endpoint span { color: rgba(255,255,255,.95); }
.relationship-network .mind-node.is-selected {
  transform: translate(-50%, -50%) scale(1.32);
  z-index: 5;
  box-shadow: 0 0 10px rgba(255,255,255,.55), 0 0 20px var(--node-glow, rgba(139,144,153,.6));
}
.relationship-network .mind-node.is-related { opacity: 1; }
.relationship-network .mind-node.is-dimmed { opacity: .14; box-shadow: none; }
.relationship-network .mind-node.is-isolated { opacity: .28; }
.relationship-network .mind-node.is-edge-endpoint {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.3);
  box-shadow: 0 0 10px rgba(255,255,255,.5), 0 0 18px var(--node-glow, rgba(139,144,153,.55));
}
.relationship-network[data-interaction="dragging"] .mind-edge,
.relationship-network[data-interaction="dragging"] .mind-node,
.relationship-network[data-interaction="panning"] .mind-edge,
.relationship-network[data-interaction="panning"] .mind-node {
  transition: none !important;
}
.relationship-network[data-interaction="dragging"] .mind-node:not(.is-dragging):not(.is-drag-neighbor) {
  pointer-events: none;
}
.relationship-network[data-interaction="dragging"] .mind-node:not(.is-dragging):not(.is-drag-neighbor):not(.is-related):not(.is-selected) {
  box-shadow: none;
}
.relationship-network .mind-node.is-dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.36);
  transition: none;
  z-index: 8;
  will-change: left, top;
  box-shadow: 0 0 10px rgba(255,255,255,.6), 0 0 18px var(--node-glow, rgba(139,144,153,.6));
}
.relationship-network .mind-node.is-drag-neighbor {
  opacity: 1;
  z-index: 3;
  will-change: left, top;
}
.relationship-network .mind-node.is-settling { animation: relationship-node-settle .18s ease-out; }
.relationship-network-focus, .relationship-network-help { position: absolute; z-index: 6; color: #7a7a88; pointer-events: none; }
.relationship-network-focus { top: 14px; left: 16px; display: grid; gap: 3px; }
.relationship-network-focus strong { color: #c8c8d4; font-size: 10px; font-weight: 500; }
.relationship-network-focus span { color: #6a6a78; font-size: 9px; }
.relationship-network-help { left: 16px; bottom: 13px; font-size: 9px; }
.relationship-network .mind-edge-detail { left: 50%; right: auto; bottom: 38px; width: min(680px, calc(100% - 40px)); transform: translateX(-50%); border-color: #2a2a36; background: rgba(18,18,26,.94); color: #e2e2ea; box-shadow: none; }
.relationship-network .mind-edge-detail span { color: #9a9aa8; }
.relationship-map-expanded-host .relationship-network { height: calc(100% - 63px); min-height: 0; }
.relationship-map-dialog { background: #12121a; border-color: #1c1c24; }
.relationship-map-expanded-host { background: #12121a; }
@keyframes relationship-node-settle { from { transform: translate(-50%, -50%) scale(1.36); } to { transform: translate(-50%, -50%) scale(1.32); } }
@media (prefers-reduced-motion: reduce) { .relationship-network .mind-node, .relationship-network-stage { transition-duration: .01ms; animation-duration: .01ms; } }

.outline-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 32px; }
.outline-summary article { display: grid; padding: 17px; border: 1px solid var(--line); background: var(--surface-soft); }
.outline-summary strong { font-size: 26px; }.outline-summary span { color: var(--muted); font-size: 10px; }
.planning-section + .planning-section { margin-top: 42px; }.section-title { display: flex; justify-content: space-between; margin-bottom: 15px; }.section-title h2 { margin: 0; font-size: 21px; }
.foreshadow-card.is-overdue { border-color: #b55743; box-shadow: inset 3px 0 #b55743; }.foreshadow-links { margin-top: 13px; }
.outline-list { display: grid; gap: 8px; }.outline-row { display: grid; grid-template-columns: minmax(150px, 1.1fr) repeat(3, minmax(130px, 1fr)) auto; gap: 16px; align-items: start; padding: 15px; border: 1px solid var(--line); background: var(--surface-soft); }
.outline-row small { color: var(--accent); font-size: 9px; }.outline-row h3 { margin: 4px 0 0; font-size: 14px; }.outline-row b { font-size: 10px; }.outline-row p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; white-space: pre-wrap; }
.outline-row.is-complete { opacity: .66; }.outline-actions { display: grid; gap: 7px; justify-items: end; }.outline-actions span { color: var(--accent); font-size: 9px; }.outline-actions button { border: 1px solid var(--line); background: transparent; border-radius: 3px; padding: 5px 8px; font-size: 9px; }

.galaxy-dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: #05070d; color: #eef6ff; }
.galaxy-dialog::backdrop { background: #05070d; }.galaxy-shell { position: relative; width: 100%; height: 100%; overflow: hidden; touch-action: none; background: #05070d; cursor: grab; contain: strict; }
.galaxy-shell.is-rotating-camera { cursor: grabbing; }.galaxy-background, .galaxy-graph, .galaxy-node-layer { position: absolute; inset: 0; width: 100%; height: 100%; }.galaxy-background { opacity: 1; transition: opacity .2s ease; }.galaxy-background.hidden-stars { opacity: .96; }
.galaxy-graph { z-index: 2; }.galaxy-node-layer { z-index: 3; pointer-events: none; }
.galaxy-node { --node-size: 12px; position: absolute; left: 0; top: 0; display: grid; grid-template-rows: var(--node-size) auto; justify-items: center; align-items: start; gap: 5px; padding: 8px; border: 0; background: transparent; color: #edf7ff; cursor: grab; touch-action: none; pointer-events: auto; transform-origin: center; opacity: var(--depth-opacity, 1); will-change: transform, opacity; }
.galaxy-node i { width: var(--node-size); height: var(--node-size); border-radius: 50%; background: radial-gradient(circle at 34% 30%, #fff 0 7%, color-mix(in srgb, var(--node-color) 54%, #fff) 19%, var(--node-color) 51%, color-mix(in srgb, var(--node-color) 52%, #07101f) 100%); box-shadow: 0 0 4px rgba(255,255,255,.88), 0 0 calc(7px + var(--node-glow) * 11px) var(--node-color), 0 0 calc(15px + var(--node-glow) * 25px) color-mix(in srgb, var(--node-color) 72%, transparent); filter: brightness(var(--node-brightness)); transition: filter .18s ease, box-shadow .18s ease; }.galaxy-node span { opacity: 0; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 6px; border-radius: 4px; background: rgba(5,7,13,.68); font-size: 10px; text-align: center; text-shadow: 0 1px 3px #000; transition: opacity .14s ease; }
.galaxy-node.show-label span, .galaxy-node:hover span, .galaxy-node:focus-visible span, .galaxy-node.is-selected span, .galaxy-node.is-related span, .galaxy-node.is-edge-endpoint span { opacity: 1; }.galaxy-node.is-selected i { background: #fff4bd; box-shadow: 0 0 5px #fff, 0 0 18px #ffc86b, 0 0 42px rgba(255,173,66,.82); }.galaxy-node.is-related i { background: #d8f4ff; box-shadow: 0 0 4px #fff, 0 0 15px #438cff, 0 0 28px rgba(67,140,255,.56); }.galaxy-node.is-edge-endpoint i { background: #fff; box-shadow: 0 0 6px #fff, 0 0 22px #6fcaff, 0 0 48px rgba(67,140,255,.92); }.galaxy-node.is-dimmed { opacity: .16; }.galaxy-node.is-selected, .galaxy-node.is-related, .galaxy-node.is-edge-endpoint { z-index: 2; }
.galaxy-node.is-dragging { cursor: grabbing; z-index: 6; }
.galaxy-close { position: fixed; z-index: 8; top: 22px; right: 25px; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; background: rgba(5,7,13,.62); color: #fff; font-size: 25px; }
.galaxy-stats { position: fixed; z-index: 7; left: 22px; bottom: 20px; color: rgba(235,245,255,.82); font-size: 11px; }
.galaxy-controls { position: fixed; z-index: 7; right: 23px; top: 50%; display: grid; width: 128px; gap: 7px; transform: translateY(-50%); padding: 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; background: rgba(5,7,13,.66); backdrop-filter: blur(12px); }
.galaxy-controls button { border: 1px solid rgba(255,255,255,.14); border-radius: 5px; padding: 7px; background: rgba(255,255,255,.05); color: #dcecff; font-size: 9px; }
.galaxy-legend { position: fixed; z-index: 7; right: 22px; bottom: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px 12px; margin: 0; padding: 11px; list-style: none; border: 1px solid rgba(255,255,255,.12); border-radius: 7px; background: rgba(5,7,13,.66); color: rgba(235,245,255,.8); font-size: 9px; }.galaxy-legend li { display: flex; align-items: center; gap: 5px; }
.galaxy-detail { position: fixed; z-index: 7; left: 22px; top: 22px; width: min(300px, 30vw); max-height: 55vh; overflow: auto; padding: 15px; border: 1px solid rgba(255,255,255,.14); border-radius: 8px; background: rgba(5,7,13,.74); backdrop-filter: blur(14px); }.galaxy-detail strong, .galaxy-detail small { display: block; }.galaxy-detail strong { font-size: 18px; }.galaxy-detail small, .galaxy-detail p { color: rgba(220,235,250,.65); font-size: 9px; }.galaxy-detail ul { display: grid; gap: 7px; padding: 0; list-style: none; font-size: 9px; }.galaxy-detail li { display: flex; align-items: center; gap: 6px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.ai-heading { display: flex; align-items: center; gap: 8px; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.ai-heading > div { display: flex; gap: 8px; align-items: center; }
.ai-heading small { margin-left: auto; color: var(--muted); font-size: 10px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(94,118,92,.14); }
.ai-conversation-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 5px; align-items: center; padding: 10px 0; }
.ai-conversation-toolbar > span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.ai-conversation-toolbar button { padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-size: 9px; }
.ai-conversation-toolbar button:hover, .ai-conversation-toolbar button[aria-expanded="true"] { background: var(--paper-deep); color: var(--ink); }
.ai-history-dialog-body { min-height: min(360px, 55vh); max-height: 65vh; overflow-y: auto; padding: 18px 24px 24px; }
.ai-history-list { display: grid; gap: 8px; }
.ai-history-item { display: grid; gap: 5px; width: 100%; min-width: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); text-align: left; }
.ai-history-item:hover { border-color: var(--accent); background: var(--paper-deep); }
.ai-history-item.is-active { border-color: color-mix(in srgb, var(--accent) 58%, var(--line)); background: var(--row-active); box-shadow: inset 3px 0 var(--accent); }
.ai-history-item strong, .ai-history-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-history-item strong { font-size: 14px; font-weight: 600; }.ai-history-item small { color: var(--muted); font-size: 10px; }
.ai-history-empty { margin: 0; padding: 48px 12px; color: var(--muted); font-size: 12px; text-align: center; }
.field-label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; margin: 14px 0 10px; }
.field-label select { padding: 8px; font-size: 12px; }
.book-summary-context-percent-field { width: min(100%, 280px); }
.context-compact-threshold-field { width: min(100%, 280px); }
.book-summary-context-percent-field input, .context-compact-threshold-field input { min-height: 40px; padding: 8px 12px; font-size: 15px; font-family: var(--font-latin), monospace; }
.field-label textarea {
  width: 100%;
  min-height: 140px;
  padding: 12px 14px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  resize: vertical;
}
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.quick-actions button { border: 1px solid var(--line); background: transparent; border-radius: 3px; padding: 7px; color: var(--muted); font-size: 10px; }
.quick-actions button:hover { color: var(--ink); background: var(--paper-deep); }
.ai-feed { flex: 1; min-height: 0; overflow-y: auto; margin: 16px -5px; padding: 0 5px; }
.assistant-message, .user-message { position: relative; margin-bottom: 12px; padding: 12px 13px; border-radius: 5px; font-size: 12px; line-height: 1.55; }
.assistant-message { background: var(--paper-deep); }
.assistant-message.has-message-actions, .user-message.has-message-actions { margin-bottom: 42px; }
.user-message { margin-left: 24px; background: var(--accent); color: #fff; }
.assistant-message > .message-heading, .user-message > .message-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 5px; opacity: .65; font-size: 9px; }
.message-heading > span { letter-spacing: .12em; }.message-heading time { flex: 0 0 auto; font-variant-numeric: tabular-nums; letter-spacing: .03em; }
.message-body { min-width: 0; overflow-wrap: anywhere; }
.message-card-actions { position: absolute; right: 0; bottom: -31px; display: flex; align-items: center; gap: 12px; height: 24px; }
.message-card-actions button { display: inline-flex; align-items: center; gap: 4px; min-width: 0; padding: 3px 2px; border: 0; background: transparent; color: var(--muted); font-size: 9px; }
.message-card-actions button:hover, .message-card-actions button:focus-visible { color: var(--accent-dark); }
.message-action-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.message-body > :first-child { margin-top: 0; }.message-body > :last-child { margin-bottom: 0; }
.message-body p { margin: 0 0 10px; white-space: normal; }
.message-body h1, .message-body h2, .message-body h3, .message-body h4 { margin: 14px 0 7px; color: inherit; line-height: 1.35; }
.message-body h1 { font-size: 17px; }.message-body h2 { font-size: 15px; }.message-body h3, .message-body h4 { font-size: 13px; }
.message-body ul, .message-body ol { margin: 7px 0 11px; padding-left: 21px; }.message-body li { margin: 4px 0; }
.message-body li.markdown-depth-1 { margin-left: 14px; }.message-body li.markdown-depth-2 { margin-left: 28px; }.message-body li.markdown-depth-3 { margin-left: 42px; }
.message-body blockquote { margin: 9px 0; padding: 6px 9px; border-left: 3px solid currentColor; background: rgba(255,255,255,.35); opacity: .82; }
.message-body pre { max-width: 100%; overflow-x: auto; margin: 9px 0; padding: 9px 10px; border-radius: 4px; background: #292724; color: #f6f1e7; font: 10px/1.55 var(--font-latin), monospace; white-space: pre; }
.message-body code { padding: 1px 4px; border-radius: 3px; background: rgba(49,42,32,.1); font-family: var(--font-latin), monospace; font-size: .9em; }.message-body pre code { padding: 0; background: transparent; color: inherit; }
.message-body .markdown-table-scroll { max-width: 100%; overflow-x: auto; margin: 9px 0; border: 1px solid var(--line); border-radius: 4px; overscroll-behavior-inline: contain; scrollbar-color: var(--muted) var(--surface-soft); scrollbar-gutter: stable; scrollbar-width: thin; }
.message-body .markdown-table-scroll::-webkit-scrollbar { height: 8px; }.message-body .markdown-table-scroll::-webkit-scrollbar-track { background: var(--surface-soft); }.message-body .markdown-table-scroll::-webkit-scrollbar-thumb { border-radius: 4px; background: var(--muted); }
.message-body .markdown-table-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.message-body .markdown-table-scroll table { width: max-content; min-width: 100%; border-collapse: collapse; }
.message-body .markdown-table-scroll th, .message-body .markdown-table-scroll td { padding: 7px 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow-wrap: normal; white-space: nowrap; }
.message-body .markdown-table-scroll th:last-child, .message-body .markdown-table-scroll td:last-child { border-right: 0; }
.message-body .markdown-table-scroll tbody tr:last-child td { border-bottom: 0; }
.message-body .markdown-table-scroll th { background: var(--surface-soft); font-weight: 600; }
.message-body .markdown-table-scroll .markdown-align-left { text-align: left; }.message-body .markdown-table-scroll .markdown-align-center { text-align: center; }.message-body .markdown-table-scroll .markdown-align-right { text-align: right; }
.message-body a { color: var(--accent-dark); text-decoration: underline; text-underline-offset: 2px; }.user-message .message-body a { color: inherit; }
.message-body hr { margin: 12px 0; border: 0; border-top: 1px solid currentColor; opacity: .22; }
.message-meta { margin-top: 8px; color: var(--muted); font-size: 9px; }
.ai-process-details { margin: 0 0 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: color-mix(in srgb, var(--surface-soft) 82%, transparent); }
.ai-process-details > summary { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 8px 10px; color: var(--muted); cursor: pointer; font-size: 10px; list-style: none; }
.ai-process-details > summary::-webkit-details-marker { display: none; }
.ai-process-details > summary::before { content: ""; width: 6px; height: 6px; flex: 0 0 auto; border: 1px solid currentColor; border-radius: 50%; }
.is-streaming .ai-process-details[open] > summary::before { background: var(--accent); animation: ai-process-pulse 1.2s ease-in-out infinite; }
.ai-process-details > summary > span { flex: 1 1 auto; color: var(--ink); font-weight: 600; }
.ai-process-details > summary > small { flex: 0 0 auto; font: 9px/1.4 var(--font-latin), monospace; }
.ai-process-details[open] > summary { border-bottom: 1px solid var(--line); }
.ai-process-list { display: grid; gap: 7px; padding: 9px; }
.ai-process-step { display: grid; min-width: 0; gap: 5px; }
.ai-process-step > small { color: var(--muted); font: 8px/1.4 var(--font-latin), monospace; }
.ai-process-step-body { max-height: 220px; overflow: auto; padding: 8px 9px; border-left: 2px solid color-mix(in srgb, var(--accent) 46%, var(--line)); background: var(--paper-deep); color: var(--muted); font-size: 10px; }
.ai-process-intermediate-step .ai-process-step-body { border-left-color: var(--muted); }
.ai-process-tool-step { padding-top: 1px; }
@keyframes ai-process-pulse { 0%, 100% { opacity: .45; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { .is-streaming .ai-process-details[open] > summary::before { animation: none; } }
.ai-tool-call-list { display: grid; gap: 5px; margin-top: 10px; }
.ai-tool-call-summary { display: flex; align-items: center; justify-content: space-between; width: 100%; min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); color: var(--muted); font: 9px/1.4 var(--font-latin), monospace; text-align: left; }
.ai-tool-call-summary::after { content: "查看详情"; flex: 0 0 auto; margin-left: 8px; color: var(--accent-dark); }
.ai-tool-call-summary:hover, .ai-tool-call-summary:focus-visible { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--surface); color: var(--ink); }
.ai-tool-call-summary.is-failed { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); color: var(--accent-dark); }
.ai-tool-call-dialog { width: min(720px, 92vw); }
.ai-tool-call-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 18px 24px 24px; }
.ai-tool-call-info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); }
.ai-tool-call-info > div { min-width: 0; }
.ai-tool-call-info dt { margin-bottom: 4px; color: var(--muted); font-size: 9px; }
.ai-tool-call-info dd { min-width: 0; margin: 0; color: var(--ink); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.ai-tool-call-info code, .ai-tool-call-info time { font-family: var(--font-latin), monospace; }
.ai-tool-call-description { grid-column: 1 / -1; }
.ai-tool-call-detail section { min-width: 0; }
.ai-tool-call-detail h3 { margin: 0 0 7px; color: var(--muted); font-size: 10px; font-weight: 600; }
.ai-tool-call-detail pre { min-height: 120px; max-height: 32vh; overflow: auto; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--paper-deep); color: var(--ink); font: 10px/1.55 var(--font-latin), monospace; white-space: pre-wrap; word-break: break-word; }
.ai-tool-call-detail section:last-child pre { min-height: 180px; }
@media (max-width: 680px) { .ai-tool-call-info { grid-template-columns: minmax(0, 1fr); }.ai-tool-call-description { grid-column: auto; }.ai-tool-call-detail pre { min-height: 100px; max-height: 26vh; }.ai-tool-call-detail section:last-child pre { min-height: 140px; } }
.guard-card { margin-top: 10px; padding: 9px 10px; border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 4px; background: var(--surface-soft); }
.guard-card.warning { border-left-color: #c07b31; }.guard-card.failed { border-left-color: var(--accent); }
.guard-card strong { display: block; margin-bottom: 5px; font-size: 10px; }.guard-card p { margin: 4px 0; color: var(--muted); font-size: 9px; line-height: 1.45; }.guard-card p b { color: var(--ink); }
.message-actions { display: flex; gap: 7px; margin-top: 10px; }
.message-actions button { border: 1px solid rgba(139,61,44,.25); background: var(--surface); color: var(--accent-dark); font-size: 10px; padding: 5px 8px; border-radius: 3px; }
.prompt-box { border-top: 1px solid var(--line); padding-top: 12px; }
.ai-context-warning { display: grid; gap: 9px; margin-bottom: 9px; padding: 10px; border: 1px solid color-mix(in srgb, #bf6a35 58%, var(--line)); border-radius: 5px; background: color-mix(in srgb, #bf6a35 10%, var(--surface)); }
.ai-context-warning.hidden { display: none; }
.ai-context-warning strong { display: block; color: var(--ink); font-size: 11px; }
.ai-context-warning p { margin: 3px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.ai-context-warning > div:last-child { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-context-warning button { padding: 5px 7px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 9px; }
.ai-context-warning button:first-child { border-color: var(--accent); background: var(--accent); color: #fff; }
.ai-context-warning button:hover, .ai-context-warning button:focus-visible { border-color: var(--accent); color: var(--accent-dark); }
.ai-context-warning button:first-child:hover, .ai-context-warning button:first-child:focus-visible { background: var(--accent-dark); color: #fff; }
.prompt-options { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 7px; }
.prompt-options select { padding: 6px; color: var(--muted); font-size: 10px; }
.prompt-model-field { margin: 0 0 7px; }
.prompt-model-field select { padding: 6px; color: var(--muted); font-size: 10px; }
.prompt-composer { position: relative; }
.ai-mention-menu { position: absolute; z-index: 20; left: 0; right: 0; bottom: calc(100% + 6px); max-height: 230px; overflow-y: auto; padding: 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: 0 12px 34px rgba(49,42,32,.18); }
.ai-mention-option { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 4px; background: transparent; text-align: left; }
.ai-mention-option:hover, .ai-mention-option:focus-visible { background: var(--paper-deep); }
.ai-mention-option small { color: var(--accent); font-size: 8px; }
.ai-mention-option strong { overflow: hidden; font-size: 10px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.ai-mention-empty { margin: 0; padding: 10px; color: var(--muted); font-size: 10px; text-align: center; }
.ai-prompt { display: block; width: 100%; min-height: 104px; margin: 0; padding: 10px 10px 44px; overflow-y: auto; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink); font-size: 12px; line-height: 1.45; white-space: pre-wrap; word-break: break-word; cursor: text; }
.ai-prompt:empty::before { color: var(--muted); content: attr(data-placeholder); pointer-events: none; }
.ai-prompt:focus { border-color: #a77768; box-shadow: 0 0 0 3px rgba(167,119,104,.12); outline: 0; }
.ai-prompt-reference { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; margin: 0 2px; padding: 2px 4px 2px 7px; border: 1px solid color-mix(in srgb, var(--accent) 48%, var(--line)); border-radius: 999px; background: color-mix(in srgb, var(--accent) 13%, var(--paper)); color: var(--accent-dark); font-size: 10px; line-height: 1.25; vertical-align: baseline; }
.ai-prompt-reference > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-prompt-reference button { width: 16px; height: 16px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; font: 14px/1 var(--font-latin), monospace; }
.ai-prompt-reference button:hover, .ai-prompt-reference button:focus-visible { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.prompt-composer-actions { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; align-items: center; }
.ai-context-meter { --context-usage: 0; --context-meter-color: var(--green); position: relative; display: grid; flex: 0 0 32px; place-items: center; width: 32px; height: 32px; overflow: visible; border: 0; border-radius: 50%; background: conic-gradient(var(--context-meter-color) calc(var(--context-usage) * 1%), rgba(143,132,116,.2) 0); color: var(--ink); font-family: var(--font-latin); line-height: 1; }
.ai-context-meter::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 1px rgba(143,132,116,.12); }
.ai-context-meter::after { content: attr(data-tooltip); position: absolute; z-index: 30; right: 0; bottom: calc(100% + 8px); width: max-content; max-width: 220px; padding: 6px 8px; border: 1px solid rgba(255,255,255,.1); border-radius: 4px; background: #292724; color: #fff; font: 10px/1.35 var(--font-latin), monospace; white-space: nowrap; box-shadow: 0 6px 18px rgba(49,42,32,.25); opacity: 0; pointer-events: none; transform: translateY(3px); transition: opacity .12s ease, transform .12s ease; }
.ai-context-meter:hover::after, .ai-context-meter:focus-visible::after { opacity: 1; transform: translateY(0); }
.ai-context-meter b { position: relative; z-index: 1; font-size: 9px; font-weight: 600; }.ai-context-meter.is-warning { --context-meter-color: #bf6a35; }.ai-context-meter.is-danger { --context-meter-color: #ad463c; }.ai-context-meter.is-empty { opacity: .62; }
.ai-send-button { min-width: 54px; height: 32px; padding: 0 11px; border: 0; border-radius: 4px; background: var(--accent); color: #fff; font-size: 10px; font-weight: 600; box-shadow: 0 4px 12px rgba(139,61,44,.2); }
.ai-send-button:hover { background: var(--accent-dark); }.ai-send-button:disabled { cursor: wait; opacity: .62; }
.ai-citations { display: grid; gap: 6px; max-height: 190px; overflow-y: auto; margin-bottom: 8px; }
.ai-citation-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; border: 1px solid var(--line); border-radius: 5px; background: var(--paper); overflow: hidden; }
.ai-citation-main { min-width: 0; padding: 8px 9px; border: 0; background: transparent; text-align: left; }
.ai-citation-main strong, .ai-citation-main small, .ai-citation-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-citation-main strong { font-size: 10px; }.ai-citation-main small { margin-top: 2px; color: var(--accent); font-size: 8px; }.ai-citation-main span { margin-top: 4px; color: var(--muted); font-size: 9px; }
.ai-citation-remove { width: 30px; border: 0; border-left: 1px solid var(--line); background: transparent; color: var(--muted); }
.ai-citation-card pre { display: none; grid-column: 1 / -1; max-height: 160px; overflow: auto; margin: 0; padding: 9px; border-top: 1px solid var(--line); background: var(--surface); font: 10px/1.55 var(--font-cjk), sans-serif; white-space: pre-wrap; }
.ai-citation-card.is-expanded pre { display: block; }
.message-citations { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }.message-citations span { padding: 3px 6px; border: 1px solid currentColor; border-radius: 10px; font-size: 8px; opacity: .75; }

.toast-region { position: fixed; inset: auto 24px 24px auto; z-index: 2147483647; display: grid; max-width: calc(100vw - 48px); margin: 0; padding: 0; gap: 8px; overflow: visible; border: 0; background: transparent; color: inherit; pointer-events: none; }
.toast-region[data-position="top-right"] { top: 78px; bottom: auto; }
.toast-region[data-position="bottom-right"] { top: auto; bottom: 24px; }
.toast { max-width: 360px; background: var(--toast-bg); color: var(--toast-fg); padding: 11px 15px; border-radius: 4px; box-shadow: var(--shadow); font-size: 12px; animation: toast-appear-top .18s ease; }
.toast-region[data-position="bottom-right"] .toast { animation-name: toast-appear-bottom; }
.toast.error { background: var(--toast-error-bg); color: var(--toast-error-fg); }
.chapter-type-menu { position: fixed; z-index: 80; width: 176px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: 0 14px 38px rgba(49,42,32,.22); }
.chapter-type-menu strong { display: block; overflow: hidden; margin: 0 2px 8px; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.chapter-type-menu > div { display: grid; gap: 3px; }
.chapter-type-menu button { border: 0; border-radius: 3px; padding: 7px 8px; background: transparent; text-align: left; font-size: 11px; }
.chapter-type-menu button:hover, .chapter-type-menu button.active { background: var(--paper-deep); color: var(--accent-dark); }
.line-citation-menu { position: fixed; z-index: 82; display: grid; min-width: 230px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); box-shadow: 0 14px 38px rgba(49,42,32,.22); }
.line-citation-menu strong { padding: 5px 7px 8px; color: var(--muted); font-size: 9px; }
.line-citation-menu button { border: 0; border-radius: 4px; padding: 8px; background: transparent; text-align: left; font-size: 11px; }.line-citation-menu button:hover { background: var(--paper-deep); color: var(--accent-dark); }
@keyframes toast-appear-top { from { opacity: 0; transform: translateY(-7px); } }
@keyframes toast-appear-bottom { from { opacity: 0; transform: translateY(7px); } }

.dialog { width: min(570px, 92vw); max-height: 88vh; border: 1px solid var(--line); border-radius: 5px; padding: 0; background: var(--panel); box-shadow: var(--shadow); }
.wide-dialog { width: min(800px, 92vw); }
.dialog::backdrop { background: rgba(34,30,25,.42); backdrop-filter: blur(3px); }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 23px; font-weight: 500; }
.dialog-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 21px;
  line-height: 1;
}
.dialog-close:hover, .dialog-close:focus-visible {
  border-color: var(--line);
  background: var(--paper-deep);
  color: var(--accent-dark);
  outline: none;
}
.dialog-fields { display: grid; gap: 14px; padding: 22px 24px; max-height: 58vh; overflow-y: auto; }
.dialog-fields label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.dialog-fields input, .dialog-fields textarea, .dialog-fields select { width: 100%; padding: 9px 10px; font-size: 13px; }
.dialog-fields textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.form-field { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.item-list-rows { display: grid; gap: 7px; }
.item-list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.item-list-row button, .item-list-add { border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--muted); font-size: 10px; }
.item-list-row button { padding: 0 10px; }
.item-list-add { justify-self: start; padding: 7px 11px; }
.keyword-chip-field > small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.keyword-chip-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 42px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.keyword-chip-editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 14%, transparent); }
.keyword-chip-editor > input[data-keyword-input] { flex: 1 1 160px; width: auto; min-width: 140px; padding: 6px 3px; border: 0; background: transparent; color: var(--ink); outline: none; }
.keyword-chip-editor > input[data-keyword-input]:focus { border: 0; box-shadow: none; }
.keyword-chip { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 3px 5px 3px 10px; border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line)); border-radius: 16px; background: var(--paper-deep); color: var(--ink); font-size: 11px; line-height: 1.3; }
.keyword-chip button { display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 15px; line-height: 1; }
.keyword-chip button:hover, .keyword-chip button:focus-visible { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-dark); outline: none; }
.structured-list-field > small { color: var(--muted); font-size: 9px; line-height: 1.5; }
.structured-list-rows { display: grid; gap: 9px; }
.structured-list-row { display: grid; gap: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); }
.key-value-list-row { grid-template-columns: minmax(120px, .42fr) minmax(0, 1fr) auto; }
.section-list-row { grid-template-columns: minmax(0, 1fr) auto; }
.section-list-row textarea { grid-column: 1 / -1; min-height: 130px; }
.structured-list-row button { grid-column: -2 / -1; grid-row: 1; border: 1px solid var(--line); border-radius: 4px; padding: 0 10px; background: var(--panel); color: var(--muted); font-size: 10px; }
.character-identity { color: var(--ink) !important; font-weight: 600; }
.character-species { display: flex; align-items: center; gap: 7px; margin-top: 10px; color: var(--muted); font-size: 10px; }
.character-detail-list { display: grid; gap: 5px; margin: 12px 0; }
.character-detail-list div { display: grid; grid-template-columns: minmax(70px, .42fr) minmax(0, 1fr); gap: 8px; font-size: 10px; }
.character-detail-list dt { color: var(--muted); }
.character-detail-list dd { margin: 0; overflow-wrap: anywhere; }
.character-summary { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 4; white-space: normal !important; }
.character-section-count { display: block; margin-top: 8px; color: var(--accent-dark); }
.chip-picker { display: flex; flex-wrap: wrap; gap: 7px; max-height: 190px; overflow-y: auto; padding: 9px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-soft); }
.dialog-fields .member-chip { position: relative; display: inline-flex !important; width: auto; cursor: pointer; }
.member-chip input { position: absolute; width: 1px !important; height: 1px; opacity: 0; }
.member-chip span { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--muted); font-size: 10px; transition: background .14s ease, border-color .14s ease, color .14s ease; }
.member-chip input:checked + span { border-color: var(--accent); background: var(--accent); color: #fff; }
.member-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.checkbox-field { display: flex !important; align-items: center; grid-template-columns: 18px 1fr; }
.checkbox-field input { width: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px 20px; }
.dialog-actions .reset-button { margin-right: auto; }
.character-editor-dialog { width: min(1180px, 96vw); height: min(820px, 94vh); max-width: none; max-height: none; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.character-editor-dialog::backdrop { background: rgba(34,30,25,.48); backdrop-filter: blur(3px); }
.character-editor-dialog > form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: 100%; height: 100%; }
.character-editor-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px 16px; border-bottom: 1px solid var(--line); }
.character-editor-header h2, .character-editor-header h3 { margin: 0; }
.character-editor-title-row { display: flex; align-items: center; gap: 10px; margin-top: 3px; }
.character-editor-title-row h2 { font-size: 24px; font-weight: 600; }
.character-version-badge { display: inline-flex; align-items: center; min-height: 22px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper-deep); color: var(--accent-dark); font: 10px/1 var(--font-latin), monospace; }
.character-editor-header-actions { display: flex; align-items: center; gap: 8px; }
.character-editor-header-actions .ghost-button { min-height: 34px; }
.character-editor-header-actions .ghost-button:disabled { cursor: not-allowed; opacity: .46; }
.character-editor-workspace { display: grid; grid-template-columns: 190px minmax(0, 1fr); min-height: 0; }
.character-editor-workspace.history-open { grid-template-columns: 180px minmax(0, 1fr) 320px; }
.character-editor-nav { display: flex; min-width: 0; flex-direction: column; gap: 5px; padding: 18px 12px; border-right: 1px solid var(--line); background: var(--surface-soft); }
.character-editor-nav button { display: grid; gap: 3px; width: 100%; padding: 11px 12px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); text-align: left; font-size: 12px; }
.character-editor-nav button small { overflow: hidden; color: var(--muted); font-size: 9px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.character-editor-nav button:hover { background: var(--paper-deep); color: var(--ink); }
.character-editor-nav button[aria-selected="true"] { background: var(--row-active); color: var(--accent-dark); font-weight: 600; box-shadow: inset 3px 0 var(--accent); }
.character-editor-fields { min-width: 0; overflow-y: auto; padding: 24px clamp(20px, 3vw, 38px) 32px; }
.character-editor-section { display: grid; gap: 22px; }
.character-editor-section > header { display: flex; align-items: end; justify-content: space-between; gap: 24px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.character-editor-section > header h3 { margin: 2px 0 0; font-size: 21px; }
.character-editor-section > header p { max-width: 430px; margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; text-align: right; }
.character-editor-section-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 20px; }
.character-editor-section-fields > label, .character-editor-section-fields > .form-field { display: grid; align-content: start; gap: 7px; color: var(--muted); font-size: 11px; }
.character-editor-section-fields > label:has(textarea), .character-editor-section-fields > .structured-list-field, .character-editor-section-fields > .chip-field, .character-editor-field-help { grid-column: 1 / -1; }
.character-editor-section-fields input, .character-editor-section-fields textarea, .character-editor-section-fields select { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font-size: 13px; }
.character-editor-section-fields textarea { min-height: 120px; resize: vertical; line-height: 1.65; }
.character-editor-section-fields .section-list-row textarea { min-height: 180px; }
.character-editor-section-fields .member-chip { position: relative; display: inline-flex; width: auto; cursor: pointer; }
.character-editor-section-fields .item-list-row button, .character-editor-section-fields .structured-list-row button { min-width: 54px; }
.character-editor-relationships-field { display: grid; grid-column: 1 / -1; gap: 12px; }
.character-relationship-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.character-relationship-toolbar p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.character-relationship-toolbar .ghost-button { flex: 0 0 auto; min-height: 32px; }
.character-relationship-row { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); }
.character-relationship-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.character-relationship-heading > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; min-width: 0; }
.character-relationship-heading strong { font-size: 14px; }
.character-relationship-heading span { color: var(--muted); font-size: 10px; }
.character-relationship-heading button { flex: 0 0 auto; padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-size: 10px; }
.character-relationship-heading button:hover { border-color: var(--accent); color: var(--accent-dark); }
.character-relationship-keywords { display: grid; gap: 6px; }
.character-relationship-keywords > small { color: var(--muted); font-size: 9px; }
.character-relationship-keywords > div { display: flex; flex-wrap: wrap; gap: 5px; }
.character-relationship-empty-keywords, .character-relationship-status { color: var(--muted); font-size: 10px; }
.character-relationship-status { margin: 0; padding: 18px 12px; border: 1px dashed var(--line); border-radius: 4px; text-align: center; }
.character-editor-empty-field { display: grid; align-content: start; gap: 7px; color: var(--muted); font-size: 11px; }
.character-editor-empty-field span { padding: 11px; border: 1px dashed var(--line); border-radius: 4px; font-size: 10px; }
.character-editor-field-help { margin: -8px 0 0; color: var(--muted); font-size: 9px; }
.character-history-panel { min-width: 0; overflow-y: auto; border-left: 1px solid var(--line); background: var(--surface-soft); }
.character-history-heading { position: sticky; z-index: 2; top: 0; display: flex; align-items: flex-start; justify-content: space-between; padding: 18px 16px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.character-history-heading h3 { margin: 2px 0 0; font-size: 16px; }
.character-history-heading button { width: 28px; height: 28px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 20px; }
.character-history-list { display: grid; gap: 10px; padding: 12px; }
.character-history-empty { margin: 0; padding: 22px 10px; color: var(--muted); font-size: 10px; text-align: center; }
.character-version-card { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel); }
.character-version-card.is-current { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: inset 3px 0 var(--accent); }
.character-version-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.character-version-card-heading > div { display: flex; align-items: center; gap: 6px; }
.character-version-card-heading strong { color: var(--accent-dark); font-size: 13px; }
.character-version-card-heading span, .character-version-card-heading time { color: var(--muted); font-size: 8px; }
.character-version-card p { margin: 0; color: var(--ink); font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.character-version-changes { display: flex; flex-wrap: wrap; gap: 4px; }
.character-version-changes span { padding: 2px 6px; border-radius: 10px; background: var(--paper-deep); color: var(--muted); font-size: 8px; }
.character-version-card > button { justify-self: end; padding: 6px 8px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-size: 9px; }
.character-version-card > button:not(:disabled):hover { border-color: var(--accent); color: var(--accent-dark); }
.character-version-card > button.is-confirming { border-color: var(--accent); background: var(--accent); color: #fff; }
.character-version-card > button:disabled { cursor: default; opacity: .68; }
.character-editor-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 22px; padding: 14px 22px 18px; border-top: 1px solid var(--line); background: var(--panel); }
.character-editor-actions > label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.character-editor-actions input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font-size: 12px; }
.character-editor-actions > div { display: flex; gap: 8px; }
.character-editor-actions button { min-height: 36px; }
.appearance-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 22px 24px; }
.appearance-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
.appearance-grid select { width: 100%; padding: 9px 10px; font-size: 13px; }
.font-preview { grid-column: 1 / -1; padding: 16px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.font-preview strong, .font-preview span { display: block; }
.font-preview strong { margin-bottom: 8px; font-size: 17px; }
.font-preview span { color: var(--muted); }
.font-preview span + span { margin-top: .55em; }
.versions-list { padding: 18px 24px 28px; max-height: 65vh; overflow: auto; }
.version-row { display: grid; grid-template-columns: 75px 1fr auto; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); align-items: start; }
.version-row p { margin: 0; color: var(--muted); font-size: 11px; white-space: pre-wrap; max-height: 70px; overflow: hidden; }
.entity-history-list { display: grid; gap: 10px; padding: 18px 24px 28px; max-height: 65vh; overflow: auto; }
.entity-version-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 18px; padding: 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); }
.entity-version-card.is-current { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: inset 3px 0 var(--accent); }
.entity-version-card header { display: flex; align-items: center; gap: 8px; min-width: 0; }
.entity-version-card header strong { color: var(--accent-dark); font-size: 13px; }
.entity-version-card header span, .entity-version-card time { color: var(--muted); font-size: 9px; }
.entity-version-card time { justify-self: end; }
.entity-version-card p { grid-column: 1 / -1; margin: 0; color: var(--ink); font-size: 11px; line-height: 1.55; overflow-wrap: anywhere; }
.entity-version-card small { align-self: center; color: var(--muted); font-size: 9px; }
.entity-version-card > button { justify-self: end; padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-size: 9px; }
.entity-version-card > button:not(:disabled):hover { border-color: var(--accent); color: var(--accent-dark); }
.entity-version-card > button.is-confirming { border-color: var(--accent); background: var(--accent); color: #fff; }
.entity-version-card > button:disabled { cursor: default; opacity: .68; }
.entity-history-empty { margin: 0; padding: 28px 12px; color: var(--muted); font-size: 11px; text-align: center; }
.relationship-table .relationship-actions { white-space: nowrap; }
.relationship-table .relationship-actions button + button { margin-left: 5px; }

@media (max-width: 540px) {
  .member-invite-form { grid-template-columns: minmax(0, 1fr); }
  .onboarding-popover { width: calc(100vw - 24px); }
  .onboarding-popover-header { padding-inline: 15px; }
  .onboarding-popover-body { padding: 16px 17px 18px; }
  .onboarding-popover-body h2 { font-size: 19px; }
  .onboarding-popover-footer { padding-inline: 15px; }
}

@media (max-width: 1100px) {
  .left-panel { padding-inline: 10px; }
  .ai-panel { padding-inline: 14px; }
  .editor-toolbar { grid-template-areas: "path" "title" "actions"; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-inline: 6%; }
  .editor-actions { justify-content: flex-end; flex-wrap: wrap; }
  .outline-row { grid-template-columns: 1fr 1fr; }.outline-actions { justify-items: start; }
  .character-editor-workspace, .character-editor-workspace.history-open { grid-template-columns: 150px minmax(0, 1fr); }
  .character-editor-workspace.history-open .character-history-panel { position: absolute; z-index: 3; top: 0; right: 0; bottom: 0; width: min(340px, 44vw); box-shadow: -12px 0 32px rgba(49,42,32,.16); }
  .character-editor-workspace { position: relative; }
}

@media (max-width: 850px) {
  .top-actions .ghost-button:not(.settings-button) { display: none; }
  .book-shelf { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
  .settings-hub-grid { grid-template-columns: 1fr; }
  .character-editor-dialog { width: 98vw; height: 96vh; }
  .character-editor-workspace, .character-editor-workspace.history-open { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .character-editor-nav { flex-direction: row; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .character-editor-nav button { flex: 0 0 130px; }
  .character-editor-nav button[aria-selected="true"] { box-shadow: inset 0 -3px var(--accent); }
  .character-editor-section-fields { grid-template-columns: minmax(0, 1fr); }
  .character-editor-section-fields > label, .character-editor-section-fields > .form-field, .character-editor-field-help { grid-column: 1; }
  .character-editor-section > header { align-items: flex-start; flex-direction: column; gap: 7px; }
  .character-editor-section > header p { text-align: left; }
  .character-editor-actions { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .character-editor-actions > div { justify-content: flex-end; }
  .character-editor-workspace.history-open .character-history-panel { width: min(360px, 86vw); }
}

@media (max-width: 640px) {
  .ai-history-dialog-body { min-height: min(360px, 62vh); padding: 12px 14px 18px; }
  .account-settings-body { padding: 16px; }
  .account-settings-section { padding: 15px; }
  .account-settings-form, .password-settings-form, .api-key-settings, .api-key-result { grid-template-columns: minmax(0, 1fr); }
  .avatar-settings { grid-template-columns: 64px minmax(0, 1fr); }
  .profile-avatar-preview { width: 64px; height: 64px; }
  .account-settings-form .primary-button { width: 100%; }
}

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