/* ============================================================
   PPT Master Web Agent — client-first product UI
   Light-first, token-driven, dark-mode aware.
   ============================================================ */

:root {
  /* neutrals — faint cool bias toward the indigo accent, not flat grey */
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --border: #e6e8f0;
  --border-strong: #d3d7e3;
  --text: #191c26;
  --muted: #656d80;
  --faint: #8b93a6;
  /* brand — solid indigo, no gradient hero cliché */
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --ring: rgba(79, 70, 229, 0.28);
  /* semantic */
  --good: #0d9488;
  --good-soft: #d5f2ee;
  --warn: #d97706;
  --danger: #e11d48;
  --danger-soft: #fde7ec;
  --shadow: 0 1px 2px rgba(20, 24, 40, 0.04), 0 8px 24px -12px rgba(20, 24, 40, 0.14);
  --radius: 8px;
  --radius-sm: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f15;
    --surface: #161922;
    --surface-2: #1d212c;
    --border: #272c38;
    --border-strong: #333a49;
    --text: #eceef5;
    --muted: #9aa3b6;
    --faint: #6f7789;
    --accent: #7c83f7;
    --accent-hover: #8f96ff;
    --accent-soft: #1c2033;
    --ring: rgba(124, 131, 247, 0.32);
    --good: #2dd4bf;
    --good-soft: #16302e;
    --warn: #f59e0b;
    --danger: #fb7185;
    --danger-soft: #331a22;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -14px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="light"] {
  --bg: #f7f8fb; --surface: #ffffff; --surface-2: #f2f4f9; --border: #e6e8f0;
  --border-strong: #d3d7e3; --text: #191c26; --muted: #656d80; --faint: #8b93a6;
  --accent: #4f46e5; --accent-hover: #4338ca; --accent-soft: #eef0fe; --ring: rgba(79,70,229,.28);
  --good: #0d9488; --good-soft: #d5f2ee; --warn: #d97706; --danger: #e11d48; --danger-soft: #fde7ec;
  --shadow: 0 1px 2px rgba(20,24,40,.04), 0 8px 24px -12px rgba(20,24,40,.14);
}
:root[data-theme="dark"] {
  --bg: #0d0f15; --surface: #161922; --surface-2: #1d212c; --border: #272c38;
  --border-strong: #333a49; --text: #eceef5; --muted: #9aa3b6; --faint: #6f7789;
  --accent: #7c83f7; --accent-hover: #8f96ff; --accent-soft: #1c2033; --ring: rgba(124,131,247,.32);
  --good: #2dd4bf; --good-soft: #16302e; --warn: #f59e0b; --danger: #fb7185; --danger-soft: #331a22;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 12px 32px -14px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; text-wrap: balance; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- app bar ---------- */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); }
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  font-weight: 800; font-size: 17px; color: #fff;
  background: var(--accent); border-radius: 9px;
  box-shadow: 0 4px 12px -4px var(--ring);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 15px; font-weight: 700; }
.brand-text small { font-size: 11px; color: var(--faint); letter-spacing: 0.02em; }
.appbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.runtime-badge {
  display: inline-flex; align-items: center; min-height: 30px; padding: 5px 10px;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px;
}
.runtime-badge[data-kind="ok"] { color: #166534; background: #dcfce7; border-color: #86efac; }
.runtime-badge[data-kind="error"] { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.runtime-badge[data-kind="pending"] { color: var(--accent); background: var(--accent-soft); border-color: rgba(14, 116, 144, .2); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 38px; padding: 8px 15px; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 550;
  color: #fff; background: var(--accent); border: 1px solid var(--accent);
  border-radius: 9px; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
/* in-flight button: inline spinner + stable disabled look, no layout jump */
.btn.busy { position: relative; pointer-events: none; }
.btn.busy::before {
  content: ""; width: 13px; height: 13px; flex: 0 0 13px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .btn.busy::before { animation: none; border-right-color: currentColor; opacity: .4; }
}
/* two-step destructive confirm: armed state is unmistakably "hot" */
.btn.danger.armed { color: #fff; background: var(--danger); border-color: var(--danger); }
.btn.danger.armed:hover:not(:disabled) { background: var(--danger); border-color: var(--danger); }
.btn.sec { color: var(--text); background: var(--surface); border-color: var(--border-strong); }
.btn.sec:hover { background: var(--surface-2); border-color: var(--accent); }
.btn.ghost { color: var(--muted); background: transparent; border-color: transparent; font-weight: 500; min-height: 32px; padding: 5px 10px; font-size: 13px; }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.danger { color: var(--danger); background: transparent; border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.primary-cta { min-height: 48px; padding: 12px 32px; font-size: 16px; font-weight: 650; box-shadow: 0 8px 22px -10px var(--ring); }
.primary-cta:disabled { opacity: .6; cursor: default; box-shadow: none; }

/* ---------- app shell: task sidebar + main column ---------- */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); align-items: start; min-height: 100vh; }
.shell-main { min-width: 0; }
.task-sidebar {
  position: sticky; top: 0; align-self: start;
  display: flex; flex-direction: column; gap: 10px;
  height: 100vh; overflow-y: auto;
  padding: 16px 10px; background: var(--surface); border-right: 1px solid var(--border);
}
.task-sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; gap: 8px; }
.task-sidebar-head h3 { font-size: 12px; }
.task-sidebar-head .btn.ghost { min-height: 26px; padding: 4px 8px; font-size: 12px; color: var(--accent); }
.task-sidebar-list { display: grid; gap: 4px; align-content: start; overflow-y: auto; min-height: 0; }
.task-sidebar-item {
  display: grid; gap: 3px; padding: 9px 10px; text-align: left; font: inherit;
  color: var(--text); background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; width: 100%;
}
.task-sidebar-item:hover:not(:disabled) { background: var(--surface-2); }
.task-sidebar-item:disabled { opacity: .55; cursor: default; }
.task-sidebar-item.active { background: var(--accent-soft); border-color: var(--accent); }
.task-sidebar-item-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.task-sidebar-item-title .name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sidebar-item-meta { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-sidebar-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: 0 0 7px; }
.task-sidebar-item[data-status="running"] .task-sidebar-dot { background: var(--accent); animation: sidebar-pulse 1.6s ease-in-out infinite; }
.task-sidebar-item[data-status="waiting_confirmation"] .task-sidebar-dot,
.task-sidebar-item[data-status="interrupted"] .task-sidebar-dot { background: var(--warn); }
.task-sidebar-item[data-status="succeeded"] .task-sidebar-dot { background: var(--good); }
.task-sidebar-item[data-status="failed"] .task-sidebar-dot,
.task-sidebar-item[data-status="cancelled"] .task-sidebar-dot { background: var(--danger); }
@keyframes sidebar-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 4px var(--accent-soft); } }
@media (prefers-reduced-motion: reduce) {
  .task-sidebar-item[data-status="running"] .task-sidebar-dot { animation: none; }
}
.task-sidebar-empty { padding: 8px 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .task-sidebar {
    position: static; height: auto; max-height: none;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .task-sidebar-list { grid-auto-flow: column; grid-auto-columns: minmax(190px, 230px); overflow-x: auto; padding-bottom: 4px; }
}

/* ---------- layout shell ---------- */
.app { max-width: 1120px; margin: 0 auto; padding: 26px 22px 80px; display: grid; gap: 22px; }
.stage { display: grid; gap: 18px; }

/* ---------- client workflow pages ---------- */
.wizard-nav {
  display: flex; gap: 6px; padding: 6px; overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.wizard-step {
  display: grid; grid-template-columns: 24px max-content; align-items: center; gap: 7px;
  min-height: 38px; padding: 6px 10px; color: var(--muted); background: transparent;
  border: 1px solid transparent; border-radius: 6px; cursor: pointer; font: inherit;
}
.wizard-step span {
  display: grid; place-items: center; width: 22px; height: 22px;
  color: var(--muted); background: var(--surface-2); border-radius: 50%; font-size: 11px;
}
.wizard-step b { font-size: 12px; font-weight: 600; letter-spacing: 0; }
.wizard-step:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.wizard-step.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.wizard-step.active span { color: #fff; background: var(--accent); }
.wizard-step:disabled { opacity: .42; cursor: default; }
.wizard-page-head { display: grid; gap: 5px; padding: 4px 2px 0; }
.wizard-page-head span { color: var(--accent); font-size: 12px; font-weight: 650; }
.wizard-page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.wizard-footer {
  position: sticky; bottom: 12px; z-index: 12;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px;
  padding: 10px 12px; background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.wizard-footer .hint { text-align: center; }
.wizard-hidden { display: none !important; }
body[data-mode="client"] .compose-grid { grid-template-columns: minmax(0, 1fr); }

/* ---------- start choice (sidebar is the task switcher; this is just "new") ---------- */
.start-grid { display: grid; grid-template-columns: 1fr; gap: 14px; align-items: stretch; }
.start-history-hint { margin: 0; padding: 0 2px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.start-option {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 8px;
  padding: 22px 20px; text-align: left; font: inherit; color: var(--text);
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: box-shadow .15s, transform .05s;
}
.start-option:hover { box-shadow: 0 0 0 3px var(--ring); transform: translateY(-1px); }
.start-icon { font-size: 22px; color: var(--accent); }
.start-option strong { font-size: 17px; font-weight: 700; }
.start-option span:last-child { color: var(--muted); font-size: 13px; line-height: 1.5; }
.start-history { display: grid; grid-template-rows: auto 1fr; min-width: 0; }
.start-history-list { display: grid; gap: 8px; align-content: start; max-height: 340px; overflow: auto; padding: 2px; }
.start-history-item {
  display: grid; gap: 3px; padding: 10px 12px; text-align: left; font: inherit;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.start-history-item:hover:not(:disabled) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.start-history-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.start-history-title strong { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.start-history-meta { color: var(--muted); font-size: 12px; }
.start-last { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
@media (max-width: 760px) {
  .start-grid { grid-template-columns: 1fr; }
}

.hero { padding: 8px 2px 2px; }
.hero .lede { margin: 8px 0 0; max-width: 60ch; color: var(--muted); font-size: 15px; }

/* ---------- cards ---------- */
.card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head, .selector-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}
.card-head h2, .selector-head h3 { margin-right: auto; }
.muted-badge { color: var(--faint); font-size: 12px; }
.chip-tag {
  padding: 3px 10px; font-size: 12px; font-weight: 550;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 999px;
}

/* ---------- route grid ---------- */
.route-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.route-card {
  display: flex; flex-direction: column; gap: 7px;
  min-height: 198px; padding: 14px 15px; text-align: left;
  color: var(--text); background: var(--surface); font: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.route-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.route-card.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.route-badge {
  width: fit-content; padding: 2px 8px; color: var(--accent);
  background: var(--accent-soft); border: 1px solid rgba(14, 116, 144, .2);
  border-radius: 999px; font-size: 11px; font-weight: 650;
}
.route-card strong { font-size: 14px; font-weight: 600; }
.route-card span { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.route-summary { color: var(--text) !important; }
.route-detail { min-height: 36px; }
.route-meta {
  display: grid; grid-template-columns: 34px 1fr; gap: 6px;
  padding-top: 6px; border-top: 1px solid var(--border);
}
.route-meta b { color: var(--text); font-size: 12px; font-weight: 650; }

/* ---------- compose grid ---------- */
.compose-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.compose-grid.single { grid-template-columns: minmax(0, 1fr); }

.route-guide {
  display: grid; gap: 8px; margin: 0 0 16px; padding: 12px 14px;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.route-guide:empty { display: none; }
.route-guide strong { color: var(--text); font-size: 13px; font-weight: 650; }
.route-guide ol {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: route-step;
}
.route-guide li {
  position: relative; min-width: 0; padding: 7px 8px 7px 30px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 7px;
  font-size: 11.5px; line-height: 1.4; counter-increment: route-step;
}
.route-guide li::before {
  content: counter(route-step); position: absolute; top: 7px; left: 8px;
  display: grid; place-items: center; width: 16px; height: 16px;
  color: #fff; background: var(--accent); border-radius: 999px; font-size: 10px; font-weight: 700;
}

.fields { display: grid; gap: 13px; }
.field-textarea { min-height: 88px; padding: 10px 12px; line-height: 1.5; font-size: 14px; resize: vertical; }
.field-help { color: var(--faint); font-size: 12px; line-height: 1.45; }
.field { display: grid; gap: 6px; margin-bottom: 13px; }
.field span { color: var(--muted); font-size: 13px; font-weight: 500; }
input, textarea, select {
  width: 100%; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input, select { min-height: 40px; padding: 9px 12px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
textarea { min-height: 340px; padding: 12px; resize: vertical; line-height: 1.55; font-size: 13px; }

/* ---------- uploader ---------- */
.uploader { margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border); }
.upload-help { display: block; margin: -7px 0 10px; }
.dropzone {
  display: flex; align-items: center; justify-content: center;
  padding: 18px; margin-bottom: 10px; text-align: center;
  color: var(--muted); background: var(--surface-2);
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }
.dropzone-text { font-size: 13.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions.compact { margin-top: 2px; }

/* ---------- appearance tabs + gallery ---------- */
.selector-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.tab {
  min-height: 34px; padding: 6px 8px; font-size: 12.5px; font-weight: 500;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }

.resource-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; max-height: 460px; overflow: auto; padding: 2px; }
.resource-card {
  display: grid; gap: 8px; width: 100%; padding: 8px; text-align: left;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .05s;
}
.resource-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.resource-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.resource-card strong { font-size: 13px; font-weight: 600; }
.resource-card p { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.style-preview { width: 100%; aspect-ratio: 16 / 9; background: #fff; border: 1px solid var(--border); border-radius: 7px; object-fit: cover; }
.swatch-row { display: flex; align-items: center; gap: 8px; }
.swatch { width: 16px; height: 16px; flex: 0 0 16px; border: 1px solid rgba(120,120,120,.35); border-radius: 999px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 5px; }
.pill { padding: 2px 7px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; font-size: 10.5px; }

/* ---------- CTA bar ---------- */
.cta-bar {
  display: grid; gap: 8px;
  padding: 16px 18px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.cta-main { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---------- workspace ---------- */
.workspace { padding-top: 4px; }
.ws-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ws-title { display: flex; align-items: center; gap: 12px; }
.status-pill {
  padding: 4px 12px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px;
}
body[data-jobstate="running"] .status-pill { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
body[data-jobstate="waiting_confirmation"] .status-pill,
body[data-jobstate="interrupted"] .status-pill { color: var(--warn); border-color: var(--warn); background: transparent; }
body[data-jobstate="succeeded"] .status-pill { color: var(--good); background: var(--good-soft); border-color: var(--good); }
body[data-jobstate="failed"] .status-pill,
body[data-jobstate="cancelled"] .status-pill { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }

.restore-row { display: flex; gap: 8px; align-items: center; }
.restore-row select { min-width: 190px; }

/* ---------- progress rail ---------- */
.progress-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.progress-step {
  display: flex; align-items: center; gap: 9px;
  padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; font-weight: 500;
}
.progress-step .dot { width: 11px; height: 11px; flex: 0 0 11px; border-radius: 999px; background: var(--border-strong); transition: background .2s, box-shadow .2s; }
.progress-step.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.progress-step.active .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--ring); animation: pulse 1.6s ease-in-out infinite; }
.progress-step.done { color: var(--text); }
.progress-step.done .dot { background: var(--good); }
.progress-steps.failed .progress-step.active .dot { background: var(--danger); animation: none; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px var(--ring); } 50% { box-shadow: 0 0 0 6px transparent; } }
@media (prefers-reduced-motion: reduce) { .progress-step.active .dot { animation: none; } }

/* ---------- empty state ---------- */
.empty-state {
  display: grid; place-items: center; gap: 8px;
  padding: 44px 20px; text-align: center;
  color: var(--faint); background: var(--surface);
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
}
.empty-mark { font-size: 26px; color: var(--accent); opacity: .7; }
.empty-state p { margin: 0; font-size: 14px; }
body[data-phase="working"] #empty-workspace { display: none; }

/* ---------- gate panels (confirm / preview) ---------- */
.gate-panel {
  padding: 14px; background: var(--surface);
  border: 1px solid var(--accent); border-radius: var(--radius);
  box-shadow: 0 0 0 3px var(--ring), var(--shadow);
}
.gate-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.gate-head h3 { color: var(--text); font-size: 15px; margin-right: auto; }
.gate-panel iframe {
  width: 100%; height: 760px; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}

/* ---------- native Step 4 confirm panel ---------- */
.confirm-native { display: grid; gap: 16px; }
.confirm-stagebar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.confirm-stagechip {
  padding: 3px 11px; font-size: 12px; font-weight: 600;
  color: var(--accent); background: var(--accent-soft); border-radius: 999px;
}
.confirm-proposal {
  margin: 0; padding: 12px 14px; color: var(--text); font-size: 14px; line-height: 1.6;
  background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 8px;
}
.preset-lock-summary {
  display: grid; gap: 3px; padding: 11px 13px;
  color: var(--muted); background: var(--good-soft);
  border: 1px solid var(--good); border-radius: var(--radius-sm);
}
.preset-lock-summary strong { color: var(--text); font-size: 13px; }
.preset-lock-summary span { font-size: 12px; line-height: 1.45; }
.confirm-fields { display: grid; gap: 16px; }
.confirm-field { display: grid; gap: 7px; }
.confirm-label { color: var(--muted); font-size: 13px; font-weight: 550; }
.confirm-checks { display: flex; flex-wrap: wrap; gap: 14px; }
.confirm-chk { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.confirm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.confirm-card {
  display: grid; gap: 8px; padding: 12px; text-align: left;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.confirm-card:hover { border-color: var(--border-strong); }
.confirm-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.confirm-card strong { font-size: 13px; font-weight: 600; }
.confirm-typo { margin: 0; font-size: 16px; }
.confirm-typo-sub { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.confirm-actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.fill-plan-summary {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px;
}
.fill-plan-summary > div {
  display: grid; gap: 3px; padding: 12px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fill-plan-summary strong { color: var(--text); font-size: 20px; }
.fill-plan-summary span { color: var(--muted); font-size: 12px; }
.fill-plan-meta {
  display: grid; gap: 5px; padding: 12px 14px;
  color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm);
}
.fill-plan-meta p, .fill-plan-slide p { margin: 0; font-size: 13px; line-height: 1.55; }
.fill-plan-meta strong, .fill-plan-slide b { color: var(--text); }
.fill-plan-slides { display: grid; gap: 10px; }
.fill-plan-slide {
  display: grid; gap: 7px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fill-plan-slide-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fill-plan-slide-head strong { color: var(--text); font-size: 14px; }
.fill-plan-slide-head span, .fill-plan-slide-head em {
  padding: 2px 8px; color: var(--muted); background: var(--surface-2);
  border-radius: 999px; font-size: 12px; font-style: normal;
}
.fill-plan-slide-foot { display: flex; justify-content: space-between; color: var(--faint); font-size: 12px; }
.warn-text { color: var(--warning, #b56a00); }
.fill-plan-warnings, .fill-plan-blockers {
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fill-plan-warnings { background: var(--surface-2); }
.fill-plan-blockers { color: var(--danger); background: var(--danger-soft); border-color: var(--danger); }
.fill-plan-warnings strong, .fill-plan-blockers strong { font-size: 13px; }
.fill-plan-warnings ul, .fill-plan-blockers ul {
  display: grid; gap: 5px; margin: 8px 0 0; padding-left: 20px; font-size: 12px; line-height: 1.5;
}
@media (max-width: 760px) {
  .fill-plan-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.preview-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.preview-actions .refine-prompt { flex: 1 1 520px; min-height: 92px; }

/* ---------- editable outline ---------- */
.outline-list { display: grid; border-top: 1px solid var(--border); }
.outline-page { padding: 16px 2px; border-bottom: 1px solid var(--border); }
.outline-page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.outline-page-head strong { font-size: 13px; }
.outline-page-tools { display: flex; gap: 5px; }
.icon-btn {
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  color: var(--muted); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 18px; line-height: 1;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.danger-icon { color: var(--danger); }
.outline-page-fields { display: grid; grid-template-columns: minmax(0, 2fr) minmax(160px, .7fr); gap: 12px; }
.outline-page-fields .field { margin: 0; }
.outline-points { grid-column: 1 / -1; }
.outline-points textarea { min-height: 92px; }
.fill-outline-page-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fill-outline-page-title span {
  padding: 2px 8px; color: var(--muted); background: var(--surface-2);
  border-radius: 999px; font-size: 12px;
}
.fill-outline-rationale {
  display: grid; gap: 5px; margin-bottom: 12px; padding: 10px 12px;
  color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.45;
}
.fill-outline-rationale b { color: var(--text); }
.fill-outline-fields { grid-template-columns: 1fr; }
.fill-outline-edit small {
  display: block; max-height: 58px; overflow: auto; color: var(--faint);
  font-size: 11px; line-height: 1.4;
}
.fill-outline-edit textarea, .fill-outline-native-edit textarea { min-height: 76px; }
.fill-outline-native-edit {
  display: grid; gap: 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fill-outline-native-edit > strong { font-size: 13px; }
.fill-outline-cell-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px;
}
.fill-outline-series {
  display: grid; grid-template-columns: minmax(180px, .5fr) minmax(260px, 1fr); gap: 10px;
}
@media (max-width: 760px) {
  .fill-outline-series { grid-template-columns: 1fr; }
}
.outline-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }

/* ---------- workspace grid ---------- */
.ws-grid { display: grid; grid-template-columns: 1fr; gap: 18px; }

/* slide filmstrip / gallery */
.page-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-top: 6px; }
.page-thumb { margin: 0; padding: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: border-color .15s, transform .05s; }
.page-thumb:hover { border-color: var(--accent); transform: translateY(-2px); }
.page-thumb img { width: 100%; aspect-ratio: 16 / 9; background: #fff; border-radius: 6px; object-fit: contain; box-shadow: 0 1px 3px rgba(20,24,40,.12); }
.page-thumb figcaption { margin-top: 7px; color: var(--muted); font-size: 12px; text-align: center; }

/* ---------- artifact lists ---------- */
.artifact-list { display: grid; gap: 8px; margin: 8px 0 0; padding: 0; list-style: none; }
.artifact-list li {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 10px 12px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px;
}
.artifact-list strong { color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.artifact-list a { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; color: #fff; background: var(--accent); border-radius: 7px; text-decoration: none; font-weight: 550; }
.artifact-list a:hover { background: var(--accent-hover); }
/* Keeps the row on the list's 2-column grid when it carries an action button. */
.artifact-actions { display: inline-flex; align-items: center; gap: 10px; }
.artifact-actions .btn { min-height: 26px; padding: 4px 9px; font-size: 12px; }

/* ---------- operator extras ---------- */
.op-extras { display: grid; gap: 16px; }
.handoff { padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; line-height: 1.55; }
.handoff strong { color: var(--text); }
.handoff code { color: var(--accent); }
.runtime-log {
  min-height: 150px; max-height: 300px; margin: 0; padding: 12px; overflow: auto;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.subgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.events, .catalog { min-height: 120px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; }
.events { margin: 8px 0 0; padding-left: 28px; }
.events li { margin-bottom: 7px; }
.catalog dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px; margin: 8px 0 0; }
.catalog dt { color: var(--text); }
.catalog dd { margin: 0; }

.hidden { display: none !important; }

/* ---------- toast notifications ---------- */
#toast-stack {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 60; display: grid; gap: 8px; width: min(480px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 11px 14px; font-size: 13.5px; line-height: 1.5;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  overflow-wrap: anywhere; cursor: pointer; pointer-events: auto;
  animation: toast-in .22s ease-out;
}
.toast-warn { border-left-color: var(--warn); }
.toast-ok { border-left-color: var(--good); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity .28s, transform .28s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .toast { animation: none; }
  .toast.leaving { transition: none; }
}

/* ---------- dual-mode visibility ---------- */
body[data-mode="client"] [data-op] { display: none !important; }
body[data-mode="operator"] [data-client] { display: none !important; }
/* Client mode: the API badge is diagnostics — surface it only while
   connecting or on failure, disappear once everything is healthy. */
body[data-mode="client"] #api-status[data-kind="ok"] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .compose-grid { grid-template-columns: 1fr; }
  .route-guide ol { grid-template-columns: 1fr 1fr; }
  .subgrid { grid-template-columns: 1fr; }
  .progress-steps { grid-template-columns: 1fr 1fr; }
  .ws-head { align-items: flex-start; }
  .wizard-footer { grid-template-columns: auto auto; }
  .wizard-footer .hint { display: none; }
  .outline-page-fields { grid-template-columns: 1fr; }
  .outline-points { grid-column: auto; }
  h1 { font-size: 25px; }
}

@media (max-width: 520px) {
  .route-guide ol { grid-template-columns: 1fr; }
  .wizard-step { grid-template-columns: 22px; }
  .wizard-step b { display: none; }
  .outline-actions { align-items: stretch; flex-direction: column; }
}
