/* ============================================================================
   STUDIO — one theme (black + white), one infinite canvas, one command bar.
   ========================================================================== */

:root {
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", "PingFang SC",
    "Microsoft YaHei", monospace;

  --bg: #0a0a0b;          /* the infinite plane */
  --grid: #ffffff14;      /* dot grid */
  --ink: #f4f4f2;         /* white */
  --ink-dim: #f4f4f288;
  --ink-faint: #f4f4f244;
  --line: #ffffff1f;
  --line-2: #ffffff33;
  --panel: #161618;       /* bars & flyouts */
  --panel-2: #1f1f22;
  --panel-line: #ffffff1a;

  --shadow: 0 24px 60px -20px #000000cc, 0 8px 22px -10px #00000099;
  --glow: 0 0 0 1px var(--line), 0 24px 50px -24px #000000e6;

  --r: 15px;
  --ease: cubic-bezier(0.22, 0.9, 0.26, 1);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}
body {
  font-family: var(--mono);
  color: var(--ink);
  background: var(--bg);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}
button {
  font-family: inherit;
  cursor: pointer;
  color: inherit;
}
::selection {
  background: var(--ink);
  color: var(--bg);
}

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

/* --------------------------------------------------------------- canvas --- */
.canvas {
  position: absolute;
  inset: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--grid) 1px, transparent 1.5px);
  background-repeat: repeat;
  cursor: grab;
  touch-action: none;
  overflow: hidden;
}
.canvas.is-panning {
  cursor: grabbing;
}
/* subtle radial fade toward edges for depth */
.canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 95% at 50% 45%, transparent 55%, #000000aa 100%);
}

.world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* --------------------------------------------------------------- items ---- */
.item {
  position: absolute;
  transform: translate(-50%, -50%);
  background: #000;
  border: 1px solid var(--line-2);
  box-shadow: var(--glow);
  overflow: hidden;
  cursor: grab;
  transition: box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
  animation: drop 0.5s var(--ease) both;
}
.item:active {
  cursor: grabbing;
}
.item.is-ref {
  border-style: dashed;
  border-color: var(--line);
  opacity: 0.92;
}
.item.is-selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink), 0 24px 50px -24px #000000e6;
}
.item__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}
.item__tag {
  position: absolute;
  top: 6px;
  left: 7px;
  font-size: 8.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: #000000aa;
  padding: 2px 5px;
  border-radius: 4px;
  pointer-events: none;
}
.item__bar {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(-3px);
  transition: 0.2s var(--ease);
}
.item:hover .item__bar {
  opacity: 1;
  transform: none;
}
.mini {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-2);
  background: #000000b3;
  backdrop-filter: blur(6px);
  border-radius: 7px;
  color: var(--ink);
  transition: 0.15s var(--ease);
}
.mini:hover {
  background: var(--ink);
  color: #000;
  border-color: var(--ink);
}

/* generation frame (pending) */
.item.is-pending {
  border-style: dashed;
  border-color: var(--ink-dim);
  background: #0d0d0f;
  display: grid;
  place-items: center;
  cursor: default;
  animation: none;
}
.frame__scan {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--ink);
  box-shadow: 0 0 16px 2px #ffffff66;
  animation: scan 1.7s var(--ease) infinite;
}
.frame__pct {
  font-size: 20px;
  font-weight: 300;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.frame__pct small {
  font-size: 10px;
  color: var(--ink-dim);
}

/* ------------------------------------------------------------- command --- */
.bar {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 5px;
  width: min(96vw, 680px);
  padding: 7px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--panel-line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  animation: bar-in 0.55s var(--ease) both;
}
.tools {
  display: flex;
  gap: 1px;
  flex: none;
}

/* primary tool + flyout group */
.tg {
  position: relative;
}
.t {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  border-radius: 11px;
  color: var(--ink-dim);
  transition: 0.16s var(--ease);
}
.t:hover {
  color: var(--ink);
  background: #ffffff0f;
}
.t.on {
  color: var(--ink);
  background: #ffffff17;
}
.t--val {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  width: auto;
  min-width: 40px;
  padding: 0 7px;
}
.t__val {
  font-size: 8px;
  letter-spacing: 0.02em;
  line-height: 1;
  color: inherit;
  opacity: 0.85;
}
.t__dot {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 6px;
  height: 6px;
  padding: 0 3px;
  border-radius: 99px;
  background: var(--ink);
  color: #000;
  font-size: 8px;
  line-height: 6px;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.divider {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--panel-line);
  flex: none;
}

/* prompt field */
.field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 4px 0 8px;
}
.field input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.01em;
}
.field input::placeholder {
  color: var(--ink-faint);
}
.magic {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-faint);
  transition: 0.15s var(--ease);
}
.magic:hover {
  color: var(--ink-dim);
}
.magic.on {
  color: var(--ink);
  background: #ffffff14;
}

/* send key */
.send {
  flex: none;
  position: relative;
  width: 40px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: var(--ink);
  color: #000;
  transition: 0.16s var(--ease);
}
.send:hover {
  transform: translateY(-1px);
}
.send:disabled {
  background: #ffffff1f;
  color: var(--ink-faint);
  cursor: not-allowed;
  transform: none;
}
.send.is-busy {
  background: transparent;
  cursor: pointer;
}
.send__ring {
  position: absolute;
  inset: 5px;
  border-radius: 8px;
  border: 1.5px solid #ffffff22;
  border-top-color: var(--ink);
  animation: spin 0.8s linear infinite;
}
/* click the busy button to cancel — a stop square appears on hover */
.send__stop {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: var(--ink);
  opacity: 0;
  transition: opacity 0.15s var(--ease);
}
.send.is-busy:hover .send__stop {
  opacity: 1;
}

/* tooltip (shared) */
[data-tip] {
  position: relative;
}
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(3px);
  padding: 4px 7px;
  background: var(--ink);
  color: #000;
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: 0.15s var(--ease);
  /* above flyouts (z 6) so a hovered tool's tip is never hidden behind a panel */
  z-index: 12;
}
[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ----------------------------------------------------------- flyout ------ */
.flyout {
  position: absolute;
  bottom: calc(100% + 11px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  box-shadow: var(--shadow);
  padding: 9px;
  width: max-content;
  max-width: min(86vw, 440px);
  z-index: 6;
  animation: fly-in 0.18s var(--ease) both;
}
.flyout::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 11px;
  height: 11px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--panel);
  border-right: 1px solid var(--panel-line);
  border-bottom: 1px solid var(--panel-line);
}
.flyrow {
  display: flex;
  gap: 5px;
  align-items: stretch;
}
.flycol {
  display: grid;
  gap: 9px;
}
.flylabel {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

/* secondary tool button */
.s {
  position: relative;
  min-width: 44px;
  height: 48px;
  padding: 0 6px;
  display: grid;
  place-items: center;
  gap: 3px;
  grid-auto-flow: row;
  border: 1px solid var(--line);
  background: #ffffff08;
  border-radius: 10px;
  color: var(--ink-dim);
  transition: 0.14s var(--ease);
}
.s:hover {
  color: var(--ink);
  border-color: var(--line-2);
}
.s.on {
  color: var(--ink);
  border-color: var(--ink);
  background: #ffffff14;
}
.s small {
  font-size: 8px;
  letter-spacing: 0.06em;
}
.ratio {
  display: grid;
  place-items: center;
  width: 20px;
  height: 18px;
}
.ratio i {
  display: block;
  border: 1.4px solid currentColor;
  border-radius: 2px;
}

/* segmented */
.seg {
  display: inline-flex;
  background: #ffffff0a;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: 0.14s var(--ease);
}
.seg button:hover {
  color: var(--ink-dim);
}
.seg button.on {
  background: var(--ink);
  color: #000;
}

.frow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.ipt {
  width: 100%;
  background: #ffffff08;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  outline: none;
}
.ipt:focus {
  border-color: var(--ink);
}
.ipt.num {
  width: 78px;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.num::-webkit-outer-spin-button,
.num::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.lock {
  width: 30px;
  height: 30px;
  flex: none;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #ffffff08;
  border-radius: 8px;
  color: var(--ink-dim);
  transition: 0.14s var(--ease);
}
.lock:hover {
  color: var(--ink);
}
.lock.on {
  color: var(--ink);
  border-color: var(--ink);
}

/* brand rows */
.brow {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-width: 200px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--ink);
  transition: 0.14s var(--ease);
}
.brow:hover {
  background: #ffffff0a;
}
.brow.on {
  border-color: var(--ink);
}
.brow .nm {
  font-size: 12px;
}
.sws {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
}
.sw {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  border: 1px solid var(--line-2);
}

/* reference thumbs */
.thumb {
  position: relative;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  border: 0;
  border-radius: 5px;
  background: #000000bf;
  color: #fff;
  display: grid;
  place-items: center;
}
.add {
  width: 48px;
  height: 48px;
  border: 1px dashed var(--line-2);
  background: transparent;
  border-radius: 9px;
  color: var(--ink-dim);
  display: grid;
  place-items: center;
}
.add:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* zoom readout (faint, corner) */
.zoom {
  position: fixed;
  left: 14px;
  bottom: 16px;
  z-index: 30;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
  user-select: none;
  pointer-events: none;
}

/* toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 80vw;
  padding: 8px 12px;
  background: var(--ink);
  color: #000;
  border-radius: 10px;
  font-size: 11.5px;
  box-shadow: var(--shadow);
  animation: fly-in 0.22s var(--ease) both;
}

/* ------------------------------------------------------- konva canvas ---- */
.stagewrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--bg);
}

/* gallery panel (thumbnails, lazy) */
.gallery {
  display: grid;
  grid-template-columns: repeat(5, 60px);
  gap: 6px;
  max-width: 336px;
  max-height: 320px;
  overflow-y: auto;
  padding: 1px;
}
.gthumb {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 7px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
}
.gthumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: grab;
  display: block;
}
.gthumb img:active {
  cursor: grabbing;
}
.gthumb__del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 5px;
  background: #000000bf;
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: 0.15s var(--ease);
}
.gthumb:hover .gthumb__del {
  opacity: 1;
}
.gthumb__del:hover {
  background: var(--danger, #dc2626);
}

/* --------------------------------------------------- gallery side drawer -- */
.gdrawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  /* above the command bar (z 40) so the bar never covers the drawer */
  z-index: 48;
  width: 348px;
  max-width: 88vw;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--panel) 97%, transparent);
  backdrop-filter: blur(20px) saturate(1.2);
  border-left: 1px solid var(--panel-line);
  box-shadow: -28px 0 70px -34px #000;
  animation: drawer-in 0.22s var(--ease) both;
}
@keyframes drawer-in {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}
.gdrawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 12px 9px;
}
.gtabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: #ffffff0a;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.gtabs button {
  padding: 5px 16px;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.14s var(--ease);
}
.gtabs button.on {
  background: var(--ink);
  color: #000;
}
.gdrawer__close {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  border-radius: 8px;
  cursor: pointer;
}
.gdrawer__close:hover {
  background: #ffffff10;
  color: var(--ink);
}
.gsearch {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 12px 6px;
  padding: 7px 10px;
  background: #ffffff0a;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink-faint);
}
.gsearch input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 12.5px;
  outline: none;
}
.gsearch button {
  border: 0;
  background: transparent;
  color: var(--ink-faint);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.gsearch button:hover {
  color: var(--ink);
}
.gdrawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 100px;
}
.gsec {
  margin-bottom: 16px;
}
.gsec__date {
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  padding: 7px 2px;
  background: linear-gradient(var(--panel) 60%, transparent);
  z-index: 1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-dim);
}
.gsec__date i {
  font-style: normal;
  font-size: 10px;
  color: var(--ink-faint);
  background: #ffffff0d;
  padding: 1px 7px;
  border-radius: 99px;
}
.gsec__date::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--panel-line);
}
.ggrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 4px;
}
.gcard {
  position: relative;
  aspect-ratio: 1;
  border-radius: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
}
.gcard img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  display: block;
  transition: transform 0.2s var(--ease);
}
.gcard:active img {
  cursor: grabbing;
}
.gcard:hover img {
  transform: scale(1.06);
}
.gcard__del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 6px;
  background: #000000c4;
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  cursor: pointer;
  transition: 0.15s var(--ease);
}
.gcard:hover .gcard__del {
  opacity: 1;
}
.gcard__del:hover {
  background: #dc2626;
}
.gcard__name {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 6px 4px;
  font-size: 9.5px;
  color: #fff;
  background: linear-gradient(transparent, #000000cc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.gempty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 0;
  color: var(--ink-faint);
  font-size: 12px;
}

/* ---------------------------------------------------- token usage report -- */
/* stat cards */
.tstats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  padding: 4px 12px 10px;
}
.tstat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  background: #ffffff08;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.tstat--lg {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), #ffffff06);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
.tstat__k {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}
.tstat__v {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.tstat--lg .tstat__v {
  font-size: 26px;
  letter-spacing: -0.01em;
}
.tstat__est {
  font-style: normal;
  font-size: 8.5px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #ffffff14;
  color: var(--ink-faint);
}

/* daily bar chart (hand-rolled) */
.tchart {
  padding: 4px 12px 12px;
  border-bottom: 1px solid var(--panel-line);
}
.tchart__head {
  font-size: 10.5px;
  color: var(--ink-dim);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.tbars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 78px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.tbar {
  flex: 1 0 14px;
  min-width: 14px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.tbar > i {
  width: 100%;
  min-height: 3px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 45%, transparent));
  transition: filter 0.15s var(--ease);
}
.tbar:hover > i {
  filter: brightness(1.25);
}
.tbar > span {
  font-size: 8.5px;
  color: var(--ink-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* timeline detail rows */
.tlist {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.trow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.trow:hover {
  background: #ffffff07;
  border-color: var(--line);
}
.trow__thumb {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #ffffff0a;
  border: 1px solid var(--line);
  color: var(--ink-faint);
}
.trow__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.trow__main {
  flex: 1;
  min-width: 0;
}
.trow__name {
  font-size: 12px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.trow__chips {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
  font-size: 9.5px;
  color: var(--ink-faint);
}
.trow__chips em {
  font-style: normal;
  padding: 1px 5px;
  border-radius: 4px;
  background: #ffffff10;
  color: var(--ink-dim);
}
.trow__tok {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  text-align: right;
}
.trow__tok b {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.trow__tok small {
  font-size: 9px;
  color: var(--ink-faint);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- prompt templates -- */
.tpl {
  width: 392px;
}
.tplnav {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}
.tplnav__arrow {
  flex: 0 0 auto;
  width: 24px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff0a;
  color: var(--ink-dim);
  cursor: pointer;
  transition: 0.14s var(--ease);
}
.tplnav__arrow:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
}
.tplnav__arrow--l svg {
  transform: rotate(180deg);
}
.tplnav__arrow.off {
  opacity: 0.32;
  pointer-events: none;
}
.tplnav--noscroll .tplnav__arrow {
  display: none;
}
.tpltabs {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tpltabs::-webkit-scrollbar {
  display: none;
}
.tpltabs button {
  padding: 5px 11px;
  white-space: nowrap;
}
.tplhint {
  padding: 2px 14px 10px;
  font-size: 11px;
  color: var(--ink-dim);
  line-height: 1.5;
}
.tplgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pcard {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #ffffff06;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  transition:
    border-color 0.15s var(--ease),
    transform 0.15s var(--ease);
}
.pcard:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  transform: translateY(-2px);
}
.pcard__img {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #0000002e;
  overflow: hidden;
}
.pcard__img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pcard__ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--ink-faint);
  font-size: 11px;
  background:
    radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--accent) 22%, transparent), transparent),
    linear-gradient(135deg, #ffffff10, #ffffff03);
}
.pcard__apply {
  position: absolute;
  inset: auto 0 0 0;
  padding: 14px 9px 7px;
  font-size: 11px;
  font-weight: 550;
  color: #fff;
  background: linear-gradient(0deg, #000000c2, transparent);
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.15s var(--ease),
    transform 0.15s var(--ease);
}
.pcard:hover .pcard__apply {
  opacity: 1;
  transform: translateY(0);
}
.pcard__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 0 10px 10px;
}
.pcard__title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}
.pcard__style {
  font-size: 9.5px;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* lightbox (zoom + details) */
.lightbox {
  position: relative;
  display: flex;
  max-width: min(94vw, 940px);
  max-height: 88vh;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: fly-in 0.2s var(--ease) both;
}
.lightbox__img {
  flex: 1;
  min-width: 0;
  display: grid;
  place-items: center;
  background: #000;
  padding: 8px;
}
.lightbox__img img {
  max-width: 100%;
  max-height: 86vh;
  object-fit: contain;
  display: block;
}
.lightbox__side {
  width: 244px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px;
  border-left: 1px solid var(--panel-line);
  overflow-y: auto;
}
.lightbox__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.lightbox__prompt {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-dim);
  max-height: 32vh;
  overflow-y: auto;
}
.lightbox__meta {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.lightbox__meta div {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
}
.lightbox__meta dt {
  color: var(--ink-faint);
  margin: 0;
}
.lightbox__meta dd {
  color: var(--ink-dim);
  margin: 0;
  font-family: var(--mono);
}
.lightbox__acts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}
.lightbox__hint {
  font-size: 10px;
  color: var(--ink-faint);
}
.lightbox__close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: #00000066;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.lightbox__close:hover {
  background: #000000aa;
}

.grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(var(--grid) 1px, transparent 1.5px);
  background-repeat: repeat;
}

/* contextual image-edit toolbar (appears above the selected image) */
.editbar {
  position: absolute;
  z-index: 30;
  transform: translate(-50%, calc(-100% - 12px));
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 5px;
  max-width: 94vw;
  background: color-mix(in srgb, var(--panel) 93%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--panel-line);
  border-radius: 13px;
  box-shadow: var(--shadow);
  animation: editbar-in 0.16s var(--ease) both;
}
@keyframes editbar-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-100% - 4px)) scale(0.96);
  }
}
.editbar__t {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  border-radius: 9px;
  color: var(--ink-dim);
  font-size: 12px;
  white-space: nowrap;
  transition: 0.14s var(--ease);
}
.editbar__t:hover {
  color: var(--ink);
  background: #ffffff12;
}
.editbar__t.on {
  color: var(--ink);
  background: #ffffff1c;
}
.editbar__t:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.editbar__icon {
  padding: 8px;
}
.editbar__primary {
  color: var(--ink);
}
.editbar__primary:hover:not(:disabled) {
  background: var(--ink);
  color: #000;
}
.editbar__sep {
  width: 1px;
  height: 20px;
  margin: 0 3px;
  flex: none;
  background: var(--panel-line);
}
.editbar__group {
  position: relative;
  display: flex;
}
@keyframes pop-fade {
  from {
    opacity: 0;
  }
}
.editpop {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  min-width: 152px;
  padding: 5px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  backdrop-filter: blur(16px) saturate(1.2);
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  box-shadow: var(--shadow);
  animation: pop-fade 0.14s var(--ease) both;
}
.editpop--chips {
  right: auto;
  left: 50%;
  transform: translateX(-50%);
  min-width: 0;
}
.editpop__hd {
  font-size: 10px;
  color: var(--ink-faint);
  padding: 3px 6px 7px;
  letter-spacing: 0.04em;
}
.editpop__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-width: 224px;
  padding: 0 2px 2px;
}
.editpop__chips button {
  padding: 6px 11px;
  border: 1px solid var(--line);
  background: #ffffff08;
  color: var(--ink-dim);
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  transition: 0.13s var(--ease);
}
.editpop__chips button:hover {
  background: var(--ink);
  color: #000;
  border-color: var(--ink);
}
.editpop__i {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  border-radius: 7px;
  font-size: 12px;
  text-align: left;
  transition: 0.12s var(--ease);
}
.editpop__i:hover {
  background: #ffffff12;
  color: var(--ink);
}
.editpop__i.danger:hover {
  background: color-mix(in srgb, #ff5a5a 16%, transparent);
  color: #ffb4b4;
}

/* generation frame overlay */
.genframe {
  position: absolute;
  z-index: 20;
  cursor: grab;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(130% 130% at 50% 45%, #16161c, #08080a);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 30px 80px -28px #000,
    0 0 70px -12px rgba(255, 255, 255, 0.22);
}
.genframe:active {
  cursor: grabbing;
}
.genframe > * {
  pointer-events: none;
}
.genframe__glow {
  position: absolute;
  inset: -60%;
  background: conic-gradient(
    from 0deg,
    transparent 0 52%,
    rgba(255, 255, 255, 0.55) 70%,
    rgba(255, 255, 255, 0.08) 80%,
    transparent 88% 100%
  );
  filter: blur(16px);
  opacity: 0.8;
  animation: spin 3.2s linear infinite;
}
.genframe__aurora {
  position: absolute;
  inset: -25%;
  background: linear-gradient(
    115deg,
    transparent 22%,
    rgba(255, 255, 255, 0.1) 40%,
    rgba(255, 255, 255, 0.24) 50%,
    rgba(255, 255, 255, 0.1) 60%,
    transparent 78%
  );
  filter: blur(20px);
  mix-blend-mode: screen;
  animation: aurora 2.8s ease-in-out infinite;
}
.genframe__core {
  position: absolute;
  width: 46%;
  height: 46%;
  left: 27%;
  top: 27%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4), transparent 70%);
  filter: blur(12px);
  animation: corepulse 1.9s ease-in-out infinite;
}
.genframe__particles {
  position: absolute;
  inset: 0;
}
.genframe__particles span {
  position: absolute;
  bottom: -6px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 7px rgba(255, 255, 255, 0.9);
  animation-name: rise;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
.genframe__beam {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.95), transparent);
  box-shadow: 0 0 22px 5px rgba(255, 255, 255, 0.45);
  animation: beam 2s var(--ease) infinite;
}
.genframe__pct {
  position: relative;
  z-index: 2;
  font-size: 24px;
  font-weight: 300;
  color: #fff;
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.6);
  font-variant-numeric: tabular-nums;
}
.genframe__pct small {
  font-size: 11px;
  opacity: 0.7;
}
.genframe__provider {
  position: absolute;
  z-index: 2;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #fff;
  white-space: nowrap;
}
.genframe__dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  animation: gen-dot 1.1s ease-in-out infinite;
}
@keyframes gen-dot {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}
.genframe__cancel {
  position: absolute;
  z-index: 3;
  top: 9px;
  right: 9px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  /* override .genframe > * { pointer-events: none } so the button is clickable */
  pointer-events: auto;
  transition:
    background 0.15s var(--ease),
    border-color 0.15s var(--ease);
}
.genframe__cancel:hover {
  background: rgba(206, 44, 44, 0.62);
  border-color: rgba(255, 130, 130, 0.6);
}

/* visible app title (网吧 name in standalone mode) */
.apptitle {
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 30;
  padding: 7px 13px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

/* full-screen notice (standalone login required) */
.notice {
  position: fixed;
  inset: 0;
  z-index: 110; /* above simple mode (90) — a login/auth prompt must always show */
  display: grid;
  place-items: center;
  background: rgba(6, 6, 8, 0.8);
  backdrop-filter: blur(6px);
}
.notice__card {
  width: min(90vw, 360px);
  padding: 28px 26px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  box-shadow: var(--shadow);
  text-align: center;
}
.notice__title {
  font-size: 17px;
  font-weight: 650;
  color: var(--ink);
  margin-bottom: 10px;
}
.notice__msg {
  margin: 0 0 18px;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.6;
}
.notice__btn {
  display: inline-block;
  text-decoration: none;
}
.reveal {
  position: absolute;
  z-index: 19;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.55), transparent 62%);
  animation: bloom 0.85s var(--ease) forwards;
}
@keyframes aurora {
  0%,
  100% {
    transform: translate(-14%, 5%);
    opacity: 0.5;
  }
  50% {
    transform: translate(14%, -5%);
    opacity: 0.95;
  }
}
@keyframes corepulse {
  0%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.18);
    opacity: 0.95;
  }
}
@keyframes rise {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  85% {
    opacity: 0.85;
  }
  100% {
    transform: translateY(-480px) scale(1);
    opacity: 0;
  }
}
@keyframes beam {
  0% {
    top: -3%;
    opacity: 0;
  }
  12%,
  88% {
    opacity: 1;
  }
  100% {
    top: 103%;
    opacity: 0;
  }
}
@keyframes bloom {
  0% {
    opacity: 0;
    transform: scale(0.95);
    filter: blur(10px);
  }
  28% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.05);
    filter: blur(0);
  }
}

/* --------------------------------------------------------- inpaint modal -- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 7, 0.72);
  backdrop-filter: blur(4px);
  animation: modal-fade 0.18s var(--ease) both;
}
@keyframes modal-fade {
  from {
    opacity: 0;
  }
}
.paintbox {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: min(92vw, 760px);
  max-height: 92vh;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: fly-in 0.2s var(--ease) both;
}
.paintbox__head,
.paintbox__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.paintbox__stage {
  position: relative;
  align-self: center;
  max-width: 100%;
  line-height: 0;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.paintbox__stage img {
  display: block;
  max-width: 100%;
  max-height: 56vh;
  object-fit: contain;
  user-select: none;
}
.paintbox__paint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  opacity: 0.5;
  touch-action: none;
}
.paintbox__foot .ipt {
  flex: 1;
}
.btn-ghost,
.btn-go {
  flex: none;
  border-radius: 9px;
  padding: 8px 14px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  transition: 0.15s var(--ease);
}
.btn-ghost:hover {
  color: var(--ink);
}
.btn-go {
  background: var(--ink);
  color: #000;
  border-color: var(--ink);
  font-weight: 600;
}
.btn-go:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* crop overlay */
.crop {
  position: absolute;
  border: 1.5px solid #fff;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  cursor: move;
  touch-action: none;
}
.crop__h {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 2px;
  touch-action: none;
}
.crop__h--nw {
  left: -6px;
  top: -6px;
  cursor: nwse-resize;
}
.crop__h--ne {
  right: -6px;
  top: -6px;
  cursor: nesw-resize;
}
.crop__h--sw {
  left: -6px;
  bottom: -6px;
  cursor: nesw-resize;
}
.crop__h--se {
  right: -6px;
  bottom: -6px;
  cursor: nwse-resize;
}

/* adjust sliders */
.adjust {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 4px 2px 2px;
}
.adjustrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-dim);
}
.adjustrow > span {
  flex: none;
  width: 44px;
}
.adjustrow input[type="range"] {
  flex: 1;
}
.adjustrow > b {
  flex: none;
  width: 32px;
  text-align: right;
  font-family: var(--mono);
  font-weight: 500;
  color: var(--ink);
}

/* 3D multi-angle picker */
.anglebox {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(92vw, 420px);
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: fly-in 0.2s var(--ease) both;
}
.anglepick {
  position: relative;
  height: 252px;
  display: grid;
  place-items: center;
  perspective: 780px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  overflow: hidden;
  background: radial-gradient(circle at 50% 42%, #1a1a22, #0a0a0c 72%);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.anglepick:active {
  cursor: grabbing;
}
.anglefloor {
  position: absolute;
  left: 50%;
  top: 67%;
  width: 184px;
  height: 46px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.5), transparent 70%);
  filter: blur(4px);
  pointer-events: none;
}
.anglecube {
  position: relative;
  width: 116px;
  height: 116px;
  transform-style: preserve-3d;
  pointer-events: none;
}
.anglecube__f {
  position: absolute;
  width: 116px;
  height: 116px;
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 300;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.05);
}
.anglecube__f--front {
  transform: rotateY(0deg) translateZ(58px);
  background: rgba(255, 255, 255, 0.16);
}
.anglecube__f--back {
  transform: rotateY(180deg) translateZ(58px);
}
.anglecube__f--right {
  transform: rotateY(90deg) translateZ(58px);
  background: rgba(255, 255, 255, 0.09);
}
.anglecube__f--left {
  transform: rotateY(-90deg) translateZ(58px);
  background: rgba(255, 255, 255, 0.09);
}
.anglecube__f--top {
  transform: rotateX(90deg) translateZ(58px);
  background: rgba(255, 255, 255, 0.12);
}
.anglecube__f--bottom {
  transform: rotateX(-90deg) translateZ(58px);
  background: rgba(255, 255, 255, 0.03);
}
.anglecam {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  pointer-events: none;
}
.angle__label {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.angle__label span {
  font-size: 11px;
  font-weight: 400;
  color: var(--ink-faint);
  font-family: var(--mono);
}
.angle__presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.angle__presets button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: #ffffff08;
  color: var(--ink-dim);
  border-radius: 8px;
  font-size: 12px;
  transition: 0.13s var(--ease);
}
.angle__presets button:hover {
  background: var(--ink);
  color: #000;
  border-color: var(--ink);
}

/* ----------------------------------------------------------- VI manager -- */
.vimanage {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: #ffffff08;
  color: var(--ink-dim);
  border-radius: 8px;
  font-size: 12px;
  transition: 0.13s var(--ease);
}
.vimanage:hover {
  background: var(--ink);
  color: #000;
  border-color: var(--ink);
}
.vibox {
  display: flex;
  width: min(94vw, 780px);
  height: min(86vh, 620px);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: fly-in 0.2s var(--ease) both;
}
.vilist {
  width: 210px;
  flex: none;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--panel-line);
  background: #ffffff05;
}
.vilist__hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 8px;
  font-size: 12px;
  color: var(--ink-dim);
}
.vinew {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-dim);
  border-radius: 7px;
  font-size: 11px;
}
.vinew:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.vilist__body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.vilist__empty {
  padding: 24px 12px;
  font-size: 11px;
  color: var(--ink-faint);
  text-align: center;
}
.virow {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  border-radius: 8px;
  text-align: left;
  transition: 0.12s var(--ease);
}
.virow:hover {
  background: #ffffff0d;
  color: var(--ink);
}
.virow.on {
  background: #ffffff16;
  color: var(--ink);
}
.virow__logo {
  width: 26px;
  height: 26px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  color: #000;
}
.virow__logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.virow__nm {
  flex: 1;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.virow__del {
  opacity: 0;
  color: var(--ink-faint);
  display: grid;
  place-items: center;
  padding: 2px;
  border-radius: 5px;
}
.virow:hover .virow__del {
  opacity: 1;
}
.virow__del:hover {
  color: #ff8a8a;
}
.viform {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.viform__hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 10px;
  border-bottom: 1px solid var(--panel-line);
}
.viform__body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.vifield {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.vifield > span {
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.viform textarea.ipt {
  resize: vertical;
  line-height: 1.5;
}
.vimedia {
  display: flex;
  align-items: center;
  gap: 10px;
}
.vilogo {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fff;
  color: #888;
  overflow: hidden;
}
.vilogo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.virefs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.viref {
  position: relative;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.viref img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.viref button {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 15px;
  height: 15px;
  border: 0;
  border-radius: 5px;
  background: #000000c0;
  color: #fff;
  display: grid;
  place-items: center;
}
.viref--add {
  display: grid;
  place-items: center;
  background: #ffffff08;
  color: var(--ink-dim);
  border-style: dashed;
}
.viref--add:hover {
  color: var(--ink);
}
.vipalette {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.viswatch {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--panel-line);
}
.viswatch button {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  opacity: 0;
  text-shadow: 0 0 3px #000;
}
.viswatch:hover button {
  opacity: 1;
}
.viswatch--add {
  display: grid;
  place-items: center;
  background: #ffffff08;
  color: var(--ink-dim);
  border-style: dashed;
  cursor: pointer;
  overflow: hidden;
}
.viswatch--add input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.viform__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--panel-line);
}
.viform__gen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 99px;
  background: var(--line-2);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
}

/* ----------------------------------------------------- context menu ------ */
.ctxmenu {
  position: fixed;
  z-index: 70;
  min-width: 188px;
  padding: 5px;
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  box-shadow: var(--shadow);
  animation: ctx-in 0.12s var(--ease) both;
}
@keyframes ctx-in {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(-3px);
  }
}
.ctxmenu__item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 7px 9px;
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  border-radius: 7px;
  text-align: left;
  font-family: var(--mono);
  font-size: 12px;
  transition: 0.12s var(--ease);
}
.ctxmenu__item:hover {
  background: #ffffff10;
  color: var(--ink);
}
.ctxmenu__item.danger:hover {
  background: color-mix(in srgb, #ff5a5a 16%, transparent);
  color: #ffb4b4;
}
.ctxmenu__item:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.ctxmenu__kbd {
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
}
.ctxmenu__sep {
  height: 1px;
  margin: 4px 6px;
  background: var(--panel-line);
}

/* ---------------------------------------------------------------- motion - */
@keyframes bar-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(16px);
  }
}
@keyframes fly-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(7px) scale(0.97);
  }
}
@keyframes drop {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.94);
  }
}
@keyframes scan {
  0% {
    top: -2%;
    opacity: 0;
  }
  12%,
  88% {
    opacity: 1;
  }
  100% {
    top: 102%;
    opacity: 0;
  }
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    /* Cap iterations too — without this, `infinite` animations loop a full cycle
       every 0.01ms and strobe instead of stopping. */
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  /* Loading indicators are functional feedback during a long (60-70s) generation,
     so keep them animating smoothly — re-assert their real timings so the blanket
     reset above doesn't turn them into a flicker. The busiest motion (rising
     particles) is intentionally left to settle. */
  .send__ring {
    animation: spin 1.4s linear infinite !important;
  }
  .genframe__glow {
    animation: spin 3.2s linear infinite !important;
  }
  .genframe__aurora {
    animation: aurora 2.8s ease-in-out infinite !important;
  }
  .genframe__core {
    animation: corepulse 1.9s ease-in-out infinite !important;
  }
  .genframe__beam {
    animation: beam 2s var(--ease) infinite !important;
  }
  .genframe__dot {
    animation: gen-dot 1.1s ease-in-out infinite !important;
  }
  /* "尘归 · Ashfall": the one-click waiting animation is a brief, user-triggered loading
     state and the drifting dust is the intended experience, so re-assert its animations
     at FULL timing here — otherwise the blanket "*{animation:0.01ms}" reset above would
     freeze the image defocus, the ring spin and the glow. The canvas dust keeps running
     because simplebusy.js no longer bails under reduced motion. */
  .simplebusy {
    animation: sb-fade 0.5s var(--ease) both !important;
  }
  .simpleframe__img.is-dissolving {
    animation:
      sb-defocus 7s var(--ease) forwards !important,
      sb-breathe 5s ease-in-out 7s infinite alternate !important;
  }
  .simplebusy__ring {
    animation: simple-spin 1.1s linear infinite !important;
  }
  .simplebusy__halo {
    animation: simple-spin 3.6s linear infinite reverse !important;
  }
  .simplebusy__glow {
    animation: sb-glow 2.4s ease-in-out infinite !important;
  }
  .simplebusy__core {
    animation: sb-core-in 0.9s var(--ease) 5.8s forwards !important;
  }
}

/* ----------------------------------------------------------- simple mode -- */
.simplewrap {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(120% 120% at 50% 0%, #14141a 0%, #070708 70%);
  backdrop-filter: blur(8px);
  animation: drop 0.4s var(--ease) both;
}
.simplecard {
  width: min(94vw, 460px);
  max-height: 94vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.simplehead {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.simplehead__title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--ink);
}
.simpleexit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  transition: 0.15s var(--ease);
}
.simpleexit:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
}
.simplefields {
  display: flex;
  gap: 10px;
}
.simplefield {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.simplefield__lbl {
  font-size: 11px;
  color: var(--ink-faint);
}
.simplefield__ipt {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  font-size: 13px;
  color: var(--ink);
  background: #0e0e10;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s var(--ease);
}
.simplefield__ipt:focus {
  border-color: var(--ink-dim);
}
.simpleframe {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 56vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0c0c0e;
}
.simpleframe__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  animation: drop 0.5s var(--ease) both;
}
.simpleframe__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  color: var(--ink-faint);
  font-size: 12.5px;
}
/* ============================================================ */
/* "尘归 · Ashfall" waiting animation — the original image defocuses and sheds a dense
   field of glowing dust (a single <canvas> in simplebusy.js), a luminous wavefront
   sweeps it during the build-up, then a counter-rotating jewel ring ignites. The image
   filter is driven by @keyframes ONLY (never inline transition) so the zoom/pan
   controller, which rewrites img.style.transform/.transition on every interaction,
   never clobbers it. The blur lives ONLY on the image (no veil backdrop-filter). */

/* L0 — the reference image: defocus once (forwards), then breathe forever so it never
   re-sharpens / never looks finished. mask rim eroded by JS via --sb-keep/--sb-gone
   (floored, so the photo is ALWAYS visible — honoring 在原图上). */
.simpleframe__img.is-dissolving {
  animation:
    sb-defocus 7s var(--ease) forwards,
    sb-breathe 5s ease-in-out 7s infinite alternate;
  -webkit-mask: radial-gradient(120% 120% at 50% 47%, #000 var(--sb-keep, 100%), rgba(0, 0, 0, 0.6) var(--sb-gone, 140%));
  mask: radial-gradient(120% 120% at 50% 47%, #000 var(--sb-keep, 100%), rgba(0, 0, 0, 0.6) var(--sb-gone, 140%));
  will-change: filter;
}
.simpleframe__img.is-revealing {
  animation: none;
  filter: blur(0) brightness(1) saturate(1);
  transition: filter 0.6s var(--ease);
  -webkit-mask: none;
  mask: none;
}
@keyframes sb-defocus {
  0% {
    filter: blur(0) brightness(1) saturate(1);
  }
  50% {
    filter: blur(8px) brightness(0.84) saturate(1.14);
  }
  100% {
    filter: blur(13px) brightness(0.78) saturate(1.16);
  }
}
@keyframes sb-breathe {
  from {
    filter: blur(12.5px) brightness(0.78) saturate(1.16);
  }
  to {
    filter: blur(14px) brightness(0.8) saturate(1.2);
  }
}

/* L1 — overlay + dark veil (plain gradient, NO backdrop-filter: only one full-frame
   blur exists, on the image). */
.simplebusy {
  position: absolute;
  inset: 0;
  overflow: hidden;
  animation: sb-fade 0.5s var(--ease) both;
}
.simplebusy__veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 42%, transparent 38%, rgba(8, 8, 10, 0.46) 100%),
    rgba(8, 8, 10, 0.32);
}
@keyframes sb-fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* L2 — luminous wavefront bar (translateY + opacity driven by JS; ::before = glow). */
.simplebusy__front {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, #29d0ff 30%, #7a5cff 70%, transparent);
  filter: drop-shadow(0 0 6px rgba(41, 208, 255, 0.8));
  will-change: transform, opacity;
}
.simplebusy__front::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -28px;
  height: 56px;
  background: linear-gradient(180deg, transparent, rgba(122, 92, 255, 0.18), transparent);
}

/* L3 — the dust canvas (additive glow over the dimmed photo). */
.simplebusy__canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* L4 — spinner cluster; the wrapper scales in (overlay layer, safe to transform). */
.simplebusy__core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  opacity: 0;
  transform: scale(0.6);
  animation: sb-core-in 0.9s var(--ease) 5.8s forwards;
}
@keyframes sb-core-in {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  70% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}
.simplebusy__halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0deg 200deg, #29d0ff 270deg, #7a5cff 320deg, #ff2e9a 360deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  opacity: 0.55;
  animation: simple-spin 3.6s linear infinite reverse;
}
.simplebusy__ring {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #ff2e9a, #7a5cff, #29d0ff, #2bff88, #ffe14d, #ff2e9a);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 6px), #000 calc(100% - 5px));
  box-shadow: 0 0 36px rgba(122, 92, 255, 0.55);
  animation: simple-spin 1.1s linear infinite;
}
.simplebusy__glow {
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(122, 92, 255, 0.5), transparent 70%);
  filter: blur(10px);
  animation: sb-glow 2.4s ease-in-out infinite;
}
@keyframes sb-glow {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.8;
  }
}
.simplebusy__label {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--ink);
  white-space: nowrap;
  background: rgba(8, 8, 10, 0.42);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  animation: simple-pulse 1.5s ease-in-out infinite;
}
.simplebusy__prov {
  margin-left: 4px;
  padding: 1px 7px;
  font-size: 10.5px;
  border-radius: 999px;
  color: var(--ink-dim);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
}
.simplebusy__prov.is-on {
  color: #0a0a0b;
  background: linear-gradient(90deg, #7a5cff, #29d0ff);
  border-color: transparent;
  font-weight: 600;
}
.simpleerr {
  font-size: 12px;
  color: #ff6b6b;
  text-align: center;
}
.simpleactions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.simplego {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 18px;
  font-size: 14px;
  border-radius: 12px;
}
.simplebtn--ghost {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 18px;
  font-size: 14px;
  border-radius: 12px;
  color: var(--ink-dim);
  background: transparent;
  border: 1px solid var(--line);
  transition: 0.15s var(--ease);
}
.simplebtn--ghost:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
}
@keyframes simple-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes simple-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}
/* zoom + pan on the result frame (images can be very large) */
.simpleframe {
  touch-action: none;
  user-select: none;
}
.simpleframe__img {
  transform-origin: center center;
  will-change: transform;
  -webkit-user-drag: none;
}
.simplezoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.simplezoom button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  font-size: 17px;
  line-height: 1;
  color: var(--ink);
  background: rgba(10, 10, 12, 0.62);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: 0.14s var(--ease);
}
.simplezoom button:hover {
  background: rgba(36, 36, 42, 0.85);
  border-color: var(--ink-dim);
}
.simpleraw {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 3;
  font-size: 11px;
  color: var(--ink-dim);
  background: rgba(10, 10, 12, 0.62);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  text-decoration: none;
  backdrop-filter: blur(4px);
  transition: 0.14s var(--ease);
}
.simpleraw:hover {
  color: var(--ink);
  border-color: var(--ink-dim);
}
.simplehint {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  pointer-events: none;
  font-size: 10.5px;
  color: var(--ink-faint);
  background: rgba(10, 10, 12, 0.5);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ----------------------------------------------------------- about modal -- */
.about {
  width: min(94vw, 560px);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}
.about__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--panel-line);
  flex: none;
}
.about__title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  color: var(--ink);
}
.about__close {
  color: var(--ink-faint);
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 4px;
  border-radius: 7px;
  transition: 0.15s var(--ease);
}
.about__close:hover {
  color: var(--ink);
  background: var(--line);
}
.about__body {
  overflow-y: auto;
  padding: 6px 16px 18px;
}
.about__sec {
  padding: 12px 0;
  border-top: 1px solid var(--panel-line);
}
.about__sec:first-child {
  border-top: 0;
}
.about__h {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--ink);
}
.about__p {
  margin: 6px 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ink-dim);
}
.about__dim {
  color: var(--ink-faint);
  font-size: 11.5px;
}
.about__row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin: 4px 0;
  font-size: 12px;
  color: var(--ink-dim);
}
.about__key {
  flex: none;
  min-width: 54px;
  color: var(--ink);
  background: var(--line);
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 11.5px;
}
.about__code {
  margin: 8px 0;
  padding: 11px 12px;
  background: #0c0c0e;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 11.5px;
  line-height: 1.55;
  color: #d6d6dc;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
