/* ============================================================
   EndPaperAI — 微光拟物风格 (soft neumorphism)
   ============================================================ */

:root {
  --bg:           #eef1f6;
  --bg-grad:      radial-gradient(ellipse at top left, #f5f7fc 0%, #eef1f6 55%, #e7ebf2 100%);
  --surface:      #f3f5fa;
  --surface-grad: linear-gradient(145deg, #fafbff 0%, #eaeef5 100%);
  --surface-deep: #e6eaf1;

  --text:         #1f2733;
  --text-soft:    #3d4656;
  --muted:        #6a7588;
  --border:       rgba(38,50,78,0.08);

  --primary:      #4c6fff;
  --primary-deep: #3a58df;
  --primary-soft: rgba(76,111,255,0.12);

  --danger:       #e05252;
  --ok:           #1fbf75;
  --warn:         #ef9a3a;

  --radius-xl:    24px;
  --radius-lg:    18px;
  --radius-md:    14px;
  --radius-sm:    10px;
  --radius-pill:  999px;

  /* Shadow vocabulary — "outer raised" + "inset well" + "pressed" */
  --sh-out:       -8px -8px 20px rgba(255,255,255,0.9), 8px 8px 22px rgba(38,50,78,0.09);
  --sh-out-sm:    -3px -3px 8px rgba(255,255,255,0.85), 4px 4px 12px rgba(38,50,78,0.07);
  --sh-in:        inset 3px 3px 7px rgba(38,50,78,0.07), inset -3px -3px 7px rgba(255,255,255,0.9);
  --sh-press:     inset 5px 5px 12px rgba(38,50,78,0.12), inset -5px -5px 12px rgba(255,255,255,0.55);
  --sh-primary:   -3px -3px 9px rgba(255,255,255,0.6), 6px 8px 18px rgba(76,111,255,0.35);
  --sh-primary-h: -3px -3px 9px rgba(255,255,255,0.75), 8px 10px 24px rgba(76,111,255,0.48);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ */
/* Topbar — floating pill                                       */
/* ------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  margin: 20px 24px 0;
  padding: 14px 24px;
  background: var(--surface-grad);
  border-radius: var(--radius-xl);
  box-shadow: var(--sh-out);
  /* Stay pinned on screen while the page scrolls. A thin backdrop blur
     keeps the cards readable as they pass under the bar. */
  position: sticky;
  top: 14px;
  z-index: 20;
  backdrop-filter: saturate(1.15) blur(10px);
  -webkit-backdrop-filter: saturate(1.15) blur(10px);
}
body { padding-top: 0; }  /* topbar has its own margin-top */
.topbar .brand {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.3px;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(135deg, #4c6fff, #7b5cff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.topbar nav { display: flex; gap: 4px; align-items: center; }
.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  transition: background .2s, color .2s, box-shadow .2s;
}
.topbar nav a:hover { background: var(--primary-soft); color: var(--primary); }
.topbar nav a.nav-sub { font-size: 12px; padding: 4px 10px; opacity: 0.78; }

.container { max-width: 1080px; margin: 0 auto; padding: 28px 24px 48px; }

/* ------------------------------------------------------------ */
/* Typography                                                   */
/* ------------------------------------------------------------ */
h1 { font-size: 24px; margin: 0 0 22px; font-weight: 600; letter-spacing: 0.3px; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 600; color: var(--text-soft); }

/* ------------------------------------------------------------ */
/* Cards                                                        */
/* ------------------------------------------------------------ */
.card {
  background: var(--surface-grad);
  border-radius: var(--radius-xl);
  padding: 24px 26px;
  margin-bottom: 22px;
  box-shadow: var(--sh-out);
}
.card-narrow { max-width: 440px; margin: 0 auto; }

/* ------------------------------------------------------------ */
/* Form controls — inset well                                   */
/* ------------------------------------------------------------ */
label { display: block; margin: 14px 0 8px; font-weight: 500; color: var(--text); font-size: 14px; }

input[type=text],
input[type=password],
input[type=number],
textarea,
select {
  width: 100%;
  padding: 12px 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--sh-in);
  transition: box-shadow .25s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  box-shadow: var(--sh-in), 0 0 0 3px var(--primary-soft);
}
textarea {
  resize: vertical;
  min-height: 200px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.6;
}
input[type=file] {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-grad);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--sh-out-sm);
  cursor: pointer;
  font-family: inherit;
  color: var(--text-soft);
}
input[type=file]::file-selector-button {
  margin-right: 12px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, #5a7bff, #4561f0);
  color: #fff;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  box-shadow: -1px -1px 3px rgba(255,255,255,0.4), 2px 2px 6px rgba(76,111,255,0.3);
}
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236a7588' d='M6 8 0 1.4 1.4 0 6 4.6 10.6 0 12 1.4z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* ------------------------------------------------------------ */
/* Buttons                                                      */
/* ------------------------------------------------------------ */
button, .btn, .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 24px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  margin-top: 14px;
  transition: transform .12s, box-shadow .2s, color .2s;
  font-family: inherit;
}
button, .btn {
  background: linear-gradient(145deg, #5a7bff 0%, #4561f0 100%);
  color: #fff;
  box-shadow: var(--sh-primary);
}
button:hover, .btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-primary-h);
}
button:active, .btn:active {
  transform: translateY(0);
  box-shadow: inset 3px 3px 8px rgba(0,0,0,0.15), inset -3px -3px 8px rgba(255,255,255,0.2);
}

.btn-secondary {
  background: var(--surface-grad);
  color: var(--text-soft);
  box-shadow: var(--sh-out-sm);
}
.btn-secondary:hover { color: var(--primary); transform: translateY(-1px); }
.btn-secondary:active { transform: translateY(0); box-shadow: var(--sh-press); }

.inline-form { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form input { width: auto; }
.inline-form button { margin-top: 0; }

.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; line-height: 1.6; }
.hint em { font-style: normal; color: var(--primary); font-weight: 500; }

/* ------------------------------------------------------------ */
/* Flash messages                                               */
/* ------------------------------------------------------------ */
.flashes { list-style: none; padding: 0; margin: 0 0 22px; }
.flash {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  box-shadow: var(--sh-out-sm);
  font-size: 14px;
}
.flash-error   { background: #fde9e9; color: var(--danger); }
.flash-success { background: #e0f7ec; color: var(--ok); }
.flash-message, .flash- { background: #e8efff; color: var(--primary); }

/* ------------------------------------------------------------ */
/* Meta dl, status, progress                                    */
/* ------------------------------------------------------------ */
.meta { display: grid; grid-template-columns: 120px 1fr; gap: 12px 22px; margin: 0; }
.meta dt { color: var(--muted); font-size: 13px; }
.meta dd { margin: 0; color: var(--text); }
.err { color: var(--danger); }

.status {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  box-shadow: var(--sh-out-sm);
}
.status-queued     { background: linear-gradient(145deg,#e9efff,#d9e3ff); color: #3a55c7; }
.status-processing { background: linear-gradient(145deg,#fff4d9,#ffe8b3); color: #a66a11; }
.status-completed  { background: linear-gradient(145deg,#e3f8ee,#cdf1df); color: var(--ok); }
.status-failed     { background: linear-gradient(145deg,#fde9e9,#f9d3d3); color: var(--danger); }
.status-stopped    { background: linear-gradient(145deg,#eef1f6,#dde2ec); color: var(--muted); }

.progress-bar {
  display: inline-block;
  width: 260px;
  height: 12px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  vertical-align: middle;
  margin-right: 10px;
  box-shadow: var(--sh-in);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4c6fff, #7b93ff 50%, #9fb4ff);
  border-radius: var(--radius-pill);
  transition: width .5s ease;
  box-shadow: inset 1px 1px 2px rgba(255,255,255,0.3);
}

.eta-chip {
  color: var(--muted);
  font-size: 13px;
  margin-left: 4px;
}

/* Code history list */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface-grad);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-out-sm);
  flex-wrap: wrap;
}
.history-row.is-current {
  box-shadow: var(--sh-out-sm), 0 0 0 2px var(--primary) inset;
  background: linear-gradient(145deg, #f4f7ff 0%, #e4ebff 100%);
}
.history-main { min-width: 0; flex: 1; }
.history-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.history-code {
  font-size: 14px;
  letter-spacing: 1px;
  font-weight: 500;
  padding: 3px 12px;
}
.history-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.history-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.history-actions form { margin: 0; }
.history-actions .btn, .history-actions .btn-secondary { margin: 0; }

.actions { margin-top: 20px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.actions form { margin-top: 0; }
.actions .hint { margin: 0 0 0 auto; }

/* ------------------------------------------------------------ */
/* Tables                                                       */
/* ------------------------------------------------------------ */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.data-table th {
  padding: 10px 14px;
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .15s; }
.data-table tbody tr:hover { background: var(--primary-soft); }
.data-table .empty { text-align: center; color: var(--muted); padding: 40px; }
.data-table a { color: var(--primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }

/* Stats pills */
.stats { list-style: none; padding: 0; margin: 0 0 16px; display: flex; gap: 12px; flex-wrap: wrap; }
.stats li {
  color: var(--muted);
  padding: 10px 18px;
  background: var(--bg);
  border-radius: var(--radius-md);
  box-shadow: var(--sh-in);
  font-size: 13px;
}
.stats strong { color: var(--text); margin-left: 8px; font-size: 16px; font-weight: 600; }

/* ------------------------------------------------------------ */
/* Admin tab nav                                                */
/* ------------------------------------------------------------ */
.admin-nav {
  display: flex;
  gap: 6px;
  margin: -24px -26px 18px;
  padding: 14px 20px;
  background: linear-gradient(180deg, var(--surface-deep), var(--bg));
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  align-items: center;
}
.admin-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 8px 20px;
  border-radius: var(--radius-pill);
  transition: all .2s;
  font-size: 14px;
}
.admin-nav a:hover { color: var(--primary); }
.admin-nav a.active {
  background: var(--surface-grad);
  color: var(--primary);
  box-shadow: var(--sh-out-sm);
}
.admin-nav .push-right { margin-left: auto; }
.admin-nav .inline-form button { margin-top: 0; padding: 8px 18px; }

/* Grid form for creating codes */
.grid-form {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 16px;
  align-items: end;
}
.grid-form label { margin: 0; }
.grid-form button { margin-top: 0; }

/* ------------------------------------------------------------ */
/* Change / segment cards                                       */
/* ------------------------------------------------------------ */
.change-grid { display: flex; flex-direction: column; gap: 16px; }

.change-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--sh-out-sm);
}
.change-card header {
  padding: 12px 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: linear-gradient(180deg, #fafbff, var(--surface-deep));
  border-bottom: 1px solid var(--border);
}

.tag {
  display: inline-block;
  padding: 3px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  background: var(--primary-soft);
  color: var(--primary);
}
.tag-stage { background: #dde4ff; color: #3a55c7; }
.tag-ok    { background: #d9f3e4; color: var(--ok); }
.tag-muted { background: #e6eaf1; color: var(--muted); }

.change-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.change-before, .change-after {
  margin: 0;
  padding: 18px 20px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-soft);
}
.change-before { background: #fff5f5; }
.change-after  { background: #f0fbf5; border-left: 1px solid var(--border); }
.change-cols-single { grid-template-columns: 1fr; }
.change-cols-single .change-before { background: var(--surface); }

/* Segment state tints */
.seg-card.state-pending { opacity: 0.88; }
.seg-card.state-pending .change-after { background: var(--surface); color: var(--muted); }
.seg-card.state-title   { opacity: 0.8; }
.seg-card.state-skipped { opacity: 0.9; }
.seg-card.state-skipped .change-before {
  background: #fff8e5;
  border-left: 3px solid var(--warn);
}

/* Final output block */
.final-output {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg);
  padding: 22px 24px;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.8;
  box-shadow: var(--sh-in);
  color: var(--text-soft);
}

/* ------------------------------------------------------------ */
/* Radio selection cards (run mode)                             */
/* ------------------------------------------------------------ */
.radio-group { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.radio-card {
  display: flex;
  gap: 14px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  background: var(--surface-grad);
  box-shadow: var(--sh-out-sm);
  font-weight: normal;
  margin: 0;
  align-items: flex-start;
  transition: transform .12s, box-shadow .2s;
}
.radio-card:hover { transform: translateY(-1px); }
.radio-card input[type=radio] {
  margin-top: 5px;
  width: auto;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.radio-card strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 15px; }
.radio-card p { margin: 0; }
.radio-card:has(input:checked) {
  box-shadow: var(--sh-out-sm), 0 0 0 2px var(--primary) inset;
  background: linear-gradient(145deg, #f4f7ff 0%, #e4ebff 100%);
}

/* Checkbox row */
.check-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-grad);
  border-radius: var(--radius-md);
  box-shadow: var(--sh-out-sm);
  margin: 14px 0 4px;
  font-weight: 500;
  cursor: pointer;
  transition: transform .12s;
}
.check-line:hover { transform: translateY(-1px); }
.check-line input[type=checkbox] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}

/* ------------------------------------------------------------ */
/* Preview (paragraph-selection) page                           */
/* ------------------------------------------------------------ */
.preview-list { display: flex; flex-direction: column; gap: 10px; }
.preview-row {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface-grad);
  border-radius: var(--radius-lg);
  box-shadow: var(--sh-out-sm);
  cursor: pointer;
  margin: 0;
  font-weight: normal;
  align-items: flex-start;
  transition: transform .12s, box-shadow .2s, background .2s;
}
.preview-row:hover { transform: translateY(-1px); }
.preview-row input[type=checkbox] {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.preview-row:has(input:checked) {
  background: linear-gradient(145deg, #f4f7ff 0%, #e4ebff 100%);
  box-shadow: var(--sh-out-sm), 0 0 0 2px var(--primary) inset;
}
.preview-row.row-title   { opacity: 0.65; cursor: not-allowed; }
.preview-row.row-skipped { background: linear-gradient(145deg, #fff8ea, #fff1d9); }
.preview-body { flex: 1; min-width: 0; }
.preview-head { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.preview-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-soft);
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

/* ------------------------------------------------------------ */
/* Admin — codes page                                           */
/* ------------------------------------------------------------ */
.code-create-form {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto;
  gap: 16px;
  align-items: end;
}
.code-create-form .field { display: flex; flex-direction: column; gap: 6px; }
.code-create-form .field label { margin: 0; }
.code-create-form .field .hint { margin: 0; font-size: 12px; }
.code-create-form .field-wide { }
.code-create-form .field-action button { margin: 0; }

.codes-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.codes-header h2 { margin: 0; }
.counter {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 1px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  margin-left: 8px;
  vertical-align: middle;
}
.code-search {
  width: auto;
  flex: 1;
  max-width: 320px;
  margin-left: auto;
  padding: 8px 14px;
  font-size: 13px;
}

.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
.codes-table { min-width: 820px; }
.codes-table td { vertical-align: middle; }
.codes-table .ts-cell { color: var(--muted); font-size: 13px; white-space: nowrap; }
.codes-table .note-cell { color: var(--text-soft); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.code-cell { display: inline-flex; align-items: center; gap: 8px; }
.code-val { font-size: 14px; letter-spacing: 0.5px; font-weight: 500; }
.btn-copy {
  margin: 0;
  padding: 4px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-grad);
  color: var(--text-soft);
  box-shadow: var(--sh-out-sm);
}
.btn-copy:hover { color: var(--primary); transform: none; box-shadow: var(--sh-out-sm); }
.btn-copy.ok { background: linear-gradient(145deg, #e3f8ee, #cdf1df); color: var(--ok); }

.quota-cell { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.quota-numbers { font-size: 13px; color: var(--text-soft); }
.mini-progress {
  width: 100%;
  height: 8px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  box-shadow: var(--sh-in);
  overflow: hidden;
}
.mini-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4c6fff, #7b93ff);
  border-radius: var(--radius-pill);
  transition: width .3s;
}
.mini-progress-fill.fill-warn   { background: linear-gradient(90deg, #ef9a3a, #f5b866); }
.mini-progress-fill.fill-danger { background: linear-gradient(90deg, var(--danger), #ee7575); }

.btn-sm { margin: 0; padding: 6px 14px; font-size: 12px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .code-create-form { grid-template-columns: 1fr 1fr; }
  .code-create-form .field-wide { grid-column: span 2; }
  .code-create-form .field-action { grid-column: span 2; }
  .code-create-form .field-action button { width: 100%; }
  .codes-header { gap: 10px; }
  .code-search { max-width: none; margin-left: 0; width: 100%; }
}

/* ============================================================ */
/* /start page                                                  */
/* ============================================================ */

/* Stage 1 — centered hero for code entry */
.hero-wrap {
  max-width: 460px;
  margin: 40px auto 0;
}
.card-hero {
  text-align: center;
  padding: 44px 36px 36px;
}
.hero-title {
  font-size: 30px;
  font-weight: 600;
  margin: 0 0 10px;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #4c6fff, #7b5cff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-subtitle {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 14px;
}
.hero-form { display: flex; flex-direction: column; gap: 12px; }
.hero-form input[type=text],
.hero-form input[type=password] {
  font-size: 15px;
  padding: 14px 18px;
}
/* Redemption-code-specific cosmetics (centered, spaced, uppercase).
   Must NOT apply to admin login inputs → scope by name=code. */
.hero-form input[name="code"] {
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.hero-form button {
  margin-top: 4px;
  width: 100%;
  padding: 13px 22px;
  font-size: 15px;
}
.hero-hint { text-align: center; margin-top: 20px; }
.hero-subaction {
  display: block;
  text-align: center;
  margin-top: 10px;
  color: var(--primary);
  font-size: 13px;
  text-decoration: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background .2s;
}
.hero-subaction:hover { background: var(--primary-soft); }

/* Stage 2 — centered multi-step form */
.page-center { max-width: 720px; margin: 0 auto; }

.code-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  gap: 20px;
  flex-wrap: wrap;
}
.banner-left { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.banner-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.banner-code {
  font-size: 15px;
  letter-spacing: 1px;
  font-weight: 500;
  padding: 3px 12px;
  align-self: flex-start;
}
.banner-note { font-size: 12px; color: var(--muted); }
.banner-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.banner-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}
.banner-remaining { font-size: 13px; color: var(--text-soft); }
.banner-remaining strong { color: var(--text); font-size: 16px; }
.banner-progress { width: 100%; }

/* Step block */
.start-form { padding: 28px 30px; }
.step { margin-bottom: 26px; }
.step:last-of-type { margin-bottom: 0; }
.step-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--text);
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, #5a7bff, #4561f0);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--sh-primary);
  flex-shrink: 0;
}
.step-hint { margin-top: 10px; }

/* Segmented pill radios (processing_mode) */
.segmented {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.segmented label {
  margin: 0;
  cursor: pointer;
  font-weight: normal;
}
.segmented input[type=radio] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segmented span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  background: var(--surface-grad);
  color: var(--text-soft);
  box-shadow: var(--sh-out-sm);
  font-size: 14px;
  transition: background .2s, color .2s, transform .12s;
}
.segmented label:hover span { transform: translateY(-1px); color: var(--primary); }
.segmented label:has(input:checked) span {
  background: linear-gradient(145deg, #5a7bff, #4561f0);
  color: #fff;
  box-shadow: var(--sh-primary);
}
.segmented label:has(input:checked):hover span { color: #fff; }
.segmented em {
  font-style: normal;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: rgba(255,255,255,0.18);
  color: inherit;
}
.segmented label:not(:has(input:checked)) em {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Source tabs (docx vs. text) */
.source-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-pill);
  box-shadow: var(--sh-in);
  width: fit-content;
}
.source-tabs .tab {
  margin: 0;
  padding: 8px 22px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
}
.source-tabs .tab:hover { color: var(--primary); transform: none; box-shadow: none; }
.source-tabs .tab.active {
  background: linear-gradient(145deg, #5a7bff, #4561f0);
  color: #fff;
  box-shadow: var(--sh-primary);
}
.source-tabs .tab.active:hover { color: #fff; }
.source-panel { margin-top: 4px; }

/* Final CTA */
.start-cta {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}
.start-cta button {
  min-width: 220px;
  padding: 14px 40px;
  font-size: 15px;
  letter-spacing: 1px;
}

@media (max-width: 720px) {
  .hero-wrap { margin-top: 20px; }
  .card-hero { padding: 32px 22px 26px; }
  .hero-title { font-size: 24px; }
  .page-center { padding: 0; }
  .start-form { padding: 22px 20px; }
  .code-banner { padding: 14px 18px; }
  .banner-right { width: 100%; }
  .banner-stats { min-width: 0; flex: 1; }
  .start-cta button { width: 100%; min-width: 0; }
  .source-tabs { width: 100%; }
  .source-tabs .tab { flex: 1; padding: 8px 12px; }
  .segmented { gap: 6px; }
  .segmented span { padding: 8px 14px; font-size: 13px; }
}

/* ------------------------------------------------------------ */
/* Misc                                                         */
/* ------------------------------------------------------------ */
#live-counter {
  font-weight: normal;
  color: var(--muted);
  margin-left: 10px;
  font-size: 14px;
}

code {
  background: var(--bg);
  padding: 2px 10px;
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  box-shadow: var(--sh-in);
  color: var(--text);
}

.hidden { display: none; }

/* ------------------------------------------------------------ */
/* Scrollbar polish (WebKit)                                    */
/* ------------------------------------------------------------ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(145deg, #cbd1dd, #b8bfcb);
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ------------------------------------------------------------ */
/* Responsive                                                   */
/* ------------------------------------------------------------ */
@media (max-width: 720px) {
  .topbar { margin: 12px; padding: 12px 18px; flex-wrap: wrap; gap: 12px; }
  .container { padding: 20px 16px 40px; }
  .card { padding: 20px; border-radius: var(--radius-lg); }
  .grid-form { grid-template-columns: 1fr 1fr; }
  .change-cols { grid-template-columns: 1fr; }
  .change-after { border-left: none; border-top: 1px solid var(--border); }
  .meta { grid-template-columns: 100px 1fr; }
  .progress-bar { width: 160px; }
  .admin-nav { margin: -20px -20px 16px; flex-wrap: wrap; }
  h1 { font-size: 21px; }
}
