/* WordToMod — "dark armoury" theme. Self-contained: no external fonts,
   images or CDN assets; every texture is a CSS gradient. */

/* ---- Design tokens (UI contract §2; legacy aliases kept for old rules) ---- */
:root {
  --bg: #0a0c0f;
  --bg-elev: #11141a;
  --panel: #161a22;
  --border: #242a35;
  --border-strong: #3a4150;
  --gold: #d5a651;
  --gold-bright: #eac47c;
  --gold-dim: #8a6d34;
  --ember: #c0392b;
  --ember-bright: #e77b6d;
  --ok: #3fa96b;
  --ok-bright: #5fc98d;
  --text: #e8e4da;
  --text-dim: #9a948a;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 10px 30px rgba(0, 0, 0, 0.45);
  --focus-ring: 0 0 0 3px rgba(213, 166, 81, 0.28);
  /* Legacy aliases — older rules and any inline usage keep resolving. */
  --bg-2: var(--bg-elev);
  --panel-2: #1c212b;
  --muted: var(--text-dim);
  --gold-soft: var(--gold-bright);
  --red: var(--ember);
  --red-soft: var(--ember-bright);
  --wrap: 880px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, Helvetica,
    Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Consolas", "Menlo", monospace;
  /* Display face for page-level titles only: a print-like serif (Georgia +
     Songti/SimSun for CJK) gives the "chronicle" flavor the armory theme
     wants, while body text stays on the sans stack for readability. */
  --display: Georgia, "Times New Roman", "Songti SC", "SimSun", serif;
}

/* ---- Base ---- */
* { box-sizing: border-box; }

/* The hidden attribute must always win, even over display:flex/grid rules. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  /* Two faint gold halos + a whisper-quiet diagonal grain over the base. */
  background:
    radial-gradient(1100px 540px at 20% -12%, rgba(213, 166, 81, 0.08), transparent 65%),
    radial-gradient(900px 520px at 95% -8%, rgba(213, 166, 81, 0.045), transparent 70%),
    repeating-linear-gradient(-38deg, rgba(232, 228, 218, 0.012) 0 1px, transparent 1px 11px),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

::selection { background: rgba(213, 166, 81, 0.32); }

a { color: var(--gold); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: var(--gold-bright); }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
/* Text controls carry their own gold ring on :focus instead. */
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; }
/* Radios/checkboxes have no border-glow focus style of their own — without an
   outline they would be the only keyboard-unreachable-looking controls. */
input[type="radio"]:focus-visible, input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}

.main { flex: 1 0 auto; padding: 40px 20px 64px; }

.muted { color: var(--text-dim); }
.accent { color: var(--gold); }

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 15, 0.72);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 60px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.2px;
}
.brand:hover { color: var(--text); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(140deg, var(--gold-bright), var(--gold-dim));
  color: #181206;
  font-weight: 800;
  font-size: 16px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), var(--shadow-1);
}
.brand-text { font-size: 18px; }
.brand-tag {
  color: var(--text-dim);
  font-size: 13px;
  border-left: 1px solid var(--border-strong);
  padding-left: 14px;
}

.auth-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
}
.auth-user {
  font-weight: 600;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-user:hover { color: var(--gold-bright); }
.auth-credit {
  color: var(--gold-bright);
  border: 1px solid var(--border-strong);
  background: rgba(213, 166, 81, 0.07);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 13px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.auth-link { color: var(--text-dim); }
.auth-link:hover { color: var(--gold-bright); }
.auth-link-strong { color: var(--gold); font-weight: 600; }
.logout-form { display: inline; margin: 0; }
.linklike {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.15s ease;
}
.linklike:hover { color: var(--gold-bright); }

/* "+ 新建任务" — always-visible CTA, the site-wide way back to the creator. */
.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  color: #1c1406;
  background: linear-gradient(135deg, var(--gold-bright), #b8862f);
  border: 1px solid rgba(234, 196, 124, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), var(--shadow-1);
  transition: filter 0.16s ease, transform 0.16s ease;
}
.nav-cta:hover { filter: brightness(1.08); color: #1c1406; }
.nav-cta:active { transform: translateY(1px); }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  padding: 22px 0;
  text-align: center;
}
.site-footer a { color: var(--text-dim); }
.site-footer a:hover { color: var(--gold-bright); }

/* ---- Hero (index) ---- */
.hero { margin-bottom: 32px; }
.hero h1 {
  font-family: var(--display);
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1.22;
  margin: 0 0 12px;
  letter-spacing: 1px;
}
.hero .accent {
  background: linear-gradient(115deg, var(--gold-bright) 20%, var(--gold) 55%, #c9793f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.lede { color: var(--text-dim); font-size: 17px; margin: 0; max-width: 62ch; }
.feature-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.chip {
  font-size: 13px;
  color: var(--gold-bright);
  border: 1px solid var(--border-strong);
  background: rgba(213, 166, 81, 0.06);
  border-radius: 999px;
  padding: 5px 12px;
}

/* ---- Cards / panels ---- */
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), var(--shadow-1);
}
.panel + .panel { margin-top: 18px; }
.panel-error { border-color: rgba(192, 57, 43, 0.55); }
.panel-error h2 { color: var(--ember-bright); }

/* ---- Badges (status chips shared by job meta / jobs list) ---- */
.badge {
  /* inline-block, not flex: text-overflow only ellipsizes an inline/block
     text container, so long pack names in .job-meta would hard-clip on flex. */
  display: inline-block;
  vertical-align: middle;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-dim);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.job-meta .badge { max-width: 280px; }
.badge-run {
  color: var(--gold-bright);
  border-color: rgba(213, 166, 81, 0.45);
  background: rgba(213, 166, 81, 0.08);
}
.badge-wait {
  color: var(--gold-bright);
  border-color: var(--gold-dim);
  background: rgba(138, 109, 52, 0.14);
}
.badge-done {
  color: var(--ok-bright);
  border-color: rgba(63, 169, 107, 0.5);
  background: rgba(63, 169, 107, 0.1);
}
.badge-fail {
  color: var(--ember-bright);
  border-color: rgba(192, 57, 43, 0.5);
  background: rgba(192, 57, 43, 0.1);
}
.badge-warn {
  display: inline-block;
  margin-left: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ember-bright);
  border: 1px solid rgba(192, 57, 43, 0.55);
  border-radius: 999px;
  padding: 1px 9px;
}

/* ---- Forms ---- */
.create-form { margin-top: 24px; }
.field { margin-bottom: 20px; }
.field:last-of-type { margin-bottom: 0; }
label.field-label,
.field-label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 8px;
}
.field-hint { color: var(--text-dim); font-size: 13px; margin: 6px 0 0; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 11px 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; min-height: 96px; }
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="file"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: var(--focus-ring);
}
input[type="file"] { padding: 9px 12px; cursor: pointer; }
input[type="file"]::file-selector-button {
  background: var(--panel-2);
  color: var(--gold-bright);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 6px 12px;
  margin-right: 12px;
  cursor: pointer;
  font: inherit;
}
input::placeholder, textarea::placeholder { color: rgba(154, 148, 138, 0.75); }

/* Mode radios */
.mode-group { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.mode-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 13px 15px;
  cursor: pointer;
  background: var(--bg-elev);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.mode-option:hover { border-color: var(--gold); }
.mode-option:focus-within { border-color: var(--gold); box-shadow: var(--focus-ring); }
.mode-option input { margin-top: 3px; accent-color: var(--gold); }
.mode-option:has(input:checked) {
  border-color: var(--gold);
  background: rgba(213, 166, 81, 0.08);
}
.mode-option .mo-title { font-weight: 600; }
.mode-option .mo-desc { color: var(--text-dim); font-size: 13px; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  padding: 11px 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease, background-color 0.16s ease,
    border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.btn-gold {
  background: linear-gradient(135deg, var(--gold-bright), #b8862f);
  color: #1c1406;
  border-color: rgba(234, 196, 124, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), var(--shadow-1);
}
.btn-gold:hover { filter: brightness(1.08); color: #1c1406; }
.btn-gold:disabled { filter: grayscale(0.5) brightness(0.8); cursor: not-allowed; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.02);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(213, 166, 81, 0.06);
}
.btn-sm { padding: 7px 14px; font-size: 13.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
input:disabled,
textarea:disabled { opacity: 0.6; cursor: not-allowed; }
.mode-option:has(input:disabled) { cursor: not-allowed; opacity: 0.7; }
.form-actions { margin-top: 24px; display: flex; flex-wrap: wrap; gap: 12px; }

/* ---- Alerts ---- */
.alert-error {
  background: rgba(192, 57, 43, 0.12);
  border: 1px solid rgba(192, 57, 43, 0.6);
  color: var(--ember-bright);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 22px;
  font-size: 14px;
}
.alert-ok {
  background: rgba(63, 169, 107, 0.1);
  border: 1px solid rgba(63, 169, 107, 0.55);
  color: var(--ok-bright);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 22px;
  font-size: 14px;
}

/* Inline alert inside the create form (client-side upload errors) */
.upload-alert { margin: 20px 0 0; }

/* ---- Dropzone (index; markup by the frontend agent) ---- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 30px 20px;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(213, 166, 81, 0.025), transparent 60%), var(--bg-elev);
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}
.dropzone:hover { border-color: var(--gold); background-color: rgba(213, 166, 81, 0.045); }
.dropzone.is-drag {
  border-color: var(--gold);
  background-color: rgba(213, 166, 81, 0.07);
  box-shadow: 0 0 0 4px rgba(213, 166, 81, 0.14);
}
.dropzone.has-file {
  border-style: solid;
  border-color: var(--gold-dim);
  background-color: rgba(213, 166, 81, 0.04);
}
/* The real input covers the whole zone; keyboard focus lights the frame. */
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  margin: 0;
  padding: 0;
}
.dropzone:focus-within { border-color: var(--gold); box-shadow: var(--focus-ring); }
.dropzone svg, .dz-icon { width: 28px; height: 28px; color: var(--gold); opacity: 0.85; }
.dropzone p { margin: 0; }
.dropzone-title, .dz-main { font-weight: 600; font-size: 15px; }
.dropzone-hint, .dz-sub { color: var(--text-dim); font-size: 13px; }

/* Per-file progress rows (main pack + reference packs) */
.file-list { display: grid; gap: 8px; margin-top: 12px; }
.file-list:empty { display: none; }
.file-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.18s ease;
}
.file-row-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}
.file-row-meta {
  color: var(--text-dim);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.file-row-status { color: var(--text-dim); font-size: 12.5px; white-space: nowrap; }
/* Compact "移除" button at the end of a row. */
.file-row-remove {
  padding: 3px 10px;
  font-size: 12px;
  border-radius: 7px;
  color: var(--text-dim);
}
.file-row-remove:hover {
  color: var(--ember-bright);
  border-color: rgba(192, 57, 43, 0.55);
  background: rgba(192, 57, 43, 0.08);
}
/* The bar renders below the name/meta/status line regardless of DOM order. */
.file-row-bar {
  order: 10;
  flex-basis: 100%;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  overflow: hidden;
}
.file-row-fill {
  position: relative;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  overflow: hidden;
  transition: width 0.18s linear;
}
.file-row.is-active { border-color: rgba(213, 166, 81, 0.45); }
.file-row.is-done .file-row-status { color: var(--ok-bright); }
.file-row.is-done .file-row-fill { background: linear-gradient(90deg, var(--gold), var(--gold-bright)); }
.file-row.is-error { border-color: rgba(192, 57, 43, 0.55); }
.file-row.is-error .file-row-status,
.file-row.is-error .file-row-name { color: var(--ember-bright); }
.file-row.is-error .file-row-fill { background: var(--ember); }

/* Reference-mods section wrapper */
.ref-box {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.012);
}
.ref-box .field-label { margin-bottom: 4px; }
.ref-box .field-hint { margin: 0 0 12px; }

/* ---- Chunked upload progress (create form, legacy classes) ---- */
.upload-progress { margin-top: 16px; }
.up-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--border);
  overflow: hidden;
}
.up-fill {
  position: relative;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  box-shadow: 0 0 10px rgba(213, 166, 81, 0.32);
  overflow: hidden;
  transition: width 0.18s linear;
}
/* Soft light sweep across every active fill bar. */
.up-fill::after,
.file-row-fill::after,
.progressbar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.22) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: shimmer 1.8s ease-in-out infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.up-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.up-pct {
  color: var(--gold-bright);
  font-weight: 600;
  font-size: 14px;
  min-width: 44px;
}
.up-status { margin: 8px 0 0; font-size: 13px; color: var(--text-dim); }
.up-status.is-error { color: var(--ember-bright); }

/* Split savings note (SPLIT_SPEC 3b) */
.split-savings {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(213, 166, 81, 0.1);
  border: 1px solid rgba(213, 166, 81, 0.45);
  color: var(--gold-bright);
  font-size: 13px;
  line-height: 1.55;
}

/* ---- Job page ---- */
.job { display: block; }
.job-back { margin: 0 0 14px; font-size: 14px; }
.job-back a { color: var(--text-dim); }
.job-back a:hover { color: var(--gold-bright); }
.job-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-cancel {
  color: var(--ember-bright);
  border-color: rgba(192, 57, 43, 0.45);
}
.btn-cancel:hover {
  color: #fff;
  border-color: var(--ember);
  background: rgba(192, 57, 43, 0.18);
}
/* Actionable link inside an error alert (e.g. 「前往我的任务」). */
.alert-action {
  color: var(--gold-bright);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.alert-action:hover { color: var(--gold); }

.job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 18px;
}
.job-id-label {
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.job-id {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--gold-bright);
  word-break: break-all;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 8px 16px 8px 12px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-1);
}

/* Mode / main pack / reference-pack badges row */
.job-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 20px;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(213, 166, 81, 0.25);
  border-top-color: var(--gold);
  animation: spin 0.9s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Stepper (job page; markup by the frontend agent) ---- */
.stepper {
  display: flex;
  align-items: flex-start;
  margin: 4px 0 18px;
  padding: 0;
  list-style: none;
}
.step {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
/* Connector line from the previous dot to this one. */
.step:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 10px;
  left: calc(-50% + 17px);
  right: calc(50% + 17px);
  height: 2px;
  border-radius: 2px;
  background: var(--border-strong);
}
.step.is-done:not(:first-child)::before,
.step.is-active:not(:first-child)::before {
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
}
.step-dot {
  position: relative;
  z-index: 1;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--bg-elev);
  flex: none;
}
.step-label {
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text-dim);
  overflow-wrap: break-word;
  max-width: 100%;
}
/* Done: solid gold dot with a dark check. */
.step.is-done .step-dot {
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
}
.step.is-done .step-dot::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 3px;
  width: 5px;
  height: 9px;
  border: solid #1a1206;
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.step.is-done .step-label { color: var(--text); }
/* Active: glowing pulsing dot. */
.step.is-active .step-dot {
  border-color: var(--gold);
  background: rgba(213, 166, 81, 0.14);
  animation: step-pulse 1.6s ease-in-out infinite;
}
.step.is-active .step-dot::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px rgba(213, 166, 81, 0.7);
}
.step.is-active .step-label { color: var(--gold-bright); font-weight: 600; }
@keyframes step-pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(213, 166, 81, 0.12); }
  50% { box-shadow: 0 0 0 7px rgba(213, 166, 81, 0.22); }
}
/* Failed: ember dot with a cross. */
.step.is-fail .step-dot {
  border-color: var(--ember);
  background: rgba(192, 57, 43, 0.14);
}
.step.is-fail .step-dot::before,
.step.is-fail .step-dot::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  border-radius: 2px;
  background: var(--ember-bright);
}
.step.is-fail .step-dot::before { transform: translate(-50%, -50%) rotate(45deg); }
.step.is-fail .step-dot::after { transform: translate(-50%, -50%) rotate(-45deg); }
.step.is-fail .step-label { color: var(--ember-bright); }

/* Thin progress bar under the stepper */
.progressbar {
  height: 6px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progressbar-fill {
  position: relative;
  height: 100%;
  width: 5%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  overflow: hidden;
  transition: width 0.6s ease;
}
#progress-hint { margin: 14px 0 0; }

/* Questions form */
#questions-panel h2, #done-panel h2, #failed-panel h2,
#merge-panel h2, #chat-panel h2 { margin: 0 0 8px; font-size: 20px; }
#answers-form { margin-top: 18px; display: grid; gap: 18px; }
fieldset.q {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 0;
  background: rgba(255, 255, 255, 0.012);
}
fieldset.q legend {
  padding: 0 8px;
  font-weight: 600;
  color: var(--gold-bright);
}
fieldset.q .opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 7px 0;
  cursor: pointer;
}
fieldset.q .opt:hover { color: var(--gold-bright); }
fieldset.q .opt input { margin-top: 4px; accent-color: var(--gold); }
fieldset.q textarea { margin-top: 4px; }

#download-btn { margin-top: 8px; }
#failed-error { color: var(--ember-bright); word-break: break-word; }

/* ---- Conversational Q&A (chat window) ---- */
#chat-summary { margin: 0 0 16px; font-size: 14px; }

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 460px;
  min-height: 120px;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.chat-row { display: flex; flex-direction: column; max-width: 100%; }
.chat-row-user { align-items: flex-end; }
.chat-row-assistant { align-items: flex-start; }

.chat-bubble {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}
.chat-bubble-user {
  background: rgba(213, 166, 81, 0.14);
  border: 1px solid rgba(213, 166, 81, 0.35);
  border-bottom-right-radius: 4px;
  color: var(--text);
}
.chat-bubble-assistant {
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--gold);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.chat-bubble.is-failed {
  border-color: rgba(192, 57, 43, 0.6);
  color: var(--ember-bright);
}

.chat-ts {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.chat-empty { text-align: center; margin: auto 0; }

/* "AI 正在思考…" placeholder; delays stagger if several dots are rendered. */
.chat-thinking {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-style: italic;
}
.chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex: none;
  animation: chat-pulse 1.1s ease-in-out infinite;
}
.chat-dot:nth-of-type(2) { animation-delay: 0.18s; }
.chat-dot:nth-of-type(3) { animation-delay: 0.36s; }
@keyframes chat-pulse {
  0%, 100% { opacity: 0.25; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

.chat-error {
  color: var(--ember-bright);
  font-size: 14px;
  margin: 12px 0 0;
}

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.chat-input-row textarea {
  flex: 1 1 auto;
  min-height: 70px;
  margin: 0;
}
.chat-input-row .btn { flex: none; }

#chat-panel.is-waiting .chat-list { opacity: 0.92; }

/* "开始制作" hand-off below the chat */
.chat-build {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.build-form { margin-top: 4px; }
.build-form textarea { margin-bottom: 0; }
.build-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
}

/* ---- Split-job local merge panel ---- */
.merge-note {
  margin: 12px 0 14px;
  padding: 12px 14px;
  background: var(--panel-2);
  border: 1px solid rgba(213, 166, 81, 0.35);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.65;
}
.merge-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.merge-controls input[type="file"] {
  flex: 1 1 260px;
  min-width: 0;
  padding: 9px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 14px;
}
.merge-controls input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--gold-bright);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.merge-controls input[type="file"]::file-selector-button:hover {
  border-color: var(--gold);
  background: rgba(213, 166, 81, 0.08);
}
.merge-controls .btn { flex: 0 0 auto; }
.merge-status { margin: 12px 0 0; color: var(--gold-bright); font-size: 14px; }
.merge-error { margin: 12px 0 0; color: var(--ember-bright); font-size: 14px; }

/* ---- 「我的任务」 list page ---- */
.jobs-page { max-width: 760px; margin: 0 auto; }
.jobs-list { display: grid; gap: 14px; margin-top: 14px; }

/* Section split: running jobs (slot counter + cancel) vs finished history. */
.jobs-section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 30px 0 4px;
  font-size: 16px;
  font-weight: 700;
}
.jobs-slots {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gold-bright);
  border: 1px solid var(--gold-dim);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.jobs-section-hint { margin: 0; font-size: 13px; }
.jobs-item-body {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  color: var(--text);
  text-decoration: none;
}
.jobs-item-body:hover { color: var(--text); }
.jobs-item-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

/* New card (design), with a state-coloured spine on the left. */
.job-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 16px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), var(--shadow-1);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}
.job-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--border-strong);
}
.job-card.is-run::before { background: linear-gradient(180deg, var(--gold-bright), var(--gold-dim)); }
.job-card.is-wait::before { background: var(--gold-dim); }
.job-card.is-done::before { background: var(--ok); }
.job-card.is-fail::before { background: var(--ember); }
.job-card:hover {
  transform: translateY(-2px);
  border-color: var(--gold-dim);
  box-shadow: var(--shadow-2);
  color: var(--text);
}

/* Legacy jobs-list classes, restyled onto the new look. The card itself is a
   flex row (body link + optional cancel action), so no display:block here. */
.jobs-item {
  color: var(--text);
}
.jobs-item:hover { color: var(--text); }
.jobs-item-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.jobs-mode {
  font-size: 12px;
  color: var(--text-dim);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.jobs-state {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold-bright);
  border: 1px solid rgba(213, 166, 81, 0.4);
  background: rgba(213, 166, 81, 0.07);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}
.jobs-state-done {
  color: var(--ok-bright);
  border-color: rgba(63, 169, 107, 0.5);
  background: rgba(63, 169, 107, 0.1);
}
.jobs-state-failed,
.jobs-state-expired,
.jobs-state-cancelled {
  color: var(--ember-bright);
  border-color: rgba(192, 57, 43, 0.55);
  background: rgba(192, 57, 43, 0.1);
}
.jobs-time {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 13px;
  font-family: var(--mono);
  white-space: nowrap;
}
.jobs-text {
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: break-word;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.jobs-id {
  margin-top: 6px;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--mono);
  word-break: break-all;
}

/* Empty state */
.jobs-empty { text-align: center; margin-top: 24px; padding: 40px 24px; }
.jobs-empty-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 1px dashed var(--gold-dim);
  background: rgba(213, 166, 81, 0.06);
  color: var(--gold);
}
.jobs-empty-mark svg { width: 22px; height: 22px; }
.jobs-empty-title { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.jobs-empty .btn { margin-top: 14px; }

/* ---- Account page ---- */
.account { max-width: 620px; margin: 0 auto; }
.account .auth-title { margin-bottom: 20px; }
.account .card + .card { margin-top: 18px; }
.section-title { margin: 0 0 14px; font-size: 18px; }

/* Balance stat card: one big number with a faint gold wash. */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 26px 24px;
  background:
    radial-gradient(440px 150px at 15% 0%, rgba(213, 166, 81, 0.1), transparent 70%),
    var(--panel);
}
.stat-label {
  color: var(--text-dim);
  font-size: 12.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}
.stat-value {
  font-size: clamp(34px, 6vw, 44px);
  font-weight: 700;
  line-height: 1.15;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}
.stat-unit {
  margin-left: 8px;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0;
}
.stat-meta { margin: 6px 0 0; color: var(--text-dim); font-size: 13px; }

.account-summary { display: grid; gap: 2px; }
.acct-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.acct-row:last-child { border-bottom: none; }
.acct-key { color: var(--text-dim); font-size: 14px; }
.acct-val { font-weight: 600; text-align: right; word-break: break-all; }
.acct-val.balance {
  font-family: var(--mono);
  color: var(--gold-bright);
  font-size: 18px;
}
.acct-val .unit { color: var(--text-dim); font-size: 13px; font-weight: 400; }

/* Redeem form: one line */
.redeem-form { display: flex; gap: 10px; flex-wrap: wrap; }
.redeem-form input[type="text"] { flex: 1 1 200px; }
.redeem-form .btn { flex: none; }

/* Ledger table (.table is the contract name; table.ledger the legacy one) */
.table-wrap { overflow-x: auto; }
.table,
table.ledger { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td,
table.ledger th, table.ledger td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table thead th,
table.ledger thead th {
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
}
.table tbody tr:last-child td,
table.ledger tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td,
table.ledger tbody tr:hover td { background: rgba(255, 255, 255, 0.015); }
.table .ts,
table.ledger .ts {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 13px;
}
.table .num,
table.ledger .num {
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.table .num.pos, table.ledger .num.pos { color: var(--ok-bright); }
.table .num.neg, table.ledger .num.neg { color: var(--ember-bright); }

.account-actions { margin-top: 22px; }
.account-actions form { margin: 0; }

/* ---- Auth pages (login / register / notices) ---- */
.auth-page { max-width: 420px; margin: 0 auto; }
.auth-page.narrow { max-width: 480px; }
.auth-head { text-align: center; }
.auth-brand {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--gold-bright), var(--gold-dim));
  color: #181206;
  font-weight: 800;
  font-size: 20px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), var(--shadow-1);
}
.auth-title { font-size: clamp(24px, 4vw, 30px); margin: 0 0 8px; letter-spacing: -0.3px; }
.auth-sub { color: var(--text-dim); margin: 0 0 22px; }
.auth-form { margin-top: 4px; }
.auth-alt { color: var(--text-dim); font-size: 14px; text-align: center; margin: 18px 0 0; }

/* Notice cards (verify sent / verify result) */
.notice-card { text-align: center; padding: 34px 26px; }
.notice-card .prompt-actions { justify-content: center; }
.notice-icon {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
}
.notice-icon svg { width: 28px; height: 28px; }
.notice-ok .notice-icon {
  color: var(--gold);
  border-color: rgba(213, 166, 81, 0.55);
  background: rgba(213, 166, 81, 0.07);
}
.notice-fail .notice-icon {
  color: var(--ember-bright);
  border-color: rgba(192, 57, 43, 0.55);
  background: rgba(192, 57, 43, 0.08);
}
.notice-text { margin: 0 0 6px; }
.notice-fail .auth-title { color: var(--ember-bright); }

/* Prompt / login-required card on index */
.login-prompt { margin-top: 24px; }
.login-prompt h2 { margin: 0 0 8px; font-size: 20px; }
.prompt-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }

/* ---- Responsive (≤680px) ---- */
@media (max-width: 680px) {
  .main { padding: 28px 16px 48px; }
  .header-inner { height: 56px; gap: 10px; }
  /* Fold secondary header items; keep the CTA, username and auth links. */
  .brand-tag, .auth-credit, .nav-fold { display: none; }
  .auth-area { gap: 10px; font-size: 13px; }
  .auth-user { max-width: 92px; }
  .nav-cta { padding: 7px 12px; font-size: 13px; }
  .mode-group { grid-template-columns: 1fr; }
  .card, .panel { padding: 18px 16px; }
  .job-head { align-items: flex-start; }
  .step-label { font-size: 11px; }
  .chat-bubble { max-width: 94%; }
  .chat-input-row { flex-direction: column; align-items: stretch; }
  .jobs-time { margin-left: 0; width: 100%; }
  .job-card { flex-direction: column; align-items: stretch; }
  .jobs-item-actions { justify-content: flex-end; }
  .merge-controls { flex-direction: column; align-items: stretch; }
  .job-card { padding: 14px 16px 14px 20px; }
  .notice-card { padding: 26px 18px; }
}

/* ---- Reduced motion: kill every animation and transition ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner {
    animation: none;
    /* Shorthand first: border-color would otherwise override the top color. */
    border-color: var(--gold);
    border-top-color: rgba(213, 166, 81, 0.25);
  }
  .up-fill::after, .file-row-fill::after, .progressbar-fill::after { display: none; }
}
