/* MOSS 番茄小说工作流 — 暗色主题 v2 */

:root {
  color-scheme: dark;
  /* 基础灰阶（更柔和的层次） */
  --bg: #0b0d12;
  --bg-elev: #12151c;
  --bg-card: #161a23;
  --bg-card-hover: #1b202b;
  --bg-input: #0d1017;

  /* 边框（更细腻） */
  --border: #232836;
  --border-soft: #1c2030;
  --border-strong: #2e3344;

  /* 文字（更清晰的对比层次） */
  --text: #eaecf2;
  --text-dim: #9da3b3;
  --text-muted: #6a7185;
  --text-subtle: #4a5061;

  /* 主色系（番茄红，但有明暗） */
  --accent: #ef4444;
  --accent-hover: #dc2626;
  --accent-soft: rgba(239, 68, 68, 0.12);
  --accent-glow: rgba(239, 68, 68, 0.25);
  --accent-2: #f59e0b;

  /* 状态色 */
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.1);
  --yellow: #f59e0b;
  --yellow-soft: rgba(245, 158, 11, 0.1);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.1);
  --blue: #3b82f6;
  --blue-soft: rgba(59, 130, 246, 0.1);
  --purple: #a78bfa;
  --purple-soft: rgba(167, 139, 250, 0.1);

  /* 几何 */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 12px 36px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 0 3px var(--accent-soft);

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  --font-serif: "PingFang SC", "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", "Source Han Serif", Georgia, serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --font-num: "Inter", -apple-system, sans-serif;

  /* 动效 */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 0.15s;
  --t-normal: 0.22s;
  --t-slow: 0.4s;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); color: var(--text); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

a { color: var(--blue); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: #60a5fa; text-decoration: underline; text-underline-offset: 3px; }

button { font-family: inherit; font-size: inherit; cursor: pointer; }

input, textarea, select { font-family: inherit; font-size: inherit; }

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

/* ────── 顶栏 ────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(18, 21, 28, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  user-select: none;
}

.brand .logo {
  font-size: 24px;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}
.brand .title {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand .subtitle {
  color: var(--text-muted);
  font-size: 11px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  letter-spacing: 0.05em;
}

.topnav {
  display: flex;
  gap: 2px;
}

.topnav a {
  position: relative;
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: color var(--t-fast), background var(--t-fast);
}

.topnav a:hover {
  background: var(--bg-card);
  color: var(--text);
  text-decoration: none;
}

.topnav a.active {
  color: var(--text);
  background: var(--bg-card);
}
.topnav a.active::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 14px;
  right: 14px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px 1px 0 0;
}

/* ────── 主内容 ────── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 28px 80px;
  animation: fadeIn 0.3s var(--ease);
}

.page-title {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.page-sub {
  color: var(--text-dim);
  margin-bottom: 28px;
  font-size: 14px;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ────── 卡片 ────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
  transition: border-color var(--t-fast);
}

.card:hover { border-color: var(--border-strong); }

.card h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.row > * { flex-shrink: 0; }
.row .grow { flex-grow: 1; flex-shrink: 1; min-width: 0; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  main { padding: 20px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .brand .subtitle { display: none; }
  .topnav { gap: 0; }
  .topnav a { padding: 6px 10px; font-size: 12px; }
}

/* ────── 表单 ────── */
label.field {
  display: block;
  margin-bottom: 14px;
}

label.field > .label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="email"],
textarea,
select {
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  font-size: 13px;
}

input::placeholder, textarea::placeholder {
  color: var(--text-subtle);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea {
  resize: vertical;
  min-height: 100px;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.65;
}

textarea.large { min-height: 320px; }

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239da3b3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

/* ────── 按钮 ────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--t-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-card-hover);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 4px 12px var(--accent-glow);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 18px var(--accent-glow);
}

.btn.danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--red);
}

.btn.danger:hover:not(:disabled) {
  background: var(--red);
  color: white;
  border-color: var(--red);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--bg-card);
  color: var(--text);
}

.btn.small {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 5px;
}

.btn.tiny {
  padding: 2px 8px;
  font-size: 11px;
  border-radius: 4px;
}

.btn .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ────── 列表 ────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: all var(--t-normal) var(--ease);
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, var(--accent-soft) 100%);
  opacity: 0;
  transition: opacity var(--t-normal);
  pointer-events: none;
}

.project-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.project-card:hover::before { opacity: 0.5; }

.project-card .name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  position: relative;
  letter-spacing: -0.01em;
}

.project-card .meta {
  font-size: 12px;
  color: var(--text-dim);
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.empty .ico {
  font-size: 36px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.5;
  filter: grayscale(0.4);
}

.empty .title {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 4px;
  font-weight: 500;
}

/* ────── 阶段流水线 ────── */
.stage-pipeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.stage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--t-fast), background var(--t-fast);
}

.stage-row:hover { background: var(--bg-card-hover); }

.stage-row .num {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-num);
  flex-shrink: 0;
}

.stage-row .name {
  font-weight: 500;
  font-size: 13px;
}

.stage-row .desc {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 4px;
  flex-grow: 1;
}

.stage-row .status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-dim);
}

.stage-row.done .num {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.stage-row.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.stage-row.active .num {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  animation: pulse 2s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

/* ────── Agent 卡片 ────── */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all var(--t-fast);
}

.agent-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.agent-card .name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.agent-card .desc {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ────── Provider 卡片 ────── */
.provider-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 12px;
}

.provider-card .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.provider-card .name {
  font-weight: 600;
  font-size: 14px;
}

/* ────── 模态框 ────── */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(8, 9, 13, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeBg 0.18s var(--ease);
  padding: 20px;
}

@keyframes fadeBg {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s var(--ease);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal .head {
  flex-shrink: 0;  /* 在小屏 / 长内容时不被挤压 */
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal .head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  flex-grow: 1;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.modal .body {
  padding: 20px;
  overflow-y: auto;
  flex-grow: 1;
}

.modal .foot {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: rgba(0, 0, 0, 0.15);
}

/* ────── 流式输出 ────── */
.stream-output {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 60vh;
  overflow-y: auto;
  color: var(--text);
}

/* ────── 成本看板 ────── */
.usage-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 160px;
  padding: 16px 0 0;
}

.usage-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-width: 16px;
}

.usage-bar .bar {
  width: 70%;
  background: linear-gradient(to top, var(--accent), rgba(239, 68, 68, 0.4));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: opacity var(--t-fast);
}

.usage-bar:hover .bar { opacity: 0.75; }

.usage-bar .day {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
  font-family: var(--font-num);
}

.usage-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.usage-table th, .usage-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

.usage-table th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.usage-table td.r, .usage-table th.r { text-align: right; font-family: var(--font-num); }

/* ────── 阅读模式 ────── */
.reader-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  height: calc(100vh - 110px);
}

.reader-side {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-y: auto;
}

.reader-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

.reader-chapters {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.reader-chapter {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-dim);
  transition: all var(--t-fast);
}

.reader-chapter:hover {
  background: var(--bg-elev);
  color: var(--text);
}

.reader-chapter.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.reader-main {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.reader-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-elev);
}

.reader-content {
  flex-grow: 1;
  overflow-y: auto;
  padding: 40px 60px 80px;
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 2.0;
  color: #d4d6dd;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.reader-content p {
  margin: 0 0 1.2em;
  text-indent: 2em;
  letter-spacing: 0.02em;
}

@media (max-width: 720px) {
  .reader-layout { grid-template-columns: 1fr; height: auto; }
  .reader-content { padding: 24px; font-size: 16px; }
}

.history-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
}

/* ────── 焦点 Hero 卡片（项目页「下一步」） ────── */
.hero-card {
  background:
    linear-gradient(135deg, rgba(239, 68, 68, 0.04) 0%, rgba(245, 158, 11, 0.03) 100%),
    var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-bottom: 20px;
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -30%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 50%);
  pointer-events: none;
  opacity: 0.7;
}

.hero-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  background: linear-gradient(135deg, var(--accent), transparent) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.4;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero-step {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hero-step::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  animation: pulse 2s infinite;
}

.hero-title {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 10px;
  letter-spacing: -0.02em;
}

.hero-desc {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 22px;
  line-height: 1.7;
  max-width: 580px;
}

.hero-btn {
  font-size: 14px !important;
  padding: 11px 22px !important;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.hero-btn-auto {
  font-size: 13px !important;
  padding: 11px 18px !important;
  background: transparent !important;
  border: 1px dashed var(--accent) !important;
  color: var(--accent) !important;
}

.hero-btn-auto:hover:not(:disabled) {
  background: var(--accent-soft) !important;
  border-style: solid !important;
}

/* 全自动进度阶梯 */
.auto-progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 14px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}

.auto-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  transition: all var(--t-normal) var(--ease);
}

.auto-step-icon {
  font-size: 22px;
  filter: grayscale(0.7);
  opacity: 0.5;
  transition: all var(--t-normal);
}

.auto-step-name {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  font-weight: 500;
}

.auto-step-status {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-num);
}

.auto-step.running {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-soft), 0 4px 12px var(--accent-glow);
}
.auto-step.running .auto-step-icon {
  filter: none;
  opacity: 1;
  animation: pulseIcon 1.6s ease-in-out infinite;
}
.auto-step.running .auto-step-name { color: var(--text); }
.auto-step.running .auto-step-status { color: var(--accent); font-weight: 600; }

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.auto-step.done {
  border-color: rgba(16, 185, 129, 0.3);
  background: var(--green-soft);
}
.auto-step.done .auto-step-icon { filter: none; opacity: 1; }
.auto-step.done .auto-step-name { color: var(--text); }
.auto-step.done .auto-step-status { color: var(--green); font-weight: 600; }

.auto-step.skipped {
  border-color: var(--border);
  opacity: 0.55;
}

.auto-step.error {
  border-color: var(--red);
  background: var(--red-soft);
}
.auto-step.error .auto-step-status { color: var(--red); font-weight: 600; }

/* 状态卡片 */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.stat-card .num {
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  font-family: var(--font-num);
  letter-spacing: -0.02em;
}

.stat-card .label {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 6px;
  font-weight: 500;
}

.stat-card .sub {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 3px;
}

/* ────── 首次启动向导卡片 ────── */
.onb-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}

.onb-card:hover {
  border-color: var(--accent);
}

.onb-card input {
  margin: 0;
  accent-color: var(--accent);
}

.onb-card span {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.onb-card span small {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 2px;
}

.onb-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ────── 后台任务面板（隐藏中的 modal） ────── */
#task-dock {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column-reverse;     /* 新任务出现在底部，旧任务向上堆 */
  gap: 8px;
  z-index: 80;
  max-width: 320px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 4px;
  scrollbar-width: thin;
}
#task-dock::-webkit-scrollbar { width: 4px; }
#task-dock::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.dock-task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  box-shadow: 0 8px 24px var(--accent-glow), 0 1px 2px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.25s var(--ease);
  min-width: 260px;
  transition: all var(--t-fast);
}

.dock-task:hover {
  background: var(--bg-card-hover);
  transform: translateX(2px);
}

.dock-task .spin {
  font-size: 16px;
  animation: pulseTask 1.4s ease-in-out infinite;
  flex-shrink: 0;
}

.dock-task.done .spin,
.dock-task.error .spin { animation: none; }

.dock-task.done {
  border-color: var(--green);
  box-shadow: 0 8px 24px var(--green-soft), 0 1px 2px rgba(0, 0, 0, 0.3);
}

.dock-task.error {
  border-color: var(--red);
  opacity: 0.85;
}

.dock-task .t-wrap {
  flex-grow: 1;
  min-width: 0;
}

.dock-task .t {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.dock-task .t-sub {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-task.error .t-sub { color: var(--red); }
.dock-task.done .t-sub { color: var(--green); }

@keyframes pulseTask {
  0%, 100% { opacity: 1; transform: rotate(0deg); }
  50% { opacity: 0.55; transform: rotate(8deg); }
}

/* ────── Toast ────── */
#toast-host {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-size: 13px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s var(--ease);
  pointer-events: auto;
  line-height: 1.5;
}

.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--yellow); }
.toast.info { border-left-color: var(--blue); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ────── 文件树 ────── */
.tree {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.85;
}

.tree-node {
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 4px;
  transition: background var(--t-fast);
}

.tree-node:hover {
  background: var(--bg-elev);
}

.tree-node.dir { color: var(--accent-2); font-weight: 500; }
.tree-node.file { color: var(--text-dim); }
.tree-node.active { background: var(--bg-elev); color: var(--text); }

/* ────── 杂项 ────── */
.kbd {
  display: inline-block;
  padding: 1px 7px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  background: var(--bg-elev);
  border: 1px solid var(--border-soft);
  border-radius: 100px;
  font-size: 11px;
  color: var(--text-dim);
  margin-right: 4px;
  letter-spacing: 0.01em;
}

.tag.green { color: var(--green); border-color: rgba(16, 185, 129, 0.3); background: var(--green-soft); }
.tag.red { color: var(--red); border-color: rgba(239, 68, 68, 0.3); background: var(--red-soft); }
.tag.yellow { color: var(--yellow); border-color: rgba(245, 158, 11, 0.3); background: var(--yellow-soft); }
.tag.blue { color: var(--blue); border-color: rgba(59, 130, 246, 0.3); background: var(--blue-soft); }

.muted { color: var(--text-muted); }
.dim { color: var(--text-dim); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-yellow { color: var(--yellow); }
.text-blue { color: var(--blue); }

hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 16px 0;
}

pre {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: 12px;
  font-family: var(--font-mono);
  line-height: 1.6;
  color: var(--text);
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-soft);
  color: var(--text);
}

details > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

details > summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform var(--t-fast);
  color: var(--text-dim);
}

details[open] > summary::before {
  transform: rotate(90deg);
}

details > summary::-webkit-details-marker { display: none; }

details > *:not(summary) {
  margin-top: 12px;
  padding-left: 14px;
}

/* ────── Skeleton 加载占位 ────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elev) 0%, var(--bg-card) 50%, var(--bg-elev) 100%);
  background-size: 200% 100%;
  animation: skeletonShine 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeletonShine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-card {
  height: 96px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
  animation: skeletonShine 1.4s ease-in-out infinite;
}

/* ────── 全局加载条 ────── */
#nprogress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  z-index: 1000;
  box-shadow: 0 0 8px var(--accent);
  transform-origin: left;
  transform: scaleX(0);
  transition: transform 0.3s var(--ease), opacity 0.2s;
  pointer-events: none;
}

#nprogress.loading { animation: progressLoading 1.4s ease-in-out infinite; }

@keyframes progressLoading {
  0% { transform: scaleX(0); transform-origin: left; }
  50% { transform: scaleX(0.7); transform-origin: left; }
  51% { transform: scaleX(0.7); transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

/* ────── 状态点（小圆点） ────── */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-right: 6px;
  vertical-align: middle;
}
.dot.green { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 0 3px var(--yellow-soft); }

/* ────── 顶栏用户菜单 ────── */
.topnav-user { display: inline-flex; align-items: center; margin-left: 8px; padding-left: 12px; border-left: 1px solid var(--border-soft); }
.topnav-user a { color: var(--text-dim); padding: 6px 10px; border-radius: 6px; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.topnav-user a:hover { background: var(--bg-card); color: var(--text); text-decoration: none; }
.topnav-avatar {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white; font-weight: 600; font-size: 11px;
}
.topnav-username { font-weight: 500; }

/* ────── 登录 / 注册 页面 ────── */
.auth-wrap {
  min-height: 80vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  font-size: 36px;
  text-align: center;
  margin-bottom: 8px;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}
.auth-title {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.auth-sub {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 22px;
}
.auth-form { display: flex; flex-direction: column; gap: 0; }
.auth-btn { width: 100%; padding: 11px !important; margin-top: 6px; font-size: 14px; }
.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 14px;
}
.auth-tip {
  text-align: center;
  font-size: 11px;
  margin-top: 22px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

/* ────── 可访问性：尊重系统降低动画偏好 ────── */
@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;
  }
  #nprogress.loading { animation: none !important; }
}

/* ────── 文本溢出策略：长 CJK 串可换行 ────── */
.reader-content,
.modal .body,
.hero-desc,
.page-title,
.toast,
.dock-task .t,
.dock-task .t-sub {
  overflow-wrap: break-word;
  word-break: break-word;
}
.reader-content {
  /* CJK 段落：保留单字符不切断更典雅 */
  word-break: keep-all;
}

/* ────── 480px 小屏 ────── */
@media (max-width: 480px) {
  /* 触控目标 ≥ 44px */
  .btn.small, .btn.tiny, .dock-task [data-act="x"] {
    min-height: 36px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  /* hero 卡片紧凑 */
  .hero-card { padding: 20px 16px; }
  .hero-title { font-size: 20px; }
  .hero-desc { font-size: 13px; }
  /* 5 阶段进度条挤不下 → 改为可水平滚动 */
  .auto-progress {
    grid-template-columns: repeat(5, minmax(72px, 1fr));
    overflow-x: auto;
  }
  .auto-step { padding: 8px 4px; }
  .auto-step-name { font-size: 11px; }
  /* dock 与 toast 让出空间避免重叠 */
  #task-dock { left: 12px; bottom: 12px; max-width: calc(100vw - 24px); }
  #toast-host { right: 12px; bottom: 80px; }
  /* 顶栏紧凑 */
  .topbar { padding: 10px 12px; }
  .brand .title { font-size: 14px; }
  /* main 内边距 */
  main { padding: 16px 12px 60px; }
  /* modal padding */
  .modal .body { padding: 14px 16px; }
  .modal .head { padding: 12px 14px; }
  .modal .foot { padding: 10px 14px; }
}

/* 横屏短窗口（手机横屏）：modal 可用更高比例 */
@media (orientation: landscape) and (max-height: 500px) {
  .modal { max-height: 96vh; }
}
