/* ------------------------------------------------------------------
   墨影 MOYING · 生图工作室
   深色工作室 / 暖白纸感 / 朱砂一点
------------------------------------------------------------------ */

:root {
  --bg: #0a0a0b;
  --bg-2: #0d0d0f;
  --panel: #0f0f12;
  --raise: #141416;
  --line: rgba(236, 232, 224, 0.085);
  --line-strong: rgba(236, 232, 224, 0.18);
  --ink: #ece8e0;
  --paper: #f2ede3;
  --muted: #928d84;
  --dim: #5e5b55;
  --accent: #e2543a;
  --ok: #8fb37f;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", sans-serif;
  --serif: "Songti SC", "STSong", "Noto Serif SC", "Source Han Serif SC", ui-serif, Georgia, serif;
  --mono: "SF Mono", "JetBrains Mono", "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection {
  background: rgba(226, 84, 58, 0.28);
  color: #fff;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(236, 232, 224, 0.13);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(236, 232, 224, 0.22);
}

:focus-visible {
  outline: 1px solid rgba(226, 84, 58, 0.85);
  outline-offset: 2px;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

/* 颗粒感（很轻，只负责质感） */
.grain {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.055;
  mix-blend-mode: overlay;
  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' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

/* ------------------------------------------------------------ topbar */

.topbar {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 11, 0.86);
  backdrop-filter: blur(16px);
}

.rail-toggle {
  display: none;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  background: transparent;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  border-radius: 2px;
}
.rail-toggle span {
  display: block;
  width: 12px;
  height: 1px;
  background: var(--muted);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.seal {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border: 1px solid rgba(226, 84, 58, 0.65);
  color: var(--accent);
  font: 15px/1 var(--serif);
  letter-spacing: 0;
  background: rgba(226, 84, 58, 0.06);
}

.seal.sm {
  width: 19px;
  height: 19px;
  font-size: 10px;
  border-color: rgba(226, 84, 58, 0.5);
  background: rgba(226, 84, 58, 0.08);
}

.brand-name {
  margin: 0;
  font: 400 19px/1.1 var(--serif);
  letter-spacing: 0.22em;
  color: var(--paper);
}

.brand-sub {
  margin: 4px 0 0;
  font: 9px/1 var(--mono);
  letter-spacing: 0.2em;
  color: var(--dim);
  white-space: nowrap;
}

.topbar-tags {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
  padding-left: 22px;
  border-left: 1px solid var(--line);
}

.tag {
  font: 10px/1 var(--mono);
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 5px 8px;
  border-radius: 2px;
  white-space: nowrap;
}

.tag-sep {
  color: var(--dim);
  font: 11px/1 var(--mono);
}

.pod-group {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 18px;
}

.pod {
  display: flex;
  align-items: center;
  gap: 7px;
  font: 10.5px/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--dim);
}

.pod .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--dim);
  box-shadow: 0 0 0 3px rgba(94, 91, 85, 0.12);
  transition: 0.25s;
}

.pod-name {
  color: var(--muted);
}

.pod-val {
  color: var(--dim);
  min-width: 28px;
}

.pod.on .dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(143, 179, 127, 0.14);
}
.pod.on .pod-val {
  color: var(--ok);
}

.pod.off .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(226, 84, 58, 0.16);
}
.pod.off .pod-val {
  color: var(--accent);
}

/* 额度 */

.quota {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-right: 16px;
  border-right: 1px solid var(--line);
}

.quota-label {
  font: 9px/1 var(--mono);
  letter-spacing: 0.14em;
  color: var(--dim);
}

.quota-num {
  font: 10.5px/1 var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
  white-space: nowrap;
}

.quota-num b {
  font-weight: 500;
  color: var(--paper);
  margin-right: 1px;
}

.quota-num i {
  font-style: normal;
  color: var(--dim);
}

.quota-meter {
  display: block;
  width: 46px;
  height: 2px;
  background: rgba(236, 232, 224, 0.1);
  overflow: hidden;
}

.quota-meter i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--muted);
  transition: width 0.5s ease, background 0.3s;
}

.quota.low .quota-num b {
  color: var(--accent);
}

.quota.low .quota-meter i {
  background: var(--accent);
}

.quota.depleted .quota-num b,
.quota.depleted .quota-label {
  color: var(--accent);
}

.quota.depleted .quota-meter i {
  background: var(--accent);
}

.account-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 2px;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.link:hover {
  color: var(--ink);
}

/* --------------------------------------------------------- workspace */

.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 400px;
}

.eyebrow {
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.2em;
  color: var(--dim);
  text-transform: uppercase;
  white-space: nowrap;
}

.dim {
  color: var(--dim);
}

.tiny {
  margin: 0;
  font: 10.5px/1.8 var(--mono);
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ------------------------------------------------------------- rail */

.rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-2);
  border-right: 1px solid var(--line);
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 18px 13px;
}

.count {
  font: 10px/1 var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 3px 6px;
  border-radius: 2px;
}

.rail-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 10px;
  padding: 2px 18px 20px;
}

.work {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 1px solid var(--line);
  background: #0b0b0d;
  overflow: hidden;
  border-radius: 2px;
  transition: border-color 0.18s;
}

.work img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0.85;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
}

.work:hover img {
  transform: scale(1.045);
  opacity: 1;
}

.work:hover {
  border-color: var(--line-strong);
}

.work.active {
  border-color: rgba(226, 84, 58, 0.8);
}

.work.active::after {
  content: "";
  position: absolute;
  top: 5px;
  right: 5px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.work .idx {
  position: absolute;
  left: 6px;
  bottom: 5px;
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.9);
}

.rail-empty {
  flex: 1;
  margin: 0;
  padding: 6px 18px;
  font-size: 12px;
  line-height: 1.9;
  color: var(--dim);
}

.rail-foot {
  flex: 0 0 auto;
  padding: 16px 18px 18px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 9px;
}

.rail-foot .tiny.dim {
  margin-top: 3px;
  color: var(--dim);
}

/* ------------------------------------------------------------ stage */

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 18px 26px 20px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(236, 232, 224, 0.035), transparent 62%),
    var(--bg);
}

.stage-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
}

.stage-meta {
  font: 10px/1 var(--mono);
  letter-spacing: 0.08em;
  color: var(--dim);
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

/* 空白态 */

.empty {
  max-width: 540px;
  width: 100%;
  margin: auto;
  padding: 0 6px;
}

.empty-kicker {
  margin: 0;
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.28em;
  color: var(--muted);
}

.empty h2 {
  margin: 20px 0 16px;
  font: 400 clamp(34px, 3.6vw, 52px) / 1.16 var(--serif);
  letter-spacing: 0.015em;
  color: var(--ink);
}

.empty h2 em {
  font-style: normal;
  color: var(--paper);
  position: relative;
  white-space: nowrap;
}

.empty h2 em::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 2px;
  bottom: 5px;
  height: 1px;
  background: var(--accent);
  opacity: 0.65;
}

.empty-sub {
  max-width: 380px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.85;
}

.seeds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.seed {
  border: 1px solid var(--line);
  background: rgba(236, 232, 224, 0.012);
  color: var(--muted);
  padding: 8px 11px;
  border-radius: 2px;
  font-size: 12px;
  line-height: 1.4;
  text-align: left;
  transition: 0.16s ease;
}

.seed:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: rgba(236, 232, 224, 0.035);
}

/* 生成中 */

.working {
  width: min(520px, 100%);
  margin: auto;
  text-align: center;
  padding: 6px 0;
}

.working-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-height: 50vh;
  margin: 0 auto 20px;
  border: 1px solid var(--line);
  overflow: hidden;
  background:
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(236, 232, 224, 0.03) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(236, 232, 224, 0.03) 39px 40px),
    radial-gradient(circle at 50% 46%, rgba(226, 84, 58, 0.1), transparent 62%),
    #0c0c0e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.working-frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 34%;
  background: linear-gradient(180deg, transparent, rgba(226, 84, 58, 0.11), transparent);
  animation: scan 3.4s linear infinite;
}

.working-stage {
  font: 11px/1.6 var(--mono);
  letter-spacing: 0.12em;
  color: var(--ink);
  padding: 0 20px;
}

.working-timer {
  font: 10px/1 var(--mono);
  letter-spacing: 0.16em;
  color: var(--dim);
}

.working-bar {
  width: 100%;
  height: 2px;
  background: rgba(236, 232, 224, 0.07);
  overflow: hidden;
  margin-bottom: 12px;
}

.working-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.45s ease;
}

.working-bar.indeterminate i {
  width: 30%;
  animation: slide 1.9s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

.working-hint {
  margin: 0;
  font: 10px/1.8 var(--mono);
  color: var(--dim);
  letter-spacing: 0.02em;
}

/* 作品板 */

.plate {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.image-box {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border: 1px solid var(--line);
  background: #0d0d0f;
}

.image-box::before,
.image-box::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: rgba(236, 232, 224, 0.22);
  border-style: solid;
  pointer-events: none;
}
.image-box::before {
  top: 7px;
  left: 7px;
  border-width: 1px 0 0 1px;
}
.image-box::after {
  bottom: 7px;
  right: 7px;
  border-width: 0 1px 1px 0;
}

#canvasImg {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  box-shadow: 0 26px 70px -26px rgba(0, 0, 0, 0.9);
  animation: reveal 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.plate-cap {
  flex: 0 0 auto;
  width: 100%;
  padding: 13px 2px 0;
  display: grid;
  gap: 7px;
}

.cap-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.cap-title {
  margin: 0;
  font: 400 15px/1.5 var(--serif);
  color: var(--paper);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cap-index {
  flex: 0 0 auto;
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.12em;
  color: var(--dim);
}

.cap-meta {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font: 10px/1 var(--mono);
  letter-spacing: 0.06em;
  color: var(--muted);
}

.cap-prompt {
  margin: 0;
  padding-left: 10px;
  border-left: 1px solid var(--line-strong);
  font: 11px/1.7 var(--mono);
  color: #9a958b;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: zoom-in;
}

.cap-prompt.open {
  display: block;
  -webkit-line-clamp: unset;
  cursor: zoom-out;
}

.cap-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding-top: 2px;
}

/* ------------------------------------------------------------ 通用按钮 */

.ghost {
  height: 24px;
  padding: 0 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  font: 10px/1 var(--mono);
  letter-spacing: 0.08em;
  border-radius: 2px;
  transition: 0.16s;
}

.ghost:hover {
  color: var(--ink);
  border-color: var(--line);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1;
  border-radius: 2px;
  text-decoration: none;
  transition: 0.16s;
  white-space: nowrap;
}

.btn:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: rgba(236, 232, 224, 0.035);
}

.btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn.primary {
  color: var(--paper);
  border-color: rgba(236, 232, 224, 0.28);
}

.btn.danger:hover {
  color: #e08b78;
  border-color: rgba(224, 139, 120, 0.4);
}

/* ----------------------------------------------------------- thread */

.thread-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.thread-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 13px;
  border-bottom: 1px solid var(--line);
}

.thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 20px 26px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
}

.thread-empty {
  margin: auto 0;
  padding: 8px 2px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.9;
}

.thread-empty p {
  margin: 0 0 4px;
}

.thread-empty .dim {
  font-size: 12px;
}

.turn {
  display: grid;
  gap: 9px;
  animation: fade 0.32s ease both;
}

.turn-head {
  display: flex;
  align-items: center;
  gap: 7px;
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.14em;
  color: var(--dim);
  text-transform: uppercase;
}

.turn-head time {
  margin-left: auto;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.turn.user p {
  margin: 0;
  padding-left: 12px;
  border-left: 2px solid rgba(236, 232, 224, 0.28);
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.turn.agent .say {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.75;
  color: #cfcac1;
  overflow-wrap: anywhere;
}

.turn .err {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.7;
  color: #e08b78;
  border-left: 1px solid rgba(224, 139, 120, 0.4);
  padding-left: 10px;
}

.plan-mini {
  font: 10.5px/1.75 var(--mono);
  color: #8f8a80;
  background: #0b0b0d;
  border: 1px solid var(--line);
  padding: 9px 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 116px;
  overflow: auto;
}

details.plan {
  border-top: 1px solid var(--line);
  padding-top: 9px;
}

details.plan summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  cursor: pointer;
  font: 10px/1.5 var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
}

details.plan summary::-webkit-details-marker {
  display: none;
}

details.plan summary::after {
  content: "+";
  color: var(--dim);
  font-size: 12px;
}

details.plan[open] summary::after {
  content: "–";
}

details.plan .body {
  margin: 9px 0 0;
  font: 10.5px/1.75 var(--mono);
  color: #8f8a80;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

details.plan .body b {
  display: block;
  margin-top: 7px;
  color: var(--dim);
  font-weight: 400;
  font-size: 9.5px;
  letter-spacing: 0.12em;
}

.live-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font: 10px/1.6 var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
}

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}

.live-timer {
  margin-left: auto;
  color: var(--dim);
}

.caret {
  display: inline-block;
  width: 6px;
  height: 13px;
  margin-left: 2px;
  vertical-align: -1px;
  background: var(--accent);
  animation: blink 1.05s steps(1) infinite;
}

.turn-actions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------- composer */

.composer {
  flex: 0 0 auto;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: #0c0c0e;
  display: grid;
  gap: 9px;
}

.ref-attach {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  background: #0a0a0c;
}

.ref-attach-thumb {
  flex: 0 0 auto;
  width: 42px;
  height: 54px;
  border: 1px solid var(--line-strong);
  background: #111;
  overflow: hidden;
}

.ref-attach-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ref-attach-info {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ref-attach-info b {
  font: 9px/1 var(--mono);
  font-weight: 400;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.ref-attach-info span {
  font: 10px/1.4 var(--mono);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ref-remove {
  margin-left: auto;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  border-radius: 2px;
  cursor: pointer;
}

.ref-remove:hover {
  color: var(--accent);
  border-color: rgba(226, 84, 58, 0.5);
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.composer-tools .chip {
  max-width: none;
  min-width: 0;
}

.composer-tools .chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.has-ref {
  color: var(--paper);
  border-color: rgba(226, 84, 58, 0.55);
  background: rgba(226, 84, 58, 0.08);
}

.turn-ref {
  display: flex;
  align-items: center;
  gap: 9px;
}

.turn-ref img {
  width: 44px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  display: block;
}

.turn-ref span {
  font: 9px/1.4 var(--mono);
  letter-spacing: 0.12em;
  color: var(--dim);
}

.composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 168px;
  resize: none;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: 14px/1.65 var(--sans);
  padding: 4px 4px 0;
}

.composer textarea::placeholder {
  color: var(--dim);
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 2px;
  font: 10px/1 var(--mono);
  letter-spacing: 0.03em;
  transition: 0.16s;
  max-width: 72%;
}

.chip:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.chip svg {
  width: 11px;
  height: 11px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}

.chip[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.send {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--paper);
  background: var(--paper);
  color: #131312;
  border-radius: 2px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: 0.16s;
}

.send:hover {
  background: #fffdf7;
  border-color: #fffdf7;
}

.send kbd {
  font: 9.5px/1 var(--mono);
  color: rgba(19, 19, 18, 0.55);
  border: 1px solid rgba(19, 19, 18, 0.22);
  border-radius: 2px;
  padding: 2px 4px;
}

.send:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.send.busy {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

/* 参数面板 */

.params {
  border: 1px solid var(--line);
  background: #0a0a0c;
  padding: 12px;
  display: grid;
  gap: 13px;
  animation: fade 0.2s ease both;
}

.param-row {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.param-label {
  width: 50px;
  flex: 0 0 auto;
  font: 9.5px/1 var(--mono);
  letter-spacing: 0.14em;
  color: var(--dim);
  text-transform: uppercase;
}

.segs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.seg {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: 10px/1 var(--mono);
  border-radius: 2px;
  transition: 0.14s;
}

.seg:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.seg:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.seg.on {
  color: var(--paper);
  border-color: rgba(226, 84, 58, 0.55);
  background: rgba(226, 84, 58, 0.1);
}

#seedInput {
  width: 118px;
  height: 26px;
  padding: 0 8px;
  background: #0b0b0d;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
  font: 10.5px/1 var(--mono);
  outline: none;
}

#seedInput:focus {
  border-color: var(--line-strong);
}

.param-hint {
  font-size: 10px;
  color: var(--dim);
  line-height: 1.5;
}

.switch {
  position: relative;
  display: inline-flex;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  width: 32px;
  height: 18px;
  border-radius: 10px;
  background: rgba(236, 232, 224, 0.1);
  border: 1px solid var(--line);
  display: block;
  position: relative;
  transition: 0.18s;
}

.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: 0.18s;
}

.switch input:checked + .switch-track {
  background: rgba(226, 84, 58, 0.28);
  border-color: rgba(226, 84, 58, 0.5);
}

.switch input:checked + .switch-track .switch-knob {
  left: 16px;
  background: var(--paper);
}

/* ------------------------------------------------------ misc / motion */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  animation: fade 0.2s ease;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  transform: translate(-50%, 12px);
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  background: #141416;
  color: var(--ink);
  font-size: 12px;
  border-radius: 2px;
  box-shadow: 0 18px 50px -16px rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: 0.24s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: scale(0.985);
    filter: saturate(0.7);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

@keyframes scan {
  from {
    top: -40%;
  }
  to {
    top: 110%;
  }
}

@keyframes slide {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(380%);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    transform: scale(0.8);
  }
}

@keyframes blink {
  0%,
  49% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0;
  }
}

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

/* --------------------------------------------------------------- gate */

.gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 26px;
  overflow: auto;
  background:
    radial-gradient(110% 70% at 50% 0%, rgba(236, 232, 224, 0.05), transparent 60%),
    var(--bg);
  animation: fade 0.45s ease both;
}

.gate-frame {
  position: relative;
  width: min(1020px, 100%);
  min-height: min(78vh, 740px);
  display: flex;
  flex-direction: column;
  padding: clamp(22px, 3.2vw, 40px);
  border: 1px solid var(--line);
  background: rgba(13, 13, 15, 0.78);
}

.gate-frame::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(236, 232, 224, 0.04);
  pointer-events: none;
}

.gate-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gate-main {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: end;
  padding: clamp(30px, 6vh, 70px) 0;
}

.gate-copy h2 {
  margin: 18px 0 0;
  font: 400 clamp(52px, 7.2vw, 96px) / 1.03 var(--serif);
  letter-spacing: 0.02em;
  color: var(--ink);
}

.gate-copy h2 em {
  font-style: normal;
  color: var(--paper);
  position: relative;
  white-space: nowrap;
}

.gate-copy h2 em::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 4px;
  bottom: 7px;
  height: 1px;
  background: var(--accent);
  opacity: 0.7;
}

.gate-sub {
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.95;
}

.gate-form {
  display: grid;
  gap: 12px;
  align-content: end;
}

.gate-form label {
  color: var(--muted);
}

.gate-form input {
  width: 100%;
  height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--paper);
  font: 16px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  outline: none;
  transition: 0.16s;
}

.gate-form input::placeholder {
  color: var(--dim);
  letter-spacing: 0.14em;
}

.gate-form input:focus {
  border-color: rgba(226, 84, 58, 0.7);
  background: rgba(226, 84, 58, 0.03);
}

.gate-form .send {
  width: 100%;
  height: 46px;
  justify-content: center;
  gap: 10px;
}

.gate-form .send svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gate-form .send:disabled {
  opacity: 0.55;
}

.gate-error {
  margin: 0;
  color: #e08b78;
  font-size: 12px;
  line-height: 1.6;
}

.gate-hint {
  margin: 2px 0 0;
  color: var(--dim);
  font-size: 11px;
  line-height: 1.75;
}

.gate-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

body.gated .topbar,
body.gated .workspace,
body.booting .topbar,
body.booting .workspace {
  visibility: hidden;
}

/* ------------------------------------------------------------ 响应式 */

@media (max-width: 1240px) {
  .workspace {
    grid-template-columns: 236px minmax(0, 1fr) 368px;
  }
  .topbar-tags {
    display: none;
  }
}

@media (max-width: 1020px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) 372px;
  }
  .rail {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 284px;
    z-index: 20;
    transform: translateX(-102%);
    transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 30px 0 80px -30px rgba(0, 0, 0, 0.9);
  }
  .rail.open {
    transform: none;
  }
  .rail-toggle {
    display: inline-flex;
  }
  .stage {
    padding: 16px 20px 18px;
  }
}

@media (max-width: 780px) {
  .topbar {
    height: 58px;
    gap: 14px;
    padding: 0 14px;
  }
  .brand-sub {
    display: none;
  }
  .brand-name {
    font-size: 17px;
  }
  .pod-name {
    display: none;
  }
  .pod-val {
    display: none;
  }
  .pod {
    gap: 5px;
  }
  .pod .dot {
    width: 6px;
    height: 6px;
  }
  .pod-group {
    gap: 10px;
  }
  .quota {
    gap: 5px;
    padding-right: 10px;
  }
  .quota-label {
    display: none;
  }
  .quota-meter {
    width: 26px;
  }
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 46vh) minmax(0, 1fr);
  }
  .thread-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .stage {
    padding: 12px 14px 14px;
  }
  .stage-head {
    padding-bottom: 10px;
  }
  .empty {
    padding: 0;
  }
  .empty h2 {
    font-size: 30px;
    margin: 12px 0 10px;
  }
  .empty-sub {
    display: none;
  }
  .seed {
    font-size: 11px;
    padding: 6px 9px;
  }
  .seeds .seed:nth-child(n + 4) {
    display: none;
  }
  .image-box {
    padding: 6px;
  }
  .plate-cap {
    padding-top: 9px;
    gap: 5px;
  }
  .cap-prompt {
    display: none;
  }
  .cap-title {
    font-size: 13px;
  }
  .working-frame {
    max-height: 34vh;
  }
  .working-hint {
    display: none;
  }
  .thread-head {
    padding: 13px 16px 10px;
  }
  .thread {
    padding: 14px 16px 18px;
    gap: 18px;
  }
  .composer {
    padding: 10px 12px 12px;
  }
  .composer textarea {
    min-height: 44px;
    font-size: 14px;
  }
  .composer-tools {
    gap: 5px;
  }
  .composer-tools .chip {
    padding: 0 8px;
  }
  #refBtn span {
    display: none;
  }
  .ref-attach {
    gap: 8px;
  }
  .ref-attach-thumb {
    width: 36px;
    height: 46px;
  }
  .chip {
    max-width: 64%;
  }
  .toast {
    bottom: 88px;
  }
  .gate {
    padding: 0;
  }
  .gate-frame {
    width: 100%;
    min-height: 100dvh;
    border: 0;
    padding: 22px;
    background: var(--bg);
  }
  .gate-frame::before {
    display: none;
  }
  .gate-main {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 34px;
    padding: 40px 0 28px;
  }
  .gate-copy h2 {
    font-size: clamp(46px, 14vw, 68px);
  }
  .gate-sub {
    margin-top: 18px;
  }
  .gate-form input {
    height: 50px;
    font-size: 16px;
  }
  .gate-foot {
    font-size: 8px;
    gap: 10px;
  }
  .gate-foot .eyebrow {
    font-size: 8px;
    letter-spacing: 0.12em;
  }
}

@media (max-width: 420px) {
  .seeds .seed:nth-child(n + 3) {
    display: none;
  }
  .cap-actions .btn:nth-child(4) {
    display: none;
  }
}
