:root {
  --bg: #0a0a0c;
  --bg-soft: #0e0e11;
  --panel: #101013;
  --panel-2: #15151a;
  --line: rgba(255, 255, 255, 0.075);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #ece9e2;
  --muted: #8b877f;
  --muted-2: #605d57;
  --accent: #d8ff3e;
  --accent-dim: rgba(216, 255, 62, 0.16);
  --accent-ink: #14170a;
  --orange: #ff7a45;
  --ok: #7dd3a8;
  --err: #ff6b6b;
  --warn: #ffc857;
  --sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, "Songti SC", serif;
  --mono: "JetBrains Mono", "SFMono-Regular", "Cascadia Code", Consolas, monospace;
  --r: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(216, 255, 62, 0.055), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(255, 122, 69, 0.05), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

::selection { background: var(--accent); color: var(--accent-ink); }

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

/* Layout section */
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 顶栏 ---------------- */
.topbar {
  height: 62px;
  flex: 0 0 62px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 12, 0.82);
  backdrop-filter: blur(14px);
  position: relative;
  z-index: 30;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  color: var(--accent);
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.06), transparent);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.18; }
.brand-text strong { font-family: var(--serif); font-size: 17px; font-weight: 600; letter-spacing: 0.02em; }
.brand-text span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em; color: var(--muted); }

.topbar-center { display: flex; align-items: center; gap: 10px; margin-left: 12px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s;
}
.pill:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.045); }
.pill-label { color: var(--muted-2); font-size: 9px; letter-spacing: 0.18em; }
.pill .mono { font-size: 11px; color: var(--text); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-2); flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(125, 211, 168, 0.16); }
.dot.off { background: var(--err); box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.14); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(255, 200, 87, 0.14); }
.dot-ip { width: 5px; height: 5px; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.mode-tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em;
  padding: 5px 9px; border-radius: 4px;
  border: 1px solid rgba(255, 200, 87, 0.3);
  color: var(--warn);
  background: rgba(255, 200, 87, 0.06);
  text-transform: uppercase;
}
.mode-tag.live { border-color: rgba(125, 211, 168, 0.34); color: var(--ok); background: rgba(125, 211, 168, 0.06); }

.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 11px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-family: var(--sans);
  cursor: pointer;
  transition: 0.18s;
}
.ghost-btn svg { width: 15px; height: 15px; }
.ghost-btn:hover { color: var(--text); border-color: var(--line); background: rgba(255, 255, 255, 0.04); }

/* ---------------- 主布局 ---------------- */
.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 372px minmax(0, 1fr) 336px;
}

.panel { min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.composer { border-right: 1px solid var(--line); overflow-y: auto; padding: 20px 20px 16px; }
.works { background: var(--bg-soft); min-width: 0; }
.egress { border-left: 1px solid var(--line); background: var(--panel); }

.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 3px 0 0; font-family: var(--serif); font-size: 21px; font-weight: 600; letter-spacing: 0.01em; }
.eyebrow {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.2em;
  color: var(--muted-2); text-transform: uppercase;
}
.hint { font-size: 10.5px; color: var(--muted-2); }
.muted { color: var(--muted); }
.small { font-size: 10.5px; }
.mono { font-family: var(--mono); }
.count { font-size: 12px; color: var(--accent); }

/* Layout section */
.tabs { display: flex; gap: 2px; margin: 18px 0 16px; border-bottom: 1px solid var(--line); }
.tab {
  flex: 1; padding: 9px 4px;
  background: transparent; border: 0; border-bottom: 1.5px solid transparent;
  color: var(--muted); font-size: 12.5px; font-family: var(--sans);
  cursor: pointer; transition: 0.16s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

.field { margin-bottom: 15px; }
.field-label {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 7px; font-size: 11.5px; color: #b9b5ac;
}
.field-label .mono { font-size: 9.5px; }

.prompt-field textarea {
  width: 100%; resize: vertical; min-height: 118px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 13px 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px; line-height: 1.65;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.prompt-field textarea::placeholder { color: var(--muted-2); }
.prompt-field textarea:focus {
  border-color: rgba(216, 255, 62, 0.5);
  box-shadow: 0 0 0 3px rgba(216, 255, 62, 0.08);
}
.prompt-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; gap: 8px; flex-wrap: wrap; }
.prompt-tools { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.optimize-btn { flex: none; min-height: 36px; color: var(--accent); }
.optimizer-panel { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-strong); }
.optimizer-panel[hidden] { display: none; }
.optimizer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.optimizer-head h3 { font-size: 15px; margin: 0; }
.optimizer-status, .optimizer-note, .optimizer-option p { color: #aaa59c; font-size: 12px; line-height: 1.65; overflow-wrap: anywhere; }
.optimizer-results { display: flex; flex-direction: column; gap: 20px; margin-bottom: 12px; }
.optimizer-option .stack { margin: 0 0 6px; color: var(--text); }
.optimizer-option textarea { min-height: 130px; font-size: 14px; }
.optimizer-option .action-btn { width: 100%; min-height: 40px; }
.optimizer-option p { margin: 6px 0 10px; }
.settings-tabs { flex-wrap: wrap; }
.prompt-meta .mono { font-size: 10px; color: var(--muted-2); }

.text-btn {
  background: transparent; border: 0; padding: 0;
  color: var(--muted); font-size: 11px; cursor: pointer;
  font-family: var(--sans);
}
.text-btn:hover { color: var(--accent); }

.ref-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ref-add {
  aspect-ratio: 1; border: 1px dashed var(--line-strong); border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted-2); font-size: 9.5px; cursor: pointer; transition: 0.18s;
  background: rgba(255, 255, 255, 0.015);
}
.ref-add svg { width: 16px; height: 16px; }
.ref-add:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.ref-item { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.ref-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-item button {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
  border-radius: 50%; border: 0; background: rgba(0, 0, 0, 0.72); color: #fff;
  font-size: 11px; line-height: 1; cursor: pointer;
}
.ref-item button:hover { background: var(--err); }

.ratio-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.ratio {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 8px 2px 6px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--muted); font-size: 9.5px; font-family: var(--mono); cursor: pointer;
  transition: 0.16s;
}
.ratio i { display: block; width: var(--w); height: var(--h); border: 1.2px solid currentColor; border-radius: 2px; }
.ratio:hover { border-color: var(--line-strong); color: var(--text); }
.ratio.active { border-color: rgba(216, 255, 62, 0.55); color: var(--accent); background: rgba(216, 255, 62, 0.06); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.segmented { display: flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; }
.seg {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font-size: 11px; padding: 6px 3px; border-radius: 6px; cursor: pointer;
  font-family: var(--sans); white-space: nowrap; transition: 0.16s;
}
.seg:hover { color: var(--text); }
.seg.active { background: rgba(255, 255, 255, 0.08); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset; }
.speed-seg .seg { font-size: 10.5px; }

.select, .text-input {
  width: 100%; height: 34px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 0 10px; font-size: 12.5px; font-family: var(--sans); outline: none;
  transition: border-color 0.16s;
}
.text-input.mono { font-family: var(--mono); font-size: 11.5px; }
textarea.text-input { height: auto; padding: 9px 10px; line-height: 1.55; resize: vertical; }
.select:focus, .text-input:focus { border-color: rgba(216, 255, 62, 0.45); }

.stack { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 11.5px; color: #b9b5ac; }
.stack .hint { font-size: 10px; color: var(--muted-2); line-height: 1.5; font-style: normal; }

.advanced { border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2); margin-bottom: 14px; }
.advanced summary {
  list-style: none; cursor: pointer; padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: #b9b5ac;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary:hover { color: var(--text); }
.advanced-body { padding: 4px 12px 12px; border-top: 1px solid var(--line); }
.range-row { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 11px; color: #b9b5ac; }
.range-row b { color: var(--text); font-weight: 500; margin-left: 4px; }
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.13); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--bg); cursor: pointer;
  box-shadow: 0 0 0 1px rgba(216, 255, 62, 0.5);
}
.switch-row { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 11.5px; color: #b9b5ac; }
.switch input { display: none; }
.switch i {
  width: 30px; height: 17px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); position: relative; transition: 0.2s; flex: 0 0 auto;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 13px; height: 13px;
  border-radius: 50%; background: #b9b5ac; transition: 0.2s;
}
.switch input:checked + i { background: rgba(216, 255, 62, 0.85); }
.switch input:checked + i::after { left: 15px; background: var(--accent-ink); }
.switch.big { font-size: 12.5px; color: var(--text); }

.prompt-preview {
  font-family: var(--mono); font-size: 10px; line-height: 1.6;
  color: var(--muted-2); background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid rgba(216, 255, 62, 0.35);
  padding: 7px 10px; border-radius: 0 6px 6px 0;
  margin-bottom: 12px; max-height: 58px; overflow: hidden;
  word-break: break-all;
}

.submit-row { display: flex; align-items: center; gap: 12px; }
.primary-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  height: 46px; border-radius: 8px; border: 0;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--sans); font-size: 14px; font-weight: 700; letter-spacing: 0.02em;
  cursor: pointer; transition: transform 0.12s, box-shadow 0.18s, background 0.18s;
  box-shadow: 0 6px 22px -8px rgba(216, 255, 62, 0.5);
}
.primary-btn svg { width: 17px; height: 17px; }
.primary-btn:hover { background: #e4ff6a; }
.primary-btn:active { transform: translateY(1px); }
.primary-btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }
.primary-btn.small { height: 34px; flex: 0 0 auto; padding: 0 18px; font-size: 12.5px; }
.kbd-hint { font-size: 10px; white-space: nowrap; }
.compose-note { margin: 10px 0 0; font-size: 10.5px; color: var(--muted-2); line-height: 1.5; }

/* Layout section */
.works-head { padding: 20px 24px 14px; align-items: flex-end; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 4px; }
.filter {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 11px; padding: 5px 9px; border-radius: 5px; cursor: pointer; font-family: var(--sans);
}
.filter:hover { color: var(--text); }
.filter.active { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, 0.04); }

.works-scroll { flex: 1; overflow-y: auto; padding: 22px 24px 40px; position: relative; }
.work-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

.work-card {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--panel); display: flex; flex-direction: column;
  transition: border-color 0.18s, transform 0.18s;
}
.work-card.fresh { animation: cardIn 0.35s ease both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.work-card:hover { border-color: var(--line-strong); }
.work-media { position: relative; aspect-ratio: 1; background: #08080a; cursor: zoom-in; overflow: hidden; }
.work-media img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s; }
.work-card:hover .work-media img { transform: scale(1.02); }
.work-media.grid4 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.work-media.grid4 img { aspect-ratio: 1; }
.work-badge {
  position: absolute; top: 9px; left: 9px;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em;
  padding: 3px 7px; border-radius: 3px;
  background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(4px);
  color: var(--ok); border: 1px solid rgba(125, 211, 168, 0.3);
}
.work-badge.run { color: var(--warn); border-color: rgba(255, 200, 87, 0.3); }
.work-badge.fail { color: var(--err); border-color: rgba(255, 107, 107, 0.3); }
.work-ip {
  position: absolute; bottom: 9px; right: 9px;
  font-family: var(--mono); font-size: 9px; padding: 3px 6px; border-radius: 3px;
  background: rgba(0, 0, 0, 0.66); color: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.work-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255, 255, 255, 0.08); }
.work-progress i { display: block; height: 100%; background: var(--accent); transition: width 0.4s; }
.work-body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 9px; }
.work-prompt { font-size: 12px; line-height: 1.5; color: #d5d1c7; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.work-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-family: var(--mono); font-size: 9px; color: var(--muted-2); }
.work-meta .chip { border: 1px solid var(--line); padding: 2px 5px; border-radius: 3px; }
.work-meta .node { color: var(--muted); max-width: 108px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.work-meta .spacer { margin-left: auto; }
.work-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.work-actions button {
  min-width: 0; height: 26px; border-radius: 5px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font-family: var(--mono); font-size: 9.5px; cursor: pointer; transition: 0.15s;
}
.work-actions button:hover { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.work-actions button.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); border-color: var(--line-strong); }

.empty-state { text-align: center; padding: 64px 20px; max-width: 520px; margin: 0 auto; color: var(--muted); }
.empty-state[hidden] { display: none; }
.empty-glyph { color: rgba(255, 255, 255, 0.14); width: 104px; margin: 0 auto 6px; }
.empty-state h3 { font-family: var(--serif); font-size: 22px; color: #cfcbc1; margin: 6px 0 6px; font-weight: 500; }
.empty-state p { font-size: 12px; margin: 0 0 20px; }
.empty-samples { display: flex; flex-direction: column; gap: 7px; align-items: center; }
.empty-samples button {
  border: 1px solid var(--line); background: rgba(255, 255, 255, 0.02); color: var(--muted);
  border-radius: 999px; padding: 6px 14px; font-size: 11px; cursor: pointer; transition: 0.16s;
}
.empty-samples button:hover { color: var(--accent); border-color: rgba(216, 255, 62, 0.4); }

/* ---------------- 出口面板 ---------------- */
.egress { overflow-y: auto; }
.egress .panel-head { padding: 20px 18px 12px; align-items: flex-start; }
.egress-body { padding: 0 18px 18px; display: flex; flex-direction: column; gap: 14px; }
.icon-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center;
}
.icon-btn svg { width: 14px; height: 14px; }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
#egressExpandBtn { display: none; }

.counter-block { display: flex; gap: 14px; align-items: center; padding-top: 4px; }
.ring-wrap { position: relative; width: 108px; height: 108px; flex: 0 0 auto; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring-bg { stroke: rgba(255, 255, 255, 0.07); }
.ring-fg {
  stroke: var(--accent); stroke-linecap: round;
  stroke-dasharray: 326.7; stroke-dashoffset: 326.7;
  transition: stroke-dashoffset 0.5s ease, stroke 0.3s;
}
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
}
.ring-center strong { font-family: var(--serif); font-size: 26px; font-weight: 500; line-height: 1; letter-spacing: -0.02em; }
.ring-center strong span { font-size: 15px; color: var(--muted-2); }
.ring-center .mono { font-size: 8px; letter-spacing: 0.18em; color: var(--muted-2); }
.counter-side { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.exit-node, .exit-ip { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.exit-node .mono, .exit-ip .mono { font-size: 8.5px; letter-spacing: 0.14em; }
.exit-node strong { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 172px; }
.ip-link {
  background: transparent; border: 0; padding: 0; text-align: left;
  color: var(--accent); font-size: 12px; cursor: pointer; letter-spacing: 0.02em;
}
.ip-link:hover { text-decoration: underline; }
.exit-ip .small { font-size: 9.5px; }

.rotation-switch {
  display: flex; flex-direction: column; gap: 9px;
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-2);
}
.every-control { display: flex; align-items: center; gap: 7px; font-size: 10.5px; }
.mini-input {
  width: 58px; height: 28px; text-align: center;
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line-strong); border-radius: 6px;
  color: var(--accent); font-size: 13px; outline: none;
}
.mini-input:focus { border-color: var(--accent); }

.egress-actions { display: flex; gap: 8px; }
.action-btn {
  flex: 1; height: 33px; border-radius: 7px;
  border: 1px solid var(--line-strong); background: transparent; color: #cfcbc1;
  font-size: 11.5px; font-family: var(--sans); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: 0.16s; padding: 0 10px;
}
.action-btn svg { width: 14px; height: 14px; }
.action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.action-btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.action-btn.accent:hover { background: #e6ff72; color: var(--accent-ink); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.node-head { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.node-head-actions { display: flex; align-items: center; gap: 8px; font-size: 10px; }
.node-list {
  display: flex; flex-direction: column; gap: 3px;
  max-height: 226px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: rgba(0, 0, 0, 0.16);
}
.node-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 7px 8px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: #c4c0b6; cursor: pointer;
  font-size: 11px; text-align: left; transition: 0.14s;
}
.node-row:hover { background: rgba(255, 255, 255, 0.04); border-color: var(--line); }
.node-row.current { background: rgba(216, 255, 62, 0.075); border-color: rgba(216, 255, 62, 0.32); color: var(--text); }
.node-row .n-idx { font-family: var(--mono); font-size: 8.5px; color: var(--muted-2); width: 16px; flex: 0 0 auto; }
.node-row .n-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-row .n-lat { font-family: var(--mono); font-size: 8.5px; color: var(--muted-2); flex: 0 0 auto; }
.node-row .n-lat.good { color: var(--ok); }
.node-row .n-lat.bad { color: var(--err); }
.node-row .n-count { font-family: var(--mono); font-size: 8.5px; color: var(--muted-2); flex: 0 0 auto; }
.node-empty { padding: 22px 12px; text-align: center; color: var(--muted-2); font-size: 11px; }

.egress-log-head { display: flex; justify-content: space-between; align-items: center; }
.egress-log { display: flex; flex-direction: column; gap: 3px; font-family: var(--mono); font-size: 9px; color: var(--muted-2); }
.egress-log .log-line { display: flex; gap: 8px; white-space: nowrap; overflow: hidden; }
.egress-log .log-line b { color: var(--muted); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }
.egress-log .log-line .reason { color: rgba(216, 255, 62, 0.6); }
.egress-foot {
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid var(--line); padding-top: 11px; margin-top: 2px; font-size: 10px;
}

/* ---------------- 弹窗 ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(4, 4, 6, 0.72); backdrop-filter: blur(8px);
  display: grid; place-items: center; padding: 24px;
  animation: fadeIn 0.18s ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #0f0f12; border: 1px solid var(--line-strong); border-radius: 14px;
  box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 0.8);
  max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  animation: popIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
.settings-modal { width: min(680px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px 14px; }
.modal-head h2 { margin: 3px 0 0; font-family: var(--serif); font-size: 22px; font-weight: 600; }

.settings-tabs { display: flex; gap: 2px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.stab {
  padding: 9px 12px; background: transparent; border: 0; border-bottom: 1.5px solid transparent;
  color: var(--muted); font-size: 12px; cursor: pointer;
}
.stab.active { color: var(--text); border-bottom-color: var(--accent); }
.settings-body { padding: 18px 22px 8px; overflow-y: auto; }
.stab-panel { display: none; }
.stab-panel.active { display: block; }
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }
.mode-card {
  text-align: left; padding: 11px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--muted);
  display: flex; flex-direction: column; gap: 3px; cursor: pointer; transition: 0.16s;
}
.mode-card strong { color: #d8d4c9; font-size: 12px; font-weight: 500; }
.mode-card span { font-size: 10px; line-height: 1.45; }
.mode-card:hover { border-color: var(--line-strong); }
.mode-card.active { border-color: var(--accent); background: rgba(216, 255, 62, 0.06); }
.mode-card.active strong { color: var(--accent); }
.egress-fields { display: none; }
.egress-fields.active { display: block; }
.inline-actions { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.inline-actions .action-btn { flex: 0 0 auto; padding: 0 14px; }
.log-box {
  margin: 4px 0 8px; padding: 10px 12px; border-radius: 8px;
  background: #08080a; border: 1px solid var(--line);
  font-family: var(--mono); font-size: 9.5px; line-height: 1.65; color: var(--muted);
  max-height: 132px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
.rotation-explain { margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: rgba(255, 255, 255, 0.025); border: 1px solid var(--line); }
.rotation-explain p { margin: 0 0 6px; font-size: 11px; color: var(--muted); line-height: 1.6; }
.rotation-explain p:last-child { margin-bottom: 0; }
.modal-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px; border-top: 1px solid var(--line); gap: 12px;
}
.modal-foot .inline-actions { margin: 0; }
.modal-foot .action-btn { flex: 0 0 auto; padding: 0 14px; }

/* ---------------- 灯箱 ---------------- */
.lightbox {
  width: min(1180px, 100%); height: min(760px, calc(100vh - 48px));
  background: #0d0d10; border: 1px solid var(--line-strong); border-radius: 14px;
  display: grid; grid-template-columns: minmax(0, 1fr) 318px; overflow: hidden;
  position: relative; animation: popIn 0.22s ease;
}
.lightbox-close { position: absolute; top: 12px; right: 12px; z-index: 3; background: rgba(0, 0, 0, 0.5); }
.lightbox-stage { position: relative; display: grid; place-items: center; background: #08080a; padding: 28px; }
.lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.lightbox-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.lightbox-loading[hidden] { display: none; }
.lightbox-side { border-left: 1px solid var(--line); padding: 22px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }
.lightbox-meta p { margin: 6px 0 0; font-size: 11.5px; line-height: 1.6; color: #cfcbc1; }
.lightbox-meta p.mono { font-size: 10px; color: var(--muted); word-break: break-all; }
.action-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 8px; }
.work-actions button.ghost { grid-column: 1 / -1; }
:is(.work-actions, .action-grid) button[data-label^="U"] { grid-row: 1; }
:is(.work-actions, .action-grid) button[data-label^="V"] { grid-row: 2; }
:is(.work-actions, .action-grid) button[data-label$="1"] { grid-column: 1; }
:is(.work-actions, .action-grid) button[data-label$="2"] { grid-column: 2; }
:is(.work-actions, .action-grid) button[data-label$="3"] { grid-column: 3; }
:is(.work-actions, .action-grid) button[data-label$="4"] { grid-column: 4; }
.action-grid button {
  height: 30px; border-radius: 5px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02); color: #c4c0b6;
  font-family: var(--mono); font-size: 10px; cursor: pointer; transition: 0.15s;
}
.action-grid button:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.lightbox-links { display: flex; flex-direction: column; gap: 7px; margin-top: auto; }

/* ---------------- Toast ---------------- */
.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 15px; border-radius: 8px;
  background: #17171c; border: 1px solid var(--line-strong);
  color: #ddd9cf; font-size: 12px;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.7);
  animation: toastIn 0.22s ease both;
  max-width: min(520px, 90vw);
}
.toast[data-kind="error"] { border-color: rgba(255, 107, 107, 0.4); color: #ffc9c9; }
.toast[data-kind="ok"] { border-color: rgba(125, 211, 168, 0.4); color: #c9f0dd; }
.toast .t-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.toast[data-kind="error"] .t-dot { background: var(--err); }
.toast[data-kind="ok"] .t-dot { background: var(--ok); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Layout section */
@media (max-width: 1320px) {
  .layout { grid-template-columns: 340px minmax(0, 1fr) 306px; }
}
@media (max-width: 1150px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 340px minmax(0, 1fr); }
  .egress { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
  .works { min-height: 560px; }
  #egressExpandBtn { display: grid; }
  .egress-body { max-height: 420px; overflow-y: auto; }
}
@media (max-width: 860px), (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) {
  html, body { height: auto; min-height: 100%; }
  body { --muted: #aaa59c; --muted-2: #959087; display: block; min-height: 100svh; overflow-y: auto; }
  .topbar {
    position: sticky; top: 0; height: auto; min-height: 64px; gap: 8px;
    padding: max(10px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  }
  .brand { flex-shrink: 0; gap: 8px; }
  .brand-text strong, .ghost-btn { white-space: nowrap; }
  .topbar-right { gap: 2px; }
  .topbar-right .mode-tag { display: none; }
  .topbar .ghost-btn { min-height: 44px; padding: 0 10px; }
  .topbar-center { display: none; }
  .brand-text span { display: none; }
  .layout { display: block; padding-bottom: env(safe-area-inset-bottom); }
  .egress { display: none; }
  .composer {
    border-right: 0; border-bottom: 1px solid var(--line); max-height: none; overflow: visible;
    padding: 20px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  }
  .prompt-field textarea, .select, .text-input, .text-input.mono { font-size: 16px; }
  .optimizer-option textarea { font-size: 16px; }
  .prompt-tools .text-btn { padding-left: 0; }
  .optimizer-panel .text-btn { min-height: 44px; }
  .prompt-field textarea { min-height: 144px; }
  .tab, .seg, .filter, .select, .text-input, .action-btn, .primary-btn.small, .stab { min-height: 44px; }
  .tab, .seg, .speed-seg .seg { font-size: 13px; }
  .field-label, .stack { font-size: 13px; }
  .eyebrow, .hint, .field-label .mono, .prompt-meta .mono, .prompt-preview, .work-badge, .work-ip, .ref-add { font-size: 11px; }
  .stack .hint { font-size: 12px; }
  .ratio { min-height: 52px; font-size: 11px; }
  .two-col > *, .work-card { min-width: 0; }
  .ref-item button { width: 44px; height: 44px; font-size: 18px; }
  .prompt-meta .text-btn { min-height: 44px; padding-left: 12px; font-size: 13px; }
  .advanced summary { min-height: 48px; flex-wrap: wrap; gap: 6px; }
  .advanced summary .mono { font-size: 10px; }
  .submit-row .kbd-hint { display: none; }
  .primary-btn { min-height: 50px; font-size: 16px; }
  .compose-note { font-size: 12px; }
  .works { min-height: 0; }
  .works-head { padding: 20px 16px 12px; flex-wrap: wrap; align-items: flex-start; }
  .filters { width: 100%; gap: 4px; }
  .filter { flex: 1; font-size: 13px; }
  .works-scroll { padding: 16px; overflow: visible; flex: none; }
  .work-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .work-prompt { font-size: 14px; }
  .work-meta { font-size: 11px; }
  .work-actions button, .action-grid button { min-height: 44px; font-size: 12px; }
  .empty-state { padding: 32px 0; }
  .empty-samples button { min-height: 44px; width: 100%; white-space: normal; }
  .modal-backdrop {
    padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .modal, .lightbox { max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .modal-head { padding: 16px; }
  .modal-head .icon-btn, .lightbox-close { min-width: 44px; min-height: 44px; }
  .settings-tabs { padding: 0 12px; }
  .settings-body { min-height: 0; padding: 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; }
  .modal-foot .inline-actions { width: 100%; }
  .modal-foot .inline-actions > button { flex: 1; }
  .lightbox { display: block; height: auto; overflow-y: auto; }
  .lightbox-close { position: sticky; top: 8px; margin: 8px 8px -52px auto; }
  .lightbox-stage { min-height: 0; padding: 56px 12px 16px; }
  .lightbox-stage img { max-height: 50vh; max-height: 50dvh; }
  .lightbox-side { border-left: 0; border-top: 1px solid var(--line); padding: 16px; overflow: visible; }
  .lightbox-meta p { font-size: 14px; overflow-wrap: anywhere; }
  .settings-modal { width: 100%; }
  .mode-cards { grid-template-columns: 1fr; }
  .toasts { bottom: max(16px, env(safe-area-inset-bottom)); width: calc(100% - 32px); }
  .toast { max-width: 100%; overflow-wrap: anywhere; }
  button, select, summary, .ref-add, .switch { touch-action: manipulation; }
}
@media (max-width: 600px) {
  .work-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 380px) {
  .brand-mark { width: 30px; height: 30px; }
  .brand-text strong { font-size: 16px; }
  .ratio-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .speed-seg .seg { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
