﻿:root {
  color-scheme: light;
  --bg-gradient-start: #f8f4ed;
  --bg-gradient-middle: #f3ede2;
  --bg-gradient-end: #efe8db;
  --bg: #f5efe6;
  --bg-strong: #efe7da;
  --surface: rgba(255, 250, 243, 0.92);
  --surface-strong: #fffaf4;
  --surface-muted: rgba(245, 237, 226, 0.96);
  --line: rgba(95, 106, 114, 0.12);
  --line-strong: rgba(27, 39, 49, 0.08);
  --text: #1f2933;
  --muted: #6b7480;
  --primary-rgb: 15, 118, 110;
  --primary-soft: #0d9488;
  --primary: #0f766e;
  --primary-strong: #115e59;
  --accent-rgb: 201, 111, 40;
  --accent-strong: #8d4e1e;
  --accent-strong-hover: #6c3e18;
  --accent: #c96f28;
  --danger-rgb: 180, 35, 60;
  --danger: #b4233c;
  --info-rgb: 37, 99, 235;
  --neutral-rgb: 148, 163, 184;
  --shadow: 0 10px 28px rgba(38, 47, 55, 0.07);
  --shadow-soft: 0 6px 16px rgba(38, 47, 55, 0.04);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --transition: 180ms ease;
  --focus-ring: 0 0 0 4px rgba(var(--primary-rgb), 0.14);
  --press-scale: 0.985;
  --font-heading: "Aptos Display", "Segoe UI Variable Display", "Segoe UI", sans-serif;
  --font-body: "Aptos", "Segoe UI Variable Text", "Segoe UI", sans-serif;
  --control-font-size: 0.86rem;
  --control-font-weight: 500;
  --control-letter-spacing: 0.01em;
  --field-control-height: 42px;
  --aligned-field-height: 46px;
  --meta-caption-row-height: 30px;
  --meta-control-row-height: 46px;
  --aligned-field-font-size: 1rem;
  --workspace-main-heading-size: clamp(1.12rem, 0.56vw + 0.84rem, 1.42rem);
  --workspace-main-heading-line-height: 1.08;
  --workspace-main-head-min-height: 34px;
  --workspace-col-sidebar: 400px;
  --workspace-col-tree: 420px;
  --workspace-col-sidebar-tight: 62px;
  --workspace-col-tree-tight: 62px;
  --workspace-col-sidebar-compact: 360px;
  --workspace-col-tree-compact: 380px;
  --workspace-col-sidebar-tight-compact: 58px;
  --workspace-col-tree-tight-compact: 58px;
  --workspace-col-detail-min: 360px;
  --workspace-col-gap: 24px;
  --arrow-control-bg: rgba(255, 255, 255, 0.84);
  --arrow-control-bg-hover: #fffdf8;
  --arrow-control-border: rgba(31, 41, 51, 0.14);
  --arrow-control-border-hover: rgba(var(--primary-rgb), 0.24);
  --arrow-control-color: #627387;
  --arrow-control-color-hover: var(--primary-strong);
  --arrow-control-shadow: 0 2px 8px rgba(38, 47, 55, 0.05);
  --arrow-control-shadow-hover: 0 6px 12px rgba(var(--primary-rgb), 0.1);
}

:root[data-theme="ocean"] {
  --bg-gradient-start: #eff5ff;
  --bg-gradient-middle: #e8f1ff;
  --bg-gradient-end: #dce9ff;
  --bg: #eaf2fb;
  --bg-strong: #dfe9f6;
  --surface: rgba(247, 251, 255, 0.9);
  --surface-strong: #f9fcff;
  --surface-muted: rgba(236, 244, 253, 0.96);
  --line: rgba(71, 88, 122, 0.2);
  --line-strong: rgba(23, 39, 64, 0.12);
  --text: #162437;
  --muted: #5f7088;
  --primary-rgb: 29, 78, 216;
  --primary-soft: #2563eb;
  --primary: #1d4ed8;
  --primary-strong: #1e3a8a;
  --accent-rgb: 14, 116, 144;
  --accent-strong: #0f5c72;
  --accent-strong-hover: #0d4f61;
  --accent: #0e7490;
}

:root[data-theme="sunset"] {
  --bg-gradient-start: #fff3e7;
  --bg-gradient-middle: #ffebdc;
  --bg-gradient-end: #fde2cf;
  --bg: #ffefe2;
  --bg-strong: #fbe4d1;
  --surface: rgba(255, 248, 241, 0.9);
  --surface-strong: #fff8f1;
  --surface-muted: rgba(251, 237, 225, 0.96);
  --line: rgba(127, 84, 58, 0.2);
  --line-strong: rgba(69, 36, 21, 0.12);
  --text: #422816;
  --muted: #87664e;
  --primary-rgb: 194, 65, 12;
  --primary-soft: #ea580c;
  --primary: #c2410c;
  --primary-strong: #9a3412;
  --accent-rgb: 190, 24, 93;
  --accent-strong: #9d174d;
  --accent-strong-hover: #831843;
  --accent: #be185d;
}

:root[data-theme="slate"] {
  --bg-gradient-start: #f4f7fb;
  --bg-gradient-middle: #edf2f8;
  --bg-gradient-end: #e4ebf3;
  --bg: #edf2f8;
  --bg-strong: #e3eaf2;
  --surface: rgba(248, 251, 255, 0.9);
  --surface-strong: #f9fbfe;
  --surface-muted: rgba(238, 244, 250, 0.96);
  --line: rgba(71, 85, 105, 0.2);
  --line-strong: rgba(30, 41, 59, 0.12);
  --text: #1f2937;
  --muted: #607085;
  --primary-rgb: 51, 65, 85;
  --primary-soft: #475569;
  --primary: #334155;
  --primary-strong: #1e293b;
  --accent-rgb: 15, 118, 110;
  --accent-strong: #115e59;
  --accent-strong-hover: #134e4a;
  --accent: #0f766e;
}

:root[data-theme="rose"] {
  --bg-gradient-start: #fff5f8;
  --bg-gradient-middle: #ffedf3;
  --bg-gradient-end: #fde4ee;
  --bg: #fef0f5;
  --bg-strong: #f9e6ed;
  --surface: rgba(255, 248, 252, 0.9);
  --surface-strong: #fff8fc;
  --surface-muted: rgba(251, 237, 244, 0.96);
  --line: rgba(129, 92, 116, 0.2);
  --line-strong: rgba(81, 41, 63, 0.12);
  --text: #3f2231;
  --muted: #7f6271;
  --primary-rgb: 192, 38, 107;
  --primary-soft: #db2777;
  --primary: #c0266b;
  --primary-strong: #9d174d;
  --accent-rgb: 194, 65, 12;
  --accent-strong: #9a3412;
  --accent-strong-hover: #7c2d12;
  --accent: #c2410c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(160deg, var(--bg-gradient-start) 0%, var(--bg-gradient-middle) 45%, var(--bg-gradient-end) 100%);
  color: var(--text);
  font-family: var(--font-body);
  scrollbar-width: auto;
  scrollbar-color: rgba(31, 41, 51, 0.14) transparent;
}

body {
  position: relative;
  overflow-x: hidden;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: rgba(31, 41, 51, 0.14);
  border-radius: 999px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track,
html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner {
  background: transparent;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    filter var(--transition),
    opacity var(--transition);
}

button:focus-visible,
[role="button"]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button:active:not(:disabled),
[role="button"]:active {
  transform: translateY(0) scale(var(--press-scale));
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

input:not([type="checkbox"]):not([type="file"]),
select {
  min-height: var(--field-control-height);
  line-height: 1.2;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(var(--primary-rgb), 0.58);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
  background: #fffdfa;
}

textarea {
  resize: vertical;
  min-height: 110px;
}

.thinking-path-textarea {
  line-height: 1.6;
  min-height: calc(1.6em * 3 + 24px);
  height: calc(1.6em * 3 + 24px);
}

#nodeEssenceInput {
  line-height: 1.6;
  min-height: calc(1.6em * 3 + 24px);
  height: calc(1.6em * 3 + 24px);
}

#nodeOutputChecklistInput,
#nodeElementsInput {
  line-height: 1.76;
  min-height: calc(1.76em * 4 + 24px);
  height: calc(1.76em * 4 + 24px);
}

#templateDescriptionInput {
  min-height: calc(3 * 1.45em + 24px);
  height: calc(3 * 1.45em + 24px);
  max-height: calc(3 * 1.45em + 24px);
  resize: none;
  line-height: 1.45;
  overflow-y: auto;
}

.aurora {
  position: fixed;
  z-index: 0;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.45;
  pointer-events: none;
}

.aurora-a {
  top: -90px;
  left: -40px;
  width: 420px;
  height: 420px;
  background: radial-gradient(circle, rgba(var(--primary-rgb), 0.22) 0%, rgba(var(--primary-rgb), 0) 68%);
}

.aurora-b {
  right: -80px;
  bottom: 80px;
  width: 360px;
  height: 360px;
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.19) 0%, rgba(var(--accent-rgb), 0) 70%);
}

.app-shell {
  position: relative;
  z-index: 1;
  padding: 30px;
}

.card {
  background: var(--surface);
  border: 1px solid rgba(31, 41, 51, 0.06);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px 28px;
  align-items: center;
  padding: 24px 32px;
  margin-bottom: 24px;
  background:
    linear-gradient(138deg, rgba(255, 250, 243, 0.98), rgba(248, 243, 235, 0.96)),
    radial-gradient(circle at top right, rgba(var(--primary-rgb), 0.05), transparent 38%);
  box-shadow: 0 8px 20px rgba(38, 47, 55, 0.05);
}

.brand-block {
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  min-width: 0;
}

.brand-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(160deg, var(--primary), var(--primary-soft));
  color: white;
  display: grid;
  place-items: center;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 0.98rem;
  box-shadow: 0 6px 14px rgba(var(--primary-rgb), 0.12);
}

.eyebrow,
.panel-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.eyebrow {
  letter-spacing: 0.04em;
  text-transform: none;
}

.panel-label {
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar h1,
.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.topbar h1 {
  font-size: clamp(1.7rem, 1.25vw + 1rem, 2.2rem);
  line-height: 1.04;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.09);
  color: var(--primary-strong);
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1;
  border: 1px solid rgba(var(--primary-rgb), 0.1);
}

.subhead {
  margin: 0;
  max-width: 920px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.62;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: flex-end;
  align-self: center;
}

.sync-state-topbar {
  cursor: default;
  pointer-events: auto;
  border: none;
}

.status-chip,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 36px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-strong);
  font-family: var(--font-body);
  font-size: var(--control-font-size);
  font-weight: var(--control-font-weight);
  letter-spacing: var(--control-letter-spacing);
  border: 1px solid rgba(var(--primary-rgb), 0.1);
  white-space: nowrap;
}

.status-chip.muted,
.pill {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent-strong);
  border-color: rgba(var(--accent-rgb), 0.12);
}

.sync-state {
  --sync-rgb: var(--primary-rgb);
  min-width: 96px;
  position: relative;
  gap: 6px;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
  overflow: visible;
  cursor: default;
  background: transparent;
  color: var(--primary-strong);
  border-color: rgba(var(--sync-rgb), 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.34),
    0 0 0 1px rgba(var(--sync-rgb), 0.04),
    0 6px 14px rgba(var(--sync-rgb), 0.08);
  backdrop-filter: blur(8px) saturate(112%);
  -webkit-backdrop-filter: blur(8px) saturate(112%);
  transition:
    background-color 220ms ease,
    border-color 220ms ease,
    color 220ms ease,
    box-shadow 220ms ease;
}

.sync-state::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.78;
  box-shadow: 0 0 0 4px rgba(var(--sync-rgb), 0.1);
}

.sync-state.is-changing {
  animation: sync-state-swap 360ms ease;
}

.sync-state.synced {
  --sync-rgb: var(--primary-rgb);
  background: transparent;
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.2);
}

.sync-state.pending {
  --sync-rgb: var(--accent-rgb);
  background: transparent;
  color: var(--accent-strong);
  border-color: rgba(var(--accent-rgb), 0.2);
}

.sync-state.dirty {
  --sync-rgb: var(--danger-rgb);
  background: transparent;
  color: #a14a59;
  border-color: rgba(var(--danger-rgb), 0.14);
}

.sync-state.error {
  --sync-rgb: var(--danger-rgb);
  background: transparent;
  color: var(--danger);
  border-color: rgba(var(--danger-rgb), 0.24);
}

.system-entry-button {
  appearance: none;
  cursor: pointer;
  min-width: 96px;
  justify-content: center;
  text-align: center;
  background: transparent;
  color: var(--text);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    0 2px 8px rgba(38, 47, 55, 0.05);
  backdrop-filter: blur(8px) saturate(110%);
  -webkit-backdrop-filter: blur(8px) saturate(110%);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    box-shadow var(--transition);
}

.system-entry-button:hover {
  background: rgba(255, 255, 255, 0.56);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.52),
    0 6px 12px rgba(var(--primary-rgb), 0.08);
}

.system-entry-button:focus-visible {
  outline: none;
  box-shadow:
    var(--focus-ring),
    inset 0 1px 0 rgba(255, 255, 255, 0.52),
    0 6px 12px rgba(var(--primary-rgb), 0.08);
}

.ai-config-trigger {
  appearance: none;
  cursor: pointer;
  min-width: 96px;
  justify-content: center;
  white-space: nowrap;
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition);
}

.ai-config-trigger:hover {
  transform: translateY(-1px);
  background: rgba(var(--primary-rgb), 0.15);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.ai-config-trigger.muted {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent-strong);
  border-color: rgba(var(--accent-rgb), 0.12);
}

.ai-config-trigger.muted:hover {
  background: rgba(var(--accent-rgb), 0.15);
  border-color: rgba(var(--accent-rgb), 0.2);
  box-shadow: 0 4px 10px rgba(var(--accent-rgb), 0.08);
}

.ai-config-trigger.ready {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.12);
}

.ai-config-trigger.ready:hover {
  background: rgba(var(--primary-rgb), 0.15);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.ai-config-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.ai-config-trigger:active:not(:disabled) {
  box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.08);
}

.theme-quick-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  display: inline-block;
  width: auto;
  flex: 0 0 auto;
  min-width: 132px;
  height: 36px;
  line-height: 1.2;
  padding-right: 34px;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 16px) calc(50% - 2px) / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 11px) calc(50% - 2px) / 6px 6px no-repeat,
    rgba(var(--primary-rgb), 0.1);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.12);
}

.theme-quick-select:hover {
  transform: translateY(-1px);
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 16px) calc(50% - 2px) / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 11px) calc(50% - 2px) / 6px 6px no-repeat,
    rgba(var(--primary-rgb), 0.15);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.theme-quick-select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.backup-trigger {
  appearance: none;
  cursor: pointer;
  min-width: 96px;
  justify-content: center;
  white-space: nowrap;
  text-align: center;
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.12);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), border-color var(--transition), color var(--transition), opacity var(--transition);
}

.backup-trigger:hover {
  transform: translateY(-1px);
  background: rgba(var(--primary-rgb), 0.15);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.backup-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.backup-trigger:disabled {
  cursor: default;
  transform: none;
  opacity: 0.72;
  box-shadow: none;
}

@keyframes sync-pulse {
  0% {
    opacity: 0.32;
  }

  50% {
    opacity: 0.95;
  }

  100% {
    opacity: 0.32;
  }
}

@keyframes sync-state-swap {
  0% {
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }

  45% {
    transform: translateY(-1px) scale(1.02);
    filter: saturate(1.03);
  }

  100% {
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }
}

.workspace {
  --workspace-sidebar-current: var(--workspace-col-sidebar);
  --workspace-tree-current: var(--workspace-col-tree);
  display: grid;
  grid-template-columns:
    var(--workspace-sidebar-current)
    var(--workspace-tree-current)
    minmax(var(--workspace-col-detail-min), 1fr);
  gap: var(--workspace-col-gap);
  align-items: start;
}

@media (min-width: 1101px) {
  .workspace {
    --workspace-sync-panel-height: calc(100vh - 190px);
    --workspace-sync-panel-height: calc(100dvh - 190px);
  }

  .workspace > .sidebar,
  .workspace > .tree-panel,
  .workspace > .detail-stack {
    align-self: stretch;
  }

  .workspace > .sidebar {
    height: var(--workspace-sync-panel-height);
    min-height: var(--workspace-sync-panel-height);
    max-height: var(--workspace-sync-panel-height);
    overflow: hidden;
  }

  .workspace > .sidebar > .panel:first-child {
    flex: 0 0 auto;
  }

  .workspace > .sidebar > .template-library-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .workspace > .sidebar > .template-library-panel .template-list-frame {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }

  .workspace > .sidebar > .template-library-panel .template-list {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
  }

  .workspace > .detail-stack > .detail-panel {
    height: auto;
    min-height: var(--workspace-sync-panel-height);
    max-height: none;
    overflow: visible;
  }

  .workspace > .tree-panel.is-template-selected {
    height: var(--workspace-sync-panel-height);
    min-height: var(--workspace-sync-panel-height);
    max-height: var(--workspace-sync-panel-height);
    overflow: hidden;
  }

  .workspace > .tree-panel > .panel-head,
  .workspace > .tree-panel > .template-meta-grid,
  .workspace > .tree-panel > .tree-toolbar {
    flex: 0 0 auto;
  }

  .workspace > .tree-panel .tree-view {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
  }
}

.workspace.is-sidebar-compact {
  --workspace-sidebar-current: var(--workspace-col-sidebar-tight);
}

.workspace.is-tree-compact {
  --workspace-tree-current: var(--workspace-col-tree-tight);
}

.workspace.is-focus-sidebar,
.workspace.is-focus-tree,
.workspace.is-focus-detail {
  grid-template-columns: minmax(0, 1fr);
}

.workspace.is-focus-sidebar > .tree-panel,
.workspace.is-focus-sidebar > .detail-stack {
  display: none;
}

.workspace.is-focus-tree > .sidebar,
.workspace.is-focus-tree > .detail-stack {
  display: none;
}

.workspace.is-focus-detail > .sidebar,
.workspace.is-focus-detail > .tree-panel {
  display: none;
}

.workspace.is-generate-mode .tree-panel .template-meta-grid {
  display: none;
}

.workspace.is-generate-mode .tree-panel .tree-toolbar-group-icons {
  display: none;
}

.workspace.is-generate-mode .tree-panel .tree-toolbar-row-main {
  justify-content: flex-start;
}

.workspace.is-generate-mode .tree-panel .tree-toolbar-switch {
  margin-left: 0;
}

.workspace.is-focus-sidebar .panel-width-toggle,
.workspace.is-focus-tree .panel-width-toggle,
.workspace.is-focus-detail .panel-width-toggle {
  display: none;
}

.workspace.is-sidebar-compact .sidebar > .panel:first-child {
  padding: 10px 8px;
}

.workspace.is-sidebar-compact .sidebar > .template-create-collapse-divider {
  display: none;
}

.workspace.is-sidebar-compact .sidebar > .panel:not(:first-child) {
  display: none;
}

.workspace.is-sidebar-compact .sidebar > .panel:first-child > :not(.panel-head) {
  display: none;
}

.workspace.is-sidebar-compact .sidebar > .panel:first-child .panel-head {
  margin: 0;
  justify-content: center;
}

.workspace.is-sidebar-compact .sidebar > .panel:first-child .panel-head > :not(.panel-head-actions) {
  display: none;
}

.workspace.is-sidebar-compact .sidebar > .panel:first-child .panel-head-actions .panel-focus-toggle,
.workspace.is-tree-compact .tree-panel .panel-head-actions .panel-focus-toggle {
  display: none;
}

.workspace.is-tree-compact .tree-panel {
  padding: 10px 8px;
  min-height: auto;
  height: auto !important;
  min-height: auto !important;
  max-height: none !important;
  overflow: visible !important;
  align-self: start;
}

.workspace.is-tree-compact .tree-panel > :not(.panel-head) {
  display: none;
}

.workspace.is-tree-compact .tree-panel .tree-panel-title {
  display: none;
}

.workspace.is-tree-compact .tree-panel .panel-head {
  margin: 0;
  justify-content: center;
}

.sidebar,
.detail-stack {
  display: flex;
  flex-direction: column;
  gap: var(--workspace-col-gap);
  min-width: 0;
}

.template-create-collapse-divider {
  display: flex;
  justify-content: center;
  margin: -8px 0 -4px;
}

.template-create-collapse-toggle {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 34px;
  min-width: 34px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--arrow-control-border);
  background: var(--arrow-control-bg);
  color: var(--arrow-control-color);
  box-shadow: var(--arrow-control-shadow);
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.template-create-collapse-toggle svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.template-create-collapse-toggle:hover,
.template-create-collapse-toggle:focus-visible {
  transform: translateY(-1px);
  background: var(--arrow-control-bg-hover);
  color: var(--arrow-control-color-hover);
  border-color: var(--arrow-control-border-hover);
  box-shadow: var(--arrow-control-shadow-hover);
}

.template-create-collapse-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--arrow-control-shadow-hover);
}

.sidebar.is-template-create-collapsed > #templateCreatePanel {
  padding-bottom: 12px;
}

.sidebar.is-template-create-collapsed > #templateCreatePanel > :not(.panel-head) {
  display: none;
}

.sidebar.is-template-create-collapsed > #templateCreatePanel .panel-head {
  margin-bottom: 0;
}

.panel {
  padding: 24px;
}

.panel.grow {
  min-height: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.panel-head.compact {
  margin-bottom: 16px;
}

.panel-head-actions,
.detail-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.panel-width-toggle,
.panel-focus-toggle {
  appearance: none;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--arrow-control-border);
  border-radius: 10px;
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  background: var(--arrow-control-bg);
  color: var(--arrow-control-color);
  box-shadow: none;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.panel-width-toggle svg,
.panel-focus-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel-width-toggle:hover,
.panel-width-toggle:focus-visible,
.panel-focus-toggle:hover,
.panel-focus-toggle:focus-visible {
  transform: translateY(-1px);
  background: var(--arrow-control-bg-hover);
  color: var(--arrow-control-color-hover);
  border-color: var(--arrow-control-border-hover);
  box-shadow: var(--arrow-control-shadow-hover);
}

.panel-width-toggle:focus-visible,
.panel-focus-toggle:focus-visible {
  box-shadow: var(--focus-ring), var(--arrow-control-shadow-hover);
}

.panel-focus-toggle.active {
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.2);
}

.panel-width-toggle.active {
  background: var(--arrow-control-bg);
  color: var(--arrow-control-color);
  border-color: var(--arrow-control-border);
  box-shadow: none;
}

.panel-width-toggle:disabled {
  opacity: 0.58;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.tree-panel-head {
  align-items: flex-start;
}

.tree-panel-title {
  min-width: 0;
  flex: 1 1 auto;
}

.tree-panel-title-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-top: 8px;
}

.tree-panel-title-row h2 {
  margin: 0;
  min-width: 0;
  max-width: none;
  line-height: var(--workspace-main-heading-line-height);
  font-size: var(--workspace-main-heading-size);
  white-space: nowrap;
}

.tree-display-toggle {
  position: relative;
  min-height: 33px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  white-space: nowrap;
  border: 1px solid rgba(31, 41, 51, 0.06);
  border-radius: 999px;
  background: rgba(31, 41, 51, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  color: var(--text);
  gap: 0;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--control-font-size);
  font-weight: var(--control-font-weight);
  line-height: 1;
  letter-spacing: var(--control-letter-spacing);
  transition: transform var(--transition), color var(--transition), opacity var(--transition), background var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.tree-display-toggle span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font: inherit;
  color: inherit;
}

.tree-display-toggle span::before {
  content: "";
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(95, 106, 114, 0.22);
  background: rgba(255, 250, 243, 0.78);
  color: transparent;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), color var(--transition);
}

.tree-display-toggle:hover {
  background: rgba(var(--primary-rgb), 0.1);
  border-color: rgba(var(--primary-rgb), 0.14);
  box-shadow: 0 12px 22px rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
  transform: translateY(-1px);
}

.tree-display-toggle:focus-within {
  background: rgba(var(--primary-rgb), 0.1);
  border-color: rgba(var(--primary-rgb), 0.14);
  box-shadow: var(--focus-ring), 0 12px 22px rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
}

.tree-display-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tree-display-toggle input:checked + span::before {
  content: "\2713";
  color: white;
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  border-color: rgba(var(--primary-rgb), 0.18);
  box-shadow: 0 6px 12px rgba(var(--primary-rgb), 0.18);
}

.tree-display-toggle input:disabled + span {
  opacity: 0.56;
}

.template-library-head {
  align-items: flex-start;
  margin-bottom: 2px;
}

.toolbar-actions,
.tab-switcher,
.inline-actions,
.drawer-actions,
.tree-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.field > span {
  font-size: 0.92rem;
  color: var(--muted);
}

.field small {
  color: var(--muted);
}

#nodeOutputChecklistInput,
#nodeElementsInput,
.compiled-prompt-output,
.tree-node-essence {
  font-family: var(--font-body);
  font-size: 0.96rem;
  font-weight: 400;
  line-height: 1.76;
  letter-spacing: 0;
}

.field-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.field-meta-title {
  font-size: 0.96rem;
  font-weight: 600;
  color: #344054;
  letter-spacing: 0.01em;
}

.field-meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.1);
  border: 1px solid rgba(var(--primary-rgb), 0.12);
  color: var(--primary-strong);
  font-family: var(--font-body);
  font-size: var(--control-font-size);
  font-weight: var(--control-font-weight);
  line-height: 1;
  letter-spacing: var(--control-letter-spacing);
  white-space: nowrap;
}

.field-meta-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.72);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.08);
}

.compiled-prompt-panel {
  gap: 0;
  overflow: hidden;
  border: 1px solid rgba(196, 185, 169, 0.3);
  border-radius: 24px;
  background: rgba(248, 244, 237, 0.92);
  box-shadow: none;
}

.compiled-prompt-collapse-divider {
  grid-column: 1 / -1;
  display: block;
  margin: -6px 0 2px;
}

.compiled-prompt-collapse-toggle {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(31, 41, 51, 0.14);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  box-shadow: 0 2px 8px rgba(38, 47, 55, 0.06);
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.compiled-prompt-collapse-copy {
  display: grid;
  gap: 2px;
  text-align: left;
  min-width: 0;
}

.compiled-prompt-collapse-copy strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.compiled-prompt-collapse-copy span {
  font-size: 0.8rem;
  color: var(--muted);
}

.compiled-prompt-collapse-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--arrow-control-border);
  background: var(--arrow-control-bg);
  color: var(--arrow-control-color);
}

.compiled-prompt-collapse-icon svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.compiled-prompt-collapse-toggle:hover,
.compiled-prompt-collapse-toggle:focus-visible {
  transform: translateY(-1px);
  background: #fffdfa;
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.24);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.compiled-prompt-collapse-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

#promptEditorGrid.is-compiled-prompt-collapsed .compiled-prompt-panel {
  display: none;
}

.compiled-prompt-panel-head {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 18px 22px 14px;
  background: rgba(247, 243, 236, 0.88);
  border-bottom: 1px solid rgba(196, 185, 169, 0.24);
}

.compiled-prompt-note {
  margin: 0;
  font-size: 0.82rem;
  color: #707b88;
  line-height: 1.66;
}

.compiled-prompt-panel-body {
  padding: 18px 22px 22px;
  background: rgba(247, 243, 236, 0.84);
}

.compiled-prompt-panel:focus-within {
  border-color: rgba(186, 170, 148, 0.62);
  box-shadow: 0 0 0 4px rgba(186, 170, 148, 0.08);
}

.compiled-prompt-output {
  min-height: 280px;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(244, 240, 233, 0.96), rgba(240, 235, 227, 0.98));
  border-color: rgba(196, 185, 169, 0.34);
  color: #33404c;
  box-shadow: none;
  word-spacing: 0;
  padding: 18px 20px;
  resize: vertical;
}

.compiled-prompt-output[readonly] {
  cursor: default;
}

.compiled-prompt-output[readonly]:focus {
  border-color: rgba(196, 185, 169, 0.34);
  box-shadow: none;
  background:
    linear-gradient(180deg, rgba(244, 240, 233, 0.96), rgba(240, 235, 227, 0.98));
}

.wide-field {
  grid-column: 1 / -1;
}

.template-type-field {
  width: min(100%, 9rem);
  justify-self: start;
}

.template-type-field select {
  min-width: 0;
}

.field-inline-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
  justify-content: flex-start;
}

.field-inline-row select {
  flex: 0 1 184px;
  min-width: 136px;
  max-width: 100%;
}

.editor-primary-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.95fr);
  gap: 14px;
  align-items: end;
}

@media (min-width: 1101px) {
  .detail-panel .editor-primary-row {
    margin-top: -2px;
  }
}

.editor-primary-row .field {
  margin-bottom: 0;
}

.editor-primary-row .field-inline-row {
  width: 100%;
  justify-content: flex-start;
}

.editor-primary-row .field-inline-row select {
  flex: 1 1 auto;
  min-width: 0;
}

.editor-primary-row .compact-toggle {
  margin-left: 0;
}

.compact-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: var(--aligned-field-height);
  padding: 0 12px;
  border: 1px solid rgba(31, 41, 51, 0.06);
  border-radius: 999px;
  background: rgba(247, 244, 239, 0.88);
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition);
}

.compact-toggle:hover,
.compact-toggle:focus-within {
  transform: translateY(-1px);
  border-color: rgba(var(--primary-rgb), 0.16);
  background: #fffdfa;
  color: var(--primary-strong);
  box-shadow: 0 10px 20px rgba(var(--primary-rgb), 0.08);
}

.compact-toggle:focus-within {
  box-shadow: var(--focus-ring), 0 10px 20px rgba(var(--primary-rgb), 0.08);
}

.compact-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.compact-toggle span {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding-left: 42px;
  font-size: 0.92rem;
  line-height: 1;
  letter-spacing: var(--control-letter-spacing);
}

.compact-toggle span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: rgba(var(--neutral-rgb), 0.28);
  box-shadow: inset 0 0 0 1px rgba(95, 106, 114, 0.14);
  transition: background var(--transition), box-shadow var(--transition);
}

.compact-toggle span::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fffdfa;
  box-shadow: 0 2px 6px rgba(31, 41, 51, 0.18);
  transform: translateY(-50%);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}

.compact-toggle input:checked + span::before {
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.12), 0 6px 14px rgba(var(--primary-rgb), 0.14);
}

.compact-toggle input:checked + span::after {
  transform: translate(14px, -50%);
  background: white;
}

.compact-toggle input:focus-visible + span::before {
  box-shadow: var(--focus-ring), inset 0 0 0 1px rgba(var(--primary-rgb), 0.18);
}

.template-create-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 4px;
  min-height: var(--meta-control-row-height);
  margin-bottom: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(31, 41, 51, 0.06);
}

.template-create-mode {
  border: none;
  border-radius: 14px;
  padding: 10px 12px;
  min-height: calc(var(--meta-control-row-height) - 8px);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition);
}

.template-create-mode.active {
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.template-create-mode:hover {
  transform: translateY(-1px);
}

.template-create-hint {
  margin: 0 0 8px;
  min-height: var(--meta-caption-row-height);
  display: flex;
  align-items: flex-end;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 6px;
}

.template-create-grid .field {
  margin-bottom: 0;
}

.template-create-grid .template-type-field {
  justify-self: end;
}

.template-create-upload {
  margin-top: 14px;
}

.template-create-upload + .wide,
.template-create-upload + .primary-button.wide,
.template-create-upload + .secondary-button.wide {
  margin-top: 10px;
}

#generateTemplateButton + .template-create-progress {
  margin-top: 14px;
}

.compact-upload-zone {
  min-height: 0;
  padding: 14px 16px;
}

.upload-zone {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border: 1px dashed rgba(var(--primary-rgb), 0.24);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(222, 244, 240, 0.75), rgba(255, 250, 243, 0.92));
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.upload-zone.drag-active {
  transform: translateY(-1px);
  border-color: rgba(var(--primary-rgb), 0.52);
  box-shadow: 0 14px 28px rgba(var(--primary-rgb), 0.14);
  background: linear-gradient(160deg, rgba(214, 245, 239, 0.92), rgba(255, 251, 246, 0.98));
}

.upload-zone.has-file {
  border-color: rgba(var(--primary-rgb), 0.34);
  background: linear-gradient(160deg, rgba(226, 247, 242, 0.82), rgba(255, 251, 246, 0.96));
}

.upload-zone.is-busy {
  pointer-events: none;
  opacity: 0.78;
}

.upload-zone:hover,
.upload-zone:focus-within {
  transform: translateY(-1px);
  border-color: rgba(var(--primary-rgb), 0.45);
  box-shadow: var(--shadow-soft);
}

.upload-zone:focus-within {
  box-shadow: var(--focus-ring), var(--shadow-soft);
}

.upload-zone input {
  display: none;
}

.upload-zone strong {
  display: block;
  max-width: 100%;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.upload-zone span {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.template-create-progress {
  display: grid;
  gap: 12px;
  padding: 16px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  border-radius: 24px;
  background:
    linear-gradient(155deg, rgba(233, 247, 244, 0.96), rgba(255, 251, 246, 0.98)),
    radial-gradient(circle at top right, rgba(var(--primary-rgb), 0.1), transparent 46%);
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  box-shadow: 0 18px 34px rgba(var(--primary-rgb), 0.08);
}

.template-create-progress[data-mode="blank"] {
  background:
    linear-gradient(155deg, rgba(246, 240, 229, 0.96), rgba(255, 251, 246, 0.98)),
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.12), transparent 44%);
  border-color: rgba(var(--accent-rgb), 0.14);
  box-shadow: 0 18px 34px rgba(var(--accent-rgb), 0.08);
}

.template-create-progress[data-stage="error"] {
  background:
    linear-gradient(155deg, rgba(252, 239, 241, 0.96), rgba(255, 251, 246, 0.98)),
    radial-gradient(circle at top right, rgba(var(--danger-rgb), 0.12), transparent 44%);
  border-color: rgba(var(--danger-rgb), 0.14);
  box-shadow: 0 18px 34px rgba(var(--danger-rgb), 0.08);
}

.template-create-progress-head,
.template-create-progress-stages {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.template-create-progress-stages {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.template-create-progress-head {
  flex-wrap: wrap;
}

.template-create-progress-stages::-webkit-scrollbar {
  display: none;
}

.template-create-progress-copy {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.template-create-progress-label {
  display: block;
  margin: 0 0 4px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-create-progress-title,
#templateCreateProgressTitle {
  font-size: 1.1rem;
  color: var(--text);
}

#templateCreateProgressTitle {
  display: none;
}

.template-create-progress-percent {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary-strong);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.template-create-progress[data-mode="blank"] .template-create-progress-percent {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-strong);
}

.template-create-progress[data-stage="error"] .template-create-progress-percent {
  background: rgba(var(--danger-rgb), 0.12);
  color: var(--danger);
}

.template-create-progress-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.template-create-progress-visual {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 64px;
  border-radius: 16px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(var(--primary-rgb), 0.14);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(225, 244, 238, 0.88)),
    radial-gradient(circle at center, rgba(var(--primary-rgb), 0.2), transparent 64%);
  display: block;
}

.template-create-progress-core {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.92);
  box-shadow:
    0 0 0 7px rgba(var(--primary-rgb), 0.12),
    0 0 22px rgba(var(--primary-rgb), 0.34);
  transform: translate(-50%, -50%) scale(1);
  animation: template-create-progress-core-pulse 1.45s ease-in-out infinite;
}

.template-create-progress-ping {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid rgba(var(--primary-rgb), 0.3);
  transform: translate(-50%, -50%) scale(0.45);
  animation: template-create-progress-ping 1.8s ease-out infinite;
}

.template-create-progress-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  border: 1.6px solid rgba(var(--primary-rgb), 0.22);
  border-top-color: rgba(var(--primary-rgb), 0.88);
  border-bottom-color: rgba(var(--primary-rgb), 0.16);
  transform: translate(-50%, -50%) rotate(0deg);
}

.template-create-progress-orbit-a {
  animation: template-create-progress-orbit-spin 2.4s linear infinite;
}

.template-create-progress-orbit-b {
  width: 36px;
  height: 36px;
  border-width: 1.4px;
  border-top-color: rgba(var(--accent-rgb), 0.86);
  border-right-color: rgba(var(--accent-rgb), 0.24);
  border-bottom-color: rgba(var(--accent-rgb), 0.12);
  border-left-color: rgba(var(--accent-rgb), 0.24);
  animation: template-create-progress-orbit-spin-reverse 1.6s linear infinite;
}

.template-create-progress-particle {
  position: absolute;
  top: 50%;
  left: -14px;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.68);
  filter: blur(0.1px);
  transform: translateX(0);
  will-change: left, opacity;
}

.template-create-progress-particle-a {
  animation: template-create-progress-particle-run 2.2s linear infinite;
}

.template-create-progress-particle-b {
  width: 6px;
  height: 6px;
  margin-top: -2.5px;
  background: rgba(var(--accent-rgb), 0.62);
  animation: template-create-progress-particle-run 2.2s linear infinite 0.62s;
}

.template-create-progress-particle-c {
  width: 5px;
  height: 5px;
  margin-top: -2px;
  background: rgba(var(--primary-rgb), 0.44);
  animation: template-create-progress-particle-run 2.2s linear infinite 1.18s;
}

.template-create-progress[data-mode="blank"] .template-create-progress-visual {
  border-color: rgba(var(--accent-rgb), 0.16);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(248, 237, 224, 0.9)),
    radial-gradient(circle at center, rgba(var(--accent-rgb), 0.2), transparent 64%);
}

.template-create-progress[data-mode="blank"] .template-create-progress-core {
  background: rgba(var(--accent-rgb), 0.88);
  box-shadow:
    0 0 0 7px rgba(var(--accent-rgb), 0.12),
    0 0 22px rgba(var(--accent-rgb), 0.3);
}

.template-create-progress[data-mode="blank"] .template-create-progress-ping {
  border-color: rgba(var(--accent-rgb), 0.34);
}

.template-create-progress[data-mode="blank"] .template-create-progress-orbit {
  border-color: rgba(var(--accent-rgb), 0.22);
  border-top-color: rgba(var(--accent-rgb), 0.84);
  border-bottom-color: rgba(var(--accent-rgb), 0.14);
}

.template-create-progress[data-stage="error"] .template-create-progress-visual {
  border-color: rgba(var(--danger-rgb), 0.18);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(252, 235, 238, 0.9)),
    radial-gradient(circle at center, rgba(var(--danger-rgb), 0.22), transparent 64%);
}

.template-create-progress[data-stage="error"] .template-create-progress-core {
  background: rgba(var(--danger-rgb), 0.88);
  box-shadow:
    0 0 0 7px rgba(var(--danger-rgb), 0.12),
    0 0 22px rgba(var(--danger-rgb), 0.3);
}

.template-create-progress[data-stage="error"] .template-create-progress-ping {
  border-color: rgba(var(--danger-rgb), 0.36);
}

.template-create-progress[data-stage="error"] .template-create-progress-orbit {
  border-color: rgba(var(--danger-rgb), 0.24);
  border-top-color: rgba(var(--danger-rgb), 0.88);
  border-bottom-color: rgba(var(--danger-rgb), 0.12);
}

.template-create-progress[data-stage="done"] .template-create-progress-visual {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.85), rgba(229, 243, 239, 0.9)),
    radial-gradient(circle at center, rgba(var(--primary-rgb), 0.18), transparent 70%);
}

.template-create-progress[data-stage="done"] .template-create-progress-orbit,
.template-create-progress[data-stage="done"] .template-create-progress-ping,
.template-create-progress[data-stage="done"] .template-create-progress-particle {
  animation-play-state: paused;
  opacity: 0.45;
}

.template-create-progress[data-stage="done"] .template-create-progress-core {
  animation-play-state: paused;
}

@keyframes template-create-progress-core-pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.9);
  }

  50% {
    transform: translate(-50%, -50%) scale(1.14);
  }
}

@keyframes template-create-progress-ping {
  0% {
    transform: translate(-50%, -50%) scale(0.45);
    opacity: 0.78;
  }

  75% {
    transform: translate(-50%, -50%) scale(2.9);
    opacity: 0;
  }

  100% {
    transform: translate(-50%, -50%) scale(2.9);
    opacity: 0;
  }
}

@keyframes template-create-progress-orbit-spin {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

@keyframes template-create-progress-orbit-spin-reverse {
  from {
    transform: translate(-50%, -50%) rotate(360deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(0deg);
  }
}

@keyframes template-create-progress-particle-run {
  0% {
    left: -14px;
    opacity: 0;
  }

  12% {
    opacity: 0.9;
  }

  88% {
    opacity: 0.9;
  }

  100% {
    left: calc(100% + 14px);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .template-create-progress-core,
  .template-create-progress-ping,
  .template-create-progress-orbit,
  .template-create-progress-particle {
    animation: none !important;
  }
}

.template-create-progress-bar {
  position: relative;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.12);
}

.template-create-progress-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.18), rgba(var(--primary-rgb), 0.92), rgba(var(--accent-rgb), 0.78));
  transition: width 260ms ease;
}

.template-create-progress[data-mode="blank"] .template-create-progress-bar {
  background: rgba(var(--accent-rgb), 0.12);
}

.template-create-progress[data-mode="blank"] .template-create-progress-bar span {
  background: linear-gradient(90deg, rgba(var(--accent-rgb), 0.2), rgba(var(--accent-rgb), 0.92), rgba(var(--primary-rgb), 0.62));
}

.template-create-progress[data-stage="error"] .template-create-progress-bar {
  background: rgba(var(--danger-rgb), 0.12);
}

.template-create-progress[data-stage="error"] .template-create-progress-bar span {
  background: linear-gradient(90deg, rgba(var(--danger-rgb), 0.24), rgba(var(--danger-rgb), 0.92));
}

.template-create-progress-stage {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.template-create-progress-stage::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.18);
  border: 1px solid rgba(var(--primary-rgb), 0.14);
}

.template-create-progress[data-mode="blank"] .template-create-progress-stage::before {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: rgba(var(--accent-rgb), 0.16);
}

.template-create-progress-stage.is-active,
.template-create-progress-stage.is-complete {
  color: var(--text);
}

.template-create-progress-stage.is-active::before {
  background: rgba(var(--accent-rgb), 0.92);
  border-color: rgba(var(--accent-rgb), 0.18);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.14);
}

.template-create-progress-stage.is-complete::before {
  background: rgba(var(--primary-rgb), 0.92);
  border-color: rgba(var(--primary-rgb), 0.2);
}

.template-create-progress-stage.is-error::before {
  background: rgba(var(--danger-rgb), 0.92);
  border-color: rgba(var(--danger-rgb), 0.18);
  box-shadow: 0 0 0 4px rgba(var(--danger-rgb), 0.12);
}

.template-library-panel {
  display: flex;
  flex-direction: column;
}

.template-library-toolbar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-inline: 12px;
  margin-bottom: 8px;
}

.template-library-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), rgba(245, 237, 226, 0.88)),
    radial-gradient(circle at top left, rgba(var(--primary-rgb), 0.08), transparent 48%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.template-library-summary-primary {
  display: flex;
  align-items: center;
  gap: 8px;
}

.template-library-summary-primary strong {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--text);
}

.template-library-summary-primary span {
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1;
}

.template-library-summary-secondary {
  display: flex;
  align-items: center;
  min-width: 0;
}

.template-library-summary-secondary span {
  color: var(--text);
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-library-summary-secondary small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-search-field {
  margin-bottom: 0;
  display: block;
}

.template-search-field .search-input-shell {
  min-width: 0;
}

.search-input-shell {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.search-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-input-shell input {
  padding-left: 38px;
}

#templateSearchInput {
  height: var(--field-control-height);
  font-size: var(--control-font-size);
  font-weight: var(--control-font-weight);
  letter-spacing: var(--control-letter-spacing);
}

#uploadTemplateName,
#templateNameInput,
#nodeTitleInput,
#templateSearchInput {
  padding-top: 0;
  padding-bottom: 0;
}

#uploadTemplateName,
#templateNameInput,
#uploadTemplateType,
#templateTypeInput,
#nodeTitleInput,
#nodeChapterTypeInput {
  height: var(--aligned-field-height);
  min-height: var(--aligned-field-height);
  font-family: var(--font-body);
  font-size: var(--aligned-field-font-size);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.2;
}

#uploadTemplateType,
#templateTypeInput,
#nodeChapterTypeInput {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0 38px 0 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%235b6570' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M2.5 4.25L6 7.75l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 14px) 50%;
  background-size: 12px 12px;
}

#uploadTemplateName::placeholder,
#templateSearchInput::placeholder {
  font: inherit;
  color: #7a838d;
  opacity: 1;
}

.template-list-frame {
  flex: 1;
  min-height: 0;
  padding: 12px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(245, 237, 226, 0.72)),
    radial-gradient(circle at top right, rgba(var(--accent-rgb), 0.08), transparent 42%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 430px);
  overflow: auto;
  padding-right: 4px;
}

.template-item {
  /* Keep cards at their natural height once the list starts scrolling. */
  flex: 0 0 auto;
  position: relative;
  min-height: 114px;
  padding: 12px 12px 10px;
  border: 1px solid rgba(31, 41, 51, 0.075);
  border-radius: 16px;
  background: linear-gradient(155deg, rgba(255, 255, 255, 0.92), rgba(249, 244, 236, 0.96));
  box-shadow: 0 8px 18px rgba(38, 47, 55, 0.055);
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.template-item::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.58);
  pointer-events: none;
}

.template-item:hover,
.template-item:focus-within {
  transform: translateY(-2px);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 16px 30px rgba(38, 47, 55, 0.1);
}

.template-item:hover .template-item-title,
.template-item:focus-within .template-item-title {
  color: var(--primary-strong);
}

.template-item.active {
  background:
    linear-gradient(155deg, rgba(214, 241, 233, 0.98), rgba(244, 235, 221, 0.98)),
    radial-gradient(circle at top right, rgba(var(--primary-rgb), 0.12), transparent 46%);
  border-color: rgba(var(--primary-rgb), 0.28);
  box-shadow: 0 20px 40px rgba(var(--primary-rgb), 0.16);
}

.template-item-surface {
  width: auto;
  background: transparent;
  color: inherit;
  text-align: left;
  min-width: 0;
  min-height: 86px;
  padding-right: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  cursor: pointer;
}

.template-item-surface:focus-visible,
.template-action-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.12);
}

.template-item-header {
  display: flex;
  align-items: flex-start;
  min-width: 0;
}

.template-item-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
  line-height: 1.3;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text);
  word-break: normal;
  overflow-wrap: normal;
}

.template-item-source-detail {
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.28;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-item-actions {
  position: relative;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  margin-left: auto;
  flex: 0 0 auto;
  z-index: 2;
  white-space: nowrap;
}

.template-action-divider {
  display: none;
}

.template-action-divider + .template-action-button {
  margin-left: 1px;
}

.template-action-button {
  width: 24px;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.template-action-button:disabled {
  cursor: default;
  opacity: 1;
}

.template-action-button svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.template-action-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(var(--primary-rgb), 0.22);
  color: var(--primary-strong);
  box-shadow: 0 8px 16px rgba(var(--primary-rgb), 0.12);
}

.template-action-button.active {
  background: rgba(var(--primary-rgb), 0.12);
  border-color: rgba(var(--primary-rgb), 0.18);
  color: var(--primary-strong);
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.05), 0 6px 12px rgba(var(--primary-rgb), 0.06);
}

.template-action-button.active:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(var(--primary-rgb), 0.24);
  color: var(--primary-strong);
  box-shadow: 0 8px 16px rgba(var(--primary-rgb), 0.14);
}

.template-action-button.placeholder {
  color: rgba(102, 112, 133, 0.72);
  background: rgba(247, 246, 242, 0.5);
  border-color: rgba(31, 41, 51, 0.035);
}

.template-action-button.placeholder:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(107, 116, 128, 0.14);
  color: #5b6470;
  box-shadow: 0 8px 16px rgba(38, 47, 55, 0.1);
}

.template-action-button.danger {
  color: var(--danger);
  background: rgba(var(--danger-rgb), 0.04);
  border-color: rgba(var(--danger-rgb), 0.08);
}

.template-action-button.danger:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(var(--danger-rgb), 0.18);
  color: var(--danger);
  box-shadow: 0 8px 16px rgba(var(--danger-rgb), 0.12);
}

.template-action-button:disabled:hover {
  transform: none;
  background: rgba(247, 246, 242, 0.5);
  border-color: rgba(31, 41, 51, 0.035);
  color: rgba(102, 112, 133, 0.72);
  box-shadow: none;
}

.template-item-meta-inline {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0 6px;
  min-width: 0;
}

.template-item-created {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
  display: inline-block;
  flex: 0 0 auto;
  white-space: nowrap;
}

.template-item-meta-dot {
  color: rgba(107, 116, 128, 0.7);
  font-size: 0.82rem;
}

.template-item-created-time {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.25;
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: auto;
  padding-top: 2px;
  min-height: 24px;
  flex-wrap: nowrap;
}

.template-item-badges {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 24px;
  white-space: nowrap;
}

.template-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 9px;
  font-size: 0.76rem;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
  cursor: default;
}

.template-item-badges,
.template-item-badges * {
  cursor: default;
}

.template-badge-chapter {
  color: #335fc0;
  background: rgba(var(--info-rgb), 0.065);
  border-color: rgba(var(--info-rgb), 0.13);
}

.template-badge-status {
  padding: 4px 8px;
  border-radius: 9px;
  font-size: 0.74rem;
  line-height: 1.15;
}

.template-badge-status.ready {
  color: #4d7c0f;
  background: rgba(132, 204, 22, 0.14);
  border-color: rgba(132, 204, 22, 0.18);
}

.template-badge-status.current {
  color: var(--primary-strong);
  background: rgba(var(--primary-rgb), 0.14);
  border-color: rgba(var(--primary-rgb), 0.18);
}

.template-badge-status.draft {
  color: var(--accent-strong);
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.18);
}

.template-list,
.tree-view,
#templateDescriptionInput,
.compiled-prompt-output,
.workspace,
.detail-stack,
.detail-panel,
#promptTab,
#generateTab,
#overviewTab {
  scrollbar-width: auto;
  scrollbar-color: rgba(31, 41, 51, 0.14) transparent;
}

.template-list::-webkit-scrollbar,
.tree-view::-webkit-scrollbar,
#templateDescriptionInput::-webkit-scrollbar,
.compiled-prompt-output::-webkit-scrollbar,
.workspace::-webkit-scrollbar,
.detail-stack::-webkit-scrollbar,
.detail-panel::-webkit-scrollbar,
#promptTab::-webkit-scrollbar,
#generateTab::-webkit-scrollbar,
#overviewTab::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.template-list::-webkit-scrollbar-thumb,
.tree-view::-webkit-scrollbar-thumb,
#templateDescriptionInput::-webkit-scrollbar-thumb,
.compiled-prompt-output::-webkit-scrollbar-thumb,
.workspace::-webkit-scrollbar-thumb,
.detail-stack::-webkit-scrollbar-thumb,
.detail-panel::-webkit-scrollbar-thumb,
#promptTab::-webkit-scrollbar-thumb,
#generateTab::-webkit-scrollbar-thumb,
#overviewTab::-webkit-scrollbar-thumb,
#recentDocuments::-webkit-scrollbar-thumb {
  background: rgba(31, 41, 51, 0.14);
  border-radius: 999px;
}

.template-list::-webkit-scrollbar-track,
.tree-view::-webkit-scrollbar-track,
#templateDescriptionInput::-webkit-scrollbar-track,
.compiled-prompt-output::-webkit-scrollbar-track,
.workspace::-webkit-scrollbar-track,
.detail-stack::-webkit-scrollbar-track,
.detail-panel::-webkit-scrollbar-track,
#promptTab::-webkit-scrollbar-track,
#generateTab::-webkit-scrollbar-track,
#overviewTab::-webkit-scrollbar-track,
#recentDocuments::-webkit-scrollbar-track {
  background: transparent;
}

.template-list::-webkit-scrollbar-corner,
.tree-view::-webkit-scrollbar-corner,
#templateDescriptionInput::-webkit-scrollbar-corner,
.compiled-prompt-output::-webkit-scrollbar-corner,
.workspace::-webkit-scrollbar-corner,
.detail-stack::-webkit-scrollbar-corner,
.detail-panel::-webkit-scrollbar-corner,
#promptTab::-webkit-scrollbar-corner,
#generateTab::-webkit-scrollbar-corner,
#overviewTab::-webkit-scrollbar-corner,
#recentDocuments::-webkit-scrollbar-corner {
  background: transparent;
}

.template-item p,
.tree-summary p,
.empty-state,
.overview-card,
#recentDocuments,
#templateOverview {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.tree-panel {
  min-height: calc(100vh - 162px);
  display: flex;
  flex-direction: column;
}

.template-meta-grid,
.editor-grid,
.overview-grid,
.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.template-meta-grid {
  grid-template-columns: minmax(0, 1fr) auto;
  row-gap: 7px;
}

.template-meta-grid .template-type-field {
  justify-self: end;
}

.template-meta-grid .field {
  margin-bottom: 0;
}

.template-meta-grid > .field,
.editor-primary-row > .field {
  display: grid;
  grid-template-rows: var(--meta-caption-row-height) var(--meta-control-row-height);
  row-gap: 8px;
  align-content: start;
}

.template-meta-grid > .field.wide-field {
  grid-template-rows: var(--meta-caption-row-height) auto;
  padding-top: 0;
}

.template-meta-grid > .field:nth-child(-n + 2) {
  padding-top: 0;
}

.template-meta-grid > .field > span {
  height: var(--meta-caption-row-height);
  display: flex;
  align-items: flex-end;
}

.template-meta-grid > .field:nth-child(-n + 2) > span {
  position: relative;
  top: 0;
}

.template-meta-grid > .field:nth-child(-n + 2) input,
.template-meta-grid > .field:nth-child(-n + 2) select {
  min-height: var(--meta-control-row-height);
}

.editor-primary-row > .field {
  margin-bottom: 0;
}

.template-meta-grid > .field > span,
.editor-primary-row > .field > span {
  height: var(--meta-caption-row-height);
  display: flex;
  align-items: flex-end;
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: 0;
  color: var(--muted);
}

.template-meta-grid > .field:nth-child(-n + 2) > input,
.template-meta-grid > .field:nth-child(-n + 2) > select,
.editor-primary-row > .field > input,
.editor-primary-row > .field > select,
.editor-primary-row > .field > .field-inline-row {
  height: var(--meta-control-row-height);
  min-height: var(--meta-control-row-height);
  box-sizing: border-box;
}

.tree-toolbar {
  width: 100%;
  margin: 4px 0 10px;
  overflow: hidden;
  padding-bottom: 0;
}

.tree-toolbar-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: nowrap;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.tree-toolbar-row-main {
  justify-content: space-between;
}

.tree-toolbar-group {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.tree-toolbar-group-icons {
  flex: 0 1 auto;
}

.tree-toolbar-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  margin-left: auto;
  padding: 0 10px 0 8px;
  border: 1px solid rgba(31, 41, 51, 0.05);
  border-radius: 999px;
  background: rgba(247, 244, 239, 0.88);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--transition), color var(--transition), background var(--transition), border-color var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.tree-toolbar-switch:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(var(--primary-rgb), 0.12);
  box-shadow: 0 8px 16px rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
}

.tree-toolbar-switch:focus-within {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(var(--primary-rgb), 0.12);
  box-shadow: var(--focus-ring), 0 8px 16px rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
}

.tree-toolbar-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tree-toolbar-switch-track {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 30px;
  height: 18px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(var(--neutral-rgb), 0.28);
  box-shadow: inset 0 0 0 1px rgba(95, 106, 114, 0.14);
  transition: background var(--transition), box-shadow var(--transition);
}

.tree-toolbar-switch-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fffdfa;
  box-shadow: 0 2px 6px rgba(31, 41, 51, 0.18);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
}

.tree-toolbar-switch-label {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: var(--control-font-weight);
  line-height: 1;
  letter-spacing: var(--control-letter-spacing);
}

.tree-toolbar-switch input:checked + .tree-toolbar-switch-track {
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb), 0.12), 0 6px 14px rgba(var(--primary-rgb), 0.14);
}

.tree-toolbar-switch input:checked + .tree-toolbar-switch-track .tree-toolbar-switch-thumb {
  transform: translateX(12px);
  background: white;
}

.tree-toolbar-switch input:disabled + .tree-toolbar-switch-track,
.tree-toolbar-switch input:disabled ~ .tree-toolbar-switch-label {
  opacity: 0.56;
}

.tree-toolbar-switch input:disabled ~ .tree-toolbar-switch-label {
  cursor: default;
}

.tree-toolbar-icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(31, 41, 51, 0.05);
  border-radius: 999px;
  background: rgba(247, 244, 239, 0.88);
  color: var(--muted);
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.tree-toolbar-icon-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tree-toolbar-icon-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(var(--primary-rgb), 0.18);
  color: var(--primary-strong);
  box-shadow: 0 10px 20px rgba(var(--primary-rgb), 0.1);
}

.tree-toolbar-icon-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), 0 10px 20px rgba(var(--primary-rgb), 0.1);
}

.tree-toolbar-icon-button.danger {
  color: var(--danger);
  background: rgba(var(--danger-rgb), 0.06);
  border-color: rgba(var(--danger-rgb), 0.08);
}

.tree-toolbar-icon-button.danger:hover {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(var(--danger-rgb), 0.16);
  color: var(--danger);
  box-shadow: 0 10px 20px rgba(var(--danger-rgb), 0.12);
}

.tree-toolbar-icon-button:disabled,
.tree-toolbar-icon-button:disabled:hover {
  transform: none;
  background: rgba(247, 246, 242, 0.5);
  border-color: rgba(31, 41, 51, 0.035);
  color: rgba(102, 112, 133, 0.72);
  box-shadow: none;
  cursor: default;
}

.tree-summary {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  margin-bottom: 14px;
}

.tree-view {
  overflow: auto;
  padding-right: 6px;
}

.tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-children {
  list-style: none;
  margin: 6px 0 0 18px;
  padding: 0 0 0 12px;
  border-left: 1px solid rgba(var(--primary-rgb), 0.14);
}

.tree-node {
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.66);
  border-radius: 16px;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
  transition: transform var(--transition), border-color var(--transition), background var(--transition), box-shadow var(--transition), color var(--transition);
}

.tree-node:hover {
  transform: translateX(4px);
  border-color: rgba(var(--primary-rgb), 0.18);
  background: linear-gradient(150deg, rgba(222, 244, 240, 0.72), rgba(255, 255, 255, 0.92));
  box-shadow: 0 12px 22px rgba(var(--primary-rgb), 0.08);
}

.tree-node:active {
  transform: none;
}

.tree-node:hover:active {
  transform: translateX(4px);
}

.tree-node.active {
  border-color: rgba(var(--primary-rgb), 0.24);
  background: linear-gradient(150deg, rgba(222, 244, 240, 0.78), rgba(255, 255, 255, 0.92));
  box-shadow: 0 16px 28px rgba(var(--primary-rgb), 0.12);
}

.tree-node:focus-visible {
  outline: none;
  border-color: rgba(var(--primary-rgb), 0.24);
  box-shadow: var(--focus-ring), 0 12px 22px rgba(var(--primary-rgb), 0.08);
}

.tree-node-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.tree-node-title-generate {
  align-items: flex-start;
}

.tree-node-title-main {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.tree-node-title strong {
  flex: 1 1 auto;
  min-width: 0;
}

.tree-node-generate {
  cursor: default;
}

.tree-node-generate:hover,
.tree-node-generate:active,
.tree-node-generate:hover:active {
  transform: none;
}

.tree-node-generate .tree-node-tags {
  margin-top: 1px;
}

.tree-node-optional-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--primary-strong);
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.1);
  border: 1px solid rgba(var(--primary-rgb), 0.14);
}

.tree-node-optional-toggle input {
  width: 14px;
  height: 14px;
  margin: 0;
}

.tree-node-required-label {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  color: var(--muted);
  background: rgba(31, 41, 51, 0.06);
}

.tree-node-essence {
  color: var(--muted);
  line-height: 1.76;
}

.tree-node-tags {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  flex: 0 0 auto;
}

.node-tag {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(31, 41, 51, 0.06);
  color: var(--muted);
  font-size: 0.8rem;
}

.node-tag.fixed {
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary-strong);
}

.node-tag.dynamic {
  background: rgba(31, 41, 51, 0.06);
  color: var(--muted);
}

.node-tag.optional {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-strong);
}

.detail-panel {
  min-height: calc(100vh - 162px);
}

.detail-panel.is-generate-tab-active {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 162px);
  min-height: 0;
}

.detail-panel.is-generate-tab-active #generateTab.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  gap: 10px;
}

.detail-panel.is-generate-tab-active #generateTab.active .generate-layout {
  flex: 1 1 auto;
}

.detail-panel.is-generate-tab-active #overviewTab.active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.detail-panel.is-generate-tab-active #overviewTab.active .overview-grid {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
}

.detail-panel.is-generate-tab-active #overviewTab.active .overview-compare-card {
  min-height: 0;
  height: 100%;
}

.detail-panel.is-generate-tab-active #overviewTab.active.is-overview-top-collapsed .overview-grid {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.detail-panel.is-generate-tab-active #overviewTab.active.is-overview-top-collapsed .overview-compare-card {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.detail-panel.is-generate-tab-active #overviewTab.active.is-overview-top-collapsed .overview-compare-grid {
  min-height: 0;
  height: 100%;
}

.detail-panel.is-generate-tab-active #overviewTab.active.is-overview-top-collapsed.is-overview-compare-focus-active .overview-grid {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.detail-panel.is-generate-tab-active #overviewTab.active.is-overview-top-collapsed.is-overview-compare-focus-active .overview-compare-card {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

.detail-panel.is-generate-tab-active #overviewTab.active.is-overview-top-collapsed.is-overview-compare-focus-active .overview-compare-grid {
  min-height: 0;
  height: 100%;
}

.detail-panel.is-generate-tab-active #overviewTab.active.is-overview-top-collapsed.is-overview-compare-focus-active .overview-compare-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  gap: 8px;
}

.detail-panel.is-generate-tab-active #overviewTab.active.is-overview-top-collapsed.is-overview-compare-focus-active .overview-compare-content {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.detail-panel .panel-head {
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 16px;
}

.detail-panel .panel-head.tabs-only {
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 8px;
}

.detail-head-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.detail-head-copy h2 {
  margin-right: 0;
  overflow-wrap: anywhere;
  line-height: var(--workspace-main-heading-line-height);
  font-size: var(--workspace-main-heading-size);
}

.sidebar > .panel:first-child .panel-head h2 {
  line-height: var(--workspace-main-heading-line-height);
  font-size: var(--workspace-main-heading-size);
}

@media (min-width: 1101px) {
  .sidebar > .panel:first-child .panel-head.compact,
  .tree-panel > .panel-head,
  .detail-panel > .panel-head {
    margin-bottom: 10px;
  }

  .sidebar > .panel:first-child .panel-head > div,
  .tree-panel-title-row,
  .detail-head-copy {
    min-height: var(--workspace-main-head-min-height);
  }

  .tree-panel-title-row {
    margin-top: 0;
  }
}

.tab-switcher {
  display: inline-flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  align-items: center;
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.66);
  margin-top: 4px;
  padding: 2px;
  min-height: 38px;
  border-radius: 999px;
  border: 1px solid rgba(31, 41, 51, 0.06);
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.tab-button,
.ghost-button,
.secondary-button,
.primary-button {
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform var(--transition), opacity var(--transition), background var(--transition), color var(--transition), box-shadow var(--transition), filter var(--transition);
}

.tab-button {
  background: transparent;
  color: var(--muted);
  min-height: 34px;
  padding-inline: 13px;
  font-family: var(--font-body);
  font-size: var(--control-font-size);
  font-weight: var(--control-font-weight);
  line-height: 1;
  letter-spacing: var(--control-letter-spacing);
}

.tab-button.active {
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 6px 14px rgba(var(--primary-rgb), 0.075);
}

.detail-panel .panel-head.tabs-only .tab-switcher {
  margin-top: 0;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  color: white;
  box-shadow: 0 14px 26px rgba(var(--primary-rgb), 0.2);
}

.secondary-button {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent-strong);
}

.ghost-button {
  background: rgba(31, 41, 51, 0.05);
  color: var(--text);
}

.ghost-button.small,
.secondary-button.small,
.primary-button.small {
  padding: 9px 12px;
  font-size: 0.92rem;
}

.ghost-button.danger {
  color: var(--danger);
  background: rgba(var(--danger-rgb), 0.08);
}

.tab-button:hover:not(.active),
.tab-button:focus-visible:not(.active) {
  transform: translateY(-1px);
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
}

.tab-button:focus-visible:not(.active) {
  box-shadow: var(--focus-ring), inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.tab-button.active:hover,
.tab-button.active:focus-visible {
  transform: translateY(-1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 16px 26px rgba(var(--primary-rgb), 0.14);
}

.tab-button.active:focus-visible {
  box-shadow: var(--focus-ring), inset 0 1px 0 rgba(255, 255, 255, 0.32), 0 16px 26px rgba(var(--primary-rgb), 0.14);
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px rgba(var(--primary-rgb), 0.24);
  filter: saturate(1.05) brightness(1.02);
}

.primary-button:focus-visible {
  box-shadow: var(--focus-ring), 0 18px 30px rgba(var(--primary-rgb), 0.24);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  transform: translateY(-1px);
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent-strong-hover);
  box-shadow: 0 14px 26px rgba(var(--accent-rgb), 0.12);
}

.secondary-button:focus-visible {
  box-shadow: var(--focus-ring), 0 14px 26px rgba(var(--accent-rgb), 0.12);
}

.ghost-button:hover,
.ghost-button:focus-visible {
  transform: translateY(-1px);
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-strong);
  box-shadow: 0 12px 22px rgba(var(--primary-rgb), 0.08);
}

.ghost-button:focus-visible {
  box-shadow: var(--focus-ring), 0 12px 22px rgba(var(--primary-rgb), 0.08);
}

.ghost-button.danger:hover,
.ghost-button.danger:focus-visible {
  background: rgba(var(--danger-rgb), 0.12);
  color: var(--danger);
  box-shadow: 0 12px 22px rgba(var(--danger-rgb), 0.1);
}

.ghost-button.danger:focus-visible {
  box-shadow: var(--focus-ring), 0 12px 22px rgba(var(--danger-rgb), 0.1);
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
  transform: none;
  box-shadow: none;
}

.node-progress {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: linear-gradient(140deg, rgba(222, 244, 240, 0.76), rgba(255, 250, 243, 0.92));
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  color: var(--primary-strong);
}

.node-progress-head,
.node-progress-stages {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.node-progress-head strong {
  font-size: 0.96rem;
}

.node-progress-bar {
  position: relative;
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.14);
}

.node-progress-bar span {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(var(--primary-rgb), 0.12), rgba(var(--primary-rgb), 0.9), rgba(var(--accent-rgb), 0.88));
  transition: width 240ms ease;
}

#nodePromptProgressText {
  color: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
}

.document-op-progress-text {
  color: inherit;
  font-size: 0.92rem;
  line-height: 1.5;
}

.document-generate-progress {
  position: relative;
  overflow: hidden;
}

.document-generate-progress::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0));
  transform: translateX(-130%);
  opacity: 0;
}

.document-generate-progress[data-stage="generating"]::after {
  opacity: 1;
  animation: document-generate-card-sheen 2.8s ease-in-out infinite;
}

.document-generate-progress .node-progress-bar span::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 42px;
  left: -42px;
  right: auto;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0));
  opacity: 0;
}

.document-generate-progress[data-stage="generating"] .node-progress-bar span::after {
  opacity: 1;
  animation: document-generate-progress-glint 1.5s linear infinite;
}

.document-generate-activity {
  display: none;
  align-items: center;
  gap: 7px;
  color: var(--primary-strong);
  font-size: 0.84rem;
  line-height: 1.3;
}

.document-generate-progress[data-stage="generating"] .document-generate-activity {
  display: inline-flex;
}

.document-generate-activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.3);
  box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.12);
  animation: document-generate-dot-bounce 1.2s ease-in-out infinite;
}

.document-generate-activity-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.document-generate-activity-dot:nth-child(3) {
  animation-delay: 0.4s;
}

.document-generate-activity-text {
  margin-left: 2px;
}

.document-op-progress-hint {
  color: #5f7088;
  font-size: 0.84rem;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-progress-stage {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.node-progress-stage::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.18);
  border: 1px solid rgba(var(--primary-rgb), 0.16);
}

.node-progress-stage.is-active,
.node-progress-stage.is-complete {
  color: var(--primary-strong);
}

.node-progress-stage.is-active::before {
  background: rgba(var(--accent-rgb), 0.9);
  border-color: rgba(var(--accent-rgb), 0.2);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.12);
}

.document-generate-progress[data-stage="generating"] .node-progress-stage.is-active::before {
  animation: document-generate-active-stage-pulse 1.4s ease-out infinite;
}

.node-progress-stage.is-complete::before {
  background: rgba(var(--primary-rgb), 0.9);
  border-color: rgba(var(--primary-rgb), 0.2);
}

.node-progress-stage.is-error {
  color: var(--danger);
}

.node-progress-stage.is-error::before {
  background: rgba(var(--danger-rgb), 0.9);
  border-color: rgba(var(--danger-rgb), 0.2);
  box-shadow: 0 0 0 4px rgba(var(--danger-rgb), 0.12);
}

@keyframes document-generate-card-sheen {
  0% {
    transform: translateX(-130%);
  }
  100% {
    transform: translateX(130%);
  }
}

@keyframes document-generate-progress-glint {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(360%);
  }
}

@keyframes document-generate-dot-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0) scale(1);
    background: rgba(var(--primary-rgb), 0.3);
  }
  40% {
    transform: translateY(-3px) scale(1.08);
    background: rgba(var(--primary-rgb), 0.9);
  }
}

@keyframes document-generate-active-stage-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.24);
  }
  100% {
    box-shadow: 0 0 0 8px rgba(var(--accent-rgb), 0);
  }
}

.wide {
  width: 100%;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.inset-card {
  padding: 22px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(31, 41, 51, 0.04);
}

.inner-head {
  margin-bottom: 12px;
}

.edit-mode-notice-label {
  margin: 0 0 8px;
  min-height: var(--meta-caption-row-height);
  display: flex;
  align-items: flex-end;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
}

@media (min-width: 1101px) {
  .detail-panel .edit-mode-notice-label {
    margin-top: -10px;
  }
}

.edit-mode-notice {
  margin-bottom: 20px;
  min-height: var(--meta-control-row-height);
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid rgba(var(--neutral-rgb), 0.16);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  display: flex;
  align-items: center;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.edit-mode-notice.readonly {
  background: rgba(var(--neutral-rgb), 0.08);
  color: var(--muted);
  border-color: rgba(var(--neutral-rgb), 0.16);
}

.edit-mode-notice.editing {
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.14);
}

.panel-readonly .template-meta-grid,
.panel-readonly .editor-grid {
  opacity: 0.92;
}

.panel-readonly input[readonly],
.panel-readonly textarea[readonly] {
  background: rgba(248, 245, 239, 0.86);
  color: var(--muted);
  border-color: rgba(var(--neutral-rgb), 0.16);
  box-shadow: none;
}

.panel-readonly select:disabled {
  background: rgba(248, 245, 239, 0.86);
  color: var(--muted);
  border-color: rgba(var(--neutral-rgb), 0.16);
  box-shadow: none;
  opacity: 1;
}

.panel-readonly input:disabled,
.panel-readonly textarea:disabled,
.panel-readonly button:disabled {
  opacity: 0.58;
}

.panel-readonly .compact-toggle {
  background: rgba(248, 245, 239, 0.86);
  color: var(--muted);
  border-color: rgba(var(--neutral-rgb), 0.16);
  box-shadow: none;
}

.panel-readonly .compact-toggle:hover,
.panel-readonly .compact-toggle:focus-within {
  transform: none;
  background: rgba(248, 245, 239, 0.86);
  color: var(--muted);
  border-color: rgba(var(--neutral-rgb), 0.16);
  box-shadow: none;
}

.panel-readonly .compact-toggle input:disabled + span::before {
  background: rgba(var(--neutral-rgb), 0.24);
  box-shadow: inset 0 0 0 1px rgba(var(--neutral-rgb), 0.24);
}

.panel-readonly .compact-toggle input:checked:disabled + span::before {
  background: rgba(var(--neutral-rgb), 0.34);
  box-shadow: inset 0 0 0 1px rgba(var(--neutral-rgb), 0.28);
}

.panel-readonly .compact-toggle input:disabled + span::after {
  background: #f8fafc;
  box-shadow: none;
}

.template-badge-status.current-view {
  color: #77879a;
  background: rgba(var(--neutral-rgb), 0.1);
  border-color: rgba(var(--neutral-rgb), 0.14);
}

.generate-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) 30px minmax(0, 1.14fr);
  gap: 14px;
  width: 100%;
  min-height: 0;
  height: 100%;
  align-items: stretch;
}

.generate-layout > .generate-form {
  grid-column: 1;
}

.generate-layout > .generate-preview-toggle {
  grid-column: 2;
  grid-row: 1;
}

.generate-layout > .document-preview {
  grid-column: 3;
}

.generate-preview-toggle {
  appearance: none;
  align-self: center;
  justify-self: center;
  width: 24px;
  height: 72px;
  border-radius: 999px;
  border: 1px solid var(--arrow-control-border);
  background: var(--arrow-control-bg);
  color: var(--arrow-control-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: var(--arrow-control-shadow);
  z-index: 2;
}

.generate-preview-toggle svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.generate-preview-toggle:hover,
.generate-preview-toggle:focus-visible {
  transform: translateY(-1px);
  background: var(--arrow-control-bg-hover);
  color: var(--arrow-control-color-hover);
  border-color: var(--arrow-control-border-hover);
  box-shadow: var(--arrow-control-shadow-hover);
}

.generate-preview-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--arrow-control-shadow-hover);
}

.generate-preview-toggle.active {
  background: rgba(var(--primary-rgb), 0.12);
  border-color: rgba(var(--primary-rgb), 0.26);
  color: var(--primary-strong);
}

.generate-layout.is-preview-maximized {
  grid-template-columns: 0 30px minmax(0, 1fr);
  column-gap: 10px;
}

.generate-layout.is-preview-maximized > .generate-form {
  display: none;
}

.generate-form {
  display: block;
  min-width: 0;
  min-height: auto;
  padding: 18px 18px 12px;
  background: rgba(255, 255, 255, 0.82);
}

.generate-form-scroll {
  overflow: visible;
  padding-right: 0;
}

.generate-compact-row {
  display: block;
}

.generate-compact-row .field {
  margin-bottom: 18px;
}

.generate-form .field {
  margin-bottom: 18px;
}

.generate-name-field {
  min-width: 0;
}

.generate-needs-field textarea,
.generate-business-field textarea {
  min-height: 182px;
  line-height: 1.72;
}

.reference-upload-zone {
  margin-bottom: 0;
}

.reference-file-list {
  display: grid;
  gap: 8px;
  margin: 8px 0 10px;
}

.reference-file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

.reference-file-item .ghost-button {
  width: auto;
}

.reference-file-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.reference-file-main strong {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-file-main small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.generate-form-footer {
  margin-top: 16px;
  padding-top: 0;
  border-top: none;
  display: grid;
  gap: 10px;
}

.generate-export-controls {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.generate-export-label {
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.25;
}

.generate-export-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.generate-export-row select {
  min-height: var(--field-control-height);
}

.generate-export-row .ghost-button {
  min-height: var(--field-control-height);
  padding: 9px 16px;
  align-self: stretch;
}

.generate-workflow-banner {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(31, 41, 51, 0.1);
  background: rgba(241, 245, 249, 0.92);
  color: #5f7088;
  font-size: 0.92rem;
  line-height: 1.4;
}

.generate-review-result {
  margin: 0;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(var(--primary-rgb), 0.18);
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
  font-size: 0.86rem;
  line-height: 1.45;
}

.generate-actions {
  gap: 8px;
  margin: 0;
}

.generate-actions .primary-button {
  min-height: 36px;
  padding: 7px 14px;
}

.document-preview {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 18px 18px 16px;
  background: rgba(255, 255, 255, 0.82);
}

.document-preview .inner-head {
  position: static;
  min-height: 0;
  padding-right: 0;
  margin-bottom: 10px;
  align-items: flex-start;
}

.document-preview .inner-head .document-preview-title {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
  line-height: normal;
}

.document-preview .inner-head .document-preview-title strong {
  font-weight: 600;
  color: var(--text);
}

.document-preview-stats {
  position: static;
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  flex-shrink: 0;
  margin-left: 12px;
  padding: 4px 10px;
  min-height: 0;
  border-radius: 999px;
  border: 1px solid rgba(var(--neutral-rgb), 0.16);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1;
  white-space: nowrap;
}

.generate-overview-details {
  margin-top: 6px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.66);
  padding: 10px 12px 12px;
}

.generate-overview-details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.86rem;
  user-select: none;
}

.generate-overview-details[open] > summary {
  margin-bottom: 12px;
  color: var(--primary-strong);
}

.section-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.section-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
}

.section-check input {
  width: 16px;
  height: 16px;
  margin: 0;
}

.preview-textarea {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  margin-top: -1px;
  background: rgba(255, 255, 255, 0.88);
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.72;
  letter-spacing: 0.01em;
}

.preview-textarea::placeholder {
  color: rgba(95, 112, 136, 0.86);
}

.overview-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#overviewTab .panel-label {
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  line-height: 1.35;
  color: var(--muted);
}

.overview-upper-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.overview-card {
  min-height: 320px;
}

.overview-compare-collapse-divider {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  margin: -8px 0 -4px;
}

#overviewTab.is-overview-top-collapsed .overview-upper-grid {
  display: none;
}

#overviewTab.is-overview-top-collapsed .overview-compare-collapse-divider {
  margin-bottom: 0;
}

.recent-doc-item,
.overview-line {
  min-height: 44px;
  padding: 0;
  border-bottom: 1px solid rgba(31, 41, 51, 0.06);
}

.overview-line:last-child {
  border-bottom: none;
}

.recent-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.overview-line {
  display: flex;
  align-items: center;
  gap: 4px;
  line-height: 1.45;
}

.overview-line strong {
  flex: 0 0 auto;
}

.overview-line > span {
  flex: 1 1 auto;
  min-width: 0;
}

.overview-line:not(.overview-line-multiline) > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overview-line.overview-line-multiline {
  min-height: 0;
  align-items: flex-start;
  line-height: 1.65;
  padding: 10px 0;
}

.recent-doc-main {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.recent-doc-main strong {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 400;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-doc-main p {
  margin: 0;
  flex: 0 0 220px;
  min-width: 0;
  text-align: center;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.recent-doc-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex: 0 0 auto;
  justify-content: flex-end;
}

.recent-doc-actions .ghost-button.small {
  padding: 7px 10px;
  font-size: 0.86rem;
}

#recentDocuments {
  max-height: 252px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.recent-doc-load-button,
.recent-doc-delete-button {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0 !important;
  display: inline-grid;
  place-items: center;
}

.recent-doc-load-button svg,
.recent-doc-delete-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.overview-compare-card {
  grid-column: 1 / -1;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.overview-compare-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.overview-compare-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.overview-compare-field {
  margin-bottom: 0;
  gap: 0;
}

.overview-compare-field > span {
  display: none;
}

.overview-compare-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 auto;
  gap: 12px;
  min-height: 0;
  height: 100%;
}

.overview-compare-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr);
  gap: 8px;
}

.overview-compare-pane-head {
  display: grid;
  grid-template-columns: auto 360px auto auto;
  align-items: center;
  justify-content: start;
  gap: 8px;
  min-width: 0;
}

.overview-compare-meta {
  width: max-content;
  max-width: 100%;
  min-height: var(--field-control-height);
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.overview-compare-pane-head .overview-compare-field {
  margin-bottom: 0;
  min-width: 0;
  width: 100%;
}

.overview-compare-pane-head .overview-compare-field select {
  width: 100%;
  min-width: 0;
  font-weight: 400;
}

.overview-compare-load-button,
.overview-compare-focus-button {
  appearance: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  min-width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--arrow-control-border);
  background: var(--arrow-control-bg);
  color: var(--arrow-control-color);
  box-shadow: var(--arrow-control-shadow);
  transition: transform var(--transition), background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.overview-compare-load-button svg,
.overview-compare-focus-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.overview-compare-load-button:hover,
.overview-compare-load-button:focus-visible,
.overview-compare-focus-button:hover,
.overview-compare-focus-button:focus-visible {
  transform: translateY(-1px);
  background: var(--arrow-control-bg-hover);
  color: var(--arrow-control-color-hover);
  border-color: var(--arrow-control-border-hover);
  box-shadow: var(--arrow-control-shadow-hover);
}

.overview-compare-load-button:focus-visible,
.overview-compare-focus-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), var(--arrow-control-shadow-hover);
}

.overview-compare-load-button:disabled,
.overview-compare-focus-button:disabled {
  opacity: 0.5;
  transform: none;
  cursor: default;
  box-shadow: none;
}

.overview-compare-focus-button.active {
  background: rgba(var(--primary-rgb), 0.12);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.26);
}

.overview-compare-grid.is-focus-left,
.overview-compare-grid.is-focus-right {
  display: flex;
  flex-direction: column;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  height: 100%;
}

.overview-compare-grid.is-focus-left > .overview-compare-pane:nth-child(2) {
  display: none;
}

.overview-compare-grid.is-focus-right > .overview-compare-pane:nth-child(1) {
  display: none;
}

.overview-compare-grid.is-focus-left > .overview-compare-pane:nth-child(1),
.overview-compare-grid.is-focus-right > .overview-compare-pane:nth-child(2) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  align-self: stretch;
  gap: 8px;
}

.overview-compare-grid.is-focus-left .overview-compare-content,
.overview-compare-grid.is-focus-right .overview-compare-content {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

#overviewTab.is-overview-compare-focus-active {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

#overviewTab.is-overview-compare-focus-active .overview-grid {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

#overviewTab.is-overview-compare-focus-active .overview-upper-grid,
#overviewTab.is-overview-compare-focus-active .overview-compare-collapse-divider,
#overviewTab.is-overview-compare-focus-active .overview-compare-hint {
  display: none;
}

#overviewTab.is-overview-compare-focus-active .overview-compare-card {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

#overviewTab.is-overview-compare-focus-active .overview-compare-grid {
  min-height: 0;
  height: 100%;
}

#overviewTab.is-overview-compare-focus-active .overview-compare-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  gap: 8px;
  overflow: hidden;
}

#overviewTab.is-overview-compare-focus-active .overview-compare-grid.is-focus-left .overview-compare-content,
#overviewTab.is-overview-compare-focus-active .overview-compare-grid.is-focus-right .overview-compare-content {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

.overview-compare-content {
  width: 100%;
  height: 100%;
  min-height: 280px;
  resize: none;
  background: rgba(255, 255, 255, 0.9);
  font-family: "Cascadia Code", "Consolas", monospace;
  line-height: 1.6;
}

/* 上半区收起后，把空间优先给下方版本对比，便于并排阅读。 */
#overviewTab.is-overview-top-collapsed .overview-grid {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

#overviewTab.is-overview-top-collapsed .overview-compare-card {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

#overviewTab.is-overview-top-collapsed .overview-compare-grid {
  min-height: 0;
  height: auto;
}

#overviewTab.is-overview-top-collapsed .overview-compare-pane {
  grid-template-rows: auto minmax(0, 1fr);
}

#overviewTab.is-overview-top-collapsed .overview-compare-content {
  min-height: 0;
  height: 100%;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 39, 49, 0.22);
  backdrop-filter: blur(8px);
  z-index: 10;
}

.system-drawer {
  position: fixed;
  top: 18px;
  right: 18px;
  width: min(420px, calc(100vw - 36px));
  z-index: 11;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 30px;
  box-shadow: var(--shadow-soft);
  padding: 24px;
}

.system-drawer-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.system-drawer-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px 14px;
  border-radius: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--line-strong);
}

.system-drawer-label {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.system-drawer-row .status-chip {
  width: 100%;
  min-width: 0;
  justify-content: center;
}

.system-drawer-row .theme-quick-select {
  width: 100%;
  min-width: 0;
  justify-content: center;
  text-align: center;
  text-align-last: center;
}

.system-drawer-row .theme-quick-select option {
  text-align: center;
}

/* Keep model/backup/theme controls visually aligned inside the system drawer. */
.system-drawer-row .ai-config-trigger.ready,
.system-drawer-row .backup-trigger {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.12);
}

.system-drawer-row .theme-quick-select {
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 16px) calc(50% - 2px) / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 11px) calc(50% - 2px) / 6px 6px no-repeat,
    rgba(var(--primary-rgb), 0.1);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.12);
}

.system-drawer-row .ai-config-trigger.ready:hover,
.system-drawer-row .backup-trigger:hover {
  background: rgba(var(--primary-rgb), 0.15);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.system-drawer-row .theme-quick-select:hover {
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 16px) calc(50% - 2px) / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 11px) calc(50% - 2px) / 6px 6px no-repeat,
    rgba(var(--primary-rgb), 0.15);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow: 0 4px 10px rgba(var(--primary-rgb), 0.08);
}

.config-drawer {
  position: fixed;
  top: 18px;
  right: 18px;
  width: min(480px, calc(100vw - 36px));
  z-index: 11;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.config-test-status {
  margin-top: 14px;
  height: 102px;
  padding: 16px 16px;
  border-radius: 18px;
  border: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  box-sizing: border-box;
  overflow: hidden;
}

.config-test-status-text {
  margin: 0;
  height: 100%;
  font-size: 1rem;
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow: auto;
  user-select: text;
  cursor: text;
}

.config-test-status.loading {
  background: rgba(var(--primary-rgb), 0.08);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.12);
}

.config-test-status.success {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.16);
}

.config-test-status.error {
  height: 170px;
  background: rgba(var(--danger-rgb), 0.08);
  color: var(--danger);
  border-color: rgba(var(--danger-rgb), 0.14);
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 39, 49, 0.28);
  backdrop-filter: blur(10px);
  z-index: 13;
}

.confirm-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(460px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  z-index: 14;
  background: rgba(255, 250, 243, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 22px;
}

.confirm-dialog-head {
  margin-bottom: 12px;
}

.confirm-dialog-head h2 {
  margin: 6px 0 0;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  letter-spacing: -0.03em;
}

.confirm-dialog-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.primary-button.danger {
  background: linear-gradient(135deg, #b4233c, #d92d20);
  box-shadow: 0 14px 26px rgba(var(--danger-rgb), 0.22);
}

.primary-button.danger:hover,
.primary-button.danger:focus-visible {
  box-shadow: 0 18px 30px rgba(var(--danger-rgb), 0.26);
  filter: saturate(1.04) brightness(1.02);
}

.primary-button.danger:focus-visible {
  box-shadow: var(--focus-ring), 0 18px 30px rgba(var(--danger-rgb), 0.26);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: rgba(31, 41, 51, 0.94);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  z-index: 12;
}

.empty-state {
  padding: 18px;
  text-align: center;
  border: 1px dashed rgba(31, 41, 51, 0.12);
  border-radius: 18px;
}

/* Strong content-first pass: reduce chrome, increase whitespace. */
:root {
  --bg-gradient-start: #f8f7f3;
  --bg-gradient-middle: #f7f6f2;
  --bg-gradient-end: #f6f5f1;
  --bg: #f7f6f2;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-muted: rgba(255, 255, 255, 0.97);
  --line: rgba(31, 41, 51, 0.1);
  --line-strong: rgba(31, 41, 51, 0.06);
  --shadow: none;
  --shadow-soft: none;
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --workspace-col-gap: 20px;
}

.aurora {
  display: none;
}

.app-shell {
  padding: 20px 28px 24px;
}

.card,
.inset-card,
.system-drawer,
.config-drawer,
.confirm-dialog {
  box-shadow: none;
  backdrop-filter: none;
  border-color: rgba(31, 41, 51, 0.06);
}

.topbar {
  gap: 12px 16px;
  padding: 8px 0 14px;
  margin-bottom: 16px;
  border: 0;
  border-bottom: 1px solid rgba(31, 41, 51, 0.08);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.topbar .eyebrow,
.topbar .subhead {
  display: none;
}

.brand-block {
  gap: 10px;
}

.brand-copy {
  gap: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font-size: 0.84rem;
  box-shadow: none;
}

.topbar h1 {
  font-size: clamp(1.18rem, 0.86vw + 0.92rem, 1.7rem);
  line-height: 1.1;
}

.topbar-actions {
  gap: 10px;
}

.panel {
  padding: 22px;
}

.panel-head {
  margin-bottom: 18px;
}

.field {
  gap: 9px;
  margin-bottom: 18px;
}

#promptTab .editor-grid {
  row-gap: 8px;
  column-gap: 12px;
}

@media (min-width: 1101px) {
  #promptTab .editor-grid {
    margin-top: -6px;
  }
}

#promptTab .editor-grid .field {
  gap: 7px;
  margin-bottom: 8px;
}

#promptTab .editor-primary-row {
  gap: 12px;
  margin-bottom: 2px;
}

#promptTab .compiled-prompt-collapse-divider {
  margin: -2px 0 0;
}

#promptTab > .inline-actions {
  margin-top: 8px;
}

.status-chip,
.pill {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(31, 41, 51, 0.12);
}

.sync-state,
.sync-state.synced,
.sync-state.pending,
.sync-state.dirty,
.sync-state.error {
  background: transparent;
  border: none;
  box-shadow: none;
}

.system-entry-button {
  background: transparent;
  color: var(--text);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.46),
    0 2px 8px rgba(38, 47, 55, 0.04);
}

.system-entry-button:hover {
  background: rgba(255, 255, 255, 0.62);
  color: var(--primary-strong);
  border-color: rgba(var(--primary-rgb), 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.56),
    0 6px 12px rgba(var(--primary-rgb), 0.08);
}

.system-entry-button:focus-visible {
  box-shadow: var(--focus-ring);
}

input,
textarea,
select {
  background: #ffffff;
  border-color: rgba(31, 41, 51, 0.1);
}

input:focus,
textarea:focus,
select:focus {
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.compiled-prompt-panel,
.compiled-prompt-panel-head,
.compiled-prompt-panel-body {
  background: rgba(255, 255, 255, 0.96);
}

@media (max-width: 1360px) {
  .workspace {
    --workspace-sidebar-current: var(--workspace-col-sidebar-compact);
    --workspace-tree-current: var(--workspace-col-tree-compact);
    grid-template-columns:
      var(--workspace-sidebar-current)
      var(--workspace-tree-current)
      minmax(0, 1fr);
  }

  .workspace.is-sidebar-compact {
    --workspace-sidebar-current: var(--workspace-col-sidebar-tight-compact);
  }

  .workspace.is-tree-compact {
    --workspace-tree-current: var(--workspace-col-tree-tight-compact);
  }

  .generate-layout,
  .overview-grid {
    grid-template-columns: 1fr;
  }

  .overview-upper-grid {
    grid-template-columns: 1fr;
  }

  .overview-compare-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .overview-compare-grid {
    grid-template-columns: 1fr;
  }

  .generate-preview-toggle {
    display: none;
  }

  .generate-layout > .generate-form,
  .generate-layout > .document-preview {
    grid-column: auto;
  }

  .generate-layout.is-preview-maximized > .generate-form {
    display: block;
  }

  .detail-panel.is-generate-tab-active #generateTab.active {
    overflow: auto;
  }

  .generate-layout {
    height: auto;
    min-height: auto;
  }

  .generate-form,
  .document-preview {
    min-height: auto;
  }

  .generate-form-scroll {
    overflow: visible;
    padding-right: 0;
  }

  .preview-textarea {
    min-height: 360px;
    height: auto;
  }

  .tree-panel-title-row h2 {
    white-space: normal;
  }

  .tree-toolbar-row,
  .tree-toolbar-group {
    flex-wrap: nowrap;
  }
}

@media (max-width: 1100px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
    display: flex;
    flex-direction: column;
  }

  .tree-panel,
  .detail-panel {
    min-height: auto;
  }

  .detail-panel.is-generate-tab-active {
    height: calc(100vh - 162px);
    min-height: 0;
  }

  .detail-panel.is-generate-tab-active #overviewTab.active {
    overflow: hidden;
  }

  .template-list {
    max-height: none;
  }

  .template-meta-grid,
  .editor-grid,
  .overview-grid,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .template-create-grid {
    grid-template-columns: 1fr;
  }

  .panel-width-toggle {
    display: none;
  }

  .editor-primary-row {
    grid-template-columns: 1fr;
  }

  .editor-primary-row .compact-toggle {
    margin-left: 0;
  }

  .generate-compact-row {
    display: block;
  }

  .generate-export-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .generate-actions {
    margin-left: 0;
  }

  #overviewTab.is-overview-compare-focus-active {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
  }

  #overviewTab.is-overview-compare-focus-active .overview-grid {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    gap: 14px;
  }
}

@media (max-width: 1100px) and (min-width: 721px) {
  #overviewTab.is-overview-compare-focus-active {
    height: 100%;
    min-height: 0;
  }

  #overviewTab.is-overview-compare-focus-active .overview-grid {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
  }

  #overviewTab.is-overview-compare-focus-active .overview-compare-card {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
  }

  #overviewTab.is-overview-compare-focus-active .overview-compare-grid.is-focus-left .overview-compare-content,
  #overviewTab.is-overview-compare-focus-active .overview-compare-grid.is-focus-right .overview-compare-content {
    min-height: 0;
    height: 100%;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px 12px 16px;
  }

  .detail-panel.is-generate-tab-active {
    height: auto;
    min-height: auto;
  }

  .detail-panel.is-generate-tab-active #overviewTab.active {
    overflow: auto;
  }

  .topbar {
    padding: 6px 0 10px;
    margin-bottom: 12px;
  }

  .brand-block {
    align-items: flex-start;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .tab-switcher,
  .topbar-actions,
  .tree-toolbar,
  .inline-actions,
  .drawer-actions {
    width: 100%;
  }

  .tab-button,
  .ghost-button,
  .secondary-button,
  .primary-button {
    width: 100%;
    justify-content: center;
  }

  .system-drawer,
  .config-drawer {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
    border-radius: 24px;
    padding: 20px;
  }

  .system-drawer-row {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
  }

  .field-inline-row {
    flex-wrap: wrap;
  }

  .overview-compare-pane-head {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
  }

  .tree-panel-head {
    align-items: flex-start;
  }

  .detail-panel .panel-head {
    flex-wrap: wrap;
    gap: 12px;
  }

  .detail-head-copy,
  .tab-switcher {
    width: 100%;
  }

  .tree-panel-title-row {
    align-items: flex-start;
  }

  .tree-toolbar-row {
    align-items: center;
  }

  .template-library-summary {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .template-item-surface {
    gap: 8px;
  }

  .template-item {
    min-height: 114px;
  }

  .template-item-footer {
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
  }

  .template-item-actions {
    width: auto;
    justify-content: flex-end;
  }

  .template-item-time {
    width: 100%;
  }

  .reference-file-item {
    flex-direction: column;
    align-items: stretch;
  }

  .reference-file-item .ghost-button {
    width: 100%;
  }

  .recent-doc-item {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .recent-doc-main {
    display: block;
  }

  .recent-doc-main p {
    margin: 4px 0 0;
    flex: 0 0 auto;
    width: 100%;
    text-align: center;
  }

  .recent-doc-actions {
    flex-wrap: wrap;
    justify-content: center;
  }

  .recent-doc-actions .ghost-button {
    width: auto;
  }

  .confirm-dialog-actions {
    flex-direction: column-reverse;
  }

  .field-meta-row {
    align-items: flex-start;
  }
}

@media (min-width: 1101px) {
  .detail-panel.is-generate-tab-active #generateTab.active {
    overflow: hidden;
  }

  .detail-panel.is-generate-tab-active #generateTab.active .generate-layout {
    height: 100%;
    max-height: none;
    min-height: 0;
    align-items: stretch;
  }

  .detail-panel.is-generate-tab-active #generateTab.active .generate-form,
  .detail-panel.is-generate-tab-active #generateTab.active .document-preview {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
  }

  .detail-panel.is-generate-tab-active #generateTab.active .generate-form-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .detail-panel.is-generate-tab-active #generateTab.active .generate-form-scroll::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
  }

  .detail-panel.is-generate-tab-active #generateTab.active .preview-textarea {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: auto;
    -ms-overflow-style: auto;
  }

  .detail-panel.is-generate-tab-active #generateTab.active .preview-textarea::-webkit-scrollbar {
    width: 10px;
    height: 10px;
    display: block;
  }
}

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