:root {
  color-scheme: light;
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-subtle: #f8f8f6;
  --surface-strong: #ecece8;
  --text: #191919;
  --muted: #62625d;
  --faint: #8a8a83;
  --border: #d9d9d3;
  --border-strong: #b9b9b1;
  --accent: #a87813;
  --accent-strong: #805906;
  --accent-soft: #f5e8c5;
  --success: #18794e;
  --success-soft: #dcefe5;
  --danger: #b42318;
  --danger-soft: #fbe3df;
  --focus: #315c9d;
  --header-height: 58px;
  --sidebar-width: 226px;
  --inspector-width: 292px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

body > svg[version="1.1"]:not(.icon-sprite) {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button svg,
.nav-item svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171715;
  --surface: #20201e;
  --surface-subtle: #262624;
  --surface-strong: #30302d;
  --text: #f4f4ef;
  --muted: #b6b6ae;
  --faint: #94948c;
  --border: #3a3a36;
  --border-strong: #56564f;
  --accent: #dbb85a;
  --accent-strong: #efd47e;
  --accent-soft: #4b4024;
  --success: #65c795;
  --success-soft: #1f4935;
  --danger: #ff8b7e;
  --danger-soft: #542b27;
  --focus: #8bb4f0;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 8px 12px;
  transform: translateY(-150%);
  border-radius: 4px;
  background: var(--text);
  color: var(--surface);
}

.skip-link:focus {
  transform: translateY(0);
}

.app {
  width: 100%;
  height: 100%;
}

.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: var(--header-height);
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand-lockup,
.topbar-actions,
.editor-actions,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand-lockup {
  min-width: 0;
  gap: 12px;
}

.brand-logo {
  width: 112px;
  max-height: 30px;
  object-fit: contain;
  object-position: left center;
}

.brand-divider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.book-identity {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.book-identity strong,
.book-identity span {
  max-width: 32vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-identity strong {
  font-size: 13px;
  font-weight: 650;
}

.book-identity span {
  color: var(--muted);
  font-size: 11px;
}

.topbar-actions {
  gap: 8px;
}

.model-settings-button {
  display: inline-flex;
  min-height: 36px;
  padding: 0 11px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.model-settings-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

.model-settings-button small {
  max-width: 130px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--faint);
  border-radius: 50%;
  background: transparent;
}

.connection-dot.ready {
  border-color: var(--success);
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.save-state {
  min-width: 48px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.primary-button,
.quiet-button,
.danger-button,
.icon-button,
.text-button,
.export-link {
  border: 0;
  border-radius: 5px;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

.primary-button,
.quiet-button,
.danger-button {
  min-height: 36px;
  padding: 0 13px;
  font-size: 13px;
  font-weight: 650;
}

.primary-button {
  background: var(--text);
  color: var(--surface);
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
  color: #ffffff;
}

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

.quiet-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.quiet-button:hover {
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

.danger-button {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
  color: var(--danger);
}

.danger-button:hover:not(:disabled) {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 15%, var(--surface));
}

.quiet-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.icon-button:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.workspace-shell {
  position: relative;
  display: grid;
  width: 100%;
  height: calc(100% - var(--header-height));
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--inspector-width);
}

.system-notice {
  display: flex;
  margin: 20px 28px 0;
  padding: 14px 16px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--danger);
  border-radius: 4px;
  background: var(--surface);
}

.system-notice[hidden] {
  display: none;
}

.system-notice.warning {
  border-left-color: var(--accent);
}

.system-notice-copy {
  min-width: 0;
}

.system-notice-copy strong {
  font-size: 13px;
}

.system-notice-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.system-notice-copy code {
  display: block;
  margin-top: 5px;
  color: var(--faint);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.system-notice-copy code[hidden] {
  display: none;
}

.system-notice-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
}

.system-notice-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.system-notice-actions svg {
  width: 15px;
  height: 15px;
}

@media (max-width: 700px) {
  .system-notice {
    margin: 14px 14px 0;
    align-items: stretch;
    flex-direction: column;
  }

  .system-notice-actions {
    flex-wrap: wrap;
  }
}

.app.inspector-collapsed .workspace-shell {
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) 0;
}

.app.inspector-collapsed .inspector {
  display: none;
}

.sidebar,
.inspector {
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.view-nav {
  display: grid;
  min-height: 0;
  overflow-y: auto;
  gap: 14px;
  padding: 12px 10px 8px;
}

.nav-group {
  display: grid;
  gap: 2px;
}

.nav-group-label {
  padding: 4px 10px 5px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-item {
  display: grid;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-align: left;
}

.nav-item svg {
  color: var(--faint);
}

.nav-item:hover {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 650;
}

.nav-item.active svg {
  color: var(--accent-strong);
}

.nav-primary {
  gap: 3px;
}

.nav-tools {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.nav-tools summary {
  display: grid;
  min-height: 36px;
  padding: 0 10px;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  list-style: none;
}

.nav-tools summary::-webkit-details-marker {
  display: none;
}

.nav-tools summary:hover,
.nav-tools[open] summary {
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-tools summary svg {
  width: 18px;
  height: 18px;
  color: var(--faint);
}

.nav-tool-items {
  margin-top: 4px;
  padding-left: 8px;
}

.mobile-nav-backdrop {
  display: none;
}

.inspector-backdrop {
  display: none;
}

.sidebar-divider,
.inspector-divider {
  height: 1px;
  background: var(--border);
}

.document-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.library-browser-tools {
  display: grid;
  padding: 0 10px 10px;
  gap: 6px;
}

.library-browser-tools[hidden] {
  display: none;
}

.library-browser-tools input,
.library-browser-tools select {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 11px;
}

.document-list {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 0 8px 12px;
}

.document-category-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 9px 5px;
  background: var(--surface);
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
}

.document-item {
  width: 100%;
  min-height: 48px;
  padding: 8px 9px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 3px;
  background: transparent;
  text-align: left;
}

.document-item:hover {
  background: var(--surface-subtle);
}

.document-item.active {
  border-left-color: var(--accent);
  background: var(--surface-strong);
}

.document-item strong,
.document-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-item strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 620;
}

.document-item span {
  margin-top: 4px;
  color: var(--faint);
  font-size: 10px;
}

.empty-state {
  padding: 18px 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

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

.product-tour {
  position: fixed;
  z-index: 80;
  inset: 0;
  pointer-events: none;
}

.product-tour-spotlight {
  position: fixed;
  z-index: 1;
  border: 2px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 58%), 0 0 0 5px rgb(212 175 55 / 18%);
  pointer-events: none;
  transition: top 180ms ease, right 180ms ease, bottom 180ms ease, left 180ms ease;
}

.product-tour-card {
  position: fixed;
  z-index: 2;
  width: min(360px, calc(100vw - 28px));
  padding: 17px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 18px 42px rgb(0 0 0 / 24%);
  color: var(--text);
  pointer-events: auto;
}

.product-tour-card::before {
  position: absolute;
  width: 12px;
  height: 12px;
  border-top: 1px solid var(--border-strong);
  border-left: 1px solid var(--border-strong);
  background: var(--surface);
  content: "";
  transform: rotate(45deg);
}

.product-tour-card[data-placement="bottom"]::before {
  top: -7px;
  left: 28px;
}

.product-tour-card[data-placement="top"]::before {
  bottom: -7px;
  left: 28px;
  transform: rotate(225deg);
}

.product-tour-card h2 {
  margin: 4px 0 7px;
  font-size: 17px;
}

.product-tour-card > p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.product-tour-actions {
  display: flex;
  margin-top: 15px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.product-tour-navigation {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.project-location-details {
  padding: 2px 0;
}

.project-location-details summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 12px;
}

.project-location-details[open] {
  display: grid;
  gap: 7px;
}

.project-location-details[open] summary {
  margin-bottom: 3px;
}

.sidebar-footer {
  display: grid;
  padding: 10px;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  border-top: 1px solid var(--border);
}

.export-link {
  padding: 8px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  text-decoration: none;
}

.export-link:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.main-panel {
  min-width: 0;
  overflow: auto;
  background: var(--bg);
}

.dashboard-view {
  width: min(100%, 1080px);
  min-height: 100%;
  margin: 0 auto;
  padding: 34px clamp(24px, 4vw, 54px) 48px;
}

.workspace-view {
  width: min(100%, 1160px);
  min-height: 100%;
  margin: 0 auto;
  padding: 34px clamp(24px, 4vw, 54px) 64px;
}

.workspace-view[hidden] {
  display: none;
}

.research-runtime-status {
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 11px;
}

.research-runtime-status.ready {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  color: var(--accent-strong);
}

.research-header-actions,
.research-model-setting {
  display: flex;
  align-items: center;
  gap: 8px;
}

.research-settings-dialog {
  width: min(620px, calc(100vw - 32px));
}

.research-model-setting {
  justify-content: space-between;
  margin: 8px 0 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.research-model-setting > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.research-model-setting small {
  color: var(--muted);
  font-size: 10px;
}

.research-model-setting strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-settings-fields {
  margin: 4px 0 10px;
}

.research-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 16px;
}

.research-form-card,
.research-reports-card {
  min-width: 0;
}

.research-report-list {
  display: grid;
  max-height: 420px;
  overflow: auto;
}

.research-report-item {
  display: grid;
  min-width: 0;
  padding: 11px 0;
  gap: 4px;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.research-report-item:hover,
.research-report-item.active {
  color: var(--accent-strong);
}

.research-report-item strong,
.research-report-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-report-item span {
  color: var(--muted);
  font-size: 10px;
}

.research-report-panel {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}

.research-report-content {
  max-height: 620px;
  margin: 14px 0 0;
  overflow: auto;
  color: var(--text);
  font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

.workspace-view-header {
  align-items: flex-start;
  gap: 24px;
}

.section-description {
  max-width: 680px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.segmented {
  display: flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.segment {
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.segment:hover,
.segment.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.agent-console {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
  align-items: start;
}

.agent-sessions-panel {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.agent-sessions-header,
.agent-session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.agent-sessions-header strong,
.agent-session-bar strong {
  font-size: 13px;
}

.agent-session-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.danger-mini-button {
  min-height: 30px;
  padding: 0 9px;
  border-color: color-mix(in srgb, var(--danger) 34%, var(--border));
  color: var(--danger);
}

.danger-mini-button:hover:not(:disabled) {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}

.agent-session-list {
  display: grid;
  gap: 6px;
}

.agent-session-item {
  display: grid;
  width: 100%;
  min-height: 56px;
  padding: 9px 10px;
  gap: 3px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.agent-session-item:hover,
.agent-session-item.active {
  border-color: var(--border);
  background: var(--surface-subtle);
}

.agent-session-item.active {
  border-color: var(--accent);
}

.agent-session-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.agent-session-item span {
  color: var(--muted);
  font-size: 11px;
}

.agent-session-item small {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--faint);
  font-size: 11px;
}

.agent-chat-panel {
  min-width: 0;
}

.agent-session-bar {
  min-height: 44px;
  padding: 0 0 8px;
}

.agent-session-bar span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.agent-tools-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 10px 12px;
}

.agent-tools-panel summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.agent-tools-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.agent-tools-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.agent-tool {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) auto;
  gap: 4px 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
}

.agent-tool strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.agent-tool span {
  justify-self: end;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.agent-tool p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.chat-log {
  display: grid;
  min-height: 320px;
  max-height: calc(100vh - 360px);
  margin-top: 28px;
  padding: 18px;
  overflow-y: auto;
  align-content: start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.chat-message {
  max-width: min(760px, 88%);
  padding: 12px 14px;
  border-left: 2px solid var(--accent);
  border-radius: 3px;
  background: var(--surface-subtle);
}

.chat-message.user {
  justify-self: end;
  border-right: 2px solid var(--border-strong);
  border-left: 0;
  background: var(--surface-strong);
}

.chat-message.error {
  border-color: var(--danger);
}

.chat-message strong {
  font-size: 11px;
}

.chat-message p {
  margin: 6px 0 0;
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.7;
}

.chat-markdown {
  min-width: 0;
  margin-top: 7px;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.72;
}

.chat-markdown > :first-child { margin-top: 0; }
.chat-markdown > :last-child { margin-bottom: 0; }

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4 {
  margin: 1.25em 0 0.55em;
  color: var(--text);
  font-family: var(--font-display);
  line-height: 1.3;
}

.chat-markdown h1 { font-size: 20px; }
.chat-markdown h2 { font-size: 17px; }
.chat-markdown h3,
.chat-markdown h4 { font-size: 14px; }

.chat-markdown p,
.chat-markdown ul,
.chat-markdown ol,
.chat-markdown blockquote,
.chat-markdown pre {
  margin: 0.7em 0;
}

.chat-markdown p { white-space: normal; }

.chat-markdown ul,
.chat-markdown ol {
  padding-left: 1.55em;
}

.chat-markdown li + li { margin-top: 0.25em; }

.chat-markdown blockquote {
  padding: 0.1em 0 0.1em 0.85em;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}

.chat-markdown code {
  padding: 0.12em 0.35em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-strong);
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.chat-markdown pre {
  max-width: 100%;
  padding: 11px 12px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-strong);
}

.chat-markdown pre code {
  padding: 0;
  border: 0;
  background: transparent;
  white-space: pre;
}

.chat-markdown a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.chat-markdown hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--border);
}

.chat-composer {
  display: grid;
  margin-top: 12px;
  padding: 14px;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.chat-composer label,
.compact-form label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.chat-composer textarea,
.compact-form textarea,
.compact-form input,
.compact-form select {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}

.chat-composer textarea,
.compact-form textarea {
  resize: vertical;
}

.chat-composer textarea:focus,
.compact-form textarea:focus,
.compact-form input:focus,
.compact-form select:focus {
  border-color: var(--focus);
  background: var(--surface);
}

.composer-actions {
  display: flex;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.composer-actions span,
.form-status {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.tool-grid,
.truth-grid,
.continuity-grid {
  display: grid;
  margin-top: 26px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.truth-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.tool-card-wide {
  grid-column: 1 / -1;
}

.tool-card h2 {
  margin: 0 0 14px;
  font-size: 14px;
}

.tools-view-header {
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.workspace-view-summary {
  max-width: 660px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

#tools-view .tool-grid {
  margin-top: 20px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  align-items: start;
  gap: 18px;
}

#tools-view .tool-card {
  display: flex;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  flex-direction: column;
  border-color: var(--border);
  background: var(--surface);
  box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 7%, transparent);
}

#tools-view .tool-card-wide {
  grid-column: 1 / -1;
}

#tools-view .tool-card h2 {
  margin: 3px 0 0;
  font-size: 15px;
  line-height: 1.35;
}

#tools-view .narrative-forecast-tool {
  display: flex;
}

.tool-card-header {
  position: relative;
  min-height: 108px;
  padding: 18px;
  border-top: 3px solid var(--accent);
}

.tool-card-heading {
  display: grid;
  min-width: 0;
  padding-right: 48px;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

.tool-card-wide .tool-card-heading {
  padding-right: 132px;
}

.tool-card-heading > div {
  min-width: 0;
}

.tool-card-icon {
  display: grid;
  width: 40px;
  height: 40px;
  border: 1px solid color-mix(in srgb, var(--accent) 36%, var(--border));
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  place-items: center;
}

.tool-card-icon svg {
  width: 19px;
  height: 19px;
}

.tool-card-kicker {
  margin: 0;
  color: var(--accent-strong);
  font-size: 10px;
  font-weight: 650;
  line-height: 1.4;
}

.tool-card-summary {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.tool-card-header-actions {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-card-metric {
  display: flex;
  min-height: 32px;
  padding: 0 9px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 10px;
}

.tool-card-metric strong {
  color: var(--text);
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.tool-help-button {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font: 700 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  transition: border-color 180ms ease, background-color 180ms ease, color 180ms ease;
  place-items: center;
}

.tool-card-header-actions .tool-help-button {
  position: static;
}

.tool-help-button:hover,
.tool-help-button[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.tool-help-panel {
  padding: 14px 18px 15px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 34%, var(--border));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  background: color-mix(in srgb, var(--accent-soft) 68%, var(--surface));
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.tool-help-panel[hidden] {
  display: none;
}

.tool-help-panel strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 11px;
}

.tool-help-panel p {
  margin: 0;
}

.tool-help-note {
  margin-top: 6px !important;
}

.tool-help-note span {
  margin-right: 6px;
  color: var(--accent-strong);
  font-weight: 650;
}

.tool-card-body {
  display: grid;
  min-width: 0;
  padding: 18px;
  gap: 14px;
}

#tools-view .form-grid label,
.tool-workflow-section > label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.tool-workflow-section > label {
  display: grid;
  gap: 6px;
}

#tools-view .form-grid input:not([type="checkbox"]),
#tools-view .form-grid select,
.tool-workflow-section > label textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 12px;
}

.tool-workflow-section > label textarea {
  resize: vertical;
  line-height: 1.55;
}

#tools-view .form-grid input:not([type="checkbox"]):focus,
#tools-view .form-grid select:focus,
.tool-workflow-section > label textarea:focus {
  border-color: var(--focus);
  background: var(--surface);
}

.tool-card-compact .tool-card-body {
  flex: 1;
  align-content: start;
}

#tools-view .operation-list {
  margin: 0;
}

#tools-view #diagnostic-list .operation-row {
  display: grid;
  width: 100%;
  min-height: 46px;
  padding: 9px 4px;
  grid-template-columns: 8px minmax(96px, 0.7fr) minmax(0, 1.3fr);
  justify-content: stretch;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
}

#tools-view #diagnostic-list .operation-row::before {
  align-self: center;
  grid-column: 1;
}

#tools-view #diagnostic-list .operation-row strong {
  align-self: center;
  grid-column: 2;
}

#tools-view #diagnostic-list .operation-row span {
  align-self: center;
  grid-column: 3;
}

#tools-view #diagnostic-list .diagnostic-warning::before {
  border-color: var(--accent);
  background: var(--accent);
}

#tools-view #diagnostic-list .diagnostic-error::before {
  border-color: var(--danger);
  background: var(--danger);
}

#tools-view #diagnostic-list .diagnostic-info::before {
  border-color: var(--focus);
  background: var(--focus);
}

#tools-view .tool-card-body > .form-status:last-child {
  min-height: 17px;
  margin: 0;
}

.tool-workflow {
  gap: 0;
}

.tool-workflow-section {
  display: grid;
  min-width: 0;
  padding: 18px 0;
  gap: 12px;
}

.tool-workflow-section:first-child {
  padding-top: 0;
}

.tool-workflow-section + .tool-workflow-section {
  border-top: 1px solid var(--border);
}

.tool-workflow-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.tool-workflow-heading > span {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-subtle);
  color: var(--muted);
  font: 600 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  place-items: center;
}

.tool-workflow-heading strong {
  font-size: 12px;
}

.tool-card pre,
.context-preview {
  max-width: 100%;
  max-height: 360px;
  margin: 10px 0 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.narrative-forecast-tool {
  display: grid;
  gap: 14px;
}

.narrative-forecast-tool .subsection-heading h2 {
  margin: 0;
}

.narrative-forecast-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.34fr);
  align-items: end;
  gap: 14px;
}

.narrative-forecast-controls label,
.narrative-forecast-history {
  display: grid;
  min-width: 0;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.narrative-forecast-controls textarea,
.narrative-forecast-controls input,
.narrative-forecast-controls select,
.narrative-forecast-history select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--text);
}

.narrative-forecast-controls textarea {
  min-height: 84px;
  padding: 10px;
  resize: vertical;
  font: inherit;
  line-height: 1.55;
}

.narrative-forecast-controls input,
.narrative-forecast-controls select,
.narrative-forecast-history select {
  min-height: 38px;
  padding: 7px 9px;
}

.narrative-forecast-controls textarea:focus,
.narrative-forecast-controls input:focus,
.narrative-forecast-controls select:focus,
.narrative-forecast-history select:focus {
  border-color: var(--focus);
  background: var(--surface);
}

.narrative-forecast-options {
  margin: 0;
}

.narrative-forecast-settings {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.narrative-forecast-settings > label {
  display: grid;
  min-width: 0;
  gap: 7px;
}

.narrative-forecast-actions {
  justify-content: flex-start;
}

.narrative-forecast-actions button {
  min-height: 38px;
}

.narrative-forecast-actions svg {
  width: 15px;
  height: 15px;
}

.narrative-forecast-history {
  grid-template-columns: 110px minmax(0, 1fr);
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.narrative-forecast-result {
  min-width: 0;
  padding-top: 4px;
}

.narrative-forecast-summary {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.narrative-forecast-summary > div {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 9px;
}

.narrative-forecast-summary strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.5;
}

.narrative-forecast-summary > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.narrative-forecast-summary .status-badge.stale {
  border-color: color-mix(in srgb, var(--danger) 44%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.narrative-forecast-comparison {
  max-width: 100%;
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.narrative-forecast-comparison .empty-state {
  margin: 0;
  padding: 22px 16px;
}

.narrative-forecast-comparison table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

.narrative-forecast-comparison th,
.narrative-forecast-comparison td {
  min-width: 150px;
  padding: 10px 12px;
  overflow-wrap: anywhere;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
  text-align: left;
  vertical-align: top;
}

.narrative-forecast-comparison th {
  background: var(--surface-subtle);
  color: var(--text);
  font-weight: 650;
}

.narrative-forecast-comparison th:first-child {
  width: 105px;
  min-width: 105px;
}

.narrative-forecast-comparison tr:last-child > * {
  border-bottom: 0;
}

.narrative-forecast-comparison tr > *:last-child {
  border-right: 0;
}

.narrative-forecast-tabs {
  width: 100%;
  margin-top: 16px;
  overflow-x: auto;
  justify-content: flex-start;
}

.narrative-forecast-tabs .segment {
  min-width: 150px;
  white-space: normal;
}

.narrative-forecast-detail {
  display: grid;
  min-width: 0;
  margin-top: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 24px;
  border-top: 1px solid var(--border-strong);
}

.narrative-forecast-detail-heading,
.narrative-forecast-premise,
.narrative-forecast-rationale {
  grid-column: 1 / -1;
}

.narrative-forecast-detail-heading {
  display: flex;
  padding: 16px 0 8px;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.narrative-forecast-detail-heading h3 {
  margin: 0;
  font-size: 14px;
}

.narrative-forecast-detail-heading strong {
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
}

.narrative-forecast-premise,
.narrative-forecast-rationale {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.narrative-forecast-detail > section {
  min-width: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.narrative-forecast-detail > section h4 {
  margin: 0 0 8px;
  font-size: 11px;
}

.narrative-forecast-detail > section ul {
  margin: 0;
  padding-left: 17px;
}

.narrative-forecast-detail > section li,
.narrative-forecast-detail > section p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.narrative-forecast-rationale {
  padding-top: 14px;
}

.narrative-forecast-selection-actions {
  margin-top: 16px;
}

.workspace-panel-heading,
.transfer-metrics,
.deconstruct-stats,
.skill-stats,
.import-preview-summary,
.source-report-summary > div,
.runtime-skill-row > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.workspace-panel-heading h2,
.runtime-rules-panel h2,
.profile-section h3 {
  margin: 0;
}

.workspace-panel-heading .eyebrow {
  margin-bottom: 4px;
}

.transfer-metrics,
.deconstruct-stats,
.skill-stats {
  justify-content: flex-end;
  color: var(--muted);
  font-size: 11px;
}

.transfer-metrics span,
.deconstruct-stats span,
.skill-stats span {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
}

.transfer-metrics strong,
.deconstruct-stats strong,
.skill-stats strong {
  color: var(--text);
  font-size: 18px;
}

.transfer-layout,
.deconstruct-layout,
.skills-layout {
  display: grid;
  margin-top: 24px;
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}

.transfer-layout {
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr);
}

.deconstruct-layout {
  grid-template-columns: minmax(360px, .82fr) minmax(0, 1.18fr);
}

.skills-layout {
  grid-template-columns: minmax(320px, .9fr) minmax(0, 1.1fr);
}

.transfer-panel,
.deconstruct-intake,
.deconstruct-library,
.skill-catalog,
.skill-simulator {
  min-width: 0;
  padding: 22px 24px 26px 0;
}

.transfer-panel + .transfer-panel,
.deconstruct-library,
.skill-simulator {
  padding-right: 0;
  padding-left: 24px;
  border-left: 1px solid var(--border);
}

.format-badge,
.status-badge,
.skill-meta span,
.finding-category {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.status-badge.ready,
.import-preview-summary.ready .status-badge {
  border-color: color-mix(in srgb, var(--success) 42%, var(--border));
  background: var(--success-soft);
  color: var(--success);
}

.transfer-form,
.source-form,
.skill-simulator .form-grid {
  margin-top: 18px;
}

.transfer-actions {
  justify-content: flex-end;
}

.import-preview {
  max-height: 380px;
  margin-top: 18px;
  overflow: auto;
  border-top: 1px solid var(--border);
}

.import-preview-summary {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 13px 0;
  background: var(--bg);
}

.import-preview-summary > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.import-preview-summary span,
.import-chapter-list span {
  color: var(--muted);
  font-size: 11px;
}

.import-preview-summary.conflict .status-badge {
  border-color: color-mix(in srgb, var(--danger) 42%, var(--border));
  background: var(--danger-soft);
  color: var(--danger);
}

.import-chapter-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.import-chapter-list li {
  display: grid;
  min-height: 56px;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
}

.import-chapter-list li.conflict {
  box-shadow: inset 3px 0 var(--danger);
}

.import-chapter-list code,
.runtime-skill-row code,
.source-row code {
  overflow-wrap: anywhere;
  color: var(--faint);
  font-size: 10px;
}

.import-chapter-list div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.import-chapter-list strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-book-summary {
  display: grid;
  margin: 20px 0;
  padding: 18px 0;
  gap: 5px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.export-book-summary strong {
  overflow-wrap: anywhere;
  font-size: 18px;
}

.export-book-summary span {
  color: var(--muted);
  font-size: 12px;
}

.export-format-options {
  display: grid;
  margin: 0 0 16px;
  padding: 0;
  gap: 8px;
  border: 0;
}

.export-format-options legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.export-format {
  display: grid;
  min-height: 58px;
  padding: 10px 12px;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.export-format.active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 var(--accent);
}

.export-format input {
  grid-row: 1 / 3;
}

.export-format strong {
  font-size: 12px;
}

.export-format span,
.export-format small {
  color: var(--muted);
  font-size: 10px;
}

.export-format small {
  grid-column: 3;
  grid-row: 1 / 3;
}

.export-download-button {
  display: flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.export-download-button.disabled {
  pointer-events: none;
  opacity: .45;
}

.deconstruct-report,
.runtime-rules-panel {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border-strong);
}

.deconstruct-library .source-list {
  max-height: 440px;
  margin-bottom: 0;
  overflow: auto;
}

.source-row {
  min-height: 76px;
  padding: 10px 8px;
  border-left: 3px solid transparent;
}

.source-row.active {
  border-left-color: var(--accent);
  background: var(--surface-subtle);
}

.source-row-select > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.source-row-select strong,
.source-row-select span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.source-progress {
  display: block;
  width: min(220px, 100%);
  height: 3px;
  margin-top: 4px;
  overflow: hidden;
  background: var(--surface-strong);
}

.source-progress i {
  display: block;
  height: 100%;
  background: var(--success);
}

.source-analysis-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.source-report-view {
  margin-top: 16px;
}

.source-report-summary {
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border);
}

.source-report-summary p {
  max-width: 840px;
  margin: 10px 0 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.source-report-summary > span {
  color: var(--faint);
  font-size: 10px;
}

.source-findings {
  display: grid;
}

.source-finding {
  display: grid;
  padding: 18px 0;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.source-finding > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.finding-category {
  border-color: color-mix(in srgb, var(--focus) 35%, var(--border));
  color: var(--focus);
}

.source-finding > strong {
  font-size: 13px;
  line-height: 1.65;
}

.source-finding blockquote {
  display: grid;
  margin: 0;
  padding: 10px 12px;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border-left: 3px solid var(--accent);
  background: var(--surface-subtle);
}

.source-finding blockquote p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.source-finding cite {
  color: var(--faint);
  font-size: 10px;
  font-style: normal;
}

.profile-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}

.profile-section h3 {
  margin-bottom: 10px;
  font-size: 12px;
}

.profile-item {
  display: grid;
  padding: 9px 0;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.profile-item strong,
.profile-section li {
  font-size: 12px;
  line-height: 1.6;
}

.profile-item span {
  color: var(--muted);
  font-size: 10px;
}

.source-application-success {
  display: grid;
  padding: 18px;
  gap: 6px;
  border-left: 3px solid var(--success);
  background: var(--success-soft);
}

.source-application-success code {
  overflow-wrap: anywhere;
  color: var(--success);
  font-size: 11px;
}

.reference-analysis-options {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.reference-analysis-options summary,
.reference-exclusions summary,
.reference-style-recipe details summary {
  padding: 10px 0;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.reference-analysis-options label {
  padding: 0 0 12px;
}

.reference-structure {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border-strong);
}

.reference-structure-list {
  max-height: 280px;
  margin: 10px 0 14px;
  overflow: auto;
  border-bottom: 1px solid var(--border);
}

.reference-structure-row {
  display: grid;
  min-height: 52px;
  padding: 8px 0;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
}

.reference-structure-row > span {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.reference-structure-row > div {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.reference-structure-row strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-structure-row small {
  color: var(--muted);
  font-size: 10px;
}

.reference-candidate-section {
  padding: 18px 0 2px;
  border-bottom: 1px solid var(--border-strong);
}

.reference-candidate-section h3 {
  margin: 0 0 8px;
  font-size: 12px;
}

.reference-candidate-row {
  display: grid;
  min-width: 0;
  padding: 13px 0;
  grid-template-columns: 18px minmax(220px, 1fr) minmax(420px, 1.25fr);
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
}

.reference-candidate-check {
  width: 16px;
  min-height: 16px;
}

.reference-candidate-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.reference-candidate-copy strong {
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.55;
}

.reference-candidate-copy span {
  color: var(--muted);
  font-size: 10px;
}

.reference-candidate-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  gap: 6px;
}

.reference-candidate-controls select,
.reference-candidate-controls input {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 5px 7px;
  font-size: 10px;
}

.reference-candidate-scope-id {
  grid-column: 1 / -1;
}

.reference-exclusions {
  padding-top: 12px;
}

.reference-exclusions ul {
  margin: 0 0 12px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.reference-style-surface {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border-strong);
}

.reference-style-recipe {
  display: grid;
  margin-top: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0 22px;
}

.reference-style-recipe > section,
.reference-style-recipe > details {
  min-width: 0;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.reference-style-recipe h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
}

.reference-style-row {
  display: grid;
  padding: 7px 0;
  gap: 3px;
}

.reference-style-row strong {
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.5;
}

.reference-style-row span,
.reference-fingerprint-targets span {
  color: var(--muted);
  font-size: 10px;
}

.reference-fingerprint-targets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.runtime-skill-list {
  display: grid;
  margin-top: 12px;
}

.runtime-skill-row {
  display: grid;
  padding: 14px 10px;
  gap: 7px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}

.runtime-skill-row.active {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.runtime-skill-row p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.skill-meta,
.skill-token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.skill-meta small {
  width: 100%;
  color: var(--faint);
  font-size: 10px;
}

.skill-use-actions {
  justify-content: flex-start;
  margin-top: 2px;
}

.skill-use-actions .quiet-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 10px;
}

.runtime-skill-report {
  margin-top: 16px;
  border-top: 1px solid var(--border);
}

.skill-resolution-summary {
  display: grid;
  padding: 14px 0;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.skill-resolution-summary span {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 10px;
}

.skill-resolution-summary strong {
  color: var(--text);
  font-size: 20px;
}

.skill-resolution-section,
.skill-tool-boundary {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.skill-resolution-section h3 {
  margin: 0 0 8px;
  font-size: 11px;
}

.skill-resolution-section ul {
  margin: 0;
  padding-left: 18px;
}

.skill-resolution-section li,
.skill-tool-boundary summary {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.skill-token-list span,
.skill-token-list code {
  max-width: 100%;
  padding: 4px 7px;
  overflow-wrap: anywhere;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 10px;
}

.skill-token-list.tools {
  margin-top: 10px;
}

.skill-diagnostic {
  margin: 6px 0;
  padding: 8px 10px;
  border-left: 3px solid var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 11px;
  line-height: 1.55;
}

.skill-diagnostic.clean {
  border-left-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
}

.relationship-card {
  margin-top: 26px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.relationship-heading,
.relationship-controls,
.relationship-list-heading {
  display: flex;
  align-items: center;
}

.relationship-heading {
  display: grid;
  padding-bottom: 16px;
  grid-template-columns: minmax(0, 1fr);
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.relationship-heading h2 {
  margin: 0;
  font-size: 16px;
}

.relationship-summary {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.relationship-format-help {
  max-width: 680px;
  margin: 6px 0 0;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.6;
}

.relationship-format-help code {
  overflow-wrap: anywhere;
}

.relationship-controls {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(130px, 1fr)) auto;
  align-items: end;
  gap: 12px;
}

.relationship-control {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.relationship-control span {
  color: var(--muted);
  font-size: 11px;
}

.relationship-controls select {
  width: 100%;
  min-height: 36px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
}

.relationship-controls input {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
}

.relationship-controls input:focus,
.relationship-controls select:focus {
  border-color: var(--focus);
}

.relationship-control-actions {
  display: flex;
  gap: 6px;
}

.relationship-icon-button {
  width: 36px;
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.relationship-icon-button:hover {
  border-color: var(--border-strong);
}

.relationship-icon-button svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

.relationship-icon-button[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.relationship-search-status {
  min-height: 18px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.relationship-legend {
  display: flex;
  flex-wrap: wrap;
  margin-top: 16px;
  gap: 7px 14px;
  color: var(--muted);
  font-size: 10px;
}

.relationship-legend span::before {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border: 1px solid var(--relationship-color);
  border-radius: 50%;
  background: color-mix(in srgb, var(--relationship-color) 22%, transparent);
  content: "";
}

.relationship-legend .relationship-origin-key::before {
  width: 16px;
  height: 0;
  border: 0;
  border-top: 2px solid var(--muted);
  border-radius: 0;
  background: transparent;
  vertical-align: middle;
}

.relationship-legend .relationship-origin-key.annotation::before {
  border-top-style: dotted;
}

[data-kind="character"] { --relationship-color: #4f7fba; }
[data-kind="faction"] { --relationship-color: #a65d71; }
[data-kind="place"] { --relationship-color: #3d8d70; }
[data-kind="concept"] { --relationship-color: #a87813; }
[data-kind="unknown"] { --relationship-color: #777770; }

.relationship-workspace {
  display: grid;
  min-height: 620px;
  margin-top: 12px;
  grid-template-columns: minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-subtle);
}

.relationship-stage {
  position: relative;
  min-width: 0;
  min-height: clamp(620px, 68vh, 760px);
  overflow: hidden;
  background-image: radial-gradient(var(--border) 0.7px, transparent 0.7px);
  background-size: 18px 18px;
  touch-action: none;
}

#relationship-graph {
  display: block;
  width: 100%;
  height: clamp(620px, 68vh, 760px);
  cursor: grab;
  user-select: none;
}

#relationship-graph.panning,
#relationship-graph.dragging-node { cursor: grabbing; }

.relationship-edge {
  stroke: color-mix(in srgb, var(--muted) 55%, transparent);
  stroke-width: 1.3;
  marker-end: url(#relationship-arrow);
}

.relationship-edge.annotation {
  stroke-dasharray: 2 3;
}

.relationship-edge.search-context,
.relationship-node.search-context {
  opacity: 0.38;
}

.relationship-edge.search-related {
  stroke: var(--accent-strong);
  stroke-width: 2.4;
}

.relationship-node.search-match .relationship-node-shape {
  stroke: var(--accent-strong);
  stroke-width: 4;
}

#relationship-arrow path { fill: var(--muted); }

.relationship-node {
  cursor: pointer;
  outline: none;
}

.relationship-node-shape {
  fill: color-mix(in srgb, var(--relationship-color) 18%, var(--surface));
  stroke: var(--relationship-color);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.relationship-node[data-kind="unknown"] .relationship-node-shape {
  stroke-dasharray: 4 3;
}

.relationship-node:hover .relationship-node-shape,
.relationship-node:focus-visible .relationship-node-shape,
.relationship-node.selected .relationship-node-shape {
  fill: color-mix(in srgb, var(--relationship-color) 35%, var(--surface));
  stroke-width: 3;
}

.relationship-node-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--surface-subtle);
  stroke-linejoin: round;
  stroke-width: 3.5px;
  text-anchor: middle;
}

.relationship-empty {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(420px, 80%);
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}

.relationship-inspector {
  display: grid;
  min-width: 0;
  max-height: 244px;
  padding: 16px 18px;
  overflow: hidden;
  grid-template-columns: minmax(260px, 0.75fr) minmax(0, 1.25fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.relationship-inspector h3 {
  margin: 0;
  font-size: 12px;
}

.relationship-detail {
  min-width: 0;
  max-height: 190px;
  margin-top: 8px;
  padding-right: 8px;
  overflow: auto;
  grid-column: 1;
  grid-row: 2;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.relationship-detail strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: 15px;
}

.relationship-detail p { margin: 7px 0; }

.relationship-detail ul {
  margin: 8px 0 0;
  padding-left: 17px;
}

.relationship-detail li {
  margin-top: 6px;
}

.relationship-detail li > span {
  display: block;
  color: var(--text);
}

.relationship-edge-origin {
  color: var(--muted);
  font-size: 9px;
}

.relationship-edge-origin.annotation {
  font-style: italic;
}

.relationship-source {
  display: block;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.relationship-edit-asset {
  margin-top: 10px;
}

.relationship-list-heading {
  grid-column: 2;
  grid-row: 1;
  justify-content: space-between;
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.relationship-list-heading span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.relationship-node-list {
  display: grid;
  min-width: 0;
  max-height: 190px;
  margin-top: 8px;
  overflow: auto;
  grid-column: 2;
  grid-row: 2;
}

.relationship-node-list button {
  position: relative;
  display: grid;
  width: 100%;
  padding: 8px 4px 8px 13px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 11px;
  text-align: left;
}

.relationship-node-list button::before {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: 4px 0 0 -12px;
  border-radius: 50%;
  background: var(--relationship-color);
  content: "";
}

.relationship-node-list button:hover,
.relationship-node-list button[aria-current="true"] {
  background: var(--surface-subtle);
}

.relationship-node-list small {
  margin-top: 2px;
  color: var(--muted);
}

.compact-form {
  display: grid;
  gap: 8px;
}

.compact-form > button {
  justify-self: start;
  margin-top: 4px;
}

.search-form {
  display: grid;
  margin-top: 26px;
  grid-template-columns: minmax(260px, 1fr) 170px auto;
  gap: 8px;
}

.search-form input,
.search-form select {
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.search-results {
  display: grid;
  margin-top: 14px;
  gap: 8px;
  color: var(--muted);
}

.search-result {
  display: grid;
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
  text-align: left;
  gap: 4px;
}

.search-result:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.search-result strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.search-result span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.search-result p {
  min-width: 0;
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.check-row {
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.operation-list,
.source-list {
  display: grid;
  margin: 10px 0 14px;
}

.operation-row,
.source-row {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.operation-row::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  content: "";
}

.operation-row.ok::before {
  border-color: var(--success);
  background: var(--success);
}

.operation-row.error::before {
  border-color: var(--danger);
  background: var(--danger);
}

.operation-row.stacked {
  display: grid;
  padding: 9px 0;
  grid-template-columns: 8px 1fr;
  justify-content: start;
}

.operation-row.stacked strong,
.operation-row.stacked span {
  grid-column: 2;
}

.operation-row span,
.source-row span {
  color: var(--muted);
}

.source-row > div:first-child {
  display: grid;
  gap: 3px;
}

.source-row-select {
  display: grid;
  min-width: 0;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.source-row-select input {
  width: 16px;
  min-height: 16px;
}

.source-analysis-submit-row {
  align-items: end;
}

.source-analysis-submit-row .primary-button {
  min-height: 38px;
}

.source-analysis-toolbar {
  display: flex;
  margin-top: 12px;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.source-analysis-toolbar select {
  min-height: 34px;
}

.source-report-actions:empty {
  display: none;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.section-title-row,
.subsection-heading,
.progress-copy,
.progress-meta,
.inspector-header,
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 750;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  font-weight: 680;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
  font-weight: 680;
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  padding: 0 9px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
}

.status-pill.ready {
  border-color: color-mix(in srgb, var(--success) 45%, transparent);
  background: var(--success-soft);
  color: var(--success);
}

.metric-grid {
  display: grid;
  margin-top: 28px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  position: relative;
  min-height: 100px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: inline-block;
  margin-top: 22px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 25px;
  font-weight: 650;
}

.metric small {
  margin-left: 4px;
}

.progress-band,
.next-action-band {
  margin-top: 10px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface);
}

.progress-copy strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--surface-strong);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 280ms ease;
}

.progress-meta {
  margin-top: 9px;
  color: var(--muted);
  font-size: 10px;
}

.dashboard-columns {
  display: grid;
  margin-top: 30px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 34px;
}

.dashboard-section {
  min-width: 0;
}

.subsection-heading {
  min-height: 32px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border-strong);
}

.subsection-heading > span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

.text-button {
  padding: 4px 2px;
  background: transparent;
  color: var(--accent-strong);
  font-size: 11px;
}

.readiness-row,
.recent-row {
  display: flex;
  min-height: 43px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.readiness-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.readiness-state::before {
  width: 7px;
  height: 7px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  content: "";
}

.readiness-row.ready .readiness-state {
  color: var(--success);
}

.readiness-row.ready .readiness-state::before {
  border-color: var(--success);
  background: var(--success);
}

.recent-row {
  width: 100%;
  border-top: 0;
  border-right: 0;
  border-left: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.recent-row:hover {
  color: var(--accent-strong);
}

.recent-row span:last-child {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.next-action-band {
  display: grid;
  margin-top: 34px;
  grid-template-columns: 150px 1fr;
  align-items: center;
  border-left: 3px solid var(--accent);
}

.next-actions {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.next-action {
  padding: 6px 9px;
  border-radius: 4px;
  background: var(--surface-strong);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
}

button.next-action-button {
  border: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease;
}

button.next-action-button:hover,
button.next-action-button:focus-visible {
  border-color: var(--accent);
  background: var(--surface);
  outline: none;
}

.editor-view {
  height: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.editor-view[hidden],
.dashboard-view[hidden] {
  display: none;
}

.outline-view { display: flex; height: 100%; min-height: 0; padding: 18px clamp(34px, 3vw, 46px) 22px clamp(16px, 2.2vw, 30px); overflow: hidden; flex-direction: column; background: var(--surface); }
.outline-view[hidden] { display: none; }
@media (min-width: 821px) {
  .app.inspector-collapsed .outline-view { padding-right: 60px; }
}
.outline-header { display: flex; min-height: 50px; align-items: center; justify-content: space-between; gap: 20px; }
.outline-title-block { display: grid; min-width: 0; gap: 7px; }
.outline-title-row { display: flex; min-width: 0; align-items: center; gap: 9px; }
.outline-title-row > svg { width: 21px; height: 21px; flex: 0 0 auto; color: var(--accent-strong); }
.outline-title-row h1 { margin: 0; font-size: 22px; line-height: 1; }
.outline-title-row code { overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.outline-header-actions, .outline-detail-actions, .outline-edit-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.outline-header-actions { flex: 0 0 auto; align-items: center; }
.outline-header-actions button { min-height: 36px; }
.outline-header-actions .icon-button { width: 36px; min-height: 36px; }
.outline-header-actions svg, .outline-detail-actions svg { width: 15px; height: 15px; }
.outline-stats { display: flex; min-height: 18px; align-items: center; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: 10px; }
.outline-stats span { display: inline-flex; align-items: baseline; gap: 4px; }
.outline-stats strong { color: var(--text); font-size: 12px; font-variant-numeric: tabular-nums; }
.outline-mobile-switch { display: none; }
.outline-workspace { display: grid; min-height: 0; margin-top: 12px; flex: 1; grid-template-columns: minmax(300px, 350px) minmax(460px, 1fr); overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.outline-tree-panel { display: flex; min-width: 0; min-height: 0; overflow: hidden; flex-direction: column; border-right: 1px solid var(--border); background: var(--surface-subtle); }
.outline-panel-heading { display: flex; min-height: 45px; padding: 0 12px 0 16px; flex: 0 0 auto; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.outline-panel-heading > div { display: flex; align-items: center; gap: 8px; }
.outline-panel-heading strong { color: var(--text); font-size: 12px; }
.outline-panel-heading > div > span { min-width: 25px; padding: 2px 5px; border-radius: 4px; background: var(--surface-strong); font-size: 9px; text-align: center; }
.outline-panel-actions { display: flex; gap: 2px; }
.outline-panel-actions .icon-button { width: 29px; min-height: 29px; border-color: transparent; background: transparent; }
.outline-panel-actions svg { width: 14px; height: 14px; }
#outline-expand-all svg { transform: rotate(90deg); }
.outline-tree-tools { display: grid; padding: 11px 12px 7px; flex: 0 0 auto; gap: 8px; }
.outline-search-field { position: relative; display: flex; align-items: center; }
.outline-search-field svg { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.outline-search-field input { width: 100%; min-height: 34px; padding: 6px 9px 6px 31px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); font-size: 11px; }
.outline-search-field input:focus { border-color: var(--focus); outline: 0; }
.outline-status-filter { width: 100%; padding: 2px; }
.outline-status-filter .segment { min-height: 28px; flex: 1; padding: 4px 8px; font-size: 10px; }
.outline-filter-status { min-height: 17px; margin: 0; padding: 0 14px; flex: 0 0 auto; color: var(--faint); font-size: 9px; }
.outline-tree, .outline-tree ul { margin: 0; padding: 0; list-style: none; }
.outline-tree { min-height: 0; padding: 2px 9px 24px; overflow: auto; flex: 1; scrollbar-gutter: stable; }
.outline-tree ul { margin-left: 13px; padding-left: 7px; border-left: 1px solid var(--border); }
.outline-tree-row { position: relative; display: grid; min-width: 0; margin: 1px 0; grid-template-columns: 22px minmax(0, 1fr); align-items: stretch; }
.outline-tree-toggle, .outline-tree-spacer { width: 21px; min-height: 37px; }
.outline-tree-toggle { display: grid; padding: 0; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
.outline-tree-toggle svg { width: 14px; height: 14px; transition: transform 160ms ease; }
.outline-tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.outline-tree-toggle:hover { background: var(--surface-strong); color: var(--text); }
.outline-tree-node { display: grid; min-width: 0; min-height: 37px; padding: 5px 8px; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 7px; border: 0; border-radius: 4px; background: transparent; color: var(--text); cursor: pointer; text-align: left; transition: background 140ms ease, box-shadow 140ms ease; }
.outline-tree-node:hover { background: var(--surface-strong); }
.outline-tree-node[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.outline-tree-node.editing { cursor: text; }
.outline-tree-title-input { width: 100%; min-width: 0; min-height: 24px; padding: 2px 5px; border: 1px solid var(--focus); border-radius: 4px; background: var(--surface); color: var(--text); font-size: 12px; font-weight: 620; }
.outline-row-actions { position: absolute; top: 2px; right: 2px; display: flex; min-height: 33px; padding-left: 3px; align-items: center; opacity: 0; pointer-events: none; background: var(--surface-strong); box-shadow: -6px 0 0 var(--surface-strong); transition: opacity 140ms ease; }
.outline-tree-row:hover .outline-row-actions, .outline-row-actions:focus-within { opacity: 1; pointer-events: auto; }
.outline-tree-node[aria-current="true"] ~ .outline-row-actions { background: var(--accent-soft); box-shadow: -6px 0 0 var(--accent-soft); }
.outline-row-action { display: grid; width: 30px; min-height: 32px; padding: 0; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 16px; font-weight: 600; }
.outline-row-action svg { width: 14px; height: 14px; }
.outline-row-action:hover { background: var(--surface-strong); color: var(--text); }
.outline-kind-badge { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--border-strong); border-radius: 4px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; font-weight: 700; }
.kind-volume > .outline-tree-row .outline-kind-badge { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.kind-act > .outline-tree-row .outline-kind-badge { border-radius: 999px; }
.outline-tree-title { overflow: hidden; font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.outline-chapter-status { display: grid; width: 18px; height: 18px; place-items: center; border-radius: 50%; color: var(--muted); }
.outline-chapter-status svg { width: 12px; height: 12px; stroke-width: 2.3; }
.outline-chapter-status.drafted { background: var(--success-soft); color: var(--success); }
.outline-chapter-status.planned { width: 8px; height: 8px; margin: 0 5px; border: 1px solid var(--border-strong); }
.outline-tree-empty { padding: 36px 12px; color: var(--muted); font-size: 11px; text-align: center; }
.outline-detail { min-width: 0; min-height: 0; padding: 0 clamp(20px, 3vw, 34px) 28px; overflow: auto; background: var(--surface); scrollbar-gutter: stable; }
.outline-detail-header { position: sticky; z-index: 2; top: 0; padding: 19px 0 15px; border-bottom: 1px solid var(--border); background: var(--surface); }
.outline-detail-title-row { display: flex; min-width: 0; margin-top: 8px; align-items: flex-start; justify-content: space-between; gap: 14px; }
.outline-detail h2 { min-width: 0; margin: 0; font-size: 23px; line-height: 1.25; }
.outline-detail h2.editable { padding: 3px 5px; border-radius: 4px; outline: 1px solid transparent; }
.outline-detail h2.editable:hover, .outline-detail h2.editable:focus { outline-color: var(--focus); background: var(--surface-subtle); }
.outline-detail-utility { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.outline-detail-utility .icon-button { width: 34px; min-height: 34px; }
.outline-breadcrumb { display: flex; min-width: 0; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--faint); font-size: 9px; }
.outline-breadcrumb button { max-width: 210px; padding: 2px 3px; overflow: hidden; border: 0; border-radius: 3px; background: transparent; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.outline-breadcrumb button:hover { background: var(--surface-strong); color: var(--text); }
.outline-breadcrumb button[aria-current="page"] { color: var(--accent-strong); }
.outline-node-meta { display: flex; min-height: 22px; margin-top: 9px; align-items: center; flex-wrap: wrap; gap: 6px 10px; color: var(--faint); font-size: 9px; }
.outline-node-meta code { color: var(--muted); font-size: 9px; }
.outline-meta-kind, .outline-meta-status { display: inline-flex; min-height: 20px; padding: 2px 6px; align-items: center; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-subtle); color: var(--muted); font-size: 9px; font-weight: 650; }
.outline-meta-kind.kind-volume { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.outline-meta-status.drafted { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); background: var(--success-soft); color: var(--success); }
.outline-detail-command-row { display: flex; margin-top: 13px; align-items: center; justify-content: space-between; gap: 12px; }
.outline-edit-actions, .outline-detail-actions { padding: 0; border: 0; }
.outline-edit-actions button:disabled { display: none; }
.outline-detail-actions button, .outline-edit-actions button { min-height: 32px; padding: 6px 9px; font-size: 10px; }
.outline-node-summary { min-height: 180px; padding: 20px 0 26px; color: var(--text); font-family: "Iowan Old Style", "Noto Serif CJK SC", "Songti SC", Georgia, serif; font-size: 16px; line-height: 1.9; white-space: pre-wrap; }
.outline-summary-editor { width: 100%; min-height: 210px; overflow: hidden; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-subtle); color: var(--text); white-space: normal; }
.outline-summary-editor:focus-within { border-color: var(--focus); background: var(--surface); }
.outline-summary-editor.markdown-editor-host.compact .vditor-ir,
.outline-summary-editor.markdown-editor-host.compact .vditor-wysiwyg,
.outline-summary-editor.markdown-editor-host.compact .vditor-sv { padding: 14px 4px 24px !important; }
.outline-summary-editor.markdown-editor-host .vditor-ir .vditor-reset { padding: 0 !important; }
.outline-summary-actions { display: flex; margin-top: 9px; align-items: center; justify-content: flex-end; gap: 10px; color: var(--muted); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 11px; }
.outline-edit-title-field { display: grid; gap: 8px; }
.outline-edit-title-field[hidden] { display: none; }
.outline-edit-impact { display: grid; margin: 4px 0; padding: 11px 12px; gap: 6px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); border-radius: 5px; background: var(--danger-soft); color: var(--text); font-size: 11px; line-height: 1.55; }
.outline-edit-impact[hidden] { display: none; }
.outline-edit-impact strong { color: var(--danger); font-size: 12px; }
.outline-edit-impact ul { display: grid; margin: 0; padding-left: 18px; gap: 3px; }
.outline-edit-impact li { overflow-wrap: anywhere; }
.outline-edit-impact span { color: var(--muted); }
.write-outline-context { display: grid; padding: 11px 12px; gap: 3px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-subtle); }
.write-outline-context .chapter-id { color: var(--accent); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.write-outline-context strong { font-size: 14px; }
.write-outline-context > span:last-child { color: var(--muted); font-size: 10px; }

.editor-toolbar {
  display: flex;
  min-height: 67px;
  padding: 10px 18px 10px 22px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

.library-tabs {
  display: flex;
  min-height: 42px;
  padding: 5px 18px;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.library-navigation {
  display: flex;
  min-height: 44px;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

.library-navigation[hidden] {
  display: none;
}

.library-navigation .library-tabs {
  min-width: 0;
  flex: 1;
  border-bottom: 0;
}

.library-actions {
  display: flex;
  flex: 0 0 auto;
  padding: 5px 12px 5px 6px;
  align-items: center;
  gap: 6px;
}

.library-actions select {
  min-height: 34px;
  max-width: 130px;
  padding: 0 28px 0 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
}

.library-actions .primary-button,
.library-actions .quiet-button {
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

.library-tabs[hidden] {
  display: none;
}

.library-tabs button {
  min-height: 32px;
  padding: 0 11px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.library-tabs button:hover,
.library-tabs button.active {
  background: var(--surface);
  color: var(--text);
}

.library-tabs button.active {
  box-shadow: inset 0 -2px var(--accent);
  font-weight: 650;
}

.library-tabs-page {
  margin: 16px 0 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.editor-commandbar {
  display: flex;
  min-height: 46px;
  padding: 5px 14px 5px 22px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
}

#document-editor-actions[hidden],
#editor-commandbar[hidden] {
  display: none;
}

.editor-progress,
.editor-tool-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.editor-progress {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.editor-progress span + span::before {
  content: "·";
  margin-right: 10px;
  color: var(--border-strong);
}

.editor-tool-actions {
  justify-content: flex-end;
}

.icon-text-button {
  display: inline-flex;
  min-height: 34px;
  padding: 0 9px;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.icon-text-button svg {
  width: 16px;
  height: 16px;
}

.icon-text-button:hover,
.icon-text-button[aria-pressed="true"] {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.editor-find-panel {
  display: grid;
  min-height: 54px;
  padding: 8px 14px 8px 22px;
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) minmax(110px, auto) auto auto auto 34px;
  align-items: end;
  gap: 7px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.editor-find-panel[hidden] {
  display: none;
}

.editor-find-panel label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 9px;
}

.editor-find-panel input {
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
}

.editor-find-panel > span {
  align-self: center;
  color: var(--muted);
  font-size: 10px;
}

.editor-canvas {
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  background: var(--surface-subtle);
}

.editor-title-block {
  min-width: 0;
  flex: 1;
}

.editor-path {
  margin-bottom: 3px;
  overflow: hidden;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-title {
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 17px;
  font-weight: 680;
  text-overflow: ellipsis;
}

.editor-actions {
  flex: 0 0 auto;
  gap: 7px;
}

.editor-actions > span {
  min-width: 64px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
}

.document-editor {
  width: 100%;
  height: 100% !important;
  min-height: 320px;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: var(--surface);
  color: var(--text);
}

.markdown-editor-host.fallback {
  display: block;
}

.markdown-editor-fallback {
  width: 100%;
  min-height: 520px;
  padding: 28px clamp(18px, 5vw, 64px) 80px;
  border: 0;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  line-height: 1.8;
  resize: vertical;
  tab-size: 4;
}

.markdown-editor-host.compact .markdown-editor-fallback {
  min-height: 180px;
  padding: 14px;
}

.markdown-editor-fallback:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.markdown-editor-host.vditor {
  --panel-background-color: var(--surface);
  --toolbar-background-color: var(--surface-subtle);
  --toolbar-icon-color: var(--muted);
  --toolbar-icon-hover-color: var(--text);
  --toolbar-icon-hover-background-color: var(--surface-strong);
  --textarea-background-color: var(--surface);
  --textarea-text-color: var(--text);
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.markdown-editor-host .vditor-toolbar {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 4px 16px !important;
  border-color: var(--border) !important;
  background: var(--surface-subtle) !important;
}

.markdown-editor-host .vditor-toolbar__item button {
  cursor: pointer;
}

.markdown-editor-host svg {
  fill: currentColor;
  stroke: none;
  stroke-width: 0;
}

.markdown-editor-host .vditor-toolbar__item button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.markdown-editor-host .vditor-content {
  min-height: 0 !important;
  flex: 1;
  background: var(--surface);
}

.document-editor .vditor-ir,
.document-editor .vditor-wysiwyg,
.document-editor .vditor-sv {
  height: 100%;
  min-height: 0 !important;
  padding: 36px clamp(28px, 8vw, 110px) 80px !important;
  overflow-y: auto;
  background: var(--surface) !important;
  color: var(--text) !important;
  caret-color: var(--text);
  font-family: "Iowan Old Style", "Noto Serif CJK SC", "Songti SC", Georgia, serif;
  font-size: 17px;
  line-height: 1.9;
}

.markdown-editor-host .vditor-reset,
.markdown-editor-host .vditor-reset p,
.markdown-editor-host .vditor-ir__node {
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

.markdown-editor-host .vditor-ir__marker,
.markdown-editor-host .vditor-ir__link,
.markdown-editor-host .vditor-ir__link-label {
  color: var(--accent-strong);
}

.markdown-editor-host .vditor-reset blockquote {
  border-left-color: var(--accent);
  color: var(--muted);
}

.markdown-editor-host .vditor-reset hr {
  border-color: var(--border);
}

.markdown-editor-host.compact {
  min-height: 180px;
}

.markdown-editor-host.compact .vditor-toolbar {
  min-height: 38px;
  padding: 2px 8px !important;
}

.markdown-editor-host.compact .vditor-ir,
.markdown-editor-host.compact .vditor-wysiwyg,
.markdown-editor-host.compact .vditor-sv {
  min-height: 170px !important;
  padding: 14px 15px 24px !important;
  background: var(--surface) !important;
  color: var(--text) !important;
  font-family: "Iowan Old Style", "Noto Serif CJK SC", "Songti SC", Georgia, serif;
  font-size: 15px;
  line-height: 1.8;
}

.editor-view.reading-width .document-editor {
  max-width: 780px;
  margin: 0 auto;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.editor-view.reading-width .document-editor .vditor-ir,
.editor-view.reading-width .document-editor .vditor-wysiwyg,
.editor-view.reading-width .document-editor .vditor-sv {
  padding-right: clamp(28px, 6vw, 76px) !important;
  padding-left: clamp(28px, 6vw, 76px) !important;
}

.app.editor-focus .workspace-shell {
  grid-template-columns: 0 minmax(0, 1fr) 0;
}

.app.editor-focus .sidebar,
.app.editor-focus .inspector,
.app.editor-focus .inspector-restore {
  display: none;
}

.document-editor:focus-visible {
  outline: 0;
}

.inspector {
  position: relative;
  z-index: 15;
  overflow-y: auto;
  padding: 18px 16px 24px;
  border-left: 1px solid var(--border);
}

.inspector-header {
  min-height: 42px;
}

.inspector-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inspector-tabs {
  display: grid;
  width: 100%;
  margin-top: 10px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.assistant-quick-actions {
  display: grid;
  margin-top: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.assistant-quick-actions button {
  min-height: 36px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 10px;
}

.assistant-quick-actions button:hover {
  border-color: var(--focus);
  background: var(--surface);
}

.inspector-assistant-log {
  display: grid;
  max-height: 330px;
  margin-top: 10px;
  padding-right: 3px;
  overflow-y: auto;
  gap: 8px;
}

.inspector-assistant-log article {
  padding: 9px 10px;
  border-left: 2px solid var(--border-strong);
  background: var(--surface-subtle);
  font-size: 11px;
  line-height: 1.6;
}

.inspector-assistant-log article.error {
  border-left-color: var(--danger);
  color: var(--danger);
}

.inspector-assistant-log strong {
  display: block;
  margin-bottom: 4px;
  font-size: 10px;
}

.inspector-assistant-log p,
.inspector-assistant-log .chat-markdown {
  margin: 0;
  overflow-wrap: anywhere;
}

.inspector-assistant-form {
  display: grid;
  margin-top: 12px;
  gap: 6px;
}

.inspector-assistant-form label {
  color: var(--muted);
  font-size: 10px;
}

.inspector-assistant-form textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  line-height: 1.6;
}

.inspector-tabs .segment {
  min-width: 0;
  padding: 7px 3px;
  font-size: 10px;
  text-align: center;
}

.inspector-pane[hidden] {
  display: none;
}

.inspector-context-summary {
  display: grid;
  margin-top: 18px;
  gap: 6px;
}

.inspector-context-summary span {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
}

.inspector-context-summary strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
}

.inspector-review-issues {
  display: grid;
  margin-top: 10px;
  gap: 5px;
}

.inspector-review-item {
  width: 100%;
  padding: 8px 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--text);
  cursor: pointer;
  font-size: 10px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-review-item:hover {
  border-color: var(--focus);
}

.inspector-restore {
  position: fixed;
  top: calc(var(--header-height) + 14px);
  right: 12px;
  z-index: 30;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 18px;
  box-shadow: 0 8px 20px rgb(0 0 0 / 10%);
}

.inspector-restore:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.inspector-restore[hidden] {
  display: none;
}

.agent-activity {
  width: min(760px, 96%);
  max-width: 100%;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--focus) 38%, var(--border));
  border-radius: 6px;
  background: color-mix(in srgb, var(--focus) 7%, var(--surface));
}

.agent-activity-disclosure {
  min-width: 0;
}

.agent-activity-head {
  display: grid;
  min-height: 54px;
  padding: 9px 11px;
  grid-template-columns: 16px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  transition: background 160ms ease;
}

.agent-activity-head::-webkit-details-marker {
  display: none;
}

.agent-activity-head:hover {
  background: color-mix(in srgb, var(--focus) 6%, transparent);
}

.agent-activity-head:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.agent-activity-pulse {
  width: 9px;
  height: 9px;
  justify-self: center;
  border-radius: 50%;
  background: var(--focus);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--focus) 28%, transparent);
  animation: agentPulse 1200ms ease-out infinite;
}

.agent-activity.complete .agent-activity-pulse {
  background: var(--success);
  animation: none;
}

.agent-activity.error .agent-activity-pulse {
  background: var(--danger);
  animation: none;
}

.agent-activity.long-running {
  border-color: color-mix(in srgb, #9a6700 45%, var(--border));
  background: color-mix(in srgb, #9a6700 8%, var(--surface));
}

.agent-activity.possibly-stuck {
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

.agent-activity.long-running .agent-activity-pulse {
  background: #9a6700;
}

.agent-activity.possibly-stuck .agent-activity-pulse {
  background: var(--danger);
}

.agent-activity-summary-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.agent-activity-title {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-activity-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
}

.agent-activity-elapsed {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.agent-activity-chevron {
  width: 15px;
  height: 15px;
  color: var(--muted);
  transition: transform 160ms ease;
}

.agent-activity-disclosure[open] .agent-activity-chevron {
  transform: rotate(90deg);
}

.agent-activity-body {
  padding: 10px 12px 13px;
  border-top: 1px solid color-mix(in srgb, var(--focus) 20%, var(--border));
}

.agent-activity-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.agent-activity.long-running .agent-activity-note,
.agent-activity.possibly-stuck .agent-activity-note {
  color: var(--text);
}

.agent-activity-events {
  display: grid;
  margin: 0;
  padding: 0;
  gap: 0;
  list-style: none;
}

.agent-activity-event {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 5px 0 8px;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 7px;
}

.agent-activity-event:not(:last-child)::before {
  position: absolute;
  top: 18px;
  bottom: -4px;
  left: 8px;
  width: 1px;
  background: var(--border);
  content: "";
}

.agent-activity-event-marker {
  position: relative;
  z-index: 1;
  width: 8px;
  height: 8px;
  margin-top: 4px;
  justify-self: center;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
}

.agent-activity-event.active .agent-activity-event-marker {
  border-color: var(--focus);
  background: var(--focus);
  animation: agentPulse 1200ms ease-out infinite;
}

.agent-activity-event.terminal .agent-activity-event-marker,
.agent-activity.complete .agent-activity-event-marker {
  border-color: var(--success);
  background: var(--success);
}

.agent-activity-event.failed .agent-activity-event-marker,
.agent-activity.error .agent-activity-event.terminal .agent-activity-event-marker {
  border-color: var(--danger);
  background: var(--danger);
}

.agent-activity-event-content {
  min-width: 0;
}

.agent-activity-event-heading {
  display: flex;
  min-width: 0;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.agent-activity-event-heading strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 11px;
  font-weight: 620;
  line-height: 1.45;
}

.agent-activity-event-heading span {
  flex: 0 0 auto;
  color: var(--faint);
  font-family: var(--font-mono);
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.agent-activity-message,
.agent-activity-reason {
  margin: 5px 0 0;
  padding-left: 8px;
  border-left: 2px solid var(--border-strong);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.agent-activity-reason {
  border-left-color: var(--danger);
  color: var(--danger);
}

.agent-activity-event-detail {
  margin-top: 5px;
}

.agent-activity-event-detail summary {
  width: max-content;
  max-width: 100%;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 9px;
}

.agent-activity-event-detail summary:hover {
  color: var(--text);
}

.agent-activity-event-detail pre {
  max-width: 100%;
  max-height: 220px;
  margin: 6px 0 2px;
  padding: 8px 9px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 9px;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

@keyframes agentPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--focus) 28%, transparent); }
  100% { box-shadow: 0 0 0 9px transparent; }
}

.focus-form {
  display: grid;
  margin-top: 20px;
  gap: 8px;
}

.focus-form label,
.write-dialog label {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.focus-form textarea,
.write-dialog textarea,
.write-dialog input:not([type="checkbox"]),
.write-dialog select {
  width: 100%;
  padding: 9px 10px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}

.focus-form textarea:focus,
.write-dialog textarea:focus,
.write-dialog input:not([type="checkbox"]):focus,
.write-dialog select:focus {
  border-color: var(--focus);
  background: var(--surface);
}

input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  flex: 0 0 16px;
  accent-color: var(--focus);
}

.full-button {
  width: 100%;
  margin-top: 8px;
}

.inspector-divider {
  margin: 22px 0 14px;
}

.project-facts {
  display: grid;
  margin: 0;
  gap: 11px;
}

.project-facts div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.project-facts dt,
.project-facts dd {
  margin: 0;
  font-size: 11px;
}

.project-facts dt {
  color: var(--muted);
}

.project-facts dd {
  max-width: 150px;
  overflow: hidden;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.write-dialog {
  width: min(520px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 60px rgb(0 0 0 / 22%);
}

.writing-targets-dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.writing-target-section {
  display: grid;
  padding: 16px 0 8px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.writing-target-section:first-of-type {
  margin-top: 4px;
}

.writing-target-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.writing-target-section-heading h3 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0;
}

.writing-target-section-heading span,
.writing-target-priority span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.writing-target-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.writing-target-grid label {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.number-unit-field {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
}

.write-dialog .number-unit-field input:not([type="checkbox"]) {
  min-width: 0;
  padding-right: 4px;
  border: 0;
  background: transparent;
  outline: 0;
}

.number-unit-field > span {
  padding: 0 10px 0 6px;
  color: var(--muted);
  font-size: 10px;
}

.number-unit-field:focus-within {
  border-color: var(--focus);
  background: var(--surface);
}

.writing-target-priority {
  display: flex;
  margin: 4px 0 0;
  padding-top: 12px;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--border);
}

.writing-target-priority strong {
  font-size: 11px;
}

.model-dialog {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.model-tabs { width: max-content; margin: 16px 0 12px; }
.model-tab-pane[hidden] { display: none; }
.model-profile-layout { display: grid; min-height: 430px; grid-template-columns: 220px minmax(0, 1fr); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.model-profile-browser { min-width: 0; padding: 10px; border-right: 1px solid var(--border); background: var(--surface-subtle); }
.model-profile-list { display: grid; max-height: 480px; margin-top: 10px; overflow-y: auto; gap: 4px; }
.model-profile-item { display: grid; width: 100%; min-height: 54px; padding: 9px 10px; border: 1px solid transparent; border-radius: 5px; background: transparent; color: var(--text); cursor: pointer; gap: 4px; text-align: left; }
.model-profile-item:hover { background: var(--surface); }
.model-profile-item.active { border-color: var(--focus); background: var(--surface); }
.model-profile-item strong, .model-profile-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-profile-item strong { font-size: 12px; }
.model-profile-item span { color: var(--muted); font-size: 10px; }
.model-profile-editor { min-width: 0; padding: 16px; overflow-y: auto; }
.model-profile-actions { align-items: center; }
.model-profile-actions select { width: auto; max-width: 210px; }
.action-spacer { flex: 1; }
.model-route-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.model-route-field { display: grid; min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-subtle); gap: 7px; }
.model-route-field span { color: var(--text); font-size: 12px; font-weight: 650; }
.model-route-field select { min-width: 0; }

.model-active-card {
  display: flex;
  min-height: 56px;
  padding: 10px 12px;
  align-items: center;
  gap: 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-subtle);
}

.model-active-card div {
  display: grid;
  gap: 3px;
}

.model-active-card small,
.field-help {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.model-active-card strong {
  font-size: 12px;
}

.model-security-note {
  padding: 9px 10px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}

.model-form-grid {
  display: grid;
  margin-top: 4px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 12px;
}

.model-field {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 5px;
}

.model-field.full-span {
  grid-column: 1 / -1;
}

.model-field label {
  margin-top: 0;
}

.embedding-preset-help {
  min-height: 29px;
  font-variant-numeric: tabular-nums;
}

[data-embedding-cloud][hidden] {
  display: none;
}

.secret-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.secret-input-row .quiet-button {
  min-width: 58px;
  min-height: 40px;
  padding: 0 10px;
}

.write-dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}

.write-dialog form {
  display: grid;
  padding: 22px;
  gap: 8px;
}

.setup-dialog {
  max-height: min(780px, calc(100vh - 32px));
  padding: 22px;
  overflow-y: auto;
}

.setup-dialog > .dialog-header,
.setup-dialog > .dialog-note {
  margin-right: 0;
  margin-left: 0;
}

.setup-dialog form {
  padding: 14px 0;
}

.project-path-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.recent-projects {
  display: grid;
  gap: 5px;
}

.recent-project-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  align-items: center;
}

.recent-project-delete {
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
  white-space: nowrap;
}

.recent-project-delete:hover {
  color: #dc2626;
  border-color: #dc2626;
}

.recent-project {
  display: grid;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
  text-align: left;
  gap: 2px;
}

.recent-project strong {
  font-size: 11px;
}

.recent-project span {
  overflow: hidden;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-divider {
  position: relative;
  border-top: 1px solid var(--border);
  text-align: center;
}

.setup-divider span {
  position: relative;
  top: -9px;
  padding: 0 8px;
  background: var(--surface);
  color: var(--faint);
  font-size: 10px;
}

.review-dialog {
  width: min(660px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
}

.review-workspace-view { height: 100%; overflow: auto; }
.review-summary-band { display: grid; margin: 18px 0; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.review-summary-band > div { display: grid; min-height: 74px; padding: 13px 16px; align-content: center; gap: 5px; }
.review-summary-band > div + div { border-left: 1px solid var(--border); }
.review-summary-band span { color: var(--muted); font-size: 10px; }
.review-summary-band strong { font-size: 21px; }
.review-workspace-layout { display: grid; min-height: 560px; grid-template-columns: 250px minmax(0, 1fr); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.review-chapter-list-panel { min-width: 0; padding: 14px 10px; border-right: 1px solid var(--border); background: var(--surface-subtle); }
.review-chapter-list { display: grid; max-height: 620px; overflow-y: auto; gap: 3px; }
.review-chapter-item { display: grid; width: 100%; min-height: 52px; padding: 8px 9px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--text); cursor: pointer; gap: 3px; text-align: left; }
.review-chapter-item:hover, .review-chapter-item.active { background: var(--surface); }
.review-chapter-item.active { border-color: var(--focus); }
.review-chapter-item strong, .review-chapter-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.review-chapter-item strong { font-size: 12px; }
.review-chapter-item span { color: var(--muted); font-size: 10px; }
.review-issue-workspace { min-width: 0; padding: 16px; background: var(--surface); }
.review-filter-bar { display: grid; grid-template-columns: minmax(140px, 1fr) 140px 160px auto; align-items: center; gap: 8px; }
.review-filter-bar h2 { margin: 0; font-size: 15px; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.review-workspace-issues { display: grid; margin-top: 12px; gap: 7px; }
.review-workspace-issue { min-width: 0; padding: 12px 13px; border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: 5px; background: var(--surface-subtle); }
.review-workspace-issue.severity-blocker { border-left-color: var(--danger); }
.review-workspace-issue.severity-high { border-left-color: #b45309; }
.review-workspace-issue.severity-medium { border-left-color: #a16207; }
.review-workspace-issue.severity-low { border-left-color: var(--focus); }
.review-workspace-issue.resolved { border-left-color: var(--success); opacity: .72; }
.review-workspace-issue p { margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.review-issue-dimension { display: block; margin-top: 5px; color: var(--faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.review-change { padding: 2px 6px; border-radius: 999px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.review-change.new { background: var(--accent-soft); color: var(--accent-strong); }
.review-change.remaining { background: var(--surface-strong); }
.review-change.resolved { background: color-mix(in srgb, var(--success) 14%, var(--surface)); color: var(--success); }

.review-dialog-content {
  padding: 22px;
}

.review-loading {
  padding: 34px 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.review-score-row {
  display: flex;
  margin-top: 22px;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-strong);
}

.review-score-row strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 34px;
  font-weight: 680;
}

.review-score-row span:not(.status-pill) {
  margin-left: 4px;
  color: var(--muted);
  font-size: 11px;
}

.review-summary {
  margin: 15px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.review-issues {
  max-height: 420px;
  overflow-y: auto;
}

.review-issue {
  padding: 13px 0;
  border-top: 1px solid var(--border);
}

.review-issue:first-child {
  border-top: 0;
}

.review-issue-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.review-issue-heading strong {
  font-size: 12px;
}

.severity {
  padding: 3px 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 9px;
  font-weight: 700;
}

.severity.critical {
  background: var(--danger-soft);
  color: var(--danger);
}

.severity.info {
  background: var(--surface-strong);
  color: var(--muted);
}

.review-issue p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.review-suggestion {
  color: var(--text) !important;
}

.review-issue-actions { display: flex; margin-top: 10px; gap: 7px; }
.review-issue-actions .quiet-button { min-height: 30px; padding: 5px 8px; font-size: 10px; }

.revision-request-dialog { width: min(620px, calc(100vw - 32px)); }
.revision-selection-box { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-subtle); }
.revision-selection-box strong { font-size: 11px; }
.revision-selection-box pre { max-height: 150px; margin: 8px 0 0; overflow: auto; color: var(--muted); font-family: "Iowan Old Style", "Noto Serif CJK SC", serif; font-size: 12px; line-height: 1.65; white-space: pre-wrap; }
.revision-preview-dialog { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.revision-preview-content { padding: 22px; }
.revision-preview-meta { display: flex; margin: 14px 0 10px; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; }
.revision-compare { display: grid; min-height: 260px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.revision-compare section { min-width: 0; padding: 12px 14px; background: var(--surface-subtle); }
.revision-compare section + section { border-left: 1px solid var(--border); background: var(--surface); }
.revision-compare strong { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.revision-compare pre, .revision-unified pre { max-height: 420px; overflow: auto; color: var(--text); font-family: "Iowan Old Style", "Noto Serif CJK SC", serif; font-size: 13px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.revision-hunks { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface-subtle); }
.revision-hunks[hidden] { display: none; }
.revision-hunks-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.revision-hunks-heading > div { display: flex; align-items: center; gap: 8px; }
.revision-hunks-heading strong { font-size: 11px; }
.revision-hunks-heading span { color: var(--muted); font-size: 10px; }
.revision-hunks-heading .quiet-button { min-height: 30px; padding: 4px 8px; font-size: 10px; }
.revision-hunks-list { display: grid; max-height: 340px; margin-top: 10px; overflow-y: auto; gap: 7px; }
.revision-hunk { display: grid; padding: 9px; grid-template-columns: 20px minmax(0, 1fr); align-items: start; gap: 7px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); cursor: pointer; }
.revision-hunk:has(input:checked) { border-color: var(--focus); }
.revision-hunk input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--focus); }
.revision-hunk strong { font-size: 10px; }
.revision-hunk pre { max-height: 130px; margin: 6px 0 0; padding: 7px 8px; overflow: auto; border-left: 2px solid var(--border-strong); background: var(--surface-subtle); font-size: 10px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.revision-hunk pre.removed { border-left-color: var(--danger); }
.revision-hunk pre.added { border-left-color: var(--success); }
.revision-unified { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 5px; }
.revision-unified summary { color: var(--muted); cursor: pointer; font-size: 10px; }
.revision-unified pre { max-height: 240px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; line-height: 1.55; }
.revision-rationale { margin: 14px 0 6px; color: var(--text); font-size: 12px; line-height: 1.65; }
.revision-history-dialog { width: min(620px, calc(100vw - 32px)); }
.revision-history-list { display: grid; max-height: 520px; margin-top: 14px; overflow: auto; gap: 6px; }
.revision-history-item { display: grid; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--text); cursor: pointer; gap: 4px; text-align: left; }
.revision-history-item:hover { border-color: var(--focus); background: var(--surface-subtle); }
.revision-history-item strong { font-size: 11px; }
.revision-history-item span { color: var(--muted); font-size: 9px; }
.revision-history-item:disabled { cursor: default; opacity: 0.7; }
.annotation-dialog { width: min(520px, calc(100vw - 32px)); }
.annotation-quote { max-height: 140px; margin: 12px 0; padding: 10px 12px; overflow: auto; border-left: 2px solid var(--accent); background: var(--surface-subtle); font-size: 11px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.annotation-history-item { display: grid; width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); gap: 5px; }
.annotation-history-item strong { font-size: 11px; overflow-wrap: anywhere; }
.annotation-history-item > span { color: var(--muted); font-size: 10px; overflow-wrap: anywhere; }
.annotation-history-item small { color: var(--faint); font-size: 9px; }
.annotation-history-actions { display: flex; margin-top: 3px; flex-wrap: wrap; gap: 6px; }
.annotation-history-actions button { min-height: 30px; padding: 4px 8px; font-size: 10px; }

.task-center-button { display: inline-flex; min-width: 48px; height: 34px; padding: 0 9px; align-items: center; justify-content: center; gap: 5px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); color: var(--muted); cursor: pointer; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; }
.task-center-button.active { border-color: var(--accent); color: var(--accent-strong); }
.task-center-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.task-center-content { padding: 22px; }
.task-center-toolbar { display: flex; margin: 12px 0; justify-content: space-between; gap: 8px; }
.task-list { max-height: min(620px, calc(100vh - 190px)); overflow: auto; }
.task-group-title { margin: 18px 0 6px; color: var(--muted); font-size: 10px; font-weight: 650; }
.task-row { display: grid; min-width: 0; padding: 9px 0; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; border-top: 1px solid var(--border); }
.task-row-copy { display: grid; min-width: 0; padding: 3px 0; border: 0; background: transparent; color: var(--text); cursor: pointer; gap: 3px; text-align: left; }
.task-row-copy strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.task-row-copy span, .task-row-copy small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.task-row.status-failed .task-row-copy small, .task-row.status-interrupted .task-row-copy small { color: var(--danger); }
.task-row-actions { display: flex; gap: 6px; }
.task-row-actions button { min-height: 30px; padding: 5px 8px; font-size: 10px; }
.task-detail-dialog { width: min(620px, calc(100vw - 32px)); }
.task-detail-events { display: grid; max-height: 480px; margin: 14px 0 0; padding: 0; overflow: auto; list-style: none; }
.task-detail-events li { display: grid; padding: 9px 0; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; border-top: 1px solid var(--border); font-size: 10px; }
.task-detail-events strong { color: var(--text); }
.task-detail-events span { color: var(--muted); }
.controlled-write-dialog { width: min(560px, calc(100vw - 32px)); }

.asset-header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.asset-header-actions button {
  white-space: nowrap;
}

.asset-workspace {
  display: grid;
  min-height: 620px;
  margin-top: 26px;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  border-top: 1px solid var(--border);
}

.asset-browser {
  min-width: 0;
  padding: 16px 14px 24px 0;
  border-right: 1px solid var(--border);
}

.asset-kind-tabs {
  display: grid;
  grid-template-columns: 1fr;
  width: 100%;
}

.asset-kind-tabs .segment {
  min-height: 34px;
  text-align: left;
}

.asset-list {
  display: grid;
  margin-top: 10px;
  gap: 4px;
}

.asset-list-item {
  display: grid;
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.asset-list-item:hover,
.asset-list-item.active {
  border-color: var(--border);
  background: var(--surface-subtle);
}

.asset-list-item input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
}

.asset-list-item strong,
.asset-list-item span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-list-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.asset-editor-panel {
  min-width: 0;
  padding: 20px 0 40px 24px;
}

.asset-editor-pane {
  min-width: 0;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  background: var(--surface);
}

.asset-editor-pane[hidden] {
  display: none;
}

.asset-editor-pane .asset-form {
  --asset-label-column: 128px;
  --asset-column-gap: 28px;
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 28px clamp(22px, 4vw, 52px) 64px;
}

.asset-empty-state {
  display: grid;
  min-height: 420px;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.asset-empty-state[hidden],
.asset-form[hidden] {
  display: none;
}

.asset-empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.asset-editor-heading {
  min-width: 0;
  padding-bottom: 14px;
}

.asset-editor-heading h2 {
  margin: 4px 0 2px;
  font-size: 20px;
}

.asset-editor-heading code {
  color: var(--muted);
  font-size: 10px;
}

.asset-kind-label {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.asset-editor-modes {
  display: flex;
  min-height: 38px;
  margin-bottom: 2px;
  align-items: end;
  gap: 20px;
  border-bottom: 1px solid var(--border);
}

.asset-mode-tab {
  position: relative;
  min-height: 38px;
  padding: 0 1px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.asset-mode-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  content: "";
}

.asset-mode-tab:hover,
.asset-mode-tab.active {
  color: var(--text);
}

.asset-mode-tab.active {
  font-weight: 650;
}

.asset-mode-tab.active::after {
  background: var(--accent);
}

.asset-mode-tab:focus-visible {
  border-radius: 3px;
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.asset-fields {
  display: grid;
  padding: 0;
}

.asset-fields[hidden],
.asset-raw-field[hidden],
.asset-relation-options[hidden] {
  display: none;
}

.asset-field-section {
  display: grid;
  padding: 24px 0;
  grid-template-columns: var(--asset-label-column) minmax(0, 1fr);
  gap: var(--asset-column-gap);
  border-bottom: 1px solid var(--border);
}

.asset-field-section > h3 {
  min-height: 20px;
  margin: 0;
  color: var(--text);
  font-size: 12px;
  font-weight: 680;
  line-height: 20px;
}

.asset-field-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.asset-field {
  display: grid;
  align-self: start;
  min-width: 0;
  gap: 6px;
}

.asset-field > span:first-child {
  display: flex;
  min-height: 20px;
  align-items: center;
  line-height: 20px;
}

.asset-field.full-span {
  grid-column: 1 / -1;
}

.asset-field small {
  color: var(--muted);
  font-size: 10px;
  line-height: 16px;
}

.asset-field textarea,
.asset-field input,
.asset-field select,
.asset-raw-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.asset-field textarea,
.asset-raw-field textarea {
  min-height: 88px;
  resize: vertical;
  line-height: 1.55;
}

.asset-markdown-editor {
  width: 100%;
  min-height: 240px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 5px;
}

.asset-relations-field {
  gap: 10px;
}

.asset-relation-heading {
  display: flex;
  min-height: 20px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.asset-relation-heading > span {
  font-size: 11px;
  font-weight: 620;
}

.asset-relation-picker {
  position: relative;
}

.asset-relation-picker > input {
  padding-left: 34px;
}

.asset-relation-search-icon {
  position: absolute;
  z-index: 1;
  top: 12px;
  left: 11px;
  width: 16px;
  height: 16px;
  pointer-events: none;
  color: var(--muted);
}

.asset-relation-options {
  position: absolute;
  z-index: 8;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 312px;
  padding: 5px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  box-shadow: 0 12px 28px rgb(0 0 0 / 12%);
  background: var(--surface);
}

.asset-relation-option {
  display: grid;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  justify-items: start;
  gap: 3px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.asset-relation-option:hover,
.asset-relation-option:focus-visible {
  outline: 0;
  background: var(--surface-strong);
}

.asset-relation-option strong {
  font-size: 12px;
}

.asset-relation-option span,
.asset-relation-option-empty {
  color: var(--muted);
  font-size: 10px;
}

.asset-relation-option-empty {
  margin: 0;
  padding: 16px 10px;
  text-align: center;
}

.asset-relation-list {
  display: grid;
  gap: 7px;
}

.asset-relation-group {
  display: grid;
  gap: 7px;
}

.asset-relation-group[hidden] {
  display: none;
}

.asset-relation-group h4 {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 620;
}

.asset-relation-reference-list {
  display: grid;
  border-top: 1px solid var(--border);
}

.asset-relation-reference-row {
  display: grid;
  min-width: 0;
  min-height: 58px;
  padding: 9px 4px;
  grid-template-columns: minmax(150px, 0.9fr) minmax(0, 1.8fr);
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.asset-relation-reference-row > .asset-relation-identity {
  padding: 0;
}

.asset-relation-reference-detail {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(82px, 0.45fr) minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.asset-relation-reference-detail strong,
.asset-relation-reference-detail span,
.asset-relation-reference-detail small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-relation-reference-detail strong {
  font-size: 10px;
  font-weight: 600;
}

.asset-relation-reference-detail span {
  font-size: 10px;
}

.asset-relation-reference-detail small {
  color: var(--muted);
  font-size: 9px;
}

.asset-relation-list.empty::before {
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--muted);
  content: "尚未连接资料";
  font-size: 10px;
  text-align: center;
}

.asset-relation-row {
  display: grid;
  min-width: 0;
  padding: 9px 10px;
  grid-template-columns: minmax(150px, 1.1fr) minmax(120px, 0.75fr) minmax(160px, 1.2fr) 30px;
  align-items: end;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
}

.asset-relation-identity {
  min-width: 0;
  padding-bottom: 5px;
}

button.asset-relation-identity {
  padding: 0 0 5px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

button.asset-relation-identity:hover strong,
button.asset-relation-identity:focus-visible strong {
  color: var(--accent-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}

button.asset-relation-identity:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.asset-relation-identity strong,
.asset-relation-identity span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-relation-identity strong {
  font-size: 12px;
}

.asset-relation-identity span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.asset-relation-property {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.asset-relation-property > span {
  color: var(--muted);
  font-size: 9px;
}

.asset-relation-property input {
  min-width: 0;
  min-height: 34px;
  padding: 7px 8px;
}

.asset-relation-remove {
  width: 30px;
  min-height: 30px;
  margin-bottom: 2px;
}

.asset-raw-field {
  display: grid;
  padding: 24px 0;
  grid-template-columns: var(--asset-label-column) minmax(0, 1fr);
  gap: var(--asset-column-gap);
  border-bottom: 1px solid var(--border);
}

.asset-raw-heading {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 4px;
}

.asset-raw-heading strong {
  min-height: 20px;
  font-size: 12px;
  line-height: 20px;
}

.asset-raw-heading code {
  color: var(--muted);
  font-size: 10px;
}

.asset-raw-field textarea {
  grid-column: 2;
  min-height: 620px;
  padding: 16px;
  background: var(--surface-subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
  tab-size: 2;
}

.asset-stage-list {
  display: grid;
  gap: 8px;
}

.asset-stage-row {
  display: grid;
  padding: 10px;
  grid-template-columns: minmax(100px, 0.7fr) minmax(120px, 1fr) minmax(150px, 1.5fr) auto;
  gap: 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-subtle);
}

.asset-stage-row input,
.asset-stage-row textarea {
  min-width: 0;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.asset-stage-row textarea {
  resize: vertical;
}

.asset-form-actions {
  position: sticky;
  z-index: 4;
  bottom: 0;
  display: grid;
  align-items: center;
  grid-template-columns: var(--asset-label-column) minmax(0, 1fr) auto;
  column-gap: var(--asset-column-gap);
  padding: 12px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.asset-form-actions .form-status {
  grid-column: 2;
  margin: 0;
}

.asset-form-actions .primary-button {
  grid-column: 3;
}

.asset-package-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
}

.asset-package-content {
  max-height: calc(100vh - 80px);
  overflow: auto;
}

.asset-package-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.asset-package-summary span {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-package-assets {
  display: grid;
  margin: 12px 0;
  gap: 8px;
}

.asset-package-item {
  display: grid;
  padding: 11px;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.asset-package-item.conflict {
  border-color: var(--warning);
}

.asset-package-item strong,
.asset-package-item span {
  display: block;
}

.asset-package-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.asset-package-item pre {
  max-height: 130px;
  margin: 8px 0 0;
  padding: 8px;
  overflow: auto;
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 10px;
  white-space: pre-wrap;
}

.asset-package-item select,
.asset-package-item input {
  width: 100%;
  min-height: 36px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

@media (max-width: 760px) {
  .revision-compare { grid-template-columns: 1fr; }
  .revision-compare section + section { border-top: 1px solid var(--border); border-left: 0; }
}

.dialog-header {
  margin-bottom: 8px;
}

.write-dialog input:not([type="checkbox"]) {
  height: 40px;
}

.write-dialog select {
  height: 40px;
}

.dialog-note {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.dialog-actions {
  margin-top: 12px;
  justify-content: flex-end;
  gap: 8px;
}

.write-progress {
  min-height: 20px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.write-progress.error {
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 90;
  max-width: min(360px, calc(100vw - 36px));
  padding: 10px 13px;
  transform: translateY(24px);
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--text);
  color: var(--surface);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--danger);
  color: #ffffff;
}

.mobile-only {
  display: none;
}

.mobile-compact-icon {
  display: none;
}

.desktop-only {
  display: inline-grid;
}

@media (max-width: 1200px) {
  .relationship-controls {
    grid-template-columns: 1fr 1fr;
  }

  .relationship-search-control,
  .relationship-control-actions {
    grid-column: 1 / -1;
  }

  .relationship-control-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 1080px) {
  :root {
    --sidebar-width: 205px;
    --inspector-width: 268px;
  }

  .dashboard-view {
    padding-right: 28px;
    padding-left: 28px;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .review-workspace-layout {
    grid-template-columns: 1fr;
  }

  .review-chapter-list-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .review-chapter-list {
    max-height: 230px;
  }

  .review-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-toolbar {
    align-items: flex-start;
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .editor-title-block,
  .editor-actions {
    width: 100%;
  }

  .editor-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .editor-commandbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-tool-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .editor-find-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .editor-find-panel > span {
    grid-column: span 2;
  }
}

@media (max-width: 1080px) {
  .outline-header {
    display: grid;
  }

  .outline-header-actions {
    justify-content: flex-start;
  }
}

@media (hover: none) {
  .outline-tree-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
  }

  .outline-row-actions {
    position: static;
    display: none;
    min-height: 36px;
    padding-left: 0;
    opacity: 1;
    pointer-events: auto;
    background: transparent;
    box-shadow: none;
  }

  .outline-tree-node[aria-current="true"] ~ .outline-row-actions {
    display: flex;
    background: transparent;
    box-shadow: none;
  }
}

@media (max-width: 820px) {
  .outline-view {
    height: calc(100vh - 100px);
    min-height: 520px;
    padding: 14px 12px 18px;
  }

  .outline-header {
    display: grid;
    min-height: 0;
    gap: 11px;
  }

  .outline-title-row code {
    display: none;
  }

  .outline-header-actions {
    display: grid;
    width: 100%;
    grid-template-columns: auto auto 36px minmax(0, 1fr);
    justify-content: stretch;
  }

  .outline-header-actions button {
    min-width: 0;
    padding-right: 8px;
    padding-left: 8px;
  }

  .outline-mobile-switch {
    display: flex;
    width: 100%;
    margin-top: 10px;
    padding: 2px;
    flex: 0 0 auto;
  }

  .outline-mobile-switch .segment {
    flex: 1;
  }

  .outline-workspace {
    margin-top: 8px;
    grid-template-columns: minmax(0, 1fr);
  }

  .outline-workspace[data-mobile-pane="tree"] .outline-detail,
  .outline-workspace[data-mobile-pane="detail"] .outline-tree-panel {
    display: none;
  }

  .outline-tree-panel {
    border-right: 0;
  }

  .outline-detail {
    padding: 0 14px 20px;
  }

  .outline-detail-header {
    position: static;
    padding-top: 15px;
  }

  .outline-detail-title-row {
    gap: 8px;
  }

  .outline-detail h2 {
    font-size: 20px;
  }

  .outline-detail-command-row {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 7px;
  }

  .outline-detail-actions,
  .outline-edit-actions {
    justify-content: flex-start;
  }

  .outline-detail-actions .primary-button {
    flex: 1;
  }

  .outline-tree-row {
    grid-template-columns: 24px minmax(0, 1fr) auto;
  }

  .outline-row-actions {
    position: static;
    display: none;
    padding-left: 0;
    opacity: 1;
    pointer-events: auto;
    background: transparent;
    box-shadow: none;
  }

  .outline-tree-node[aria-current="true"] ~ .outline-row-actions {
    display: flex;
    background: transparent;
    box-shadow: none;
  }

  .outline-row-action {
    width: 42px;
    min-height: 42px;
  }

  .outline-tree-toggle,
  .outline-tree-spacer,
  .outline-tree-node {
    min-height: 42px;
  }
}

@media (max-width: 900px) {
  .brand-logo {
    width: 84px;
  }

  .brand-divider,
  .book-identity span,
  .save-state,
  #theme-toggle {
    display: none;
  }

  .topbar-actions {
    gap: 5px;
  }

  .topbar-actions button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .workspace-shell {
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  }

  .app.editor-focus .workspace-shell {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .inspector {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    display: block;
    width: min(var(--inspector-width), calc(100vw - 36px));
    transform: translateX(100%);
    box-shadow: -12px 0 30px rgb(0 0 0 / 15%);
    transition: transform 200ms ease;
  }

  .app.inspector-collapsed .inspector {
    display: block;
  }

  .inspector.open {
    transform: translateX(0);
  }

  .inspector-backdrop:not([hidden]) {
    position: fixed;
    inset: var(--header-height) 0 0;
    z-index: 14;
    display: block;
    width: 100%;
    border: 0;
    background: rgb(0 0 0 / 38%);
  }

  .mobile-only {
    display: inline-grid;
  }

  .desktop-only,
  .inspector-restore {
    display: none;
  }

  .agent-console {
    grid-template-columns: 1fr;
  }

  .agent-sessions-panel {
    position: static;
  }

  .truth-grid {
    grid-template-columns: 1fr;
  }

  .review-workspace-layout {
    grid-template-columns: 1fr;
  }

  .review-chapter-list-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .review-chapter-list {
    max-height: 230px;
  }

  .review-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .asset-relation-row {
    position: relative;
    padding-right: 44px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .asset-relation-identity {
    grid-column: 1 / -1;
  }

  .asset-relation-remove {
    position: absolute;
    top: 10px;
    right: 8px;
  }

  .relationship-heading {
    grid-template-columns: minmax(0, 1fr);
  }

  .relationship-stage,
  #relationship-graph {
    min-height: 520px;
    height: 520px;
  }

  .relationship-inspector {
    display: block;
    max-height: none;
    overflow: visible;
  }

  .relationship-detail {
    max-height: none;
    padding-right: 0;
    overflow: visible;
  }

  .relationship-list-heading {
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
  }

  .relationship-node-list {
    max-height: 260px;
  }
}

@media (max-width: 700px) {
  .research-layout {
    grid-template-columns: 1fr;
  }

  :root {
    --header-height: 54px;
  }

  html,
  body {
    overflow: auto;
  }

  .topbar {
    position: sticky;
    top: 0;
    padding: 0 10px;
  }

  .brand-logo {
    width: 72px;
  }

  .brand-divider,
  .book-identity,
  .book-identity span,
  .save-state,
  #theme-toggle {
    display: none;
  }

  .book-identity strong {
    max-width: 23vw;
    font-size: 11px;
  }

  .topbar-actions {
    gap: 5px;
  }

  .model-settings-button {
    min-height: 32px;
    padding: 0 8px;
    font-size: 11px;
  }

  .model-settings-button small {
    display: none;
  }

  .model-settings-button > span:not(.connection-dot) {
    display: none;
  }

  .model-settings-button,
  .task-center-button {
    width: 34px;
    min-width: 34px;
    padding: 0;
    justify-content: center;
  }

  .writing-targets-button {
    width: 34px;
    min-width: 34px;
    padding: 0 !important;
    justify-content: center;
  }

  .writing-targets-button .mobile-compact-icon {
    display: block;
    width: 16px;
    height: 16px;
  }

  .writing-targets-button .mobile-compact-label {
    display: none;
  }

  .topbar .primary-button,
  .topbar .quiet-button {
    white-space: nowrap;
  }

  .topbar .primary-button,
  .topbar .quiet-button {
    min-height: 32px;
    padding: 0 9px;
    font-size: 11px;
  }

  .workspace-shell {
    display: block;
    height: auto;
    min-height: calc(100vh - var(--header-height));
  }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 45;
    display: flex;
    width: min(290px, 86vw);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 180ms ease;
    box-shadow: 14px 0 28px rgb(0 0 0 / 14%);
  }

  .app.mobile-nav-open .sidebar {
    transform: translateX(0);
  }

  .mobile-nav-backdrop:not([hidden]) {
    position: fixed;
    inset: var(--header-height) 0 0;
    z-index: 44;
    display: block;
    width: 100%;
    border: 0;
    background: rgb(0 0 0 / 38%);
  }

  .view-nav {
    display: grid;
    padding: 10px;
    overflow-y: auto;
    gap: 12px;
  }

  .nav-item {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 0 10px;
    grid-template-columns: 24px minmax(0, 1fr);
    text-align: left;
  }

  .sidebar-divider,
  .sidebar-footer {
    display: none;
  }

  .document-list {
    display: grid;
    padding: 0 8px 12px;
    overflow-y: auto;
    gap: 3px;
  }

  .document-item {
    width: 100%;
    min-width: 0;
    min-height: 46px;
    padding: 7px 8px;
    border-top: 0;
    border-left: 2px solid transparent;
    background: transparent;
  }

  .document-item.active {
    border-left-color: var(--accent);
  }

  .document-item span {
    margin-top: 2px;
  }

  .main-panel {
    min-height: calc(100vh - 100px);
    overflow: visible;
  }

  .dashboard-view {
    padding: 24px 14px 80px;
  }

  .workspace-view {
    padding: 24px 14px 80px;
  }

  .workspace-view-header {
    display: grid;
  }

  #tools-view .tool-grid {
    gap: 14px;
  }

  #tools-view .tool-card-header {
    min-height: 102px;
    padding: 15px;
  }

  .tool-card-heading {
    padding-right: 56px;
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 10px;
  }

  .tool-card-wide .tool-card-heading {
    padding-right: 100px;
  }

  .tool-card-icon {
    width: 36px;
    height: 36px;
  }

  .tool-card-header-actions {
    top: 12px;
    right: 12px;
    gap: 6px;
  }

  .tool-card-metric {
    min-height: 34px;
    padding: 0 7px;
  }

  .tool-card-metric > span {
    display: none;
  }

  .tool-help-button {
    top: 12px;
    right: 12px;
    width: 44px;
    min-width: 44px;
    height: 44px;
  }

  .tool-card-body,
  .tool-help-panel {
    padding-right: 15px;
    padding-left: 15px;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
  }

  .tool-grid,
  .continuity-grid,
  .form-grid.two,
  .model-form-grid,
  .model-route-grid,
  .review-workspace-layout,
  .review-filter-bar {
    grid-template-columns: 1fr;
  }

  .narrative-forecast-controls,
  .narrative-forecast-detail {
    grid-template-columns: 1fr;
  }

  .narrative-forecast-history {
    grid-template-columns: 1fr;
  }

  .narrative-forecast-summary {
    display: grid;
  }

  .narrative-forecast-summary > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .narrative-forecast-summary > span {
    white-space: normal;
  }

  .transfer-layout,
  .deconstruct-layout,
  .skills-layout {
    grid-template-columns: 1fr;
  }

  .transfer-panel,
  .deconstruct-intake,
  .deconstruct-library,
  .skill-catalog,
  .skill-simulator {
    padding: 18px 0;
  }

  .transfer-panel + .transfer-panel,
  .deconstruct-library,
  .skill-simulator {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .transfer-metrics,
  .deconstruct-stats,
  .skill-stats {
    justify-content: flex-start;
  }

  .transfer-metrics span:first-child,
  .deconstruct-stats span:first-child,
  .skill-stats span:first-child {
    padding-left: 0;
    border-left: 0;
  }

  .source-analysis-toolbar {
    justify-content: stretch;
  }

  .source-analysis-toolbar select,
  .source-analysis-toolbar button {
    flex: 1 1 140px;
  }

  .profile-item {
    grid-template-columns: 1fr;
  }

  .source-finding blockquote {
    grid-template-columns: 1fr;
  }

  .reference-candidate-row {
    grid-template-columns: 18px minmax(0, 1fr);
    align-items: start;
  }

  .reference-candidate-controls {
    grid-column: 2;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reference-style-recipe {
    grid-template-columns: 1fr;
  }

  .model-profile-layout {
    grid-template-columns: 1fr;
  }

  .model-profile-browser {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .model-profile-list {
    max-height: 170px;
  }

  .model-profile-actions {
    align-items: stretch;
  }

  .model-profile-actions select {
    width: 100%;
    max-width: none;
  }

  .action-spacer {
    display: none;
  }

  .review-workspace-layout {
    min-height: 0;
  }

  .review-chapter-list-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .review-chapter-list {
    max-height: 240px;
  }

  .model-field.full-span {
    grid-column: auto;
  }

  .truth-grid,
  .relationship-workspace,
  .asset-workspace {
    grid-template-columns: 1fr;
  }

  .asset-browser {
    padding-right: 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .asset-kind-tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .asset-kind-tabs .segment {
    text-align: center;
  }

  .asset-editor-panel {
    padding: 20px 0 40px;
  }

  .asset-stage-row {
    grid-template-columns: 1fr;
  }

  .asset-field-section {
    padding: 20px 0;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .asset-field-grid {
    grid-template-columns: 1fr;
  }

  .asset-field.full-span {
    grid-column: auto;
  }

  .asset-raw-field {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .asset-raw-field textarea {
    grid-column: 1;
  }

  .asset-form-actions {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
  }

  .asset-form-actions .form-status {
    grid-column: 1;
  }

  .asset-form-actions .primary-button {
    grid-column: 2;
  }

  .asset-relation-reference-row {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .asset-relation-reference-detail {
    grid-template-columns: minmax(72px, 0.45fr) minmax(0, 1fr);
  }

  .asset-relation-reference-detail small {
    grid-column: 1 / -1;
  }

  .asset-raw-field textarea {
    min-height: 480px;
  }

  .asset-package-item {
    grid-template-columns: 1fr;
  }

  .relationship-heading {
    display: grid;
  }

  .relationship-controls {
    grid-template-columns: 1fr 1fr;
  }

  .relationship-search-control,
  .relationship-control-actions {
    grid-column: 1 / -1;
  }

  .relationship-control-actions {
    justify-content: flex-start;
  }

  .relationship-stage { min-height: 430px; height: 430px; }

  #relationship-graph { height: 430px; }

  .relationship-inspector {
    max-height: none;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .search-form,
  .project-path-row {
    grid-template-columns: 1fr;
  }

  .product-tour-card {
    width: calc(100vw - 28px);
  }

  .chat-log {
    min-height: 280px;
    max-height: none;
  }

  .chat-message {
    max-width: 96%;
  }

  h1 {
    font-size: 25px;
  }

  .metric-grid {
    margin-top: 20px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-height: 88px;
    padding: 12px;
  }

  .metric strong {
    margin-top: 15px;
    font-size: 21px;
  }

  .dashboard-columns {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .next-action-band {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .next-actions {
    justify-content: flex-start;
  }

  .editor-view {
    height: calc(100vh - 100px);
    min-height: 520px;
  }

  .editor-toolbar {
    min-height: 92px;
    padding: 9px 12px;
    flex-wrap: nowrap;
    gap: 7px;
  }

  .library-tabs {
    padding-right: 10px;
    padding-left: 10px;
  }

  .library-navigation {
    display: grid;
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .library-navigation[hidden] {
    display: none;
  }

  .library-actions {
    padding: 6px 10px 8px;
    overflow-x: auto;
    border-top: 1px solid var(--border);
  }

  .library-actions select {
    min-width: 112px;
  }

  .asset-editor-pane .asset-form {
    padding: 20px 14px 56px;
  }

  .asset-editor-heading {
    display: grid;
  }

  .editor-commandbar {
    padding: 7px 10px;
  }

  .editor-progress {
    width: 100%;
    overflow: hidden;
  }

  .editor-tool-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .icon-text-button {
    min-height: 44px;
    justify-content: center;
  }

  .editor-find-panel {
    padding: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .editor-find-panel > span {
    grid-column: 1 / -1;
  }

  .editor-find-panel .quiet-button,
  .editor-find-panel .icon-button {
    min-height: 44px;
  }

  .editor-title-block {
    width: 100%;
    flex-basis: 100%;
  }

  .editor-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .document-editor {
    height: 100%;
  }

  .document-editor .vditor-toolbar {
    padding-right: 6px !important;
    padding-left: 6px !important;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .document-editor .vditor-ir,
  .document-editor .vditor-wysiwyg,
  .document-editor .vditor-sv {
    padding: 24px 18px 80px !important;
    font-size: 16px;
    line-height: 1.85;
  }

  .editor-view.reading-width .document-editor {
    border-right: 0;
    border-left: 0;
  }

  .assistant-quick-actions {
    grid-template-columns: 1fr;
  }

  .assistant-quick-actions button {
    min-height: 44px;
  }

  .inspector-assistant-log {
    max-height: 38vh;
  }

  .toast {
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 360px) {
  .topbar {
    padding: 0 6px;
  }

  .brand-logo {
    width: 56px;
  }

  .topbar-actions {
    gap: 3px;
  }

  #inspector-toggle,
  #project-settings-open {
    width: 34px;
    min-width: 34px;
    padding: 0;
    justify-content: center;
  }

  .mobile-compact-icon {
    display: block;
    width: 16px;
    height: 16px;
  }

  .mobile-compact-label {
    display: none;
  }

  #write-open {
    padding: 0 7px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
