:root {
  --bg: #0c0d10;
  --bg-2: #121419;
  --bg-3: #181b21;
  --bg-4: #20242c;
  --line: #262a33;
  --line-2: #323743;
  --text: #e9eaee;
  --text-2: #b4b9c4;
  --muted: #7d8492;
  --accent: #f2b544;
  --accent-ink: #1a1305;
  --sel: #8ab4ff;
  --sel-soft: rgba(138, 180, 255, 0.14);
  --ok: #4ade80;
  --warn: #fbbf24;
  --err: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* ---------- layout ---------- */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr) 380px;
  grid-template-rows: 52px minmax(0, 1fr);
  grid-template-areas: "top top top" "side main panel";
}
.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-2);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: 0.01em; color: var(--accent); white-space: nowrap; }
.brand span { color: var(--text); }
.title-input {
  flex: 1;
  min-width: 80px;
  max-width: 460px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 560;
}
.title-input:hover { border-color: var(--line); }
.title-input:focus { outline: none; border-color: var(--line-2); background: var(--bg-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.save-state { color: var(--muted); font-size: 12px; min-width: 52px; text-align: right; }

.sidebar {
  grid-area: side;
  border-right: 1px solid var(--line);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 8px; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.project-list { overflow: auto; flex: 1; padding: 0 8px 8px; }
.proj {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 7px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  cursor: pointer;
}
.proj:hover { background: var(--bg-3); }
.proj.active { background: var(--bg-4); border-color: var(--line-2); }
.proj-thumb { width: 40px; height: 40px; border-radius: 6px; background: var(--bg-4) center/cover no-repeat; border: 1px solid var(--line); }
.proj-name { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-meta { font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.sdot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--muted); }
.sdot.READY { background: var(--ok); }
.sdot.FAILED, .sdot.CANCELED { background: var(--err); }
.sdot.QUEUED, .sdot.SUBMITTED, .sdot.RUNNING, .sdot.SAVING { background: var(--warn); }
.sidebar-foot { padding: 10px 12px; border-top: 1px solid var(--line); }

.main { grid-area: main; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.panel { grid-area: panel; border-left: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; min-height: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  background: var(--bg-3);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-weight: 560;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--bg-4); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.small { padding: 4px 9px; font-size: 12px; }
a.btn { text-decoration: none; color: inherit; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--bg-3); color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: #f6c262; }
.btn.primary .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.btn.danger { color: var(--err); }
.btn.danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.1); }
.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 13px;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); }
.icon-btn.play { width: 38px; height: 38px; border-radius: 50%; background: var(--text); color: var(--bg); font-size: 14px; }
.icon-btn.play:hover { background: #fff; color: #000; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link:hover { color: var(--text); }
.only-mobile { display: none; }

/* ---------- stage ---------- */
.stage-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 12px 16px 6px; }
.stage-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.seg { display: inline-flex; background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.seg-btn { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-weight: 560; font-size: 12px; }
.seg-btn.active { background: var(--bg-4); color: var(--text); }
.seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.stage { flex: 1; min-height: 120px; display: grid; place-items: center; position: relative; }
.stage-box {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0, 0, 0, 0.45);
}
.stage-box .layer { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 0.35s ease; }
.stage-box .layer.on { opacity: 1; }
.stage-box video.layer { object-fit: contain; transition: none; background: #000; }
.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
  color: var(--muted);
  background: repeating-linear-gradient(135deg, #111318 0 12px, #14161c 12px 24px);
  font-size: 13px;
}
.stage-empty b { display: block; color: var(--text-2); font-size: 15px; margin-bottom: 6px; }
.stage-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 28px 14px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.78));
  font-size: 12px;
  color: #f1f2f5;
  pointer-events: none;
}
.stage-caption .cap-label { font-family: var(--mono); color: var(--accent); font-size: 11px; margin-bottom: 2px; }
.stage-caption:empty { display: none; }
.stage-tc {
  position: absolute;
  top: 10px; right: 10px;
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 7px;
  border-radius: 5px;
  color: #fff;
}
.transport { display: flex; align-items: center; gap: 6px; padding-top: 10px; }
.timecode { font-family: var(--mono); font-size: 12px; color: var(--text-2); margin-left: 8px; }
.hint { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- timeline ---------- */
.timeline { border-top: 1px solid var(--line); background: var(--bg-2); padding: 0 0 12px; }
.timeline-scroll { overflow-x: auto; overflow-y: hidden; padding: 0 16px; }
.timeline-inner { position: relative; min-width: 100%; user-select: none; -webkit-user-select: none; }
.ruler { position: relative; height: 28px; cursor: pointer; border-bottom: 1px solid var(--line); }
.tick { position: absolute; bottom: 0; width: 1px; background: var(--line-2); height: 6px; }
.tick.major { height: 11px; background: var(--muted); }
.tick-label { position: absolute; bottom: 12px; transform: translateX(-50%); font-family: var(--mono); font-size: 10px; color: var(--muted); }
.track { position: relative; height: 104px; margin-top: 10px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--line-2); }
.track.dragover { border-color: var(--sel); background: var(--sel-soft); }
.track-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; pointer-events: none; text-align: center; padding: 0 12px; }
.seg-block {
  position: absolute;
  top: 6px;
  bottom: 6px;
  border-radius: 7px;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  display: flex;
  overflow: hidden;
  cursor: grab;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.seg-block:hover { border-color: #4a5160; }
.seg-block.selected { border-color: var(--sel); box-shadow: 0 0 0 1px var(--sel), 0 0 0 4px var(--sel-soft); z-index: 3; }
.seg-block.dragging { cursor: grabbing; opacity: 0.92; z-index: 4; }
.seg-block.dropover { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.seg-block.final { border-style: dashed; }
.seg-thumb { flex: none; height: 100%; background: var(--bg-4) center/cover no-repeat; border-right: 1px solid var(--line-2); display: grid; place-items: center; color: var(--muted); font-size: 18px; }
.seg-info { min-width: 0; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; }
.seg-time { font-family: var(--mono); font-size: 11px; color: var(--accent); white-space: nowrap; }
.seg-label { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.seg-text { font-size: 11px; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; line-height: 1.35; }
.seg-handle { position: absolute; left: -1px; top: -1px; bottom: -1px; width: 4px; background: var(--accent); border-radius: 7px 0 0 7px; opacity: 0.85; }
.opening-block { position: absolute; top: 6px; bottom: 6px; border-radius: 7px; border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 11px; pointer-events: none; }
.playhead { position: absolute; top: 0; bottom: -6px; width: 0; pointer-events: none; z-index: 6; }
.playhead::before { content: ""; position: absolute; top: 0; bottom: 0; left: -1px; width: 2px; background: var(--err); }
.playhead-knob { position: absolute; top: 0; left: -7px; width: 14px; height: 14px; background: var(--err); clip-path: polygon(0 0, 100% 0, 100% 55%, 50% 100%, 0 55%); pointer-events: auto; cursor: ew-resize; }
.drag-tip { position: fixed; z-index: 50; pointer-events: none; font-family: var(--mono); font-size: 11px; background: var(--text); color: var(--bg); padding: 2px 6px; border-radius: 4px; transform: translate(-50%, -130%); }

/* ---------- panel ---------- */
.tabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); }
.tab {
  border: 0;
  background: transparent;
  padding: 8px 10px 9px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { font-size: 10px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; display: inline-grid; place-items: center; background: var(--bg-4); color: var(--text-2); }
.badge.err { background: rgba(248, 113, 113, 0.18); color: var(--err); }
.badge.warn { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
.badge.run { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
.tab-body { flex: 1; overflow: auto; padding: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .flabel { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.06em; }
.field .note { font-size: 11.5px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input, .select, .textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 7px 9px;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--sel); box-shadow: 0 0 0 3px var(--sel-soft); }
.textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
.textarea.tall { min-height: 150px; }
.input.num { width: 92px; font-family: var(--mono); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.switch:last-of-type { border-bottom: 1px solid var(--line); }
.switch input { width: 34px; height: 20px; appearance: none; background: var(--bg-4); border-radius: 10px; position: relative; cursor: pointer; transition: background 0.15s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform 0.15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); background: var(--accent-ink); }
.switch .sw-text b { display: block; font-weight: 560; }
.switch .sw-text span { font-size: 11.5px; color: var(--muted); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mode-btn { border: 1px solid var(--line-2); background: var(--bg); border-radius: 8px; padding: 8px; cursor: pointer; text-align: left; font-size: 12px; font-weight: 600; }
.mode-btn small { display: block; font-weight: 400; color: var(--muted); font-size: 10.5px; margin-top: 2px; line-height: 1.3; }
.mode-btn.active { border-color: var(--accent); background: rgba(242, 181, 68, 0.08); }
.mode-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.shot-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.shot-title { font-size: 15px; font-weight: 650; }
.shot-span { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.imgbox {
  position: relative;
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  background: var(--bg) center/contain no-repeat;
  display: grid;
  place-items: center;
  min-height: 150px;
  color: var(--muted);
  text-align: center;
  padding: 10px;
  overflow: hidden;
}
.imgbox.has { border-style: solid; background-color: #000; }
.imgbox.dragover { border-color: var(--sel); background-color: var(--sel-soft); }
.imgbox .img-meta { position: absolute; left: 8px; bottom: 8px; font-family: var(--mono); font-size: 10.5px; background: rgba(0,0,0,.65); color: #fff; padding: 2px 6px; border-radius: 4px; }
.img-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gen-box { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-3); }
.lib { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.lib button { aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg-4) center/cover no-repeat; cursor: pointer; }
.lib button:hover { border-color: var(--sel); }
.empty-panel { color: var(--muted); text-align: center; padding: 30px 10px; }
.empty-panel b { color: var(--text-2); display: block; margin-bottom: 6px; font-size: 14px; }

.msg { border-radius: 8px; padding: 8px 10px; font-size: 12px; margin-bottom: 8px; display: flex; gap: 8px; }
.msg.err { background: rgba(248, 113, 113, 0.1); color: #fecaca; border: 1px solid rgba(248, 113, 113, 0.3); }
.msg.warn { background: rgba(251, 191, 36, 0.08); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.25); }
.msg.ok { background: rgba(74, 222, 128, 0.08); color: #bbf7d0; border: 1px solid rgba(74, 222, 128, 0.25); }
.code {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--text-2);
}
.media-list { display: grid; gap: 6px; }
.media-item { display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 8px; }
.media-item .mthumb { width: 44px; height: 44px; border-radius: 5px; background: var(--bg-4) center/cover no-repeat; }
.media-item b { font-size: 12px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); }

.render-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: var(--bg-3); }
.render-card.on-stage { border-color: var(--sel); }
.render-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.chip { font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; padding: 2px 7px; border-radius: 10px; background: var(--bg-4); color: var(--text-2); }
.chip.preset { background: transparent; border: 1px solid var(--line-2); color: var(--text-2); }
.chip.preset.final { border-color: var(--accent); color: var(--accent); }
.mono { font-family: var(--mono); }
.chip.READY { background: rgba(74, 222, 128, 0.14); color: var(--ok); }
.chip.FAILED, .chip.CANCELED { background: rgba(248, 113, 113, 0.14); color: var(--err); }
.chip.QUEUED, .chip.SUBMITTED, .chip.RUNNING, .chip.SAVING { background: rgba(251, 191, 36, 0.14); color: var(--warn); }
.render-meta { font-size: 11.5px; color: var(--muted); }
.render-card video { width: 100%; border-radius: 6px; background: #000; margin: 6px 0; max-height: 260px; }
.thumb {
  position: relative;
  display: block;
  width: 100%;
  margin: 6px 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  background: #000;
  cursor: zoom-in;
}
.thumb video { display: block; width: 100%; max-height: 260px; margin: 0; border-radius: 0; object-fit: contain; pointer-events: none; }
.thumb .play-badge {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(0, 0, 0, 0.55); color: #fff; display: grid; place-items: center; font-size: 16px;
  border: 1px solid rgba(255, 255, 255, 0.35); transition: transform 0.15s, background 0.15s;
}
.thumb:hover .play-badge { transform: translate(-50%, -50%) scale(1.08); background: rgba(242, 181, 68, 0.9); color: #1a1305; }
.thumb .thumb-tag { position: absolute; right: 6px; bottom: 6px; font-family: var(--mono); font-size: 10.5px; background: rgba(0,0,0,.65); color: #fff; padding: 2px 6px; border-radius: 4px; }

/* ---------- popup viewer ---------- */
.viewer { position: fixed; inset: 0; z-index: 150; background: rgba(4, 5, 7, 0.88); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 16px; }
.viewer-card { width: min(1280px, 100%); height: min(calc(100vh - 32px), 980px); height: min(calc(100dvh - 32px), 980px); display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.viewer-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--text-2); font-size: 12.5px; }
.viewer-head .vh-title { color: var(--text); font-weight: 650; font-size: 14px; }
.viewer-head .vh-spacer { flex: 1; }
.viewer-head .btn { background: rgba(255,255,255,.06); }
.viewer-body { flex: 1 1 0; min-height: 0; display: flex; gap: 12px; justify-content: center; align-items: stretch; overflow: hidden; }
.viewer-pane { flex: 1 1 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.viewer-pane .pane-label { font-family: var(--mono); font-size: 11px; color: var(--accent); align-self: center; }
.viewer-pane video { flex: 1 1 0; min-height: 0; width: 100%; height: 0; object-fit: contain; background: #000; border-radius: 10px; box-shadow: 0 0 0 1px var(--line); }
.viewer-strip { display: flex; flex-direction: column; gap: 6px; }
.vs-track { position: relative; height: 34px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; cursor: pointer; }
.vs-seg { position: absolute; top: 0; bottom: 0; border-right: 1px solid var(--line-2); display: flex; align-items: center; gap: 6px; padding: 0 8px; font-size: 11px; color: var(--muted); overflow: hidden; white-space: nowrap; }
.vs-seg.on { background: rgba(242, 181, 68, 0.12); color: var(--text); }
.vs-seg img { height: 26px; border-radius: 3px; flex: none; }
.vs-head { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--err); pointer-events: none; }
.vs-meta { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); }
@media (max-width: 860px) {
  .viewer { padding: 8px; }
  .viewer-card { height: calc(100dvh - 16px); }
  .viewer-body { flex-direction: column; }
  .viewer-head { font-size: 11.5px; gap: 6px; }
  .vs-meta span:nth-child(2) { display: none; }
}
.render-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.spin { width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.err-text { color: #fecaca; font-size: 12px; margin-top: 6px; white-space: pre-wrap; word-break: break-word; }

/* ---------- modal + toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(5, 6, 8, 0.72); display: grid; place-items: center; z-index: 100; padding: 16px; backdrop-filter: blur(3px); }
.modal-card { width: min(520px, 100%); max-height: 90vh; overflow: auto; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 14px; padding: 20px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.modal-card h2 { margin: 0 0 10px; font-size: 17px; }
.modal-card p { color: var(--text-2); margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.copy-row { display: flex; gap: 6px; }
.copy-row .input { font-family: var(--mono); font-size: 11.5px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 9px; font-weight: 560; z-index: 200; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); max-width: min(560px, calc(100vw - 32px)); }
.toast.err { background: var(--err); color: #1b0606; }
ol.steps { padding-left: 18px; color: var(--text-2); margin: 0 0 12px; }
ol.steps li { margin-bottom: 6px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 200px minmax(0, 1fr) 330px; }
}
@media (max-width: 860px) {
  body { overflow: auto; }
  .app { display: block; height: auto; }
  .topbar { position: sticky; top: 0; z-index: 20; flex-wrap: nowrap; }
  .brand span, #btn-connect, .save-state, .btn.primary .dot { display: none; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .btn { padding: 6px 9px; font-size: 12px; }
  .title-input { min-width: 0; }
  .topbar-right { gap: 6px; }
  .only-mobile { display: inline-grid; }
  .sidebar { position: fixed; top: 52px; left: 0; bottom: 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0, 0, 0, 0.6); }
  .main { display: block; }
  .stage-wrap { padding: 12px 16px; }
  .stage { min-height: 0; }
  .hint { display: none; }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
  .tab-body { overflow: visible; }
}
