/* ============================================================
   分镜大师 Agent · Darkroom Worktable 主题（浅色）
   暖纸白底 / 墨黑文字 / 朱砂红强调 / 赭金点缀
   ============================================================ */

:root {
  --paper:      #f4efe6;   /* 暖纸底 */
  --paper-2:    #faf6ee;   /* 卡面更亮 */
  --paper-sink: #ece5d7;   /* 凹陷/输入底 */
  --ink:        #1b1714;   /* 近黑墨 */
  --ink-2:      #3a342d;
  --ink-soft:   #6b6358;   /* 次级文字 */
  --ink-faint:  #9a9082;   /* 弱化文字 */
  --vermil:     #c4422a;   /* 朱砂红强调 */
  --vermil-dk:  #9c3120;
  --ochre:      #b07a2c;   /* 赭金 */
  --line:       #d9d0bf;   /* 分隔线 */
  --line-soft:  #e4dccd;
  --good:       #4f7a3a;

  --f-display: "Fraunces", "Songti SC", Georgia, serif;
  --f-body:    "Hanken Grotesk", "PingFang SC", "Microsoft YaHei", sans-serif;
  --f-mono:    "JetBrains Mono", "SF Mono", Menlo, monospace;

  --shadow-sm: 0 1px 2px rgba(40, 30, 20, 0.06);
  --shadow-md: 0 6px 22px -10px rgba(50, 38, 24, 0.28);
  --shadow-lg: 0 18px 50px -22px rgba(50, 38, 24, 0.45);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  /* 暖纸 + 极淡点阵纹理 + 顶部微光 */
  background-image:
    radial-gradient(circle at 1px 1px, rgba(120, 100, 70, 0.05) 1px, transparent 0),
    radial-gradient(1200px 480px at 70% -10%, rgba(196, 66, 42, 0.06), transparent 60%);
  background-size: 22px 22px, 100% 100%;
  min-height: 100vh;
}

/* 颗粒覆盖层 */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

a { color: var(--vermil); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

::selection { background: rgba(196, 66, 42, 0.18); }

/* ============================================================
   顶栏
   ============================================================ */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 28px clamp(20px, 4vw, 56px) 20px;
  border-bottom: 1px solid var(--line);
  position: relative;
  max-width: 100%;
}
.topbar::after {
  content: "";
  position: absolute;
  left: clamp(20px, 4vw, 56px);
  right: clamp(20px, 4vw, 56px);
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--vermil) 0 64px, transparent 64px);
}

.topbar__brand { display: flex; align-items: center; gap: 16px; }
.topbar__mark {
  font-size: 38px;
  color: var(--vermil);
  line-height: 1;
  transform: translateY(-2px);
}
.topbar__title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.01em;
  line-height: 0.95;
  font-optical-sizing: auto;
}
.topbar__title-en {
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 0.42em;
  letter-spacing: 0.32em;
  vertical-align: middle;
  color: var(--vermil);
  margin-left: 8px;
  border: 1.5px solid var(--vermil);
  padding: 3px 8px 2px;
  border-radius: 4px;
}
.topbar__tag {
  margin: 6px 0 0;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.topbar__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 14px;
  min-width: 0;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}
.topbar__brand { min-width: 0; }
.topbar__skills { white-space: nowrap; }
.topbar__date { color: var(--ink); font-weight: 500; }
.topbar__sep { width: 1px; height: 16px; background: var(--line); }
.status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--good);
  margin-right: 5px;
  box-shadow: 0 0 0 3px rgba(79, 122, 58, 0.16);
  vertical-align: middle;
}

/* ============================================================
   通用：按钮
   ============================================================ */
.ghost-btn {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 12px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}
.ghost-btn:hover {
  color: var(--ink);
  border-color: var(--vermil);
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.ghost-btn:active { transform: translateY(1px); }
.ghost-btn--sm { padding: 5px 10px; font-size: 11px; }
.ghost-btn--stop {
  color: var(--vermil);
  border-color: var(--vermil);
}
.ghost-btn--stop:hover { background: var(--vermil); color: #fff; }

/* ============================================================
   工作台布局
   ============================================================ */
.workbench {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: clamp(20px, 2.5vw, 40px);
  align-items: start;
  padding: clamp(24px, 3vw, 40px) clamp(20px, 4vw, 56px);
  max-width: min(1500px, 100%);
  margin: 0 auto;
}

.panel-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head__num {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--vermil);
  letter-spacing: 0.1em;
}
.panel-head__title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.panel-head__hint {
  font-size: 12px;
  color: var(--ink-faint);
  margin-left: auto;
  text-align: right;
}

/* ---------- 左栏：剧本台 ---------- */
.deck {
  position: sticky;
  top: 24px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-md);
}
.deck .panel-head { margin-bottom: 14px; }

.script-wrap {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--paper-sink);
  overflow: hidden;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.script-wrap:focus-within {
  border-color: var(--vermil);
  box-shadow: 0 0 0 3px rgba(196, 66, 42, 0.1);
}
.script-input {
  width: 100%;
  height: clamp(300px, 48vh, 560px);
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: 13px;
  line-height: 1.7;
  padding: 16px;
  display: block;
}
.script-input::placeholder { color: var(--ink-faint); }

.script-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  gap: 12px;
}
.script-foot__stats {
  display: flex;
  gap: 16px;
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink-soft);
}
.script-foot__stats strong { color: var(--vermil); font-weight: 600; }
.script-foot__acts { display: flex; gap: 8px; }
.file-pick { display: inline-flex; cursor: pointer; }

/* ---------- 右栏：控制台 ---------- */
.console { min-width: 0; }

.console__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

/* 分段 Tab */
.seg {
  display: inline-flex;
  background: var(--paper-sink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}
.seg__btn {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 9px 18px;
  border-radius: 7px;
  color: var(--ink-soft);
  font-family: var(--f-body);
  transition: all 0.18s ease;
}
.seg__btn:hover { color: var(--ink); }
.seg__btn.is-active {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-sm);
}
.seg__num {
  font-family: var(--f-mono);
  font-size: 10px;
  opacity: 0.6;
  letter-spacing: 0.08em;
}
.seg__label { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.seg__en {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  opacity: 0.65;
}
.seg__btn.is-active .seg__en { color: var(--paper); opacity: 0.7; }

/* 面板切换 */
.tool-panel { display: none; }
.tool-panel.is-active {
  display: block;
  animation: panel-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tool-intro { margin-bottom: 16px; }
.tool-intro__title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 19px;
}
.tool-intro__title span {
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  text-transform: uppercase;
  margin-left: 10px;
}

/* ---------- 选角卡片网格 ---------- */
.cast {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
  min-width: 0;
}
.cast-card {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  overflow: hidden;
}
.cast-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--vermil);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.2s ease;
}
.cast-card:hover {
  border-color: var(--ink-faint);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.cast-card.is-selected {
  border-color: var(--vermil);
  background: #fff;
  box-shadow: var(--shadow-md);
}
.cast-card.is-selected::before { transform: scaleY(1); }

.cast-card__id {
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  line-height: 1.4;
  color: var(--ink-faint);
  text-transform: uppercase;
  margin-bottom: 8px;
  /* 预留两行高度：导演名长短不一时，下方标题仍对齐 */
  min-height: 2.8em;
}
.cast-card__name {
  margin: 0 0 6px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.cast-card__tagline {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--vermil-dk);
  font-weight: 500;
}
.cast-card__desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-soft);
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cast-card__cast-mark {
  position: absolute;
  top: 12px; right: 12px;
  font-family: var(--f-mono);
  font-size: 8.5px;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 5px;
  opacity: 0;
  transition: opacity 0.16s ease;
}
.cast-card.is-selected .cast-card__cast-mark {
  opacity: 1;
  color: var(--vermil);
  border-color: var(--vermil);
}
.cast-empty {
  grid-column: 1 / -1;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--paper-sink);
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.7;
}
.cast-empty code {
  font-family: var(--f-mono);
  font-size: 12px;
  background: rgba(196, 66, 42, 0.08);
  color: var(--vermil-dk);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- 接力状态条（LENS 接入分镜表） ---------- */
.chain-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid var(--vermil);
  border-left-width: 3px;
  border-radius: 9px;
  background: rgba(196, 66, 42, 0.06);
}
.chain-bar[hidden] { display: none; }
.chain-bar__icon { color: var(--vermil); font-size: 16px; line-height: 1; }
.chain-bar__text {
  font-size: 13px;
  color: var(--ink);
  line-height: 1.4;
}
.chain-bar__text strong { color: var(--vermil-dk); font-weight: 700; }
.chain-bar__text span {
  display: block;
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.chain-bar__clear { margin-left: auto; }

/* 分镜表输出卡里的「接力」高亮按钮 */
.chain-btn {
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--vermil);
  border: 1px solid var(--vermil);
  border-radius: 7px;
  padding: 7px 13px;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}
.chain-btn:hover {
  background: var(--vermil-dk);
  border-color: var(--vermil-dk);
  box-shadow: var(--shadow-md);
}
.chain-btn:active { transform: translateY(1px); }

/* ---------- RUN 行 ---------- */
.run-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 22px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line-soft);
}
.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--f-body);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: #fff;
  background: var(--ink);
  border: 0;
  border-radius: 9px;
  padding: 13px 26px;
  cursor: pointer;
  transition: all 0.16s ease;
  box-shadow: var(--shadow-md);
}
.run-btn:not(:disabled):hover {
  background: var(--vermil);
  box-shadow: var(--shadow-lg);
  transform: translateY(-1px);
}
.run-btn:not(:disabled):active { transform: translateY(0); }
.run-btn:disabled {
  background: var(--paper-sink);
  color: var(--ink-faint);
  box-shadow: none;
  cursor: not-allowed;
}
.run-btn__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--vermil);
}
.run-btn:disabled .run-btn__dot { background: var(--ink-faint); }
.run-btn:not(:disabled):hover .run-btn__dot { background: #fff; }

.run-status {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
}
.run-status.is-running { color: var(--ochre); }
.run-status.is-done { color: var(--good); }
.run-status.is-error { color: var(--vermil); }

/* ---------- 输出区 ---------- */
.tool-output { min-height: 120px; }

.empty-hint {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--paper-sink);
  padding: 48px 24px;
  text-align: center;
}
.empty-hint p {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--ink-faint);
  line-height: 1.9;
}

.output-card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.output-card__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--paper-2);
}
.output-card__tag {
  font-family: var(--f-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  font-weight: 600;
  color: #fff;
  background: var(--ink);
  padding: 4px 9px;
  border-radius: 5px;
}
.output-card__tag--video { background: var(--vermil); }
.output-card__title {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 18px;
}
.output-card__meta {
  margin-left: auto;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.output-card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--paper-sink);
}
.view-tabs {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  margin-right: auto;
}
.view-tabs button {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  padding: 6px 12px;
  transition: all 0.14s ease;
}
.view-tabs button:hover { color: var(--ink); }
.view-tabs button.is-active { background: var(--ink); color: var(--paper); }

.output-card__body {
  padding: 22px 24px;
  max-height: 62vh;
  overflow: auto;
}
.output-card__err {
  margin: 0 20px 18px;
  padding: 12px 14px;
  border-left: 3px solid var(--vermil);
  background: rgba(196, 66, 42, 0.07);
  color: var(--vermil-dk);
  font-family: var(--f-mono);
  font-size: 12px;
  border-radius: 0 6px 6px 0;
  line-height: 1.6;
}

/* 流式光标 */
.cursor {
  display: inline-block;
  width: 8px;
  height: 1.05em;
  background: var(--vermil);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* RAW 视图 */
.output-card__body pre {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

/* 渲染视图（markdown） */
.md-render { font-size: 14.5px; line-height: 1.7; color: var(--ink); }
.md-render h1, .md-render h2, .md-render h3 {
  font-family: var(--f-display);
  font-weight: 600;
  line-height: 1.2;
  margin: 1.2em 0 0.5em;
}
.md-render h1 { font-size: 22px; }
.md-render h2 { font-size: 19px; }
.md-render h3 { font-size: 16px; color: var(--vermil-dk); }
.md-render p { margin: 0.6em 0; }
.md-render code {
  font-family: var(--f-mono);
  font-size: 0.86em;
  background: rgba(176, 122, 44, 0.12);
  color: var(--ochre);
  padding: 1px 5px;
  border-radius: 4px;
}
.md-render strong { color: var(--ink); font-weight: 700; }
.md-render table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13px;
  font-family: var(--f-body);
}
.md-render th {
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-align: left;
  padding: 9px 11px;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.md-render th:first-child { border-top-left-radius: 6px; }
.md-render th:last-child { border-top-right-radius: 6px; }
.md-render td {
  padding: 8px 11px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  color: var(--ink-soft);
}
.md-render tbody tr:nth-child(even) { background: var(--paper-sink); }
.md-render tbody tr:hover { background: rgba(196, 66, 42, 0.05); }

/* ============================================================
   归档
   ============================================================ */
.archive-deck {
  padding: clamp(20px, 3vw, 36px) clamp(20px, 4vw, 56px) 12px;
  max-width: 1500px;
  margin: 0 auto;
  border-top: 1px solid var(--line);
}
.archive {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(20px, 3vw, 40px);
}
.archive__label {
  font-family: var(--f-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--vermil-dk);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
}
.archive__list { list-style: none; margin: 0; padding: 0; }
.archive__list li {
  font-family: var(--f-mono);
  font-size: 12.5px;
  color: var(--ink-soft);
  padding: 7px 0 7px 18px;
  position: relative;
  border-bottom: 1px solid var(--line-soft);
}
.archive__list li::before {
  content: "›";
  position: absolute;
  left: 2px;
  color: var(--vermil);
}
.archive__empty { color: var(--ink-faint); }
.archive__empty::before { content: "" !important; }

/* ============================================================
   底栏
   ============================================================ */
.footer {
  text-align: center;
  padding: 28px 20px 36px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-mono);
  font-size: 13px;
  padding: 12px 22px;
  border-radius: 9px;
  box-shadow: var(--shadow-lg);
  z-index: 10000;
  animation: toast-in 0.24s ease;
}
.toast[hidden] { display: none; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 1100px) {
  .workbench { grid-template-columns: 1fr; }
  .deck { position: static; }
  .script-input { height: 280px; }
}
@media (max-width: 620px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 14px; }
  .console__bar { flex-direction: column; align-items: stretch; }
  .seg { width: 100%; }
  .seg__btn { flex: 1; justify-content: center; }
  .archive { grid-template-columns: 1fr; }
}

/* ============================================================
   积分体系：登录态 + 模态
   ============================================================ */
.auth-slot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.auth-credits {
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--vermil-dk);
  background: var(--paper-sink);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px 9px;
}
.auth-user {
  font-size: 12px;
  color: var(--ink-soft);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.run-btn--sm {
  font-size: 12px;
  padding: 5px 14px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal[hidden] { display: none; }
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27, 23, 20, 0.45);
  backdrop-filter: blur(2px);
}
.modal__card {
  position: relative;
  z-index: 1;
  width: min(360px, calc(100vw - 40px));
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px 26px 24px;
  text-align: center;
}
.modal__x {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.modal__x:hover { color: var(--ink); }
.modal__title {
  font-family: var(--f-display);
  font-size: 19px;
  color: var(--ink);
  margin: 0 0 6px;
}
.modal__hint {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 18px;
}
.modal__btn {
  width: 100%;
  margin-top: 10px;
}
.modal__input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--f-mono);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-sink);
  color: var(--ink);
  margin-bottom: 4px;
}
.modal__input:focus {
  outline: none;
  border-color: var(--vermil);
}
.modal__msg {
  font-size: 12px;
  color: var(--ink-soft);
  min-height: 16px;
  margin: 12px 0 0;
}

/* 登录弹窗：邮箱表单 + 切换链接 + 分隔线 */
.modal__switch {
  font-size: 12px;
  color: var(--ink-soft);
  margin: 12px 0 0;
}
.modal__switch a {
  color: var(--vermil);
  font-weight: 600;
  margin-left: 4px;
}
.modal__divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 6px;
  color: var(--ink-faint);
  font-size: 12px;
}
.modal__divider::before,
.modal__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* 管理员：兑换码管理面板 */
.modal__card--wide { width: min(520px, calc(100vw - 40px)); }
.admin-gen {
  display: grid;
  grid-template-columns: 1fr 1fr 1.4fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
}
.admin-gen .modal__input { margin-bottom: 0; }
.admin-gen .run-btn { padding: 9px 18px; white-space: nowrap; }
.admin-stats {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink-soft);
  margin: 10px 0 8px;
  text-align: left;
}
.admin-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-sink);
}
.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}
.admin-row:last-child { border-bottom: none; }
.admin-code {
  font-family: var(--f-mono);
  font-size: 12px;
  color: var(--ink);
  flex: 1;
  text-align: left;
}
.admin-code.is-used { color: var(--ink-faint); text-decoration: line-through; }
.admin-credits-tag { color: var(--vermil-dk); font-weight: 700; }
.admin-status {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--paper-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.admin-batch { color: var(--ink-faint); min-width: 40px; text-align: right; }

/* 管理员：使用统计 */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 6px 0 16px;
}
.stat-card {
  background: var(--paper-sink);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 8px;
  text-align: center;
}
.stat-card__num {
  font-family: var(--f-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--vermil-dk);
  line-height: 1.1;
}
.stat-card__label {
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 4px;
}
.stats-table {
  max-height: 340px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-sink);
}
.stats-row {
  display: grid;
  grid-template-columns: 56px 44px 44px 44px 44px 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  font-family: var(--f-mono);
  text-align: right;
}
.stats-row:last-child { border-bottom: none; }
.stats-row--head {
  position: sticky;
  top: 0;
  background: var(--paper-2);
  color: var(--ink-soft);
  font-weight: 600;
}
.stats-row .st-day { text-align: left; color: var(--ink); }
.stats-row .st-gen { color: var(--vermil-dk); font-weight: 700; }
.st-bar {
  display: block;
  height: 8px;
  background: var(--line-soft);
  border-radius: 4px;
  overflow: hidden;
}
.st-bar i {
  display: block;
  height: 100%;
  background: var(--vermil);
  border-radius: 4px;
}
.st-bar-h { background: none; }
