:root {
  font-family: Inter, "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  color: #edf3f7;
  background: #07131c;
  font-synthesis: none;
  --surface: rgba(14, 33, 46, 0.86);
  --surface-strong: #102838;
  --line: rgba(151, 186, 202, 0.18);
  --muted: #9fb0bb;
  --gold: #d8ad59;
  --gold-bright: #f1c86e;
  --green: #6fd6a3;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 82% -10%, rgba(48, 112, 125, 0.2), transparent 36%),
    radial-gradient(circle at 8% 16%, rgba(184, 126, 41, 0.09), transparent 30%),
    linear-gradient(145deg, #07131c 0%, #091a26 55%, #07131c 100%);
}

button, select, input, textarea { font: inherit; }
button, select { cursor: pointer; }

.app-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 96px; }

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.compact-button { padding: 9px 12px; font-size: 12px; }

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  border: 1px solid rgba(216, 173, 89, 0.6); border-radius: 13px;
  background: linear-gradient(145deg, rgba(216, 173, 89, 0.18), rgba(216, 173, 89, 0.03));
  color: var(--gold-bright); font-family: Georgia, serif; font-size: 22px;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 12px; }

.compact-field { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
select, input, textarea {
  border: 1px solid var(--line); border-radius: 11px; color: #edf3f7;
  background: rgba(5, 17, 25, 0.78); outline: none;
}
select { padding: 9px 32px 9px 12px; }
input, textarea { padding: 11px 13px; }
select:focus, input:focus, textarea:focus { border-color: rgba(216, 173, 89, 0.66); box-shadow: 0 0 0 3px rgba(216, 173, 89, 0.09); }

.hero-card, .panel, .advanced-panel, .library-panel {
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.hero-card {
  min-height: 310px; padding: clamp(30px, 6vw, 70px); border-radius: 28px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 40px;
  overflow: hidden; position: relative;
}
.hero-card::after {
  content: ""; position: absolute; width: 340px; height: 340px; right: -80px; top: -120px;
  border-radius: 50%; border: 1px solid rgba(216, 173, 89, 0.12);
  box-shadow: 0 0 0 48px rgba(216, 173, 89, 0.025), 0 0 0 96px rgba(216, 173, 89, 0.018);
  pointer-events: none;
}
.status-pill { display: inline-flex; padding: 7px 11px; border: 1px solid rgba(111, 214, 163, 0.3); border-radius: 999px; color: var(--green); font-size: 12px; }
.status-pill.offline { color: #ef9a91; border-color: rgba(239, 154, 145, 0.3); }
h1 { max-width: 740px; margin: 23px 0 15px; font-family: Georgia, "Songti SC", serif; font-size: clamp(36px, 5vw, 66px); line-height: 1.08; font-weight: 500; letter-spacing: -0.03em; }
.hero-card p { max-width: 700px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.85; }
.hero-actions { min-width: 180px; position: relative; z-index: 1; }
.action-note { display: block; margin-top: 10px; color: var(--muted); font-size: 12px; text-align: center; }

button { border: 0; border-radius: 11px; transition: transform 150ms ease, border-color 150ms ease, background 150ms ease; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.48; }
.primary { padding: 12px 18px; color: #211807; background: linear-gradient(135deg, var(--gold-bright), var(--gold)); font-weight: 700; }
.secondary, .voice-button { padding: 11px 15px; color: #e8eff2; background: rgba(20, 48, 64, 0.8); border: 1px solid var(--line); }
.voice-button { display: inline-flex; gap: 8px; align-items: center; }
.voice-button > span:first-child { color: #e8756c; filter: drop-shadow(0 0 6px rgba(232, 117, 108, 0.6)); }

.dashboard-grid { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 18px; margin-top: 18px; }
.library-panel { margin-top: 18px; padding: 28px; border-radius: 22px; }
.library-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.library-heading h2 { margin: 6px 0 8px; font-size: 27px; }
.library-heading p:not(.eyebrow) { max-width: 700px; margin: 0; color: var(--muted); line-height: 1.65; }
.count-badge {
  min-width: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--gold-bright); background: rgba(216, 173, 89, 0.07); text-align: center;
  font-variant-numeric: tabular-nums;
}
.library-toolbar { display: flex; gap: 12px; margin: 24px 0 18px; }
.search-field { flex: 1; }
.search-field input { width: 100%; }
.sort-field { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.book-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.book-card {
  min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px;
  background: rgba(7, 23, 33, 0.62);
}
.book-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.book-card h3 { min-width: 0; margin: 0; font-size: 17px; line-height: 1.45; overflow-wrap: anywhere; }
.book-card p {
  display: -webkit-box; margin: 12px 0 0; overflow: hidden; color: var(--muted);
  font-size: 13px; line-height: 1.65; -webkit-box-orient: vertical; -webkit-line-clamp: 3;
}
.book-card-meta { display: flex; flex-wrap: wrap; gap: 7px 12px; margin-top: 15px; color: #c9d5da; font-size: 12px; }
.book-card-meta span { white-space: nowrap; }
.book-card-actions { display: flex; justify-content: flex-end; margin-top: 15px; }
.book-card-actions button { width: 100%; }
.book-status {
  flex: none; padding: 4px 7px; border: 1px solid rgba(216, 173, 89, 0.28);
  border-radius: 999px; color: var(--gold-bright); font-size: 10px;
}
.heavy-fields { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.heavy-fields span { padding: 4px 7px; border-radius: 7px; color: #8fa4af; background: rgba(151, 186, 202, 0.07); font-size: 10px; }
.empty-library {
  display: flex; align-items: center; gap: 16px; padding: 22px; border: 1px dashed rgba(151, 186, 202, 0.25);
  border-radius: 16px; background: rgba(7, 23, 33, 0.38);
}
.empty-library[hidden] { display: none; }
.empty-library p { margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.empty-mark {
  flex: none; width: 44px; height: 52px; display: grid; place-items: center; border: 1px solid var(--line);
  border-radius: 8px 12px 12px 8px; color: var(--gold); background: rgba(216, 173, 89, 0.06);
  font-family: Georgia, serif;
}
.load-more { display: block; margin: 16px auto 0; }
.load-more[hidden] { display: none; }
.legacy-preview { margin-top: 22px; border: 1px solid var(--line); border-radius: 17px; overflow: hidden; }
.legacy-preview summary {
  display: flex; justify-content: space-between; align-items: center; gap: 18px;
  padding: 17px 19px; cursor: pointer; background: rgba(7, 23, 33, 0.52);
}
.legacy-preview summary::marker { color: var(--gold); }
.legacy-preview summary strong, .legacy-preview summary small { display: block; }
.legacy-preview summary small { margin-top: 4px; color: var(--muted); }
.safe-badge { padding: 6px 9px; border: 1px solid rgba(111, 214, 163, 0.26); border-radius: 999px; color: var(--green); font-size: 11px; white-space: nowrap; }
.legacy-content { padding: 18px; border-top: 1px solid var(--line); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.metric-grid div { padding: 14px; border-radius: 13px; background: rgba(5, 17, 25, 0.52); }
.metric-grid span, .metric-grid strong { display: block; }
.metric-grid span { color: var(--muted); font-size: 11px; }
.metric-grid strong { margin-top: 6px; color: #eff4f6; font-size: 18px; font-variant-numeric: tabular-nums; }
.legacy-note { margin-bottom: 14px; padding: 11px 13px; border-left: 3px solid var(--gold); color: #ced8dc; background: rgba(216, 173, 89, 0.06); font-size: 13px; line-height: 1.6; }
.legacy-note.success { border-left-color: var(--green); }
.legacy-note.error { border-left-color: #e8756c; }
.book-grid > .legacy-note { grid-column: 1 / -1; }
.import-session {
  margin-top: 18px; padding: 17px; border: 1px solid var(--line); border-radius: 15px;
  background: rgba(5, 17, 25, 0.58);
}
.import-session[hidden] { display: none; }
.import-session-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.import-session-heading strong { display: block; margin-top: 5px; font-size: 16px; }
.import-progress-track { height: 7px; margin: 16px 0 10px; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, 0.07); }
.import-progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), #8ce4c0); transition: width 240ms ease; }
.import-session > p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.validation-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 15px; }
.validation-grid[hidden] { display: none; }
.validation-grid div { min-width: 0; padding: 11px; border-radius: 11px; background: rgba(151, 186, 202, 0.06); }
.validation-grid span, .validation-grid strong { display: block; }
.validation-grid span { color: var(--muted); font-size: 10px; }
.validation-grid strong { margin-top: 5px; overflow: hidden; color: #e9f1f3; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.import-alert { margin-top: 13px; padding: 10px 12px; border-left: 3px solid var(--green); color: #d9e7e5; background: rgba(111, 214, 163, 0.07); font-size: 12px; line-height: 1.6; }
.import-alert[hidden] { display: none; }
.import-alert.error { border-left-color: #e8756c; background: rgba(232, 117, 108, 0.07); }
.migration-actions { display: flex; justify-content: space-between; align-items: center; gap: 22px; margin-top: 18px; }
.migration-actions p { max-width: 720px; margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.panel { border-radius: 20px; padding: 26px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.panel h2 { margin: 5px 0 0; font-size: 20px; }
.eyebrow { margin: 0; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.progress-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.progress-track { height: 5px; margin: 22px 0; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, 0.06); }
.progress-track span { display: block; width: 83.333%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--gold-bright)); }
.milestones { display: grid; gap: 11px; margin: 0; padding: 0; list-style: none; color: var(--muted); }
.milestones li { position: relative; padding-left: 24px; }
.milestones li::before { content: ""; position: absolute; left: 2px; top: 0.45em; width: 8px; height: 8px; border: 1px solid #657681; border-radius: 50%; }
.milestones li.done { color: #e6edef; }
.milestones li.done::before { border-color: var(--green); background: var(--green); box-shadow: 0 0 0 4px rgba(111, 214, 163, 0.08); }
.milestones li.active { color: var(--gold-bright); }
.milestones li.active::before { border-color: var(--gold); background: var(--gold); box-shadow: 0 0 0 4px rgba(216, 173, 89, 0.1); }

.story-kernel-dialog {
  width: min(1160px, calc(100vw - 28px)); max-height: min(900px, calc(100vh - 28px)); padding: 0;
  overflow: hidden; border: 1px solid var(--line); border-radius: 22px; color: var(--text);
  background: #081b27; box-shadow: 0 34px 100px rgba(0, 0, 0, 0.62);
}
.story-kernel-dialog.supervisor-docked { width: min(1540px, calc(100vw - 28px)); }
.story-kernel-dialog::backdrop { background: rgba(1, 8, 12, 0.76); backdrop-filter: blur(5px); }
.story-kernel-shell { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); max-height: min(900px, calc(100vh - 28px)); }
.story-kernel-shell > header {
  display: flex; justify-content: space-between; gap: 18px; padding: 22px 24px;
  border-bottom: 1px solid var(--line); background: rgba(13, 37, 50, 0.92);
}
.story-kernel-shell h2 { margin: 5px 0 4px; font-size: 23px; }
.story-kernel-shell header small { color: var(--muted); }
.workspace-header-actions { display: flex; align-items: center; gap: 8px; }
.story-kernel-shell .workspace-header-actions .secondary { width: auto; height: auto; padding: 8px 11px; font-size: 11px; }
.story-kernel-shell header #close-kernel { width: 36px; height: 36px; color: var(--muted); background: transparent; font-size: 26px; }
.story-kernel-content { overflow-y: auto; padding: 22px 24px 28px; }
.story-kernel-content:has(.book-workspace) { overflow: hidden; padding: 0; }
.workspace-frame {
  --supervisor-width: 380px;
  position: relative; min-width: 0; min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1fr); overflow: hidden;
}
.workspace-frame:has(.supervisor-drawer.docked.open) {
  grid-template-columns: minmax(0, 1fr) var(--supervisor-width);
}
.workspace-frame > .story-kernel-content { min-width: 0; min-height: 0; }
.workspace-supervisor-fab {
  position: absolute; z-index: 6; right: 18px; bottom: 18px; width: 46px; height: 46px;
  border: 1px solid rgba(216, 173, 89, 0.6); border-radius: 50%; color: var(--gold-bright);
  background: radial-gradient(circle at 35% 28%, #23485a, #0c2230 70%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.42), 0 0 0 5px rgba(216, 173, 89, 0.05);
  font-family: Georgia, serif; font-size: 18px;
}
.workspace-supervisor-fab[hidden] { display: none; }
.book-workspace {
  display: grid; grid-template-columns: 230px minmax(0, 1fr);
  height: min(760px, calc(100vh - 126px)); min-height: 560px;
}
.chapter-nav {
  min-width: 0; min-height: 0; overflow: hidden; border-right: 1px solid var(--line);
  display: grid; grid-template-rows: auto auto auto minmax(0, 1fr);
  background: rgba(5, 17, 25, 0.55);
}
.chapter-nav-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 16px; border-bottom: 1px solid var(--line);
}
.chapter-nav-header span {
  min-width: 28px; padding: 3px 7px; border-radius: 999px; color: var(--gold-bright);
  background: rgba(216, 173, 89, 0.08); text-align: center; font-size: 11px;
}
.chapter-nav-controls {
  display: grid; gap: 7px; padding: 10px 11px 7px;
}
.chapter-nav-controls select,
.chapter-nav-controls input {
  width: 100%; min-width: 0; padding: 8px 9px; font-size: 12px;
}
.chapter-nav-summary {
  min-height: 27px; padding: 3px 13px 8px; color: var(--muted); font-size: 11px;
  border-bottom: 1px solid rgba(117, 151, 168, 0.12);
}
.chapter-nav-list { min-height: 0; overflow-y: auto; padding: 9px; }
.chapter-nav-empty { margin: 10px 7px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.chapter-nav-item {
  width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: start;
  gap: 8px; padding: 11px 10px; color: #d8e2e6; background: transparent; text-align: left;
}
.chapter-nav-order { color: var(--muted); font-size: 11px; line-height: 1.6; }
.chapter-nav-item-body { min-width: 0; display: grid; gap: 2px; }
.chapter-nav-item-body strong { overflow-wrap: anywhere; font-size: 12px; line-height: 1.55; }
.chapter-nav-item-body small { color: var(--muted); font-size: 10px; line-height: 1.45; }
.chapter-nav-item:hover:not(:disabled) { background: rgba(151, 186, 202, 0.07); }
.chapter-nav-item.active {
  color: #fff5da; background: rgba(216, 173, 89, 0.12); box-shadow: inset 3px 0 var(--gold);
}
.prose-pane {
  min-width: 0; min-height: 0; display: grid;
  grid-template-rows: auto auto minmax(320px, 1fr) auto; gap: 12px; padding: 18px 20px 20px;
  overflow-y: auto;
}
.prose-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.prose-toolbar h3 { margin: 0 0 4px; font-size: 19px; }
.prose-toolbar small { color: var(--muted); }
.prose-search { display: flex; align-items: center; gap: 6px; }
.prose-search input { width: min(260px, 28vw); padding-top: 8px; padding-bottom: 8px; }
.prose-search > span { min-width: 36px; color: var(--muted); text-align: center; font-size: 11px; }
.prose-search button { width: 34px; height: 34px; padding: 0; }
.chapter-production-gate {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px;
  background: rgba(151, 186, 202, 0.045);
}
.chapter-production-gate > div { min-width: 0; }
.chapter-production-stack { display: grid; gap: 9px; }
.chapter-production-actions { display: flex; flex: none; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.chapter-production-gate strong, .chapter-production-gate small { display: block; }
.chapter-production-gate strong { color: #e2ebee; font-size: 12px; }
.chapter-production-gate small { margin-top: 4px; color: var(--muted); line-height: 1.5; }
.workflow-responsibility {
  display: inline-flex; margin-top: 7px; padding: 3px 7px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--muted); font-size: 10px; line-height: 1.25;
}
.workflow-responsibility.background-safe { border-color: rgba(80, 190, 139, 0.35); color: var(--green); }
.workflow-responsibility.human-required { border-color: rgba(226, 178, 87, 0.38); color: #e2b257; }
.workflow-responsibility.wait { color: var(--muted); }
.workflow-auto-receipt { display: block; margin-top: 0.35rem; color: var(--green); font-size: 0.76rem; }
.chapter-production-gate button { flex: none; padding: 8px 12px; font-size: 11px; }
.generation-button { color: #211807; background: linear-gradient(135deg, var(--gold-bright), var(--gold)); font-weight: 700; }
.chapter-production-gate.frozen { border-color: rgba(80, 190, 139, 0.36); background: rgba(80, 190, 139, 0.07); }
.chapter-production-gate.frozen strong { color: var(--green); }
.chapter-production-gate.blocked, .chapter-production-gate.error {
  border-color: rgba(218, 111, 86, 0.4); background: rgba(218, 111, 86, 0.07);
}
.chapter-production-gate.blocked strong, .chapter-production-gate.error strong { color: #f0a691; }
.model-candidate-preview { border: 1px solid rgba(216, 173, 89, 0.3); border-radius: 12px; background: rgba(216, 173, 89, 0.045); }
.model-candidate-preview > summary { padding: 10px 13px; color: var(--gold-bright); cursor: pointer; font-size: 12px; }
.model-candidate-preview > div { padding: 0 12px 12px; }
.model-candidate-preview p { margin: 0 0 8px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.model-candidate-preview textarea { width: 100%; min-height: 280px; resize: vertical; color: #e7e1d2; background: #071722; font-family: Georgia, "Songti SC", serif; line-height: 1.85; }
.chapter-prose-editor {
  width: 100%; height: 100%; min-height: 320px; resize: none; padding: clamp(18px, 3vw, 34px);
  border-radius: 15px; color: #e7e1d2; background: #081824;
  font-family: Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  font-size: clamp(16px, 1.5vw, 19px); line-height: 1.95;
}
.chapter-prose-editor:disabled { opacity: 0.65; }
.prose-footer { display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 11px; }
.prose-footer strong { flex: none; color: var(--green); font-weight: 600; }
.workspace-memory { min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: rgba(7, 23, 33, 0.5); }
.workspace-memory > summary { padding: 12px 14px; color: #cbd7dc; cursor: pointer; font-size: 12px; }
.workspace-memory-content { min-width: 0; max-height: 360px; overflow-y: auto; padding: 0 16px 18px; }
.entity-manager {
  min-width: 0; margin-top: 12px; border: 1px solid rgba(216, 173, 89, 0.2); border-radius: 12px;
  background: rgba(216, 173, 89, 0.035);
}
.entity-manager > summary { padding: 11px 13px; color: var(--gold-bright); cursor: pointer; font-size: 12px; }
.entity-manager-body { padding: 0 13px 14px; }
.entity-manager-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.entity-manager-toolbar strong, .entity-manager-toolbar small { display: block; }
.entity-manager-toolbar small { max-width: 520px; margin-top: 4px; color: var(--muted); line-height: 1.5; }
.entity-manager-toolbar > div:last-child { display: flex; flex: none; gap: 7px; }
.entity-manager-toolbar button { padding: 8px 10px; font-size: 11px; }
.entity-manager-status { margin: 11px 0; color: var(--green); font-size: 11px; line-height: 1.55; }
.entity-manager-list { display: grid; gap: 7px; }
.entity-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 11px; border-radius: 10px; background: rgba(151, 186, 202, 0.055);
}
.entity-row > div { min-width: 0; }
.entity-row-identity { display: flex; align-items: center; gap: 8px; }
.entity-row-identity span {
  flex: none; padding: 2px 6px; border-radius: 999px; color: var(--gold-bright);
  background: rgba(216, 173, 89, 0.09); font-size: 9px;
}
.entity-row small {
  display: block; margin-top: 3px; overflow: hidden; color: var(--muted);
  font-size: 10px; text-overflow: ellipsis; white-space: nowrap;
}
.entity-row button { flex: none; padding: 7px 9px; font-size: 10px; }
.entity-form { display: grid; gap: 11px; margin-top: 13px; padding: 14px; border-radius: 11px; background: rgba(5, 17, 25, 0.62); }
.entity-form[hidden] { display: none; }
.entity-form h4 { margin: 0; font-size: 14px; }
.entity-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.entity-form-grid label { display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.entity-form-grid input, .entity-form-grid select, .entity-form-grid textarea { width: 100%; padding: 8px 9px; font-size: 11px; resize: vertical; }
.entity-field-wide { grid-column: 1 / -1; }
.entity-form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.entity-form-actions button { padding: 8px 11px; font-size: 11px; }
.story-record-manager {
  min-width: 0; margin-top: 12px; border: 1px solid rgba(151, 186, 202, 0.2);
  border-radius: 12px; background: rgba(151, 186, 202, 0.035);
}
.story-record-manager > summary { padding: 11px 13px; color: #cbd7dc; cursor: pointer; font-size: 12px; }
.story-record-manager-body { min-width: 0; padding: 0 13px 14px; }
.story-record-manager-help { margin: 0 0 12px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.story-record-filters {
  display: grid; grid-template-columns: 150px minmax(180px, 1fr) 150px auto;
  align-items: end; gap: 8px;
}
.story-record-filters label { min-width: 0; display: grid; gap: 5px; color: var(--muted); font-size: 10px; }
.story-record-filters label[hidden] { display: none; }
.story-record-filters input, .story-record-filters select { width: 100%; min-width: 0; padding: 8px 9px; font-size: 11px; }
.story-record-filters > button { min-height: 34px; padding: 8px 11px; font-size: 11px; }
.story-record-status { min-height: 18px; margin: 11px 0; color: var(--green); font-size: 11px; line-height: 1.55; }
.story-record-list { min-width: 0; display: grid; gap: 8px; }
.story-record-empty { margin: 0; padding: 14px; border-radius: 10px; color: var(--muted); background: rgba(151, 186, 202, 0.05); }
.story-record-row { min-width: 0; padding: 12px; border-radius: 11px; background: rgba(151, 186, 202, 0.055); }
.story-record-row > strong { display: block; margin-top: 7px; font-size: 13px; }
.story-record-row > p { margin: 8px 0 0; color: #dce5e8; line-height: 1.7; overflow-wrap: anywhere; white-space: pre-wrap; }
.story-record-row > small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.story-record-row-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.story-record-row-header > div:first-child { min-width: 0; }
.story-record-row-header strong { display: block; margin-top: 7px; overflow-wrap: anywhere; font-size: 13px; }
.story-record-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.story-record-badges span { padding: 2px 6px; border-radius: 999px; color: var(--gold-bright); background: rgba(216, 173, 89, 0.09); font-size: 9px; }
.story-record-badges span.muted { color: #bed0d8; background: rgba(151, 186, 202, 0.08); }
.story-record-actions { flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.story-record-actions button { padding: 6px 8px; font-size: 9px; }
.story-record-evidence { margin-top: 9px; border-top: 1px solid var(--line); }
.story-record-evidence > summary { padding-top: 9px; color: var(--gold-bright); cursor: pointer; font-size: 10px; }
.story-record-evidence p { margin: 8px 0 0; color: #cdd9de; line-height: 1.7; overflow-wrap: anywhere; white-space: pre-wrap; }
.story-record-pagination { display: flex; justify-content: flex-end; gap: 7px; margin-top: 10px; }
.story-record-pagination button { padding: 7px 10px; font-size: 10px; }
.kernel-preview { margin-top: 14px; }
.kernel-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.kernel-metrics div { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(13, 37, 50, 0.58); }
.kernel-metrics span, .kernel-metrics strong { display: block; }
.kernel-metrics span { color: var(--muted); font-size: 11px; }
.kernel-metrics strong { margin-top: 6px; color: var(--gold-bright); font-size: 20px; }
.kernel-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.kernel-section h3 { margin: 0 0 10px; font-size: 16px; }
.kernel-section > p { margin: 0; color: #d6e0e4; line-height: 1.75; white-space: pre-wrap; }
.kernel-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.kernel-list li { padding: 11px 13px; border-radius: 11px; background: rgba(151, 186, 202, 0.055); line-height: 1.55; }
.kernel-list strong, .kernel-list small { display: block; }
.kernel-list small { margin-top: 3px; color: var(--muted); }
.kernel-observation-note { margin: 0 0 10px; color: var(--green); font-size: 12px; }
.quick-chat > p { color: var(--muted); line-height: 1.75; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.voice-status { min-height: 24px; margin-bottom: 0; font-size: 13px; }
.live-dot { width: 9px; height: 9px; margin: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(111, 214, 163, 0.08); }

.advanced-console-dialog {
  width: min(1040px, calc(100vw - 28px)); max-height: min(900px, calc(100vh - 28px)); padding: 0;
  overflow: hidden; border: 1px solid var(--line); border-radius: 22px; color: var(--text);
  background: #081b27; box-shadow: 0 34px 100px rgba(0, 0, 0, 0.62);
}
.advanced-console-dialog::backdrop { background: rgba(1, 8, 12, 0.72); backdrop-filter: blur(5px); }
.advanced-console-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); max-height: min(900px, calc(100vh - 28px)); }
.advanced-console-shell > header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  padding: 20px 22px; border-bottom: 1px solid var(--line); background: rgba(13, 37, 50, 0.94);
}
.advanced-console-shell h2 { margin: 5px 0 4px; font-size: 23px; }
.advanced-console-shell header small { color: var(--muted); }
.advanced-console-shell header button { width: 36px; height: 36px; color: var(--muted); background: transparent; font-size: 26px; }
.advanced-console-content { overflow-y: auto; padding: 18px; }
.advanced-console-section {
  min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 16px;
  background: rgba(5, 17, 25, 0.48);
}
.advanced-console-section + .advanced-console-section { margin-top: 14px; }
.advanced-console-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.advanced-console-section-heading h3 { margin: 0; font-size: 17px; }
.advanced-console-section-heading p { max-width: 720px; margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.advanced-book-section[hidden], .advanced-console-empty[hidden] { display: none; }
.advanced-console-empty {
  margin-top: 14px; padding: 18px; border: 1px dashed rgba(151, 186, 202, 0.25);
  border-radius: 15px; color: var(--muted); background: rgba(5, 17, 25, 0.36);
}
.advanced-console-empty strong { color: #dce6e9; }
.advanced-console-empty p { margin: 6px 0 0; line-height: 1.6; }
#advanced-book-content { min-width: 0; display: grid; gap: 12px; margin-top: 15px; }
#advanced-model-settings { scroll-margin-top: 18px; }
.workflow-node-library { min-width: 0; margin-top: 15px; }
.workflow-node-library-status { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.workflow-node-retry { width: auto; margin-top: 10px; padding: 8px 11px; font-size: 11px; }
.workflow-node-summary { display: flex; flex-wrap: wrap; gap: 7px; }
.workflow-node-summary-chip,
.workflow-node-status {
  display: inline-flex; align-items: center; width: max-content; padding: 4px 8px; border-radius: 999px;
  color: #c7d5da; background: rgba(151, 186, 202, 0.08); font-size: 9px; line-height: 1.25;
}
.workflow-node-summary-chip.status-active,
.workflow-node-status.status-active { color: var(--green); background: rgba(111, 214, 163, 0.1); }
.workflow-node-summary-chip.status-gated,
.workflow-node-status.status-gated { color: var(--gold-bright); background: rgba(216, 173, 89, 0.11); }
.workflow-node-summary-chip.status-deferred,
.workflow-node-status.status-deferred { color: #b8c6cc; background: rgba(151, 186, 202, 0.08); }
.workflow-node-track {
  min-width: 0; display: flex; align-items: stretch; overflow-x: auto; margin-top: 12px; padding: 2px 2px 10px;
  scroll-snap-type: x proximity;
}
.workflow-node-step { flex: none; display: flex; align-items: center; }
.workflow-node-card {
  width: 205px; min-height: 126px; display: grid; grid-template-rows: auto minmax(38px, 1fr) auto; gap: 9px;
  padding: 12px; border: 1px solid rgba(151, 186, 202, 0.17); border-radius: 12px;
  color: #dce6e9; background: rgba(7, 24, 34, 0.72); text-align: left; scroll-snap-align: start;
}
.workflow-node-card:hover { transform: none; border-color: rgba(216, 173, 89, 0.35); }
.workflow-node-card.selected { border-color: rgba(216, 173, 89, 0.7); box-shadow: 0 0 0 2px rgba(216, 173, 89, 0.08); }
.workflow-node-card.status-deferred { border-style: dashed; }
.workflow-node-card-head,
.workflow-node-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.workflow-node-order {
  min-width: 25px; padding: 3px 6px; border-radius: 7px; color: var(--gold-bright);
  background: rgba(216, 173, 89, 0.08); text-align: center; font-size: 9px;
}
.workflow-node-kind { color: var(--muted); font-size: 9px; }
.workflow-node-card > strong { overflow-wrap: anywhere; font-size: 12px; line-height: 1.5; }
.workflow-node-card-foot small { color: var(--muted); font-size: 8px; }
.workflow-node-arrow { width: 28px; color: rgba(216, 173, 89, 0.55); text-align: center; font-size: 16px; }
.workflow-node-detail {
  min-width: 0; margin-top: 4px; padding: 16px; border: 1px solid rgba(216, 173, 89, 0.22);
  border-radius: 14px; background: rgba(216, 173, 89, 0.035);
}
.workflow-node-detail > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.workflow-node-detail h4 { margin: 5px 0 0; font-size: 16px; }
.workflow-node-detail header p { max-width: 760px; margin: 7px 0 0; color: #cbd7dc; font-size: 11px; line-height: 1.65; }
.workflow-node-contracts {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px;
  margin-top: 14px;
}
.workflow-node-contracts > div { min-width: 0; padding: 10px; border-radius: 10px; background: rgba(5, 17, 25, 0.62); }
.workflow-node-contracts span { display: block; color: var(--muted); font-size: 9px; }
.workflow-node-contracts code { display: block; margin-top: 5px; overflow-wrap: anywhere; color: #e3edf0; font-size: 10px; }
.workflow-node-contract-arrow { color: var(--gold); }
.workflow-node-facts {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 0;
}
.workflow-node-facts > div { min-width: 0; padding: 9px 10px; border-radius: 9px; background: rgba(151, 186, 202, 0.045); }
.workflow-node-facts dt { color: var(--muted); font-size: 8px; }
.workflow-node-facts dd { margin: 5px 0 0; overflow-wrap: anywhere; color: #dce6e9; font-size: 10px; line-height: 1.45; }
.workflow-node-scopes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.workflow-node-scopes > section { min-width: 0; }
.workflow-node-scopes strong { display: block; margin-bottom: 6px; color: var(--muted); font-size: 9px; }
.workflow-node-scope-list { display: flex; flex-wrap: wrap; gap: 5px; }
.workflow-node-scope-list code { padding: 4px 6px; border-radius: 6px; color: #cdd9de; background: rgba(151, 186, 202, 0.07); font-size: 8px; }
.workflow-node-implementation { display: block; margin-top: 12px; overflow-wrap: anywhere; color: var(--muted); font-size: 8px; line-height: 1.55; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; padding-top: 4px; }
.settings-grid label { display: grid; align-content: start; gap: 8px; padding-top: 18px; }
.settings-grid small { color: var(--muted); line-height: 1.5; }
.token-row { display: flex; gap: 7px; }
.token-row input { min-width: 0; flex: 1; }
.model-directory-settings {
  grid-column: 1 / -1; margin-top: 2px; padding: 19px; border: 1px solid var(--line);
  border-radius: 15px; background: rgba(7, 24, 34, 0.56);
}
.model-directory-settings > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.model-directory-settings h3 { margin: 0; font-size: 16px; }
.model-directory-settings header p { max-width: 720px; margin: 6px 0 0; color: var(--muted); line-height: 1.55; }
.safety-badge {
  flex: none; padding: 6px 9px; border: 1px solid rgba(111, 214, 163, 0.28);
  border-radius: 999px; color: var(--green); font-size: 11px;
}
.model-directory-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px; margin-top: 15px;
}
.model-directory-grid label { padding-top: 0; }
.model-directory-grid input, .model-directory-grid select { width: 100%; min-width: 0; }
.model-directory-action { display: flex; align-items: end; }
.model-directory-action button { width: 100%; min-height: 42px; }
.model-directory-status { min-height: 20px; margin: 13px 0 4px; color: var(--gold-bright); font-size: 13px; }
.model-directory-status.error { color: #ef9a91; }
.model-directory-status.success { color: var(--green); }
.model-runtime-actions { display: flex; flex-wrap: wrap; gap: 9px; margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.model-runtime-actions button { min-width: 180px; }
.model-runtime-status { min-height: 20px; margin: 10px 0 4px; color: var(--muted); font-size: 13px; }
.model-runtime-status.error { color: #ef9a91; }
.model-runtime-status.success { color: var(--green); }
.model-profile-pool {
  margin: 14px 0; padding: 13px; border: 1px solid var(--line);
  border-radius: 12px; background: rgba(255, 255, 255, 0.018);
}
.model-profile-pool > header {
  display: flex; align-items: start; justify-content: space-between; gap: 16px;
  margin-bottom: 10px;
}
.model-profile-pool > header > div { display: grid; gap: 4px; }
.model-profile-pool > header small { color: var(--muted); }
.model-profile-count {
  flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--line);
  border-radius: 999px; color: var(--gold-bright); font-size: 12px;
}
.model-runtime-profiles { display: grid; gap: 8px; }
.model-runtime-profile {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-width: 0; padding: 10px 11px; border: 1px solid var(--line);
  border-radius: 10px; background: rgba(7, 15, 24, 0.32);
}
.model-runtime-profile.active {
  border-color: rgba(111, 214, 163, 0.42);
  background: rgba(111, 214, 163, 0.055);
}
.model-runtime-profile-main {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0;
}
.model-runtime-profile-main strong { overflow-wrap: anywhere; }
.model-profile-badge {
  padding: 2px 7px; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: 11px;
}
.model-profile-badge.active {
  border-color: rgba(111, 214, 163, 0.38); color: var(--green);
}
.model-profile-badge.role {
  border-color: rgba(216, 173, 89, 0.3); color: var(--gold-bright);
}
.model-runtime-profile-actions { display: flex; flex: 0 0 auto; gap: 7px; }
.model-runtime-profile-actions button { min-height: 34px; padding: 6px 10px; }
.model-profile-remove { color: #efb0aa; }
.model-profile-empty { margin: 0; padding: 8px 2px; color: var(--muted); font-size: 13px; }
.model-role-assignments {
  margin-top: 12px; padding: 12px; border: 1px solid var(--line);
  border-radius: 11px; background: rgba(7, 15, 24, 0.32);
}
.model-role-assignments > header {
  display: flex; align-items: start; justify-content: space-between; gap: 14px;
}
.model-role-assignments > header > div { display: grid; gap: 4px; min-width: 0; }
.model-role-assignments > header small { color: var(--muted); line-height: 1.5; }
.model-role-assignment-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px; margin-top: 11px;
}
.settings-grid .model-role-assignment-grid label {
  display: grid; gap: 6px; min-width: 0; padding-top: 0;
}
.model-role-assignment-grid select { width: 100%; min-width: 0; }
.model-role-assignment-actions {
  display: flex; align-items: center; gap: 12px; margin-top: 11px;
}
.model-role-assignment-actions button { flex: 0 0 auto; min-width: 170px; }
.model-role-assignment-status { margin: 0; color: var(--muted); font-size: 12px; }
.model-role-assignment-status.error { color: #ef9a91; }
.model-role-assignment-status.warning { color: #efb06b; }
.model-role-assignment-status.success { color: var(--green); }
.model-role-assignment-notice {
  margin: 9px 0 0; color: #efb06b; font-size: 11px; line-height: 1.55;
}
.model-benchmark-panel {
  display: flex; align-items: end; justify-content: space-between; gap: 14px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
}
.model-benchmark-panel > div { display: grid; gap: 4px; }
.model-benchmark-panel small { color: var(--muted); }
.model-profile-credential-warning {
  display: block;
  margin-top: 4px;
  color: #efb06b;
  font-weight: 500;
}
.model-benchmark-panel button { flex: 0 0 auto; min-width: 190px; }
.model-benchmark-profile-selection {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px; margin-top: 10px;
}
.settings-grid .model-benchmark-profile-option {
  display: flex; align-items: flex-start; gap: 8px; min-width: 0; padding: 9px;
  border: 1px solid var(--line); border-radius: 9px;
  background: rgba(5, 17, 25, 0.4); cursor: pointer;
}
.model-benchmark-profile-option:has(input:checked) {
  border-color: rgba(216, 173, 89, 0.48); background: rgba(216, 173, 89, 0.055);
}
.model-benchmark-profile-option input { flex: 0 0 auto; margin-top: 2px; }
.model-benchmark-profile-option span { display: grid; gap: 3px; min-width: 0; }
.model-benchmark-profile-option strong { overflow-wrap: anywhere; font-size: 12px; }
.model-benchmark-profile-option small { color: var(--muted); font-size: 10px; }
.model-benchmark-status { min-height: 18px; margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.model-benchmark-status.error { color: #ef9a91; }
.model-benchmark-status.warning { color: #efb06b; }
.model-benchmark-status.success { color: var(--green); }
.model-benchmark-results { display: grid; gap: 8px; margin-top: 9px; }
.model-benchmark-result {
  padding: 10px 11px; border: 1px solid var(--line); border-radius: 10px;
  background: rgba(5, 17, 25, 0.46);
}
.model-benchmark-result > header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.model-benchmark-result > header strong { min-width: 0; overflow-wrap: anywhere; }
.model-benchmark-scores { color: var(--gold-bright); font-size: 12px; white-space: nowrap; }
.model-benchmark-role-cells {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px; margin-top: 9px;
}
.model-benchmark-role-cell {
  min-width: 0; padding: 9px; border: 1px solid var(--line);
  border-radius: 8px; background: rgba(255, 255, 255, 0.018);
}
.model-benchmark-role-cell.success { border-color: rgba(111, 214, 163, 0.24); }
.model-benchmark-role-cell.failure,
.model-benchmark-role-cell.missing { border-color: rgba(239, 154, 145, 0.28); }
.model-benchmark-role-cell > header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.model-benchmark-role-cell > header strong { font-size: 12px; }
.model-benchmark-cell-status {
  flex: 0 0 auto; padding: 2px 6px; border: 1px solid currentColor;
  border-radius: 999px; color: var(--green); font-size: 9px;
}
.model-benchmark-role-cell.failure .model-benchmark-cell-status,
.model-benchmark-role-cell.missing .model-benchmark-cell-status { color: #ef9a91; }
.model-benchmark-role-cell p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.model-benchmark-role-cell .model-benchmark-cell-failure { color: #ef9a91; }
.model-benchmark-role-cell > small { display: block; margin-top: 7px; color: var(--muted); font-size: 10px; }
.model-benchmark-role-cell details { margin-top: 8px; }
.model-benchmark-role-cell summary { cursor: pointer; color: var(--muted); font-size: 11px; }
.model-benchmark-role-cell pre {
  margin: 8px 0 0; max-height: 220px; overflow: auto; white-space: pre-wrap;
  overflow-wrap: anywhere; color: var(--text); font: inherit; font-size: 12px;
}
.model-directory-privacy { display: block; }

.workflow-receipt {
  min-width: 0; padding: 14px; border: 1px solid rgba(111, 214, 163, 0.22);
  border-radius: 12px; background: rgba(111, 214, 163, 0.035);
}
.workflow-receipt-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.workflow-receipt-heading h4 { margin: 0; font-size: 14px; }
.workflow-receipt-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.workflow-receipt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 13px 0 0; }
.workflow-receipt-grid > div { min-width: 0; padding: 10px; border-radius: 9px; background: rgba(151, 186, 202, 0.05); }
.workflow-receipt-grid dt { color: var(--muted); font-size: 9px; }
.workflow-receipt-grid dd { margin: 5px 0 0; overflow-wrap: anywhere; color: #e5edef; font-size: 11px; line-height: 1.5; }
.workflow-receipt-issue { margin: 10px 0 0; padding: 10px; border-left: 3px solid #e8756c; color: #efb2aa; background: rgba(232, 117, 108, 0.06); font-size: 11px; line-height: 1.6; }
.workflow-receipt-issue[hidden] { display: none; }
.workflow-receipt-raw { margin-top: 11px; border-top: 1px solid var(--line); }
.workflow-receipt-raw > summary { padding-top: 10px; color: var(--muted); cursor: pointer; font-size: 10px; }
.workflow-receipt-raw pre { max-height: 320px; overflow: auto; margin: 10px 0 0; padding: 11px; border-radius: 9px; color: #cbd8dd; background: #061620; font-size: 10px; line-height: 1.55; white-space: pre-wrap; }
.generation-provenance-summary { display: block; margin-top: 12px; color: var(--gold-bright); font-size: 12px; line-height: 1.65; }
.generation-provenance-plan > strong { display: block; margin-top: 12px; color: #d9e3e6; font-size: 10px; }
.generation-provenance-plan > p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.65; white-space: pre-wrap; }
.generation-provenance-checks { display: grid; gap: 6px; margin: 8px 0 0; padding: 0; list-style: none; }
.generation-provenance-checks li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-radius: 8px; background: rgba(151, 186, 202, 0.05); color: var(--muted); font-size: 10px; }
.generation-provenance-checks li strong { flex: 0 0 auto; color: var(--muted); }
.generation-provenance-checks li[data-status="pass"] strong { color: var(--green); }
.generation-provenance-checks li[data-status="fail"] strong { color: #ef9a91; }

.supervisor-fab {
  position: fixed; z-index: 20; right: 24px; bottom: 24px; width: 58px; height: 58px;
  border: 1px solid rgba(216, 173, 89, 0.62); border-radius: 50%; color: var(--gold-bright);
  background: radial-gradient(circle at 35% 28%, #23485a, #0c2230 70%); box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45), 0 0 0 7px rgba(216, 173, 89, 0.05);
  font-family: Georgia, serif; font-size: 22px;
}
:is(.supervisor-fab, .workspace-supervisor-fab)[data-attention="action-required"]::after,
:is(.supervisor-fab, .workspace-supervisor-fab)[data-attention="blocked"]::after {
  content: ""; position: absolute; top: -2px; right: -2px; width: 12px; height: 12px;
  border: 2px solid #0b1f2b; border-radius: 50%; pointer-events: none;
}
:is(.supervisor-fab, .workspace-supervisor-fab)[data-attention="action-required"]::after {
  background: var(--gold-bright); box-shadow: 0 0 0 4px rgba(216, 173, 89, 0.12);
}
:is(.supervisor-fab, .workspace-supervisor-fab)[data-attention="blocked"]::after {
  background: #e8756c; box-shadow: 0 0 0 4px rgba(232, 117, 108, 0.14);
}
.supervisor-drawer {
  position: fixed; z-index: 30; top: 0; right: 0; width: min(430px, 100vw); height: 100vh;
  display: grid; grid-template-rows: auto 1fr auto; border-left: 1px solid var(--line);
  background: rgba(6, 20, 29, 0.97); box-shadow: -30px 0 80px rgba(0, 0, 0, 0.42);
  transform: translateX(105%); transition: transform 220ms ease; backdrop-filter: blur(20px);
}
.supervisor-drawer.open { transform: translateX(0); }
.supervisor-drawer.docked {
  position: relative; z-index: 4; inset: auto; width: 100%; height: 100%; min-width: 0;
  border-left: 1px solid var(--line); transform: none; transition: none;
}
.supervisor-drawer.docked:not(.open) { display: none; }
.supervisor-resize-handle { display: none; }
.supervisor-drawer.docked.open .supervisor-resize-handle {
  position: absolute; z-index: 6; top: 0; bottom: 0; left: -6px; width: 12px;
  display: block; cursor: ew-resize; touch-action: none;
}
.supervisor-drawer.docked.open .supervisor-resize-handle::after {
  content: ""; position: absolute; top: 50%; left: 4px; width: 3px; height: 52px;
  border-radius: 99px; background: rgba(216, 173, 89, 0.34); transform: translateY(-50%);
}
.supervisor-drawer.docked.open .supervisor-resize-handle:focus-visible::after {
  background: var(--gold-bright); box-shadow: 0 0 0 3px rgba(216, 173, 89, 0.13);
}
body.supervisor-resizing { cursor: ew-resize; user-select: none; }
.supervisor-drawer header { display: flex; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--line); }
.supervisor-drawer header strong, .supervisor-drawer header small { display: block; }
.supervisor-drawer header small { margin-top: 3px; color: var(--muted); }
.supervisor-drawer header button { width: 34px; height: 34px; color: var(--muted); background: transparent; font-size: 24px; }
.messages { overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.message { max-width: 88%; padding: 12px 14px; border-radius: 14px; line-height: 1.65; white-space: pre-wrap; }
.message.assistant { align-self: flex-start; border: 1px solid var(--line); background: rgba(20, 47, 62, 0.75); }
.message.user { align-self: flex-end; color: #211807; background: #d7b468; }
.message.has-selection-rewrite { width: min(100%, 520px); max-width: 100%; }
.selection-rewrite-card {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(216, 173, 89, 0.22);
  white-space: normal;
}
.selection-rewrite-title { display: block; color: var(--gold-bright); font-size: 13px; }
.selection-rewrite-summary,
.selection-rewrite-status,
.selection-rewrite-help,
.selection-rewrite-notice { margin: 6px 0 0; color: var(--muted); font-size: 11px; line-height: 1.55; }
.selection-rewrite-status.success,
.selection-rewrite-notice.success { color: #8fd6aa; }
.selection-rewrite-status.error,
.selection-rewrite-notice.error { color: #f59b92; }
.selection-rewrite-candidate-label { display: block; margin-top: 11px; color: #d9c591; font-size: 11px; }
.selection-rewrite-candidate {
  max-height: 280px; overflow: auto; margin-top: 6px; padding: 10px 11px;
  border: 1px solid rgba(216, 173, 89, 0.24); border-radius: 9px;
  color: #e7e1d2; background: #071722; font-family: Georgia, "Songti SC", serif;
  font-size: 12px; line-height: 1.75; white-space: pre-wrap;
}
.selection-rewrite-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.selection-rewrite-actions button { width: auto; padding: 8px 10px; font-size: 11px; }
.supervisor-drawer form { padding: 16px; border-top: 1px solid var(--line); }
.supervisor-drawer textarea { width: 100%; resize: vertical; }
.supervisor-selection {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 9px; padding: 9px 10px; border: 1px solid rgba(216, 173, 89, 0.3);
  border-radius: 10px; color: var(--gold-bright); background: rgba(216, 173, 89, 0.07);
  font-size: 12px; line-height: 1.45;
}
.supervisor-selection[hidden] { display: none; }
.supervisor-selection span { min-width: 0; overflow-wrap: anywhere; }
.supervisor-selection button {
  flex: none; width: 26px; height: 26px; padding: 0; color: var(--muted);
  border: 1px solid var(--line); border-radius: 50%; background: transparent;
}
.supervisor-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 9px; }
.voice-icon { width: 42px; color: #e8756c; background: rgba(232, 117, 108, 0.09); border: 1px solid rgba(232, 117, 108, 0.22); }

@media (max-width: 800px) {
  .app-shell { width: min(100% - 24px, 680px); }
  .hero-card { grid-template-columns: 1fr; align-items: start; min-height: auto; }
  .hero-actions { width: 100%; }
  .hero-actions .primary { width: 100%; }
  .dashboard-grid, .settings-grid { grid-template-columns: 1fr; }
  .model-directory-settings > header { display: grid; }
  .model-directory-grid { grid-template-columns: 1fr; }
  .model-runtime-actions { display: grid; }
  .model-runtime-actions button { width: 100%; }
  .model-profile-pool > header, .model-runtime-profile { display: grid; }
  .model-runtime-profile-actions { width: 100%; }
  .model-runtime-profile-actions button { flex: 1; }
  .model-role-assignments > header { display: grid; }
  .model-role-assignment-grid { grid-template-columns: 1fr; }
  .model-role-assignment-actions { display: grid; }
  .model-role-assignment-actions button { width: 100%; }
  .model-benchmark-panel { display: grid; }
  .model-benchmark-panel button { width: 100%; }
  .model-benchmark-profile-selection { grid-template-columns: 1fr; }
  .model-benchmark-result > header { align-items: flex-start; flex-direction: column; }
  .model-benchmark-scores { white-space: normal; }
  .model-benchmark-role-cells { grid-template-columns: 1fr; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .validation-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book-workspace {
    grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr);
    height: calc(100vh - 114px); min-height: 0;
  }
  .chapter-nav {
    border-right: 0; border-bottom: 1px solid var(--line);
    grid-template-columns: auto minmax(250px, 1fr); grid-template-rows: auto auto;
  }
  .chapter-nav-header { padding: 10px 13px; }
  .chapter-nav-controls { grid-template-columns: minmax(140px, 0.8fr) minmax(180px, 1.2fr); padding: 7px 9px; }
  .chapter-nav-summary { grid-column: 1 / -1; padding: 2px 12px 7px; }
  .chapter-nav-list {
    grid-column: 1 / -1; height: auto; display: flex; gap: 6px; overflow-x: auto; padding: 7px 9px;
  }
  .chapter-nav-item { width: 190px; min-width: 190px; }
  .chapter-nav-item.active { box-shadow: inset 0 -3px var(--gold); }
  .prose-pane { grid-template-rows: auto auto minmax(320px, 1fr) auto; padding: 14px; }
  .prose-toolbar { flex-direction: column; }
  .chapter-production-gate { align-items: stretch; flex-direction: column; }
  .chapter-production-actions { display: grid; justify-content: stretch; }
  .chapter-production-actions button { width: 100%; }
  .prose-search, .prose-search input { width: 100%; }
  .entity-manager-toolbar { flex-direction: column; }
  .entity-form-grid { grid-template-columns: 1fr; }
  .entity-field-wide { grid-column: auto; }
  .story-record-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .story-record-search-field { grid-column: 1 / -1; }
  .advanced-console-dialog { width: calc(100vw - 12px); max-height: calc(100vh - 12px); }
  .advanced-console-shell { max-height: calc(100vh - 12px); }
  .story-kernel-dialog.supervisor-docked { width: calc(100vw - 12px); }
  .workspace-frame:has(.supervisor-drawer.docked.open) { grid-template-columns: minmax(0, 1fr); }
  .supervisor-drawer.docked.open {
    position: absolute; z-index: 8; top: 0; right: 0; bottom: 0;
    width: min(100%, 390px); height: 100%; box-shadow: -24px 0 70px rgba(0, 0, 0, 0.52);
  }
  .supervisor-drawer.docked.open .supervisor-resize-handle { display: none; }
}

@media (max-width: 520px) {
  .topbar { min-height: 68px; }
  .compact-field > span { display: none; }
  .hero-card { padding: 28px 22px; border-radius: 20px; }
  h1 { font-size: 38px; }
  .panel { padding: 22px; }
  .library-panel { padding: 21px; }
  .library-heading, .migration-actions { align-items: stretch; flex-direction: column; }
  .library-toolbar { flex-direction: column; }
  .sort-field { justify-content: space-between; }
  .sort-field select { flex: 1; }
  .book-grid, .metric-grid, .validation-grid { grid-template-columns: 1fr; }
  .kernel-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .story-kernel-dialog { width: calc(100vw - 12px); max-height: calc(100vh - 12px); }
  .story-kernel-shell { max-height: calc(100vh - 12px); }
  .story-kernel-shell > header { padding-top: 14px; padding-bottom: 14px; }
  .story-kernel-shell h2 { font-size: 18px; }
  .book-workspace { height: calc(100vh - 91px); }
  .chapter-nav { grid-template-columns: 1fr; grid-template-rows: auto auto auto; }
  .chapter-nav-header { display: none; }
  .chapter-nav-controls { grid-template-columns: 1fr 1fr; padding-top: 8px; }
  .chapter-nav-summary { grid-column: auto; }
  .chapter-nav-list { grid-column: auto; }
  .prose-pane { grid-template-rows: auto auto minmax(300px, 1fr) auto; }
  .chapter-prose-editor { min-height: 300px; padding: 18px; font-size: 16px; }
  .prose-footer { flex-direction: column; gap: 4px; }
  .story-record-filters { grid-template-columns: 1fr; }
  .story-record-search-field { grid-column: auto; }
  .story-record-row-header { flex-direction: column; }
  .story-record-actions { justify-content: flex-start; }
  .story-kernel-shell > header, .story-kernel-content { padding-left: 18px; padding-right: 18px; }
  .story-kernel-content:has(.book-workspace) { padding: 0; }
  .legacy-preview summary { align-items: flex-start; flex-direction: column; }
  .migration-actions .primary { width: 100%; }
  .supervisor-fab { right: 16px; bottom: 16px; }
  .topbar-actions { gap: 6px; }
  .compact-button { padding: 8px 9px; }
  .workspace-header-actions { align-self: center; }
  .workspace-header-actions .secondary { padding-left: 8px; padding-right: 8px; }
  .advanced-console-shell > header, .advanced-console-content { padding-left: 14px; padding-right: 14px; }
  .advanced-console-section { padding: 14px; }
  .advanced-console-section-heading, .workflow-receipt-heading { flex-direction: column; }
  .workflow-node-card { width: 185px; }
  .workflow-node-detail > header { flex-direction: column; }
  .workflow-node-contracts { grid-template-columns: 1fr; }
  .workflow-node-contract-arrow { transform: rotate(90deg); text-align: center; }
  .workflow-node-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workflow-node-scopes { grid-template-columns: 1fr; }
  .workflow-receipt-grid { grid-template-columns: 1fr; }
}
