:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-soft: #f8f9fa;
  --surface-strong: #eef0f2;
  --ink: #171a1d;
  --muted: #71777f;
  --muted-2: #9aa0a7;
  --line: #e1e4e7;
  --line-strong: #cfd3d7;
  --accent: #ed6249;
  --accent-hover: #d95039;
  --accent-soft: #fff0ec;
  --mint: #44a984;
  --mint-soft: #e9f7f1;
  --violet: #7165d9;
  --violet-soft: #efedff;
  --warning: #d18b22;
  --danger: #c84444;
  --shadow-sm: 0 1px 2px rgba(21, 25, 29, 0.05), 0 5px 16px rgba(21, 25, 29, 0.04);
  --shadow-md: 0 18px 55px rgba(21, 25, 29, 0.12);
  --sidebar: 224px;
  --inspector: 310px;
  --library: 284px;
  --radius: 6px;
  --font: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111315;
  --surface: #191c1f;
  --surface-soft: #202428;
  --surface-strong: #292e33;
  --ink: #f1f3f4;
  --muted: #9aa1a8;
  --muted-2: #737b83;
  --line: #30353a;
  --line-strong: #41484f;
  --accent: #ff725a;
  --accent-hover: #ff846f;
  --accent-soft: #38231f;
  --mint: #55c297;
  --mint-soft: #16342a;
  --violet: #9b91ef;
  --violet-soft: #2d294c;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25), 0 7px 22px rgba(0, 0, 0, 0.14);
  --shadow-md: 0 22px 60px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent);
  outline-offset: 2px;
}
button:disabled { cursor: not-allowed; opacity: 0.45; }
.lucide { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }

.app-shell { min-height: 100%; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }

.sidebar {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 20px 14px 14px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.brand-lockup { display: flex; align-items: center; gap: 11px; height: 44px; padding: 0 7px; margin-bottom: 27px; }
.brand-lockup > div:last-child { display: flex; flex-direction: column; line-height: 1; }
.brand-lockup strong { font-size: 20px; font-weight: 750; }
.brand-lockup small { margin-top: 5px; color: var(--muted); font-size: 9px; font-weight: 750; letter-spacing: 2px; }
.brand-mark { position: relative; width: 34px; height: 34px; border-radius: 7px; background: var(--ink); overflow: hidden; }
.brand-mark span { position: absolute; display: block; width: 7px; height: 7px; background: white; border-radius: 50%; }
.brand-mark span:nth-child(1) { left: 8px; top: 8px; }
.brand-mark span:nth-child(2) { right: 7px; top: 13px; background: var(--accent); }
.brand-mark span:nth-child(3) { left: 10px; bottom: 7px; width: 14px; height: 3px; border-radius: 3px; transform: rotate(-34deg); transform-origin: center; }

.primary-nav { display: grid; gap: 5px; }
.nav-section-label { padding: 2px 12px 5px; color: var(--muted-2); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.nav-section-label.management-label { margin-top: 14px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 43px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background 160ms ease, color 160ms ease;
}
.nav-item:hover { background: var(--surface-soft); color: var(--ink); }
.nav-item.active { background: var(--ink); color: var(--surface); }
.nav-item span { flex: 1; font-weight: 630; }
.nav-item b { display: grid; place-items: center; min-width: 21px; height: 21px; padding: 0 6px; border-radius: 11px; background: var(--surface-strong); color: var(--muted); font-size: 11px; }
.nav-item.active b { background: rgba(255,255,255,.16); color: white; }
.sidebar-spacer { flex: 1; }

.local-status { display: flex; align-items: center; gap: 10px; margin: 0 9px 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.local-status > div { display: flex; flex-direction: column; gap: 3px; }
.local-status strong { font-size: 12px; }
.local-status small { color: var(--muted); font-size: 11px; }
.status-dot, .live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 16%, transparent); }
.status-dot.online, .live-dot { background: var(--mint); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint) 16%, transparent); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 16%, transparent); }

.main-stage { display: grid; min-width: 0; grid-template-rows: 70px minmax(0, 1fr); overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 22px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); }
.view-heading { display: flex; align-items: center; min-width: 0; }
.breadcrumb { display: flex; align-items: center; gap: 5px; height: 18px; color: var(--muted); font-size: 11px; }
.breadcrumb .lucide { width: 12px; height: 12px; }
.project-name { width: min(300px, 34vw); padding: 2px 0; border: 0; background: transparent; color: var(--ink); font-size: 17px; font-weight: 720; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.topbar.management-mode .project-name,
.topbar.management-mode .save-state,
.topbar.management-mode #saveButton,
.topbar.management-mode #runButton { display: none; }
.save-state { display: flex; align-items: center; gap: 6px; margin-right: 5px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.save-state .lucide { width: 15px; height: 15px; }

.button, .icon-button, .chip-button, .text-button, .zoom-value { border: 0; cursor: pointer; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 15px; border-radius: 5px; font-weight: 680; transition: transform 120ms ease, background 160ms ease; white-space: nowrap; }
.button:active { transform: translateY(1px); }
.button.primary { background: var(--accent); color: white; box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 22%, transparent); }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.button.secondary:hover { background: var(--surface-soft); }
.button.danger { border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line)); background: transparent; color: var(--danger); }
.button.danger:hover { background: color-mix(in srgb, var(--danger) 9%, var(--surface)); }
.button.full-width { width: calc(100% - 32px); margin: 8px 16px 22px; }
.button.compact-button { height: 34px; padding: 0 11px; font-size: 10px; }
.button.compact-button .lucide { width: 14px; height: 14px; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 5px; background: transparent; color: var(--muted); }
.icon-button:hover { background: var(--surface-strong); color: var(--ink); }
.icon-button.small { width: 30px; height: 30px; }
.icon-button.small .lucide { width: 16px; height: 16px; }
.mobile-menu { display: none; }
.mobile-inspector { display: none; }
.text-button { padding: 0; background: transparent; color: var(--accent); font-size: 11px; font-weight: 680; }
.chip-button { display: flex; align-items: center; gap: 5px; height: 27px; padding: 0 9px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 680; }
.chip-button .lucide { width: 14px; height: 14px; }

.view { display: none; min-height: 0; overflow: auto; }
.view.active { display: block; }
#generationView.active { display: block; overflow: hidden; }
.studio-layout { display: grid; grid-template-columns: var(--library) minmax(420px, 1fr) var(--inspector); height: 100%; min-height: 0; }
.panel-section { min-width: 0; background: var(--surface); }
.library-panel { padding: 20px 18px; overflow-y: auto; border-right: 1px solid var(--line); }
.panel-heading, .label-row, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading { margin-bottom: 22px; }
.panel-heading h2, .modal h2 { margin: 3px 0 0; font-size: 17px; }
.eyebrow { color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: 1.8px; }
.control-group { margin-bottom: 21px; }
.control-group > label, .label-row label, .field-label { display: block; color: var(--ink); font-size: 11px; font-weight: 700; }
.label-row { margin-bottom: 8px; }
.label-row > span { color: var(--muted-2); font-size: 10px; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-soft); }
.segmented button { min-width: 0; height: 35px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 650; }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.task-switch button { display: flex; align-items: center; justify-content: center; gap: 6px; }
.task-switch .lucide { width: 15px; height: 15px; }
.control-group > label { margin-bottom: 8px; }

.select-wrap, .input-with-icon, .native-select { position: relative; display: flex; align-items: center; }
.select-wrap select, .native-select select, .input-with-icon input, .form-field input, .form-field textarea, .inspector-section > input, .seed-row input {
  width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); outline: 0;
}
.select-wrap select, .native-select select { appearance: none; padding: 0 34px 0 43px; cursor: pointer; }
.native-select select { padding-left: 11px; }
.select-wrap > .lucide, .native-select > .lucide { position: absolute; right: 11px; width: 15px; pointer-events: none; color: var(--muted); }
.provider-logo { position: absolute; z-index: 1; left: 8px; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 5px; background: var(--ink); color: var(--surface); font-size: 11px; font-weight: 800; }
.input-with-icon .lucide { position: absolute; left: 11px; width: 15px; color: var(--muted); }
.input-with-icon input { padding: 0 12px 0 34px; }
input:focus, textarea:focus, select:focus { border-color: color-mix(in srgb, var(--ink) 45%, var(--line)); }

.prompt-group { position: relative; }
.prompt-group textarea { width: 100%; min-height: 126px; resize: vertical; padding: 12px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); line-height: 1.6; outline: 0; }
.prompt-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 7px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; min-height: 103px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--surface-soft); color: var(--ink); cursor: pointer; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { margin-top: 4px; font-size: 12px; }
.dropzone small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.drop-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 50%; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.drop-icon .lucide { width: 15px; }
.file-list { display: grid; gap: 6px; margin-top: 8px; }
.file-item { display: grid; grid-template-columns: 27px minmax(0, 1fr) 24px; align-items: center; gap: 7px; padding: 7px; border: 1px solid var(--line); border-radius: 5px; }
.file-type-icon { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 4px; background: var(--violet-soft); color: var(--violet); }
.file-type-icon .lucide { width: 14px; height: 14px; }
.file-item div:nth-child(2) { min-width: 0; }
.file-item strong, .file-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item strong { font-size: 10px; }
.file-item small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.file-item button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.file-item button .lucide { width: 13px; height: 13px; }

.canvas-panel { position: relative; display: grid; grid-template-rows: 48px minmax(230px, 1fr) auto; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
.canvas-toolbar { display: flex; align-items: center; justify-content: space-between; z-index: 3; padding: 0 15px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 86%, transparent); backdrop-filter: blur(8px); }
.canvas-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.canvas-meta strong { color: var(--ink); font-size: 10px; letter-spacing: 1px; }
.canvas-meta > span:last-child::before { content: '/'; margin-right: 8px; color: var(--line-strong); }
.live-dot { width: 6px; height: 6px; }
.toolbar-actions { display: flex; align-items: center; gap: 2px; }
.toolbar-divider { width: 1px; height: 18px; margin: 0 5px; background: var(--line); }
.zoom-value { width: 45px; padding: 0; background: transparent; color: var(--muted); font-size: 10px; }

.flow-canvas {
  position: relative;
  min-height: 0;
  overflow: auto;
  background-color: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--muted) 20%, transparent) 1px, transparent 0);
  background-size: 22px 22px;
}
#ambientCanvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: .5; }
.flow-stage { position: relative; z-index: 2; display: grid; grid-template-columns: 185px 52px 210px 52px 185px; align-items: center; justify-content: center; min-width: 760px; min-height: 100%; padding: 60px 34px; transform-origin: center; transition: transform 180ms ease; }
.flow-node { position: relative; z-index: 2; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow-sm); overflow: visible; transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease; }
.flow-node:hover, .flow-node.active-node { border-color: color-mix(in srgb, var(--violet) 55%, var(--line)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 10%, transparent), var(--shadow-sm); transform: translateY(-2px); }
.flow-node header { display: grid; grid-template-columns: 30px minmax(0, 1fr) 18px; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.flow-node header > div { min-width: 0; }
.flow-node header small, .flow-node header strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-node header small { color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: 1px; }
.flow-node header strong { margin-top: 2px; font-size: 11px; }
.flow-node header > .lucide { width: 14px; color: var(--muted-2); }
.node-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 5px; }
.node-icon .lucide { width: 15px; }
.node-icon.coral { background: var(--accent-soft); color: var(--accent); }
.node-icon.ink { background: var(--ink); color: var(--surface); }
.node-icon.mint { background: var(--mint-soft); color: var(--mint); }
.node-body { min-height: 75px; padding: 12px; }
.node-body p { display: -webkit-box; margin: 0; overflow: hidden; color: var(--muted); font-size: 10px; line-height: 1.55; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.node-tags { display: flex; margin-top: 10px; }
.node-tags span { display: flex; align-items: center; gap: 4px; height: 21px; padding: 0 7px; border-radius: 11px; background: var(--surface-soft); color: var(--muted); font-size: 9px; }
.node-tags .lucide { width: 11px; height: 11px; }
.port { position: absolute; z-index: 4; top: 50%; width: 10px; height: 10px; margin-top: -5px; border: 2px solid var(--surface); border-radius: 50%; background: var(--line-strong); box-shadow: 0 0 0 1px var(--line-strong); }
.input-port { left: -5px; }
.output-port { right: -5px; background: var(--violet); box-shadow: 0 0 0 1px var(--violet); }
.flow-link { position: relative; z-index: 1; height: 2px; background: var(--line-strong); }
.flow-link::after { content: ''; position: absolute; right: -2px; top: -3px; width: 6px; height: 6px; border-top: 1.5px solid var(--line-strong); border-right: 1.5px solid var(--line-strong); transform: rotate(45deg); }
.flow-link span { position: absolute; top: -2px; left: -10px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: 0; }
.flow-canvas.running .flow-link span { opacity: 1; animation: flowPulse 1.2s linear infinite; }
.flow-canvas.running .second-link span { animation-delay: .55s; }
@keyframes flowPulse { from { left: -5px; } to { left: calc(100% + 5px); } }

.model-visual { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 10px; min-height: 95px; }
.signal-orbit { position: relative; width: 62px; height: 62px; border: 1px solid var(--line); border-radius: 50%; }
.signal-orbit::before { content: ''; position: absolute; inset: 10px; border: 1px dashed var(--line-strong); border-radius: 50%; animation: orbit 14s linear infinite; }
.signal-orbit b { position: absolute; inset: 21px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 5px var(--surface-strong); }
.signal-orbit span { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.signal-orbit span:nth-child(1) { left: 5px; top: 16px; }
.signal-orbit span:nth-child(2) { right: 3px; top: 30px; background: var(--mint); }
.signal-orbit span:nth-child(3) { left: 27px; bottom: -3px; background: var(--violet); }
@keyframes orbit { to { transform: rotate(360deg); } }
.model-stats { display: grid; gap: 7px; }
.model-stats span { display: block; padding-bottom: 6px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 9px; }
.model-stats span:last-child { border: 0; }
.output-preview { display: flex; flex-direction: column; justify-content: center; }
.output-placeholder { display: flex; align-items: flex-end; gap: 4px; height: 25px; }
.output-placeholder span { width: 5px; border-radius: 2px; background: var(--line-strong); }
.output-placeholder span:nth-child(1) { height: 10px; }
.output-placeholder span:nth-child(2) { height: 21px; background: var(--mint); }
.output-placeholder span:nth-child(3) { height: 15px; }
.output-preview p { margin-top: 6px; }
.output-preview.has-result img, .output-preview.has-result video { display: block; width: 100%; max-height: 70px; object-fit: cover; border-radius: 3px; }
.output-preview.has-result p { color: var(--ink); }

.run-progress { position: absolute; z-index: 5; left: 50%; bottom: 18px; display: grid; grid-template-columns: 34px minmax(120px, 1fr) 30px; align-items: center; gap: 10px; min-width: 290px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow-md); transform: translateX(-50%); }
.run-progress[hidden] { display: none; }
.progress-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.progress-icon .lucide { animation: spin 1s linear infinite; }
.run-progress strong, .run-progress span { display: block; }
.run-progress strong { font-size: 11px; }
.run-progress span { margin-top: 3px; color: var(--muted); font-size: 9px; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-drawer { z-index: 5; min-height: 55px; border-top: 1px solid var(--line); background: var(--surface); }
.result-header { display: flex; align-items: center; justify-content: space-between; height: 54px; padding: 0 15px; }
.result-header > div:first-child { display: flex; align-items: center; gap: 9px; }
.result-header strong { font-size: 12px; }
.result-badge { padding: 3px 7px; border-radius: 10px; background: var(--surface-strong); color: var(--muted); font-size: 9px; }
.result-actions { display: flex; align-items: center; gap: 2px; }
.result-content { max-height: 0; overflow: auto; padding: 0 15px; transition: max-height 220ms ease, padding 220ms ease; }
.result-drawer.expanded .result-content { max-height: 260px; padding: 0 15px 15px; }
.result-drawer.expanded #toggleResult .lucide { transform: rotate(180deg); }
.empty-result { display: grid; place-items: center; gap: 8px; min-height: 120px; color: var(--muted-2); }
.empty-result .lucide { width: 25px; height: 25px; }
.result-text { margin: 0; white-space: pre-wrap; color: var(--ink); font-family: inherit; line-height: 1.65; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.media-grid img, .media-grid video { display: block; width: 100%; max-height: 230px; object-fit: contain; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); }
.raw-details { margin-top: 12px; border-top: 1px solid var(--line); }
.raw-details summary { padding: 10px 0; color: var(--muted); cursor: pointer; font-size: 10px; }
.raw-details pre, .request-modal pre { margin: 0; overflow: auto; padding: 12px; border-radius: 5px; background: var(--surface-soft); color: var(--ink); font: 11px/1.55 "Cascadia Code", Consolas, monospace; white-space: pre-wrap; }

.inspector-panel { min-width: 0; overflow-y: auto; border-left: 1px solid var(--line); }
.inspector-tabs { position: sticky; z-index: 2; top: 0; display: grid; grid-template-columns: 1fr 1fr; height: 49px; padding: 0 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.inspector-tabs button { position: relative; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; font-weight: 700; }
.inspector-tabs button.active { color: var(--ink); }
.inspector-tabs button.active::after { content: ''; position: absolute; left: 20%; right: 20%; bottom: -1px; height: 2px; background: var(--accent); }
.inspector-tabs .mobile-inspector-close { display: none; place-items: center; padding: 0; }
.inspector-tabs .mobile-inspector-close .lucide { width: 16px; height: 16px; }
.inspector-content { display: none; }
.inspector-content.active { display: block; }
.inspector-section { padding: 18px 16px; border-bottom: 1px solid var(--line); }
.inspector-section[hidden], [data-types][hidden] { display: none !important; }
.section-title { margin-bottom: 17px; }
.section-title h3 { margin: 0; font-size: 12px; }
.section-title span { padding: 3px 7px; border-radius: 9px; background: var(--surface-strong); color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .6px; }
.range-control { margin-bottom: 19px; }
.range-control .label-row { margin-bottom: 9px; }
.range-control output { color: var(--ink); font-size: 11px; font-weight: 750; }
input[type="range"] { width: 100%; height: 3px; margin: 0; appearance: none; border-radius: 2px; background: var(--line-strong); accent-color: var(--accent); }
input[type="range"]::-webkit-slider-thumb { width: 14px; height: 14px; appearance: none; border: 3px solid var(--surface); border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.range-labels { display: flex; justify-content: space-between; margin-top: 7px; color: var(--muted-2); font-size: 8px; }
.field-label { margin: 15px 0 8px; }
.number-stepper { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto 34px; align-items: center; height: 38px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.number-stepper button { display: grid; place-items: center; height: 100%; border: 0; background: var(--surface-soft); color: var(--muted); cursor: pointer; }
.number-stepper button:first-child { border-right: 1px solid var(--line); }
.number-stepper button:last-child { border-left: 1px solid var(--line); }
.number-stepper button .lucide { width: 13px; }
.number-stepper input { min-width: 0; width: 100%; height: 100%; padding: 0 6px; border: 0; background: var(--surface); color: var(--ink); text-align: center; outline: 0; }
.number-stepper span { color: var(--muted); font-size: 9px; }
.number-stepper.compact { grid-template-columns: 38px minmax(0, 1fr) 38px; }
.ratio-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.ratio-grid button { display: grid; place-items: center; gap: 5px; height: 57px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); cursor: pointer; font-size: 9px; }
.ratio-grid button.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.ratio-shape { display: block; border: 1.5px solid currentColor; border-radius: 1px; }
.ratio-shape.square { width: 16px; height: 16px; }
.ratio-shape.landscape { width: 19px; height: 14px; }
.ratio-shape.wide { width: 21px; height: 12px; }
.ratio-shape.portrait { width: 11px; height: 19px; }
.native-select select { width: 100%; }
.seed-row { display: grid; grid-template-columns: 1fr 38px; gap: 7px; }
.seed-row input { padding: 0 11px; }
.compact-textarea, .code-input { width: 100%; min-height: 72px; resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); line-height: 1.5; outline: 0; }
.code-input { min-height: 96px; background: var(--surface-soft); font: 10px/1.55 "Cascadia Code", Consolas, monospace; }
.code-input.tall { min-height: 170px; }

.collection-view { padding: 30px; }
.collection-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; max-width: 1100px; margin: 0 auto 24px; }
.collection-header h1 { margin: 5px 0 0; font-size: 28px; }
.collection-summary { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.filter-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1100px; margin: 0 auto 15px; }
.search-box { flex: 1; max-width: 410px; }
.search-box input { background: var(--surface); }
.compact-filter { grid-auto-columns: minmax(66px, 1fr); }
.compact-filter button { height: 31px; font-size: 10px; }
.history-list { display: grid; gap: 8px; max-width: 1100px; margin: 0 auto; }
.history-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) minmax(110px, auto) minmax(100px, auto) 30px; align-items: center; gap: 13px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.history-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); }
.history-icon .lucide { width: 17px; }
.history-main { min-width: 0; }
.history-main strong, .history-main span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-main strong { font-size: 12px; }
.history-main span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.history-meta { color: var(--muted); font-size: 10px; }
.history-status { display: flex; align-items: center; gap: 6px; color: var(--mint); font-size: 10px; }
.history-status.failed { color: var(--danger); }
.empty-collection { display: grid; place-items: center; min-height: 260px; border: 1px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); }

.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; max-width: 1100px; margin: 0 auto; }
.provider-card { position: relative; padding: 17px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: var(--shadow-sm); }
.provider-card.custom-provider { border-top-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.provider-card-header { display: grid; grid-template-columns: 38px minmax(0, 1fr) 30px; align-items: center; gap: 10px; }
.provider-card .provider-logo { position: static; width: 38px; height: 38px; }
.provider-card h3 { margin: 0; font-size: 13px; }
.provider-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; text-transform: uppercase; }
.capability-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 15px; }
.capability-list span { display: inline-flex; align-items: center; gap: 4px; height: 23px; padding: 0 7px; border-radius: 4px; background: var(--surface-soft); color: var(--muted); font-size: 9px; }
.capability-list .lucide { width: 11px; height: 11px; }
.provider-card dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px 12px; margin: 17px 0; padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 10px; }
.provider-card dt { color: var(--muted); }
.provider-card dd { margin: 0; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.provider-card-footer { display: flex; align-items: center; justify-content: space-between; }
.connection-state { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.connection-state span { width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.connection-state.configured span { background: var(--mint); }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(12, 14, 16, .45); backdrop-filter: blur(4px); }
.modal-backdrop[hidden] { display: none; }
.modal { width: min(620px, 100%); max-height: min(760px, calc(100vh - 40px)); overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow-md); }
.provider-modal { width: min(760px, 100%); }
.modal > header { position: sticky; z-index: 3; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal form { padding: 18px 20px 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-field { min-width: 0; }
.form-field.wide { grid-column: 1 / -1; }
.form-field label { display: block; margin-bottom: 7px; font-size: 10px; font-weight: 700; }
.form-field input, .form-field textarea { padding: 0 11px; }
.form-field textarea { min-height: 72px; padding-top: 10px; resize: vertical; }
.form-field .label-row { margin: 0 0 7px; }
.form-field .label-row label { margin: 0; }
.capability-field { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; border: 0; }
.capability-field legend { width: 100%; margin-bottom: 7px; padding: 0; font-size: 10px; font-weight: 700; }
.check-option { cursor: pointer; }
.check-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.check-option span { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); font-size: 10px; font-weight: 650; }
.check-option span .lucide { width: 14px; height: 14px; }
.check-option input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.check-option input:focus-visible + span { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.model-field { transition: opacity 160ms ease; }
.model-field.disabled-field { opacity: .42; }
.provider-model-manager { display: grid; gap: 10px; }
.model-manager-heading { margin: 0; }
.model-manager-heading > div { min-width: 0; }
.model-manager-heading label { margin: 0; }
.model-manager-heading small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; font-weight: 400; }
.model-picker { border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); overflow: hidden; }
.model-picker-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 9px; border-bottom: 1px solid var(--line); background: var(--surface); }
.model-picker-toolbar .input-with-icon input { height: 34px; background: var(--surface-soft); }
.model-discovery-list { max-height: 210px; overflow-y: auto; }
.model-list-empty { display: grid; place-items: center; min-height: 76px; padding: 16px; color: var(--muted); font-size: 10px; text-align: center; }
.model-discovery-item { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 48px; padding: 7px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.model-discovery-item:last-child { border-bottom: 0; }
.model-discovery-item:hover { background: var(--surface); }
.model-discovery-item > input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.model-select-indicator { display: grid; place-items: center; width: 18px; height: 18px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: transparent; }
.model-select-indicator .lucide { width: 12px; height: 12px; }
.model-discovery-item > input:checked + .model-select-indicator { border-color: var(--accent); background: var(--accent); color: white; }
.model-discovery-item > input:focus-visible + .model-select-indicator { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }
.model-discovery-item.added { cursor: default; opacity: .58; }
.model-discovery-copy { min-width: 0; }
.model-discovery-copy strong, .model-discovery-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-discovery-copy strong { font-size: 10px; }
.model-discovery-copy small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.model-source-state { color: var(--muted); font-size: 9px; }
.selected-model-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.selected-model-heading > div { display: flex; align-items: center; gap: 7px; }
.selected-model-heading strong { font-size: 10px; }
.selected-model-heading span { display: grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--surface-strong); color: var(--muted); font-size: 9px; }
.selected-model-heading small { color: var(--muted); font-size: 9px; }
.selected-model-list { display: grid; gap: 6px; }
.selected-model-list > .model-list-empty { min-height: 64px; border: 1px dashed var(--line-strong); border-radius: 5px; }
.selected-model-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) 30px 30px; align-items: center; gap: 8px; min-height: 52px; padding: 7px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.selected-model-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 5px; background: var(--violet-soft); color: var(--violet); }
.selected-model-icon .lucide { width: 15px; height: 15px; }
.selected-model-copy { min-width: 0; }
.selected-model-copy strong, .selected-model-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-model-copy strong { font-size: 10px; }
.selected-model-copy small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.selected-model-copy small b { margin-right: 7px; padding: 2px 5px; border-radius: 3px; background: var(--surface-strong); color: var(--ink); font-size: 8px; }
.manual-model-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.manual-model-row input { min-width: 0; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); outline: 0; }
.model-config-modal { width: min(560px, 100%); }
.model-config-modal form { padding: 18px 20px 20px; }
.modality-field { margin: 0; padding: 0; border: 0; }
.modality-field legend { margin-bottom: 8px; padding: 0; font-size: 10px; font-weight: 700; }
.option-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.model-config-modal footer { padding-top: 18px; }
.modal-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 15px; padding: 10px; border-radius: 5px; background: var(--mint-soft); color: var(--mint); font-size: 10px; line-height: 1.5; }
.modal-note .lucide { width: 15px; }
.modal footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 18px; }
.modal footer .footer-spacer { flex: 1; }
.request-modal { width: min(720px, 100%); }
.request-modal > pre { min-height: 280px; margin: 18px 20px 0; }
.request-modal footer { padding: 15px 20px 20px; }

.toast-region { position: fixed; z-index: 200; right: 18px; bottom: 18px; display: grid; gap: 8px; width: min(330px, calc(100vw - 36px)); }
.toast { display: grid; grid-template-columns: 24px minmax(0, 1fr) 20px; align-items: start; gap: 8px; padding: 12px; border: 1px solid var(--line); border-left: 3px solid var(--ink); border-radius: 6px; background: var(--surface); box-shadow: var(--shadow-md); animation: toastIn 180ms ease; }
.toast.success { border-left-color: var(--mint); }
.toast.error { border-left-color: var(--danger); }
.toast .lucide { width: 16px; margin-top: 1px; }
.toast strong, .toast span { display: block; }
.toast strong { font-size: 11px; }
.toast span { margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.toast button { border: 0; background: transparent; color: var(--muted); cursor: pointer; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

.mobile-nav { display: none; }

@media (max-width: 1380px) {
  :root { --sidebar: 72px; --library: 255px; --inspector: 285px; }
  .sidebar { padding-inline: 10px; }
  .brand-lockup { justify-content: center; padding: 0; }
  .brand-lockup > div:last-child, .nav-item span, .nav-item b, .nav-section-label, .local-status > div { display: none; }
  .nav-item { justify-content: center; padding: 0; }
  .local-status { justify-content: center; margin-inline: 0; }
  .flow-stage { grid-template-columns: 160px 38px 185px 38px 160px; min-width: 650px; }
}

@media (max-width: 930px) {
  body { overflow: auto; }
  .app-shell { grid-template-columns: 1fr; min-height: 100vh; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 224px; transform: translateX(-100%); transition: transform 180ms ease; box-shadow: var(--shadow-md); }
  .sidebar.open { transform: translateX(0); }
  .brand-lockup { justify-content: flex-start; padding: 0 7px; }
  .brand-lockup > div:last-child, .nav-item span, .nav-item b, .local-status > div { display: flex; }
  .nav-section-label { display: block; }
  .nav-item { justify-content: flex-start; padding: 0 12px; }
  .local-status { justify-content: flex-start; margin-inline: 9px; }
  .main-stage { grid-template-rows: 64px minmax(0, 1fr); min-height: 100vh; padding-bottom: 60px; overflow: visible; }
  .topbar { position: sticky; z-index: 15; top: 0; padding-inline: 12px; }
  .mobile-menu { display: grid; margin-right: 6px; }
  .save-state, #themeButton { display: none; }
  .studio-layout { grid-template-columns: 255px minmax(0, 1fr); height: calc(100vh - 124px); }
  .inspector-panel { position: fixed; z-index: 40; top: 64px; right: 0; bottom: 60px; width: min(320px, 90vw); border-left: 1px solid var(--line); box-shadow: var(--shadow-md); transform: translateX(100%); transition: transform 180ms ease; }
  .inspector-panel.open { transform: translateX(0); }
  .inspector-tabs { grid-template-columns: 1fr 1fr 34px; padding-right: 8px; }
  .inspector-tabs .mobile-inspector-close { display: grid; }
  .mobile-inspector { display: grid; }
  .toolbar-actions { margin-left: auto; }
  .mobile-nav { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(5, 1fr); height: 60px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(9px); }
  .mobile-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: transparent; color: var(--muted); font-size: 9px; }
  .mobile-nav button.active { color: var(--accent); }
  .mobile-nav .lucide { width: 17px; height: 17px; }
}

@media (max-width: 680px) {
  .top-actions .secondary, .top-actions .button span { display: none; }
  .top-actions .button { width: 40px; padding: 0; }
  .project-name { width: min(210px, 48vw); }
  .breadcrumb { display: none; }
  .topbar.management-mode .breadcrumb { display: flex; }
  .studio-layout { display: block; height: auto; }
  .library-panel { max-height: none; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .canvas-panel { grid-template-rows: 44px 430px auto; min-height: 600px; }
  .flow-canvas { min-height: 430px; }
  .flow-stage { grid-template-columns: 150px 34px 170px 34px 150px; justify-content: flex-start; min-width: 640px; padding-inline: 45px; }
  .result-drawer.expanded .result-content { max-height: 360px; }
  .collection-view { padding: 20px 14px; }
  .collection-header { align-items: center; }
  .collection-header h1 { font-size: 22px; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .search-box { max-width: none; }
  .history-item { grid-template-columns: 36px minmax(0, 1fr) 30px; }
  .history-meta, .history-status { display: none; }
  .provider-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.wide { grid-column: auto; }
  .model-picker-toolbar, .manual-model-row { grid-template-columns: 1fr; }
  .model-picker-toolbar .button, .manual-model-row .button { width: 100%; }
  .selected-model-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .modal { max-height: calc(100vh - 20px); }
  .modal-backdrop { padding: 10px; }
  .modal footer { flex-wrap: wrap; }
  .modal footer .button { flex: 1; }
}

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