/* ============================================================
   SlideCraft — studio light: near-white, hairlines, ink + one
   sparing orange accent, serif display contrast.
   ============================================================ */

:root {
  --bg: #fafaf9;
  --sidebar: #f4f4f2;
  --surface: #ffffff;
  --elevated: #f6f6f4;
  --ink: #18181b;
  --ink-soft: #27272a;
  --muted: #57575e;
  --faint: #a1a1a8;
  --border: #e9e9e5;
  --hairline: #efefec;
  --hover: #f2f2ef;
  --accent: #ea580c;
  --accent-2: #f97316;
  --accent-soft: rgba(234, 88, 12, 0.07);
  --accent-ring: rgba(234, 88, 12, 0.18);
  --danger: #dc2626;
  --success: #178a5b;

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 10px;

  --shadow-soft: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-card: 0 1px 2px rgba(24, 24, 27, 0.03), 0 16px 40px -20px rgba(24, 24, 27, 0.12);
  --shadow-pop: 0 2px 6px rgba(24, 24, 27, 0.06), 0 24px 48px -20px rgba(24, 24, 27, 0.18);

  --font: -apple-system, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC",
                Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: rgba(234, 88, 12, 0.16); }

:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

/* Text inputs carry their own focus affordance (container border / underline),
   so the global focus ring would read as a second inner border — drop it. */
textarea:focus-visible,
.field:focus-visible,
.slide-title-input:focus-visible,
.slide-bullets:focus-visible { outline: none; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- shell: sidebar + main ---------- */

.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  flex-shrink: 0;
  width: 256px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
}

@media (max-width: 860px) {
  .sidebar { display: none; }
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 24px 20px 20px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  display: block;
}
.brand-logo.lg { width: 52px; height: 52px; margin: 0 auto; }

.brand-name {
  font-size: 16.5px;
  font-weight: 750;
  letter-spacing: -0.3px;
}

/* nav rows — plain text + stroke icon, pill highlight when active */

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 550;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s,
    box-shadow 0.15s, transform 0.15s;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
a.nav-item { text-decoration: none; }

.nav-ext {
  width: 12px !important;
  height: 12px !important;
  margin-left: auto;
  color: var(--faint);
}
.nav-item.active {
  background: #ecebe6;
  border-color: var(--border);
  color: var(--ink);
  font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.nav-item.strong {
  color: var(--ink);
  font-weight: 700;
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
  margin-bottom: 6px;
}
.nav-item.strong svg { color: var(--accent); }
.nav-item.strong:hover {
  background: var(--surface);
  border-color: #d9d9d3;
  box-shadow: var(--shadow-card);
  transform: translateY(-1px);
}

.side-sep {
  height: 1px;
  margin: 14px 20px 4px;
  background: var(--border);
}

.side-label {
  margin: 12px 24px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--faint);
}

.side-decks {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side-decks::-webkit-scrollbar { width: 6px; }
.side-decks::-webkit-scrollbar-thumb { background: #dcdcd6; border-radius: 3px; }

.side-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: none;
  padding: 9px 12px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.side-item:hover { background: var(--hover); }
.side-item.active {
  background: #ecebe6;
  border-color: var(--border);
}

.side-meta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--faint);
}

.side-dot {
  flex-shrink: 0;
  width: 6px; height: 6px;
  border-radius: 50%;
}
.side-dot.done { background: var(--success); }
.side-dot.failed { background: var(--danger); }
.side-dot.outline_ready { background: #d97706; }
.side-dot.running { background: var(--accent); animation: pulse-dot 1.2s ease-in-out infinite; }
.side-dot.draft { background: #d4d4ce; }

@keyframes pulse-dot { 50% { opacity: 0.35; } }

.side-title {
  display: block;
  width: 100%;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.side-item.active .side-title, .side-item:hover .side-title { color: var(--ink); }

.side-del {
  position: absolute;
  top: 8px;
  right: 8px;
  display: none;
  width: 20px; height: 20px;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--faint);
  font-size: 11px;
  cursor: pointer;
}
.side-item:hover .side-del { display: grid; }
.side-del:hover { color: var(--danger); background: rgba(220, 38, 38, 0.08); }

.side-empty {
  margin: 8px 12px;
  font-size: 12px;
  color: var(--faint);
  line-height: 1.9;
}

.side-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.avatar {
  flex-shrink: 0;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
}

.side-username {
  flex: 1;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-logout {
  flex-shrink: 0;
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border: none;
  border-radius: 7px;
  background: none;
  color: var(--faint);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.side-logout:hover { color: var(--danger); background: rgba(220, 38, 38, 0.08); }
.side-logout svg { width: 15px; height: 15px; }

/* ---------- main & stage ---------- */

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 28px;
}

/* long scrolling views anchor to the top instead of centering */
.stage:has(#image-view:not([hidden])) { justify-content: flex-start; }

/* ---------- auth ---------- */

.auth-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-brand { display: flex; justify-content: center; margin-bottom: 16px; }

.auth-card {
  width: 100%;
  max-width: 23rem;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 36px 32px 30px;
  animation: rise 0.4s ease both;
}

.auth-title {
  margin: 0;
  text-align: center;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -0.4px;
}
.auth-title .accent { color: var(--accent); font-family: var(--font-serif); }

.auth-sub {
  margin: 10px 0 22px;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  background: var(--elevated);
  border-radius: var(--r-sm);
  padding: 3px;
  margin-bottom: 16px;
}

.auth-tab {
  border: none;
  border-radius: 8px;
  background: none;
  padding: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.auth-tab.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-soft);
}

.field-label {
  display: block;
  margin: 14px 2px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.field {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 10px 13px;
  font: 14px/1.5 var(--font);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus { border-color: #cfcfc8; box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.04); }
.field::placeholder { color: var(--faint); }

.auth-error {
  min-height: 18px;
  margin: 10px 2px 4px;
  font-size: 12.5px;
  color: var(--danger);
}

.cta {
  width: 100%;
  border: none;
  border-radius: var(--r-sm);
  background: var(--ink);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1.5px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
}
.cta:hover:not(:disabled) { background: #000; transform: translateY(-1px); }
.cta:active:not(:disabled) { transform: none; }
.cta:disabled { opacity: 0.45; cursor: not-allowed; }

.cta.slim {
  width: auto;
  padding: 10px 20px;
  font-size: 13px;
  letter-spacing: 0.3px;
}

/* ---------- hero + composer ---------- */

.compose-view {
  width: 100%;
  max-width: 41rem;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: rise 0.4s ease both;
}

.hero-title {
  margin: 0 0 2px;
  text-align: center;
  font-size: clamp(32px, 4.6vw, 46px);
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: -1.2px;
  text-wrap: balance;
}

.hero-title .accent {
  color: var(--accent);
  font-family: var(--font-serif);
  font-weight: 900;
  letter-spacing: 0;
}

.caret {
  display: inline-block;
  width: 3px;
  height: 0.8em;
  margin-left: 4px;
  transform: translateY(3px);
  border-radius: 2px;
  background: var(--accent);
  animation: blink 1s steps(1) infinite;
}
.caret.done { display: none; }
@keyframes blink { 50% { opacity: 0; } }

.hero-sub {
  margin: 0 auto 10px;
  max-width: 26rem;
  text-align: center;
  font-size: 14px;
  line-height: 1.9;
  color: var(--muted);
  text-wrap: balance;
}

/* composer */

.composer {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.composer:focus-within,
.composer.dragover {
  border-color: rgba(234, 88, 12, 0.45);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-card);
}

.drop-veil {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-lg);
  background: rgba(250, 250, 249, 0.65);
  pointer-events: none;
}
.drop-veil span {
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: 9px;
  padding: 8px 16px;
}

.composer-text { padding: 18px 20px 4px; }

textarea {
  display: block;
  width: 100%;
  border: none;
  resize: none;
  background: transparent;
  color: var(--ink);
  font: 15px/1.75 var(--font);
  outline: none;
  min-height: 72px;
  max-height: 220px;
}
textarea::placeholder { color: var(--faint); }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 20px 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--hairline);
  background: var(--elevated);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 12px;
  color: var(--muted);
  animation: rise 0.25s ease both;
}

.chip-badge {
  display: inline-block;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #fff;
  border-radius: 4px;
  padding: 2px 5px;
}

.chip-x {
  display: grid;
  place-items: center;
  width: 17px; height: 17px;
  border: none;
  border-radius: 999px;
  background: none;
  color: var(--faint);
  font-size: 10px;
  cursor: pointer;
}
.chip-x:hover { background: var(--border); color: var(--ink); }

.upload-note {
  margin: 0;
  padding: 2px 21px 4px;
  font-size: 11.5px;
  color: var(--faint);
}
.upload-note:empty { display: none; }
.upload-note.error { color: var(--danger); }

.composer-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  background: #fbfbfa;
  border-top: 1px solid var(--hairline);
  border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px);
}

.composer-bar .pill { background: var(--surface); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.pill:hover { background: var(--hover); color: var(--ink); }
.pill svg { width: 14px; height: 14px; }
.pill.active {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.composer-hint {
  flex: 1;
  text-align: right;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--faint);
}

.send {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s, opacity 0.15s;
}
.send:hover:not(:disabled) { background: #000; transform: scale(1.05); }
.send:active:not(:disabled) { transform: scale(0.95); }
.send:disabled { opacity: 0.25; cursor: not-allowed; }
.send-arrow { width: 18px; height: 18px; }

.send-spinner {
  display: none;
  width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.send.running .send-spinner { display: block; }
.send.running .send-arrow { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* mode selector */

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
@media (max-width: 640px) { .mode-row { grid-template-columns: 1fr; } }

.mode-card {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 11px 12px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.mode-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-card); }
.mode-card.selected {
  border-color: var(--ink);
  background: var(--ink);
}

.mode-icon {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}
.mode-icon svg { width: 17px; height: 17px; }
.mode-card.selected .mode-icon { background: rgba(234, 88, 12, 0.25); }

.mode-body { min-width: 0; display: flex; flex-direction: column; gap: 1px; }

.mode-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.mode-card.selected .mode-name { color: #fff; }

.mode-tag {
  font-style: normal;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 7px;
}

.mode-hint {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mode-card.selected .mode-hint { color: rgba(255, 255, 255, 0.65); }

/* settings pills row */

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.num-pill { cursor: default; gap: 8px; }
.num-pill input {
  width: 34px;
  border: none;
  background: transparent;
  font: 600 12.5px var(--font);
  color: var(--ink);
  outline: none;
  text-align: center;
  -moz-appearance: textfield;
}
.num-pill input::-webkit-inner-spin-button { -webkit-appearance: none; }

.advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  margin-top: 4px;
}
@media (max-width: 640px) { .advanced-grid { grid-template-columns: 1fr; } }

textarea.field {
  min-height: 54px;
  font-size: 13px;
  line-height: 1.7;
}

select.field { appearance: auto; font-size: 13px; }

.tone-group { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 3px; }
.tone-group .pill.active { border-color: var(--ink); background: var(--ink); color: #fff; }

/* style reference images */

.ref-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 2px;
}

.ref-thumb {
  position: relative;
  width: 58px; height: 58px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: rise 0.25s ease both;
}
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-thumb .no-preview {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  font-size: 9px;
  color: var(--faint);
  background: var(--elevated);
  padding: 4px;
  text-align: center;
  word-break: break-all;
  overflow: hidden;
}

.ref-x {
  position: absolute;
  top: 0; right: 0;
  width: 17px; height: 17px;
  display: grid; place-items: center;
  border: none;
  border-radius: 0 0 0 7px;
  background: rgba(24, 24, 27, 0.65);
  color: #fff;
  font-size: 9px;
  cursor: pointer;
}

.ref-add {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-sm);
  background: none;
  color: var(--faint);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.ref-add:hover { border-color: var(--accent); color: var(--accent); }
.ref-add svg { width: 20px; height: 20px; }

.ref-hint {
  margin: 8px 2px 0;
  font-size: 11px;
  color: var(--faint);
}

/* example hint chips */

.hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.hint-chip {
  border: none;
  background: none;
  border-radius: 999px;
  padding: 6px 13px;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--faint);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.hint-chip:hover { background: var(--hover); color: var(--ink); }

/* ---------- template gallery ---------- */

.template-panel {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 16px 18px 18px;
  animation: rise 0.25s ease both;
}

.panel-label {
  margin: 0 0 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--faint);
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
  padding-right: 4px;
}
.template-grid::-webkit-scrollbar { width: 7px; }
.template-grid::-webkit-scrollbar-thumb { background: #e2e2dc; border-radius: 4px; }

.tpl-card {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 6px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tpl-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-card); }
.tpl-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tpl-thumb {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  overflow: hidden;
}
.tpl-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tpl-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 7%; }
.tpl-line-a { position: absolute; left: 16%; top: 26%; width: 52%; height: 11%; border-radius: 3px; }
.tpl-line-b { position: absolute; left: 16%; top: 46%; width: 66%; height: 6%; border-radius: 3px; opacity: 0.55; }
.tpl-line-c { position: absolute; left: 16%; top: 58%; width: 42%; height: 6%; border-radius: 3px; opacity: 0.35; }
.tpl-dot { position: absolute; right: 8%; bottom: 10%; width: 9px; height: 9px; border-radius: 50%; }

.tpl-name { margin: 8px 3px 1px; font-size: 12.5px; font-weight: 650; color: var(--ink); }
.tpl-desc {
  margin: 0 3px 2px;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--faint);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tpl-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 13px;
}
.tpl-badge i {
  width: 9px; height: 9px;
  border-radius: 3px;
  display: inline-block;
}

/* ---------- run / outline shared card ---------- */

.run-view, .outline-view {
  width: 100%;
  max-width: 46rem;
  animation: rise 0.4s ease both;
}

.run-card, .outline-card {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.run-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 22px 26px 16px;
}

.run-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.run-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--faint); }

.run-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 5px 12px;
}
.run-status.running { color: var(--accent); background: var(--accent-soft); }
.run-status.ok { color: var(--success); background: rgba(23, 138, 91, 0.08); }
.run-status.fail { color: var(--danger); background: rgba(220, 38, 38, 0.07); }

.status-spinner {
  width: 11px; height: 11px;
  border: 2px solid var(--accent-ring);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.runbar {
  height: 2px;
  background: var(--hairline);
  overflow: hidden;
}
.runbar span {
  display: block;
  height: 100%;
  width: 36%;
  background: var(--accent);
  border-radius: 2px;
  animation: slide 1.5s ease-in-out infinite;
}
.runbar.done { visibility: hidden; }
@keyframes slide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(300%); }
}

/* ---------- feed ---------- */

.feed {
  max-height: 46vh;
  overflow-y: auto;
  padding: 20px 26px 8px;
  scroll-behavior: smooth;
}
.feed:empty { display: none; }
.feed::-webkit-scrollbar { width: 7px; }
.feed::-webkit-scrollbar-thumb { background: #e2e2dc; border-radius: 4px; }

.feed-item {
  position: relative;
  display: flex;
  gap: 13px;
  animation: rise 0.28s ease both;
}

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

.feed-rail {
  flex-shrink: 0;
  width: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.feed-dot {
  flex-shrink: 0;
  width: 7px; height: 7px;
  margin-top: 8px;
  border-radius: 50%;
  background: #dcdcd6;
}
.feed-item.tool .feed-dot { background: var(--accent); }
.feed-item.error .feed-dot { background: var(--danger); }

.feed-rail::after {
  content: "";
  flex: 1;
  width: 1px;
  margin-top: 5px;
  background: var(--hairline);
}
.feed-item:last-child .feed-rail::after { background: transparent; }

.feed-body {
  flex: 1;
  min-width: 0;
  padding-bottom: 16px;
  font-size: 13.5px;
  line-height: 1.85;
  color: var(--ink-soft);
  word-break: break-word;
}

.feed-body h4 { margin: 2px 0; font-size: 13.5px; font-weight: 700; }
.feed-body ul { margin: 2px 0; padding-left: 18px; }
.feed-body li { margin: 1px 0; }
.feed-body strong { font-weight: 650; }
.feed-body code {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--elevated);
  border: 1px solid var(--hairline);
  border-radius: 5px;
  padding: 0.5px 5px;
}

.feed-item.error .feed-body { color: var(--danger); }

.tool-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
  margin-right: 8px;
}

.tool-detail {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
}

/* ---------- result ---------- */

.result-block {
  border-top: 1px solid var(--hairline);
  padding: 20px 26px 20px;
}

.artifact-list { display: flex; flex-direction: column; gap: 10px; }

.artifact-link {
  display: flex;
  align-items: center;
  gap: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(234, 88, 12, 0.05), transparent 45%),
    var(--surface);
  padding: 16px 18px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-soft);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.artifact-link:hover {
  border-color: rgba(234, 88, 12, 0.4);
  transform: translateY(-1px);
  box-shadow: var(--shadow-card);
}

.artifact-icon {
  flex-shrink: 0;
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent-2), #C2410C);
  box-shadow: 0 3px 10px rgba(234, 88, 12, 0.28);
}

.artifact-name {
  flex: 1;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.artifact-size { flex-shrink: 0; font-size: 12px; color: var(--faint); }

.artifact-dl {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  padding: 9px 18px;
  transition: background 0.15s;
}
.artifact-link:hover .artifact-dl { background: #000; }
.artifact-dl svg { width: 14px; height: 14px; }

.result-meta {
  margin: 10px 4px 0;
  font-size: 12px;
  color: var(--faint);
}

.result-actions { margin-top: 14px; display: flex; gap: 8px; }

/* ---------- refine ---------- */

.refine-section { margin-top: 22px; }

.refine-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.refine-label {
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding-left: 10px;
  position: relative;
}
.refine-label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  bottom: 3px;
  width: 3px;
  border-radius: 2px;
  background: var(--accent);
}

.refine-hint { font-size: 12px; color: var(--faint); }

.refine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 7px;
}

.refine-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 9px 11px;
  font-family: var(--font);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.refine-chip:hover { border-color: var(--border); box-shadow: var(--shadow-soft); }
.refine-chip.active {
  border-color: rgba(234, 88, 12, 0.5);
  background: var(--accent-soft);
}

.refine-chip .slide-no { margin: 0; }

.refine-chip-title {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.refine-panel {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  padding: 14px 16px 12px;
  animation: rise 0.25s ease both;
}

.refine-caption {
  margin: 0 0 9px;
  font-size: 12.5px;
  color: var(--muted);
}
.refine-caption strong { color: var(--accent); }

.refine-panel textarea {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  padding: 10px 12px;
  font: 13px/1.7 var(--font);
}
.refine-panel textarea:focus { border-color: rgba(234, 88, 12, 0.45); }

.refine-panel-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.refine-panel-bar .pill { font-size: 12px; padding: 6px 12px; }

.refine-files { display: flex; flex-wrap: wrap; gap: 5px; }
.refine-files .chip { font-size: 11.5px; }

/* ---------- outline editor ---------- */

.outline-body {
  padding: 4px 26px 20px;
  max-height: 56vh;
  overflow-y: auto;
}
.outline-body::-webkit-scrollbar { width: 7px; }
.outline-body::-webkit-scrollbar-thumb { background: #e2e2dc; border-radius: 4px; }

.slide-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
}

.slide-item {
  display: flex;
  gap: 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 12px 14px;
  animation: rise 0.25s ease both;
  transition: border-color 0.15s;
}
.slide-item:focus-within { border-color: var(--border); }

.slide-no {
  flex-shrink: 0;
  width: 24px; height: 24px;
  margin-top: 2px;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 750;
}

.slide-fields { flex: 1; min-width: 0; }

.slide-title-input {
  width: 100%;
  border: none;
  background: transparent;
  font: 600 14px/1.5 var(--font);
  color: var(--ink);
  outline: none;
  padding: 2px 0 6px;
  border-bottom: 1px dashed transparent;
}
.slide-title-input:focus { border-bottom-color: var(--accent); }

.slide-bullets {
  width: 100%;
  border: none;
  background: transparent;
  resize: none;
  font: 13px/1.8 var(--font);
  color: var(--muted);
  outline: none;
  min-height: 24px;
}

.slide-img-prompt {
  width: 100%;
  border: none;
  border-top: 1px dashed var(--hairline);
  background: transparent;
  margin-top: 6px;
  padding: 7px 0 2px;
  font: 12px/1.6 var(--font);
  color: var(--accent);
  outline: none;
}
.slide-img-prompt::placeholder { color: var(--faint); }

.slide-ctrl {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slide-ctrl button {
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--faint);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.slide-ctrl button:hover { background: var(--hover); color: var(--ink); }
.slide-ctrl button.del:hover { color: var(--danger); background: rgba(220, 38, 38, 0.08); }

.add-slide { margin-top: 12px; }

.outline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--hairline);
  padding: 14px 26px;
}

/* ---------- image studio ---------- */

.image-view {
  width: 100%;
  max-width: 52rem;
  animation: rise 0.4s ease both;
  align-self: center;
}

.img-head { margin-bottom: 16px; }
.img-head .run-sub { max-width: 34rem; }

.img-composer {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 16px 18px 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.img-composer:focus-within {
  border-color: rgba(234, 88, 12, 0.45);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-card);
}

.img-composer textarea { min-height: 64px; }

.img-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--hairline);
  margin-top: 10px;
  padding-top: 11px;
}

.seg {
  display: inline-flex;
  gap: 3px;
  background: var(--elevated);
  border-radius: 999px;
  padding: 3px;
}

.seg-btn {
  border: none;
  border-radius: 999px;
  background: none;
  padding: 6px 13px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn.active { background: var(--ink); color: #fff; }

.img-note { margin: 10px 2px 2px; font-size: 11px; color: var(--faint); }
.img-note.error { color: var(--danger); }

.img-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.img-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
  animation: rise 0.3s ease both;
}

.img-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--elevated);
}

.img-card .cap {
  margin: 0;
  padding: 8px 11px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.img-acts {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.15s;
}
.img-card:hover .img-acts { opacity: 1; }

.img-act {
  border: none;
  border-radius: 8px;
  background: rgba(24, 24, 27, 0.62);
  backdrop-filter: blur(4px);
  color: #fff;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  cursor: pointer;
  text-decoration: none;
}
.img-act:hover { background: rgba(24, 24, 27, 0.85); }

.img-pending {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-md);
  color: var(--faint);
  font-size: 12px;
}
.img-pending .status-spinner { margin-right: 7px; }

.img-empty {
  text-align: center;
  padding: 56px 0;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-lg);
  margin-top: 18px;
  color: var(--faint);
  font-size: 13px;
}


/* ---------- html editor ---------- */

.html-view {
  width: 100%;
  max-width: 62rem;
  animation: rise 0.4s ease both;
}

.html-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 26px 14px;
}

.html-thumb {
  min-width: 34px;
  height: 30px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.html-thumb:hover { border-color: var(--ink); color: var(--ink); }
.html-thumb.active { border-color: var(--ink); background: var(--ink); color: #fff; }
.html-thumb.dirty::after { content: "·"; color: var(--accent); font-size: 20px; margin-left: 2px; }
.html-thumb.active.dirty::after { color: var(--accent-2); }

.html-editor {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #e8e8e4;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  overflow: hidden;
}

.html-editor iframe {
  position: absolute;
  top: 0; left: 0;
  width: 1280px;
  height: 720px;
  border: none;
  transform-origin: 0 0;
  background: #fff;
}

.html-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 26px;
}
.html-actions-spacer { flex: 1; }

/* ---------- footer ---------- */

.foot {
  padding: 16px 24px 24px;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.3px;
  color: #c2c2bc;
}
