:root {
  color-scheme: light;
  --page: #eef2f3;
  --surface: #ffffff;
  --surface-muted: #f7f9f9;
  --surface-strong: #e8efef;
  --ink: #202b35;
  --ink-soft: #55636d;
  --ink-faint: #77858e;
  --line: #d6dfe1;
  --line-strong: #bdcbce;
  --teal: #087b76;
  --teal-dark: #06635f;
  --teal-pale: #e0f1ef;
  --coral: #bd553b;
  --coral-pale: #f9e7e0;
  --gold: #b87517;
  --gold-pale: #fff2d9;
  --shadow: 0 10px 30px rgba(26, 42, 47, 0.08);
  --control-height: 34px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  min-width: 320px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.app-loading { min-height: calc(100vh - 62px); display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--ink-soft); font-size: 12px; }

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

button {
  min-height: var(--control-height);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 10px;
  line-height: 1.4;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease, transform 120ms ease;
}

button:hover:not(:disabled) { border-color: #94a7aa; background: var(--surface-muted); }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(8, 123, 118, 0.22); outline-offset: 1px; }
button:disabled { cursor: not-allowed; opacity: 0.52; }

button.primary {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

button.primary:hover:not(:disabled) { border-color: var(--teal-dark); background: var(--teal-dark); }
button.quiet { background: transparent; }
button.danger { color: var(--coral); border-color: #ecc4b9; }
button.danger:hover:not(:disabled) { background: var(--coral-pale); border-color: #df9e8d; }
button.danger-button { border-color: var(--coral); background: var(--coral); color: #fff; }
button.danger-button:hover:not(:disabled) { background: #9e422c; }

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 9px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), select {
  height: var(--control-height);
  padding: 6px 9px;
  line-height: 1.4;
}

input[readonly], textarea[readonly] { background: var(--surface-muted); color: var(--ink-soft); }
.readonly-field { min-height: 34px; border: 1px solid #e5e7eb; border-radius: 6px; background: #f9fafb; padding: 8px; color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.button-link { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; color: var(--ink-soft); font-size: 12px; text-decoration: none; }
.button-link:hover { border-color: var(--teal); color: var(--teal-dark); }
.desktop-tool-actions { flex-wrap: wrap; }

textarea { min-height: 56px; resize: vertical; line-height: 1.5; }
select { min-width: 0; }
label { color: var(--ink-soft); font-size: 12px; font-weight: 620; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden { display: none !important; }

.app-header {
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(170px, 0.72fr) minmax(0, 1.28fr);
  gap: 18px;
  align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand-block { display: flex; min-width: 0; align-items: center; gap: 10px; }
.brand-mark { width: 31px; height: 31px; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 3px; padding: 6px; border-radius: 7px; background: var(--teal); }
.brand-mark span { display: block; background: #f8fbfb; border-radius: 1px; }
.brand-mark span:nth-child(1) { height: 42%; }
.brand-mark span:nth-child(2) { height: 75%; }
.brand-mark span:nth-child(3) { height: 100%; }
.brand-block h1 { margin: 0; font-size: 15px; font-weight: 730; letter-spacing: 0; }
.app-version { color: var(--ink-faint); font-size: 10px; font-weight: 620; white-space: nowrap; }
.brand-block p { margin: 0; color: var(--ink-faint); font-size: 11px; }

.project-picker, .header-actions, .style-control, .toolbar-actions, .modal-actions, .section-label, .label-with-note, .task-heading { display: flex; align-items: center; gap: 8px; }
.project-picker select { max-width: 280px; }
.icon-text { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.header-actions { min-width: 0; justify-content: flex-start; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 1px 0; scrollbar-width: none; }
.header-actions::-webkit-scrollbar { display: none; }
.header-status, .header-buttons { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.header-status { margin-left: auto; }
.header-buttons button { white-space: nowrap; }
.header-icon-button { position: relative; width: var(--control-height); min-width: var(--control-height); height: var(--control-height); display: grid; place-items: center; padding: 0; }
.header-icon-button.attention::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border: 1px solid var(--surface); border-radius: 50%; background: var(--coral); }
.generation-status { min-height: 28px; display: inline-flex; max-width: 260px; align-items: center; gap: 7px; border: 1px solid #b7d8d5; border-radius: 6px; background: var(--teal-pale); color: var(--teal-dark); padding: 4px 8px; font-size: 11px; line-height: 1.3; }
.generation-status.failed { border-color: #e1aa9b; background: var(--coral-pale); color: #913f2d; }
.generation-status.completed { border-color: #c7d5d6; background: var(--surface-muted); color: var(--ink-soft); }
.activity-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: currentColor; }
.generation-status.active .activity-dot { animation: status-pulse 1.25s ease-in-out infinite; }
@keyframes status-pulse { 0%, 100% { opacity: .35; transform: scale(.82); } 50% { opacity: 1; transform: scale(1); } }
.save-state { min-width: 42px; color: var(--ink-faint); font-size: 11px; white-space: nowrap; }
.save-state.error { color: #a14935; }
.mobile-workspace-nav { display: none; }

.global-settings {
  display: grid;
  grid-template-columns: minmax(280px, 2.2fr) minmax(116px, 0.62fr) minmax(116px, 0.62fr) minmax(190px, 1fr) minmax(220px, 1.3fr);
  gap: 11px;
  align-items: end;
  padding: 10px 18px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8fafb;
}

.global-prompt, .setting-field { min-width: 0; display: grid; gap: 4px; }
.global-label-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.project-upload { min-height: 24px; display: inline-flex; flex: 0 0 auto; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--teal); padding: 2px 6px; cursor: pointer; font-size: 10px; font-weight: 650; }
.project-upload:hover { border-color: #9bcac6; background: var(--teal-pale); }
.project-reference-list { min-height: 0; display: flex; align-items: center; gap: 5px; overflow-x: auto; }
.project-reference-list:not(:empty) { min-height: 33px; padding-top: 2px; }
.project-reference-summary { flex: 0 0 auto; color: var(--ink-faint); font-size: 10px; }
.project-reference-chip { position: relative; width: 30px; height: 30px; flex: 0 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-muted); }
.project-reference-chip img { width: 100%; height: 100%; display: block; object-fit: cover; }
.remove-project-reference { position: absolute; top: 1px; right: 1px; width: 14px; min-width: 14px; min-height: 14px; border: 0; border-radius: 3px; background: rgba(38, 47, 51, .82); color: #fff; padding: 0; font-size: 10px; line-height: 1; }
.global-prompt textarea { min-height: 44px; max-height: 72px; }
.global-settings label { display: block; }
.style-control select { flex: 1 1 auto; }
.style-control button { flex: 0 0 auto; }
.settings-note { align-self: end; margin: 0 0 3px; color: var(--ink-faint); font-size: 11px; line-height: 1.35; }

.workspace {
  height: auto;
  flex: 1 1 auto;
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(205px, 0.73fr) minmax(420px, 2fr) minmax(310px, 0.95fr);
  gap: 12px;
  padding: 12px 18px 18px;
}

.sidebar, .tree-panel, .inspector {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 2px 5px rgba(36, 55, 60, 0.025);
}

.task-sidebar { display: flex; flex-direction: column; overflow: hidden; }
.panel-heading, .tree-toolbar, .inspector-header { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.panel-heading, .inspector-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-heading h2, .tree-toolbar h2, .inspector-header h2 { margin: 0; overflow-wrap: anywhere; font-size: 16px; line-height: 1.2; }
.eyebrow { margin: 0 0 2px; color: var(--teal); font-size: 10px; font-weight: 760; letter-spacing: .08em; text-transform: uppercase; }
.mini-button { min-width: 30px; min-height: 27px; padding: 2px 7px; color: var(--ink-soft); }
.project-stats { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 16px; color: var(--ink-faint); font-size: 11px; }
.stat-pill { padding: 2px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); }
.project-panel { flex-direction: column; align-items: stretch; gap: 6px; }
.sidebar-project-picker { gap: 5px; }
.sidebar-project-picker select { flex: 1; min-width: 0; max-width: none; }
.project-details { display: flex; flex-direction: column; gap: 5px; }
.project-download { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; }
.detail-stats { display: flex; flex-wrap: wrap; gap: 5px; }
.project-details .stat-pill { font-size: 10.5px; padding: 1px 5px; }
.detail-params { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
.detail-param { color: var(--ink-faint); font-size: 10.5px; }
.detail-param b { color: var(--ink-soft); font-weight: 600; margin-right: 3px; }
.detail-line { display: flex; gap: 5px; font-size: 10.5px; line-height: 1.35; min-width: 0; }
.detail-label { color: var(--ink-faint); flex: 0 0 auto; }
.detail-value { color: var(--ink-soft); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-directory { align-items: center; }
.project-directory .detail-value { flex: 1; }
.project-detail-icon { width: 25px; min-width: 25px; height: 25px; min-height: 25px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-faint); }
.project-detail-icon .lucide-icon { width: 14px; height: 14px; }
.open-folder-button { border-color: transparent; background: transparent; padding: 0; }
.open-folder-button:hover:not(:disabled) { border-color: var(--line); background: var(--surface-muted); color: var(--teal); }
.project-prompt { align-items: flex-start; }
.project-prompt .detail-value { flex: 1; }
.detail-prompt { max-height: 4.05em; white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.section-divider { height: 1px; background: var(--line); }
.task-heading { justify-content: space-between; padding: 12px 13px 9px 16px; }
.task-heading h3 { margin: 0; font-size: 13px; }
.add-button { min-height: 28px; padding: 3px 7px; border-color: transparent; color: var(--teal); font-size: 12px; background: transparent; }
.add-button:hover:not(:disabled) { border-color: var(--line); background: var(--teal-pale); }
.task-list { flex: 1; min-height: 90px; overflow: auto; padding: 2px 8px 10px; }
.task-item { width: 100%; min-height: 49px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; align-items: center; border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 8px; text-align: left; }
.task-item:hover { background: var(--surface-muted); }
.task-item.active { border-color: #9bcac6; background: var(--teal-pale); }
.task-item-main { min-width: 0; }
.task-item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 650; }
.task-item small { display: block; overflow: hidden; color: var(--ink-faint); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.task-menu { min-width: 25px; min-height: 26px; padding: 1px 5px; border-color: transparent; color: var(--ink-faint); }
.task-menu:hover { border-color: var(--line); background: #fff; }
.sidebar-footer { padding: 11px 14px; border-top: 1px solid var(--line); background: var(--surface-muted); }
.sidebar-footer p { margin: 0; color: var(--ink-faint); font-size: 11px; line-height: 1.45; }

.tree-panel { display: flex; flex-direction: column; overflow: hidden; }
.tree-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.tree-toolbar > div:first-child { min-width: 0; }
.tree-toolbar .muted { margin: 3px 0 0; }
#task-description { max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toolbar-actions { justify-content: flex-end; flex-wrap: wrap; }
.import-trigger, .import-copy-button, .import-generate-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.leaf-filter { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--ink-soft); font-weight: 500; }
.leaf-filter input, .check-row input { width: 15px; height: 15px; margin: 0; accent-color: var(--teal); }
.tree-scroll { flex: 1; min-height: 0; overflow: auto; padding: 12px 14px 28px; background-image: linear-gradient(to bottom, transparent 27px, rgba(215, 224, 225, .28) 28px); background-size: 100% 28px; }
.prompt-tree { min-width: 480px; }
.tree-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 11px; padding: 28px; text-align: center; }
.empty-symbol { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid #a4cfcb; border-radius: 7px; background: var(--teal-pale); color: var(--teal); font-size: 25px; }
.tree-empty h3 { margin: 0; font-size: 16px; }
.tree-empty p { max-width: 380px; margin: 0; color: var(--ink-soft); font-size: 13px; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tree-footer { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; border-top: 1px solid var(--line); background: var(--surface); }
.tree-footer-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }

.tree-node { display: grid; grid-template-columns: minmax(190px, 1fr) 122px 176px; gap: 8px; align-items: center; min-height: 50px; padding: 5px 7px 5px calc(var(--tree-indent) + 2px); }
.tree-card { position: relative; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 6px; background: rgba(255, 255, 255, .9); padding: 8px 10px; cursor: pointer; }
.tree-card:hover { border-color: #c6d4d5; background: #fff; }
.tree-card.active { border-color: #86bdb9; background: #f5fbfa; box-shadow: inset 3px 0 0 var(--teal); }
.tree-card.drag-inside { border-color: var(--teal); background: var(--teal-pale); }
.tree-card.drag-before::before, .tree-card.drag-after::after { content: ""; position: absolute; z-index: 3; right: 0; left: 0; height: 3px; border-radius: 2px; background: var(--teal); pointer-events: none; }
.tree-card.drag-before::before { top: -5px; }
.tree-card.drag-after::after { bottom: -5px; }
.node-dot { width: 10px; min-width: 10px; height: 10px; min-height: 10px; display: block; border: 0; border-radius: 50%; background: var(--gold); padding: 0; }
.node-dot.parent { cursor: pointer; }
.node-dot.parent:hover:not(:disabled) { border: 0; background: #d58c1b; transform: scale(1.15); }
.node-dot.parent.collapsed { background: #fff; box-shadow: inset 0 0 0 2px var(--gold); }
.node-dot.parent.collapsed:hover:not(:disabled) { background: #fff; }
.node-dot.leaf { background: var(--teal); }
.node-text { min-width: 0; }
.node-text strong, .node-text span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-text strong { font-size: 13px; font-weight: 670; }
.node-text span { color: var(--ink-faint); font-size: 11px; }
.node-badges { min-width: 0; display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.node-badge { max-width: 72px; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--ink-faint); padding: 1px 5px; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.node-badge.dependency { max-width: 116px; display: inline-flex; align-items: center; gap: 3px; color: #84600e; border-color: #ead19b; background: var(--gold-pale); }
.node-badge.dependency.invalid { color: var(--coral); border-color: #e8b9ad; background: var(--coral-pale); }
.node-badge.dependency .lucide-icon { width: 11px; height: 11px; }
.node-badge.dependency span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.node-badge.result-success { color: var(--teal-dark); border-color: #b7dbd7; background: var(--teal-pale); }
.node-output-slot { width: 122px; min-width: 122px; height: 38px; display: grid; grid-template-columns: repeat(3, 38px); align-items: center; justify-items: center; gap: 4px; overflow: hidden; }
.node-result-thumb { position: relative; width: 38px; height: 38px; flex: 0 0 auto; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); padding: 0; cursor: pointer; }
.node-result-thumb:hover { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-pale); }
.node-result-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.node-result-thumb.primary-result { border-color: #d6a848; box-shadow: inset 0 0 0 1px #d6a848; }
.node-result-more { width: 38px; min-width: 38px; height: 38px; min-height: 38px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); color: var(--ink-soft); font-size: 10px; cursor: pointer; }
.node-result-more:hover { border-color: var(--teal); color: var(--teal); }
.node-status { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; min-height: 18px; max-height: 18px; flex: 0 0 auto; align-self: center; aspect-ratio: 1 / 1; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 1; cursor: pointer; padding: 0; border: none; }
.node-status.success { background: var(--teal); color: #fff; }
.node-status.failed { background: var(--coral); color: #fff; }
.node-status[data-error] { position: relative; }
.node-row-actions { width: 176px; min-width: 176px; display: grid; grid-template-columns: repeat(5, 32px); align-items: center; justify-content: end; gap: 4px; }
.node-action, .node-action-placeholder { width: 32px; min-width: 32px; max-width: 32px; height: 32px; min-height: 32px; max-height: 32px; }
.node-action { display: inline-flex; align-items: center; justify-content: center; padding: 0; border-color: transparent; color: var(--ink-soft); }
.node-action:hover:not(:disabled) { border-color: var(--line); background: #fff; }
.node-action.generate { color: var(--teal); }
.node-action.generate.generating { cursor: progress; }
.node-action.danger { color: var(--coral); }
.node-action.ai { color: var(--gold); }
.node-action.ai:hover:not(:disabled) { border-color: var(--gold-pale); background: var(--gold-pale); }
.lucide-icon { width: 16px; height: 16px; display: block; flex: 0 0 auto; }

/* Spinning animation shown inside an in-progress generate button. */
.spinner { display: inline-block; width: 13px; height: 13px; vertical-align: -2px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 720ms linear infinite; }
.spinner.inline { width: 11px; height: 11px; vertical-align: -1px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
button.generating { position: relative; cursor: progress; }
button.generating .button-label { opacity: 0.85; }
button.primary.generating { background: var(--teal-dark); }

.inspector { display: flex; flex-direction: column; overflow: hidden; }
.inspector-header { min-height: 70px; }
.kind-badge { max-width: 110px; overflow: hidden; border: 1px solid #b9d9d6; border-radius: 4px; background: var(--teal-pale); color: var(--teal-dark); padding: 2px 6px; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; font-weight: 650; }
.inspector-empty { display: grid; flex: 1; place-items: center; padding: 30px; text-align: center; }
.inspector-empty p { max-width: 270px; color: var(--ink-soft); }
.node-editor { flex: 1; min-height: 0; overflow: auto; padding: 16px 16px 24px; font-size: 13px; line-height: 1.5; }
.node-editor input, .node-editor textarea, .node-editor select { font-size: 13px; line-height: 1.45; }
.field-block { display: grid; gap: 5px; margin-bottom: 14px; }
.node-editor .field-block { gap: 6px; margin-bottom: 16px; }
.node-editor label, .node-editor .section-label strong { color: var(--ink-soft); font-size: 12px; font-weight: 680; line-height: 1.35; }
.node-editor .label-with-note { display: grid; justify-content: initial; align-items: start; gap: 2px; }
.node-editor .label-with-note span, .node-editor .section-label span, .node-editor .check-row small { color: var(--ink-faint); font-size: 11px; font-weight: 500; line-height: 1.45; }
.node-editor .check-row { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: 8px; align-items: start; margin: 0 0 16px; color: var(--ink); font-size: 13px; line-height: 1.4; }
.node-editor .check-row > span { padding-top: 1px; }
.node-editor .check-row small { grid-column: 2; }
.node-editor .compact-field { grid-template-columns: minmax(0, 1fr) 72px; align-items: end; column-gap: 12px; row-gap: 0; }
.node-editor .compact-field .label-with-note { grid-column: 1; align-self: center; }
.node-editor .compact-field input { grid-column: 2; grid-row: 1; min-width: 0; text-align: center; }
.node-editor .reference-section, .node-editor .final-prompt-section, .node-editor .results-section { padding: 16px 0; border-top: 1px solid var(--line); }
.node-editor .section-label { align-items: flex-start; justify-content: space-between; gap: 12px; }
.node-editor .section-label > div { min-width: 0; display: grid; gap: 2px; }
.upload-button { min-height: 29px; display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 4px 8px; color: var(--ink); background: #fff; cursor: pointer; font-size: 12px; }
.upload-button:hover { background: var(--surface-muted); border-color: #94a7aa; }
.reference-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 9px; }
.reference-empty { grid-column: 1 / -1; margin: 0; color: var(--ink-faint); font-size: 11px; }
.reference-card { position: relative; min-width: 0; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); }
.reference-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.remove-reference { position: absolute; top: 3px; right: 3px; width: 20px; min-width: 20px; min-height: 20px; border: 1px solid rgba(255,255,255,.8); border-radius: 4px; background: rgba(38, 47, 51, .8); color: #fff; padding: 0; font-size: 12px; }
.reference-sources { display: grid; gap: 0; }
.reference-sources > .section-label { margin-bottom: 8px; }
.reference-source-group { min-width: 0; padding: 12px 0; border-top: 1px solid var(--line); }
.reference-source-group:first-of-type { border-top: 0; }
.reference-source-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.reference-source-heading > div { min-width: 0; display: grid; gap: 1px; }
.node-editor .reference-source-heading strong { color: var(--ink-soft); font-size: 12px; }
.node-editor .reference-source-heading span, .node-editor .generated-reference-node-setting small { color: var(--ink-faint); font-size: 11px; font-weight: 500; line-height: 1.45; }
.reference-inherit-row { margin: 0; }
.reference-mode-control { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; margin-top: 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface-muted); padding: 3px; }
.reference-mode-control label { min-width: 0; cursor: pointer; }
.reference-mode-control input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.reference-mode-control span { min-height: 32px; display: grid; place-items: center; overflow: hidden; border: 1px solid transparent; border-radius: 4px; color: var(--ink-soft); padding: 4px 5px; text-align: center; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; }
.reference-mode-control label:hover span { color: var(--ink); background: #fff; }
.reference-mode-control input:focus-visible + span { outline: 3px solid rgba(8, 123, 118, 0.22); outline-offset: 1px; }
.reference-mode-control input:checked + span { border-color: #9bcac6; background: #fff; color: var(--teal-dark); box-shadow: 0 1px 2px rgba(26, 42, 47, .08); }
.reference-mode-control input:disabled + span { cursor: not-allowed; opacity: .46; }
.generated-reference-node-setting { display: grid; gap: 5px; margin-top: 9px; }
.generated-reference-node-setting small { display: block; }
.reference-source-summary { margin: 8px 0 0; border-radius: 5px; background: var(--teal-pale); color: var(--teal-dark); padding: 8px 9px; font-size: 11px; line-height: 1.45; }
.reference-source-summary.invalid { background: var(--coral-pale); color: #8e3d2a; }
.final-prompt { max-height: 185px; overflow: auto; margin: 9px 0 0; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); padding: 10px; color: #45545c; white-space: pre-wrap; font-family: inherit; font-size: 12px; line-height: 1.55; }
.node-actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 15px 0; border-top: 1px solid var(--line); }
.node-actions button { font-size: 12px; }
.generate-box { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid #c5dedb; border-radius: 6px; background: #f4fbfa; }
.generate-box strong { display: block; font-size: 13px; line-height: 1.4; }
.generate-box p { margin: 3px 0 0; color: var(--ink-faint); font-size: 11px; line-height: 1.45; }
.generate-box button { flex: 0 0 auto; }
.node-editor .results-section { margin-top: 2px; }
.node-results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-top: 8px; }
.result-empty { grid-column: 1 / -1; margin: 0; color: var(--ink-faint); font-size: 11px; line-height: 1.45; }
.result-card { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-muted); }
.result-card img { width: 100%; aspect-ratio: 1; display: block; object-fit: cover; }
.result-card.primary-result { border-color: #d6a848; box-shadow: inset 0 0 0 1px #d6a848; }
.result-card a, .result-card-button { display: block; width: 100%; color: inherit; text-decoration: none; background: transparent; border: 0; padding: 0; cursor: pointer; text-align: left; }
.result-card-button:focus-visible { outline: 3px solid rgba(8, 123, 118, 0.22); outline-offset: 1px; }
.result-card small { display: block; overflow: hidden; padding: 4px 5px; color: var(--ink-faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.result-card small b { margin-right: 5px; color: #8a6514; font-weight: 700; }
.primary-result-mark { position: absolute; top: 3px; left: 3px; z-index: 2; min-width: 18px; height: 18px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .8); border-radius: 4px; background: rgba(117, 81, 7, .9); color: #fff3ba; font-size: 11px; line-height: 1; pointer-events: none; }
.result-failure { grid-column: 1 / -1; border: 1px solid #e8c2b6; border-radius: 5px; background: var(--coral-pale); padding: 8px; color: #843a29; font-size: 11px; overflow-wrap: anywhere; }

dialog.modal { width: min(510px, calc(100vw - 28px)); max-height: min(760px, calc(100vh - 28px)); margin: auto; border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: var(--shadow); padding: 0; color: var(--ink); background: var(--surface); }
dialog.modal::backdrop { background: rgba(25, 38, 42, .34); }
.modal form { max-height: min(760px, calc(100vh - 28px)); overflow: auto; padding: 17px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.modal-header h2 { margin: 0; font-size: 18px; }
.close-button { min-width: 29px; min-height: 29px; padding: 2px 7px; border-color: transparent; color: var(--ink-faint); background: transparent; }
.close-button:hover { border-color: var(--line); }
.modal-note, .confirm-message { margin: 0 0 15px; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.confirm-message { white-space: pre-line; }
.modal-status { min-height: 18px; margin: -2px 0 10px; color: var(--ink-soft); font-size: 12px; }
.modal-status.error { color: var(--coral); }
.modal-actions { justify-content: flex-end; padding-top: 4px; }
.api-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.api-tab { min-height: 30px; padding: 5px 14px; border: 1px solid transparent; border-bottom: none; border-radius: 5px 5px 0 0; background: transparent; color: var(--ink-soft); font-size: 12px; font-weight: 600; cursor: pointer; }
.api-tab:hover { background: var(--surface-muted); color: var(--ink); }
.api-tab.active { border-color: var(--line-strong); border-bottom-color: var(--surface); background: var(--surface); color: var(--teal-dark); margin-bottom: -1px; }
.api-panel { display: grid; gap: 4px; }
.api-panel.hidden { display: none; }
.settings-modal { width: min(900px, calc(100vw - 32px)) !important; height: min(650px, calc(100vh - 32px)); max-height: calc(100vh - 32px) !important; overflow: hidden; }
.settings-shell { height: 100%; min-height: 0; display: flex; flex-direction: column; }
.settings-header { min-height: 68px; display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 15px 17px 12px; border-bottom: 1px solid var(--line); }
.settings-header h2 { margin: 0; font-size: 18px; }
.settings-layout { min-height: 0; display: grid; flex: 1; grid-template-columns: 150px minmax(0, 1fr); }
.settings-nav { min-width: 0; display: flex; flex-direction: column; gap: 3px; border-right: 1px solid var(--line); background: var(--surface-muted); padding: 10px 8px; }
.settings-nav button { width: 100%; min-height: var(--control-height); display: flex; align-items: center; justify-content: flex-start; gap: 8px; border-color: transparent; background: transparent; color: var(--ink-soft); padding: 7px 8px; text-align: left; }
.settings-nav button:hover:not(:disabled) { border-color: transparent; background: #edf2f2; color: var(--ink); }
.settings-nav button.active { border-color: #acd1ce; background: var(--teal-pale); color: var(--teal-dark); font-weight: 680; }
.settings-nav .lucide-icon { width: 15px; height: 15px; }
.settings-content { min-width: 0; min-height: 0; overflow: auto; padding: 18px 20px 22px; }
.settings-panel { width: 100%; max-width: 660px; }
.settings-panel[data-settings-panel="styles"] { max-width: none; }
.settings-panel-heading { margin-bottom: 14px; }
.settings-panel-heading h3 { margin: 1px 0 0; font-size: 15px; line-height: 1.3; }
.settings-modal form { max-height: none; overflow: visible; padding: 0; }
.settings-group { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.settings-group h3, .settings-group h4 { margin: 0 0 10px; font-size: 13px; }
.settings-action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.settings-action-grid button, .settings-action-grid .button-link { min-width: 0; min-height: var(--control-height); justify-content: center; padding: 6px 10px; text-align: center; }
.settings-action-grid .settings-action-full { grid-column: 1 / -1; }
.browser-storage-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.browser-storage-grid > div { min-width: 0; display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); padding: 8px; }
.browser-storage-grid span { color: var(--ink-faint); font-size: 11px; }
.browser-storage-grid strong { overflow-wrap: anywhere; color: var(--ink); font-size: 12px; }
.settings-language-field { max-width: 280px; }
.settings-language-field select { width: 100%; }
.ai-synth-limits { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.ai-synth-draft { max-height: min(360px, calc(100vh - 360px)); overflow-y: auto; padding: 2px; margin-bottom: 10px; display: grid; gap: 10px; }
.ai-synth-draft:empty { display: none; }
.ai-synth-branch { border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); padding: 10px; display: grid; gap: 6px; }
.ai-synth-check-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 7px; }
.ai-synth-branch-tag, .ai-synth-leaf-tag { display: inline-flex; align-items: center; padding: 1px 6px; border-radius: 3px; font-size: 10px; font-weight: 700; }
.ai-synth-branch-tag { background: var(--gold-pale); color: var(--gold); }
.ai-synth-leaf-tag { background: var(--teal-pale); color: var(--teal-dark); }
.ai-synth-branch-name, .ai-synth-leaf-name { min-height: 28px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--ink); font-size: 12px; }
.ai-synth-branch-prompt, .ai-synth-leaf-prompt { width: 100%; min-height: 40px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--ink); font-size: 12px; resize: vertical; }
.ai-synth-leaves { display: grid; gap: 6px; padding-left: 22px; border-left: 2px dashed var(--line-strong); margin-left: 6px; }
.ai-synth-leaf { display: grid; gap: 4px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.modal-body { max-height: 60vh; overflow-y: auto; }
.project-list-items { display: flex; flex-direction: column; gap: 6px; }
.project-list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.project-list-item.active { border-color: var(--teal); background: var(--teal-pale); }
.project-list-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.project-list-info strong { font-size: 13px; overflow-wrap: anywhere; }
.project-list-info small { color: var(--ink-faint); font-size: 11px; }
.excel-preview-modal { width: min(720px, calc(100vw - 28px)) !important; }
.excel-project-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 11px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.excel-project-row { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; padding: 9px 10px; }
.excel-project-row + .excel-project-row { border-left: 1px solid var(--line); }
.excel-project-row > span { grid-column: 1 / -1; color: var(--ink-faint); font-size: 11px; }
.excel-project-row strong { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.excel-project-row small { color: var(--ink-faint); font-size: 11px; white-space: nowrap; }
.excel-change-summary { margin-bottom: 11px; padding: 9px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.excel-change-summary h3, .excel-issue-group h3 { margin: 0 0 7px; font-size: 12px; }
.excel-change-summary > div { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.excel-change-summary span { display: inline-flex; align-items: baseline; gap: 5px; color: var(--ink-soft); font-size: 11px; }
.excel-change-summary span strong { color: var(--teal-dark); font-size: 14px; }
.excel-change-summary p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.excel-preview-issues { display: grid; gap: 8px; margin-bottom: 11px; }
.excel-issue-group { padding: 9px 10px; border-left: 3px solid var(--gold); background: #fffaf0; }
.excel-issue-group.error { border-left-color: var(--coral); background: var(--coral-pale); }
.excel-issue-group ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.excel-issue-group li { display: grid; gap: 2px; }
.excel-issue-group li span { color: var(--ink-faint); font-size: 10px; }
.excel-issue-group li p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.backup-preview-modal { width: min(720px, calc(100vw - 28px)) !important; }
.backup-preview-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0 0 11px; }
.backup-preview-stat { min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); padding: 8px; }
.backup-preview-stat strong, .backup-preview-stat span { display: block; overflow-wrap: anywhere; }
.backup-preview-stat strong { color: var(--teal-dark); font-size: 16px; line-height: 1.2; }
.backup-preview-stat span { margin-top: 3px; color: var(--ink-faint); font-size: 11px; }
.backup-version-notice { margin: 0 0 11px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; line-height: 1.45; }
.backup-version-notice.compatible { border-color: #a9d3c5; background: #f2faf7; color: #286555; }
.backup-version-notice.incompatible { border-color: #e6b6aa; background: #fff7f5; color: #914b39; }
.backup-preview-selection { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 9px; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-muted); color: var(--ink-soft); font-size: 12px; }
.backup-preview-selection > div { display: flex; flex-wrap: wrap; gap: 6px; }
.backup-preview-selection button { min-height: 28px; padding: 4px 8px; font-size: 12px; }
.backup-preview-list { display: grid; gap: 7px; max-height: min(390px, calc(100vh - 330px)); overflow-y: auto; margin-bottom: 13px; }
.backup-preview-item { min-width: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); padding: 9px 10px; }
.backup-preview-item.has-conflict { border-color: #deb56a; background: #fffaf0; }
.backup-preview-item header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.backup-preview-item strong { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.backup-preview-item header span { flex: 0 0 auto; color: var(--ink-faint); font-size: 11px; }
.backup-preview-project-check { display: flex; min-width: 0; align-items: baseline; gap: 7px; cursor: pointer; }
.backup-preview-project-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--teal); flex: 0 0 auto; }
.backup-preview-meta { display: flex; flex-wrap: wrap; gap: 5px 10px; margin: 5px 0 0; color: var(--ink-soft); font-size: 11px; }
.backup-preview-notices { display: grid; gap: 4px; margin: 7px 0 0; }
.backup-preview-notice { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.4; }
.backup-preview-notice.conflict { color: #8a6514; }
.backup-preview-actions { flex-wrap: wrap; }
.backup-result-modal { width: min(720px, calc(100vw - 28px)) !important; }
.backup-result-list { display: grid; gap: 7px; max-height: min(430px, calc(100vh - 300px)); overflow-y: auto; margin-bottom: 13px; }
.backup-result-item { min-width: 0; border: 1px solid #a9d3c5; border-radius: 6px; background: #f7fcfa; padding: 9px 10px; }
.backup-result-item.is-skipped { border-color: #dec98f; background: #fffaf0; }
.backup-result-item header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.backup-result-item header strong, .backup-result-item header span { min-width: 0; overflow-wrap: anywhere; font-size: 12px; }
.backup-result-item header span { color: var(--ink-soft); text-align: right; }
.backup-result-open { display: inline-flex; align-items: center; gap: 6px; min-height: 29px; margin-top: 8px; padding: 4px 8px; font-size: 12px; }
.wide-modal { width: min(830px, calc(100vw - 28px)) !important; }
.task-import-modal { width: min(980px, calc(100vw - 28px)) !important; max-height: min(850px, calc(100vh - 24px)) !important; overflow: hidden; }
.task-import-modal form { max-height: min(850px, calc(100vh - 24px)); display: flex; flex-direction: column; overflow: hidden; }
.task-import-layout { min-height: 0; display: grid; flex: 1; grid-template-columns: minmax(0, .94fr) minmax(0, 1.06fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.task-import-source, .task-import-preview { min-width: 0; min-height: 510px; max-height: min(630px, calc(100vh - 210px)); overflow: auto; padding: 15px 16px 15px 0; }
.task-import-preview { padding-right: 2px; padding-left: 17px; border-left: 1px solid var(--line); background: var(--surface-muted); }
.task-import-controls { display: grid; grid-template-columns: minmax(130px, .62fr) minmax(170px, 1fr); gap: 12px; align-items: end; }
.task-import-controls .field-block { margin-bottom: 10px; }
.compact-check { align-self: center; margin: 0 0 12px; font-weight: 540; }
.import-context { display: grid; gap: 7px; margin: 1px 0 12px; padding: 10px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.import-context > div { min-width: 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.import-context span, .import-preview-heading span, .import-task-prompt span { color: var(--ink-faint); font-size: 10px; font-weight: 650; }
.import-context p { min-width: 0; margin: 0; overflow: hidden; color: var(--ink-soft); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.import-ai-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.import-ai-actions button { min-width: 0; line-height: 1.2; text-align: center; }
.import-copy-button, .import-generate-button { width: 100%; }
.import-divider { height: 1px; margin: 16px 0 13px; background: var(--line); }
.import-output-field { margin-bottom: 8px; }
.import-output-field textarea { min-height: 190px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
.import-parse-button { width: 100%; }
.import-preview-empty { min-height: 470px; display: grid; place-content: center; justify-items: center; gap: 9px; color: var(--ink-faint); }
.import-preview-empty .empty-symbol { width: 46px; color: var(--ink-soft); border-color: var(--line-strong); background: var(--surface); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; }
.import-preview-empty strong { font-size: 12px; }
.import-preview-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 11px; }
.import-preview-heading > div:first-child { min-width: 0; display: grid; gap: 2px; }
.import-preview-heading strong { overflow-wrap: anywhere; font-size: 15px; }
.import-stats { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.import-stat { border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--ink-soft); padding: 2px 6px; font-size: 10px; white-space: nowrap; }
.import-stat.mismatch { border-color: #dfaa9b; background: var(--coral-pale); color: #8e3d2b; }
.import-task-prompt { margin-bottom: 10px; padding: 8px 0 10px; border-bottom: 1px solid var(--line); }
.import-task-prompt p { max-height: 6em; margin: 3px 0 0; overflow: auto; color: var(--ink-soft); font-size: 11px; line-height: 1.5; white-space: pre-wrap; }
.import-warnings { display: grid; gap: 4px; margin-bottom: 9px; border-left: 3px solid var(--gold); background: var(--gold-pale); padding: 7px 9px; color: #6f4a17; font-size: 10.5px; }
.import-tree { min-width: 0; padding: 2px 0 12px; }
.import-tree-node { min-width: 0; margin-left: calc(var(--import-depth) * 17px); border-left: 1px solid #c9d5d6; padding: 5px 5px 5px 10px; }
.import-tree-node-heading { display: flex; min-width: 0; align-items: center; gap: 6px; }
.import-tree-node-heading::before { content: ""; width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--gold); }
.import-tree-node.leaf .import-tree-node-heading::before { background: var(--teal); }
.import-tree-node strong { min-width: 0; overflow: hidden; font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.import-tree-node p { margin: 2px 0 0 13px; overflow: hidden; color: var(--ink-faint); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.task-import-modal > form > .modal-status { margin: 8px 0 0; }
.task-import-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding-top: 2px; }
.import-apply-options { min-width: 0; display: grid; gap: 6px; }
.segmented-control { display: inline-grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.segmented-control label { min-width: 0; cursor: pointer; }
.segmented-control label + label { border-left: 1px solid var(--line-strong); }
.segmented-control input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented-control span { min-height: 30px; display: grid; place-items: center; padding: 5px 9px; color: var(--ink-soft); background: var(--surface); font-size: 11px; white-space: nowrap; }
.segmented-control input:checked + span { background: var(--teal-pale); color: var(--teal-dark); font-weight: 680; }
.segmented-control input:focus-visible + span { outline: 3px solid rgba(8, 123, 118, .22); outline-offset: -3px; }
.task-import-footer .modal-actions { flex: 0 0 auto; }
.image-viewer-modal { width: min(1320px, calc(100vw - 20px)) !important; height: min(900px, calc(100vh - 20px)); max-height: calc(100vh - 20px) !important; border-color: rgba(255, 255, 255, .16) !important; border-radius: 7px !important; background: #121619 !important; color: #f4f7f8 !important; box-shadow: 0 24px 80px rgba(0, 0, 0, .55) !important; }
.image-viewer-modal::backdrop { background: rgba(0, 0, 0, .82) !important; backdrop-filter: blur(2px); }
.image-viewer-modal form { height: 100%; max-height: none; display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.image-viewer-header { min-height: 76px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 13px 16px 11px; border-bottom: 1px solid rgba(255, 255, 255, .11); background: #181d21; }
.image-viewer-heading { min-width: 0; }
.image-viewer-heading .eyebrow { color: #7ed0c9; }
.image-viewer-heading h2 { max-width: min(920px, calc(100vw - 130px)); margin: 0; overflow: hidden; color: #f7f9fa; font-size: 16px; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.image-viewer-meta { min-width: 0; display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 5px; color: #aab5bc; font-size: 11px; }
.image-viewer-meta span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-viewer-meta b { margin-right: 4px; color: #d7dfe3; font-weight: 620; }
.image-viewer-meta .viewer-primary-meta b { color: #f5cf72; }
.viewer-close { border-color: transparent; color: #c2ccd1; background: transparent; font-size: 21px; line-height: 1; }
.viewer-close:hover:not(:disabled) { border-color: rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .08); color: #fff; }
.image-viewer-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); }
.image-viewer-stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #07090a; }
.image-viewer-scroll { width: 100%; height: 100%; overflow: auto; overscroll-behavior: contain; }
.image-viewer-image-wrap { min-width: 100%; min-height: 100%; display: grid; place-items: center; padding: 24px; }
.image-viewer-image-wrap img { max-width: none; max-height: none; display: block; object-fit: contain; border-radius: 2px; box-shadow: 0 8px 30px rgba(0, 0, 0, .36); }
.image-viewer-nav { position: absolute; top: 50%; z-index: 3; width: 44px; min-width: 44px; height: 56px; min-height: 56px; display: grid; place-items: center; transform: translateY(-50%); border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px; background: rgba(18, 22, 25, .78); color: #eef3f5; padding: 0; box-shadow: 0 5px 18px rgba(0, 0, 0, .3); }
.image-viewer-nav.previous { left: 14px; }
.image-viewer-nav.next { right: 14px; }
.image-viewer-nav .lucide-icon { width: 25px; height: 25px; }
.image-viewer-nav:hover:not(:disabled) { border-color: rgba(255, 255, 255, .38); background: rgba(32, 39, 43, .94); color: #fff; }
.image-viewer-nav:active:not(:disabled) { transform: translateY(calc(-50% + 1px)); }
.image-viewer-nav:disabled { opacity: .22; }
.image-viewer-zoom { position: absolute; left: 50%; bottom: 14px; z-index: 2; display: grid; grid-template-columns: 34px 64px 34px; gap: 3px; transform: translateX(-50%); border: 1px solid rgba(255, 255, 255, .18); border-radius: 6px; background: rgba(18, 22, 25, .9); padding: 3px; box-shadow: 0 5px 18px rgba(0, 0, 0, .34); }
.viewer-icon-button, .viewer-zoom-value { height: 32px; min-height: 32px; border-color: transparent; border-radius: 4px; background: transparent; color: #eef3f5; padding: 0; }
.viewer-icon-button { width: 34px; min-width: 34px; font-size: 19px; }
.viewer-zoom-value { width: 64px; min-width: 64px; color: #bdc8cd; font-size: 11px; }
.viewer-icon-button:hover:not(:disabled), .viewer-zoom-value:hover:not(:disabled) { border-color: rgba(255, 255, 255, .13); background: rgba(255, 255, 255, .09); color: #fff; }
.image-viewer-info { min-width: 0; overflow: auto; border-left: 1px solid rgba(255, 255, 255, .11); background: #171c20; padding: 16px; }
.image-viewer-prompt-heading { display: grid; gap: 2px; margin-bottom: 10px; }
.image-viewer-prompt-heading strong { color: #f0f4f5; font-size: 13px; }
.image-viewer-prompt-heading span { color: #8f9ca4; font-size: 10px; }
.image-viewer-prompt { margin: 0; color: #ced7db; white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; line-height: 1.65; }
.image-viewer-modal .modal-status { min-height: 0; margin: 0; padding: 0 16px; background: #181d21; color: #b8c3c8; }
.image-viewer-modal .modal-status:not(:empty) { min-height: 34px; padding-top: 8px; }
.image-viewer-modal .modal-status.error { color: #ff9d88; }
.image-viewer-actions { min-height: 58px; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid rgba(255, 255, 255, .11); background: #181d21; }
.image-viewer-action-spacer { flex: 1; }
.viewer-command { border-color: rgba(255, 255, 255, .2); background: transparent; color: #e3eaed; }
.viewer-command:hover:not(:disabled) { border-color: rgba(255, 255, 255, .34); background: rgba(255, 255, 255, .08); }
.primary-image-command.active { border-color: rgba(241, 199, 97, .45); color: #f5cf72; background: rgba(173, 126, 19, .13); opacity: 1; }
.style-manager { display: grid; grid-template-columns: minmax(190px, .8fr) minmax(280px, 1.2fr); gap: 18px; min-height: 360px; }
.style-list { max-height: 530px; overflow: auto; border-right: 1px solid var(--line); padding-right: 13px; }
.style-option { width: 100%; min-height: 56px; display: block; border: 1px solid transparent; border-radius: 6px; padding: 8px; background: transparent; text-align: left; }
.style-option:hover { background: var(--surface-muted); }
.style-option.active { border-color: #9bcac6; background: var(--teal-pale); }
.style-option strong, .style-option span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.style-option strong { font-size: 13px; }
.style-option span { color: var(--ink-faint); font-size: 11px; }
.style-editor { min-width: 0; }
.small-modal { width: min(430px, calc(100vw - 28px)) !important; }
.project-modal { width: min(620px, calc(100vw - 28px)) !important; }
.project-modal form { display: flex; flex-direction: column; max-height: min(760px, calc(100vh - 28px)); padding: 17px; overflow: hidden; }
.project-form-scroll { flex: 1; min-height: 0; overflow: auto; padding-right: 2px; }
.project-form-params { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; margin-bottom: 14px; }
.project-form-params .field-block.compact { margin-bottom: 0; }
.icon-button { min-width: var(--control-height); min-height: var(--control-height); padding: 2px 6px; border-color: var(--line); color: var(--ink-soft); font-size: 14px; line-height: 1; }
.select-with-action { display: flex; align-items: center; gap: 6px; }
.select-with-action select, .select-with-action input { flex: 1; min-width: 0; }
.icon-button:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); background: var(--teal-pale); }

.toast { position: fixed; right: 18px; bottom: 18px; z-index: 10; max-width: min(420px, calc(100vw - 36px)); transform: translateY(18px); opacity: 0; pointer-events: none; border: 1px solid #a6cfca; border-radius: 6px; background: #effaf8; color: #075e59; padding: 9px 11px; box-shadow: var(--shadow); font-size: 12px; transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: #e1aa9b; background: #fff0ec; color: #9a412e; }

@media (min-width: 961px) {
  html, body { height: 100%; }
  body { overflow: hidden; }
  .workspace { min-height: 0; grid-template-rows: minmax(0, 1fr); }
}

@media (max-width: 1220px) {
  .app-header { grid-template-columns: minmax(150px, .72fr) minmax(0, 1.28fr); }
  .header-actions { grid-column: auto; }
  .workspace { height: auto; grid-template-columns: minmax(190px, .72fr) minmax(380px, 1.7fr) minmax(290px, .95fr); padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 960px) {
  .app-header { grid-template-columns: 1fr; gap: 9px; }
  .header-actions { grid-column: 1; width: 100%; border-top: 1px solid var(--line); padding-top: 8px; }
  .header-status { margin-left: 0; }
  .workspace { height: auto; min-height: 0; grid-template-columns: minmax(185px, .78fr) minmax(0, 1.8fr); }
  .inspector { grid-column: 1 / -1; min-height: 470px; }
  .task-sidebar, .tree-panel { min-height: 580px; }
}

@media (max-width: 660px) {
  html, body { height: 100%; }
  body { height: 100dvh; min-height: 100dvh; overflow: hidden; font-size: 12px; }
  .app-header { position: relative; z-index: 20; flex: 0 0 auto; gap: 7px; padding: 8px 10px; }
  .brand-mark { width: 29px; height: 29px; }
  .brand-block h1 { font-size: 14px; }
  .header-actions { position: relative; display: grid; grid-template-areas: "status buttons"; grid-template-columns: minmax(0, 1fr) var(--control-height); gap: 6px; overflow: visible; padding-top: 7px; }
  .header-status { grid-area: status; min-width: 0; margin-left: 0; }
  .generation-status { width: 100%; max-width: none; }
  .header-buttons { grid-area: buttons; min-width: 0; display: grid; grid-template-columns: var(--control-height); gap: 6px; }
  .header-buttons button { min-width: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
  .project-picker { align-items: stretch; flex-wrap: wrap; }
  .project-picker select { flex: 1 1 180px; max-width: none; }
  .save-state { display: none; }
  .backup-preview-summary { grid-template-columns: 1fr; }
  .excel-project-compare { grid-template-columns: 1fr; }
  .excel-project-row + .excel-project-row { border-top: 1px solid var(--line); border-left: 0; }
  .backup-preview-selection { align-items: flex-start; flex-direction: column; }
  .backup-preview-list { max-height: min(340px, calc(100dvh - 380px)); }
  .backup-result-list { max-height: min(390px, calc(100dvh - 320px)); }
  .backup-result-item header { align-items: flex-start; flex-direction: column; gap: 4px; }
  .backup-result-item header span { text-align: left; }
  .backup-preview-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .backup-preview-actions button { width: 100%; }
  .browser-storage-grid { grid-template-columns: 1fr; }
  .workspace { min-height: 0; display: grid; flex: 1 1 auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); overflow: hidden; padding: 8px 8px calc(68px + env(safe-area-inset-bottom)); }
  .workspace > .task-sidebar, .workspace > .tree-panel, .workspace > .inspector { height: 100%; min-height: 0; max-height: none; grid-area: 1 / 1; display: none; border-radius: 7px; }
  .workspace[data-mobile-view="tasks"] > .task-sidebar, .workspace[data-mobile-view="tree"] > .tree-panel, .workspace[data-mobile-view="inspector"] > .inspector { display: flex; }
  .task-list { min-height: 0; }
  .sidebar-footer { display: none; }
  .panel-heading, .tree-toolbar, .inspector-header { padding: 12px; }
  .tree-toolbar { flex: 0 0 auto; align-items: flex-start; flex-direction: column; gap: 9px; }
  #task-description { max-width: 100%; }
  .toolbar-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-content: stretch; gap: 6px; }
  .toolbar-actions button, .toolbar-actions .leaf-filter { min-width: 0; justify-content: center; }
  .toolbar-actions .leaf-filter { min-height: 34px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); padding: 6px 8px; }
  .tree-scroll { padding: 8px 8px 18px; overscroll-behavior: contain; }
  .prompt-tree { min-width: 0; }
  .tree-node { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 6px; min-height: 0; padding: 4px 2px 4px min(calc(var(--tree-indent) + 2px), 38px); }
  .tree-card { grid-column: 1 / -1; grid-row: 1; min-height: 48px; grid-template-columns: auto minmax(0, 1fr) auto; padding: 7px 8px; }
  .node-output-slot { grid-column: 1; grid-row: 2; width: 122px; min-width: 122px; justify-content: start; }
  .node-output-slot:empty { display: none; }
  .node-row-actions { grid-column: 2; grid-row: 2; width: 158px; min-width: 158px; grid-template-columns: repeat(5, 30px); gap: 2px; }
  .node-output-slot:empty + .node-row-actions { grid-column: 1 / -1; justify-self: end; }
  .node-action, .node-action-placeholder { width: 30px; min-width: 30px; max-width: 30px; height: 30px; min-height: 30px; max-height: 30px; }
  .tree-footer { flex: 0 0 auto; min-height: 48px; padding: 7px 10px; }
  .tree-footer .muted { min-width: 0; }
  .tree-footer-actions { min-width: 0; gap: 5px; }
  .node-editor { overscroll-behavior: contain; }
  .mobile-workspace-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 18; min-height: calc(60px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; border-top: 1px solid var(--line-strong); background: rgba(255, 255, 255, .97); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 18px rgba(26, 42, 47, .08); }
  .mobile-workspace-nav button { min-width: 0; min-height: 50px; display: grid; place-items: center; align-content: center; gap: 2px; border: 0; border-radius: 5px; background: transparent; color: var(--ink-faint); padding: 4px; font-size: 10px; line-height: 1.2; }
  .mobile-workspace-nav button.active { background: var(--teal-pale); color: var(--teal-dark); }
  .mobile-workspace-nav .lucide-icon { width: 18px; height: 18px; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
  dialog.modal:not(.image-viewer-modal) { width: calc(100vw - 16px) !important; max-height: calc(100dvh - 16px) !important; }
  dialog.modal:not(.image-viewer-modal) > form { max-height: calc(100dvh - 16px); padding: 14px; }
  dialog.settings-modal { height: calc(100dvh - 16px); overflow: hidden; }
  .settings-header { min-height: 60px; padding: 12px 13px 10px; }
  .settings-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .settings-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 7px; }
  .settings-nav button { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .settings-content { padding: 15px 14px 20px; }
  .settings-modal form { max-height: none !important; padding: 0 !important; }
  .modal-header h2 { font-size: 16px; }
  .image-viewer-modal { width: calc(100vw - 8px) !important; height: calc(100vh - 8px); max-height: calc(100vh - 8px) !important; }
  .image-viewer-header { min-height: 68px; padding: 10px 11px 9px; }
  .image-viewer-heading h2 { max-width: calc(100vw - 85px); }
  .image-viewer-meta { max-height: 32px; overflow: hidden; }
  .image-viewer-body { grid-template-columns: 1fr; grid-template-rows: minmax(290px, 1fr) minmax(100px, 180px); }
  .image-viewer-info { border-top: 1px solid rgba(255, 255, 255, .11); border-left: 0; padding: 11px; }
  .image-viewer-image-wrap { padding: 14px; }
  .image-viewer-nav { width: 38px; min-width: 38px; height: 48px; min-height: 48px; }
  .image-viewer-nav.previous { left: 7px; }
  .image-viewer-nav.next { right: 7px; }
  .image-viewer-actions { min-height: 54px; flex-wrap: wrap; padding: 8px 10px; }
  .image-viewer-action-spacer { display: none; }
  .image-viewer-actions button { flex: 1 1 auto; }
  .image-viewer-modal .modal-status { padding-left: 11px; padding-right: 11px; }
  .style-manager { grid-template-columns: 1fr; }
  .style-list { max-height: 180px; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 10px; }
  .task-import-modal { height: calc(100dvh - 24px); }
  .task-import-modal form { height: 100%; max-height: none; overflow: hidden; }
  .task-import-layout { display: block; overflow-y: auto; overscroll-behavior: contain; }
  .task-import-controls { grid-template-columns: 1fr; gap: 0; }
  .task-import-source, .task-import-preview { min-height: 0; max-height: none; overflow: visible; padding: 14px 0; }
  .task-import-preview { border-top: 1px solid var(--line); border-left: 0; background: transparent; }
  .import-preview-empty { min-height: 170px; }
  .task-import-footer { flex: 0 0 auto; align-items: stretch; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
  .import-apply-options { width: 100%; }
  .task-import-footer .modal-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 0; }
  .task-import-footer .modal-actions button { width: 100%; }
}

@media (max-width: 480px) {
  .node-editor { padding: 14px 13px 20px; }
  .node-editor input, .node-editor textarea, .node-editor select { font-size: 12px; }
  .node-editor .generate-box { flex-direction: column; align-items: stretch; }
  .node-editor .generate-box button { width: 100%; }
  .project-form-params, .ai-synth-limits { grid-template-columns: 1fr; }
  .reference-mode-control span { min-height: 42px; white-space: normal; line-height: 1.25; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions button { flex: 1 1 120px; }
  .settings-action-grid { grid-template-columns: 1fr; }
  .import-ai-actions { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .node-output-slot { grid-column: 1 / -1; }
  .node-row-actions { grid-column: 1 / -1; grid-row: 3; justify-self: end; }
  .node-output-slot:empty + .node-row-actions { grid-row: 2; }
}
