/* ==========================================================================
   神绘 · 漫画工作台 — 美术与视觉规范 (宣纸墨韵 × 现代漫研社)
   支持系统浅色 / 深色模式 (prefers-color-scheme)，零外部资源依赖
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* 1. 色彩体系 — 宣纸晨光 (Light) */
  --bg-canvas: #f5f1e8;          /* 宣纸底色 */
  --bg-surface: #fcf9f3;         /* 卡片 / 纸面 */
  --bg-elevated: #ffffff;        /* 输入框 / 浮起高亮 */
  --bg-subtle: #ede7db;          /* 浅墨洗底 / 轨道 / 缩略图画框 */
  --bg-hover: #eae3d5;           /* 悬停淡底 */
  --bg-header: rgba(252, 249, 243, 0.88);
  --bg-backdrop: rgba(24, 22, 19, 0.72);
  --bg-darkroom: #151412;        /* 大图灯箱暗房底色 */

  --ink-primary: #221f1b;        /* 松烟主墨 */
  --ink-secondary: #564f46;      /* 淡墨次文 */
  --ink-muted: #726a5f;          /* 枯墨辅助 */
  --ink-on-accent: #fcf9f3;      /* 主色反白 */

  --border-subtle: #e4dccd;      /* 细框线 */
  --border-strong: #ccc1ae;      /* 强调框线 / 表单边框 */
  --border-hover: #a79c89;       /* 悬停框线 */

  /* 品牌主强调色：青釉竹青 */
  --accent: #2a5c4f;
  --accent-hover: #21493e;
  --accent-ink: #1e463b;
  --accent-soft: #e3eee9;
  --accent-border: #a8c7bc;

  /* 国风点缀色：朱砂落款印 */
  --seal: #b84436;
  --seal-soft: #f7e6e2;

  /* 登录页书卷深底 */
  --hero-bg: #1e3730;
  --hero-bg-deep: #152822;
  --hero-ink: #f4efe6;
  --hero-muted: #bfd3c9;
  --hero-line: rgba(203, 223, 213, 0.34);

  /* 语义状态色 */
  --success: #245c44;
  --success-soft: #e1efe7;
  --warning: #8a5a18;
  --warning-soft: #f6ead2;
  --danger: #9f352a;
  --danger-soft: #f8e5e2;
  --toast-bg: #1f3730;
  --toast-error-bg: #842b22;

  --focus-ring: #3d7d6c;
  --selection-bg: #d4e6de;

  /* 2. 字体栈 — 中文系统字体优先 */
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: "Songti SC", "STZhongsong", "Noto Serif CJK SC", "Source Han Serif SC", "PingFang SC", "Microsoft YaHei UI", Georgia, serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Microsoft YaHei UI", monospace;

  /* 3. 字号阶梯 */
  --text-xs: 0.75rem;            /* 12px */
  --text-sm: 0.8125rem;          /* 13px */
  --text-base: 0.9375rem;        /* 15px */
  --text-md: 1.0625rem;          /* 17px */
  --text-lg: 1.25rem;            /* 20px */
  --text-xl: clamp(1.375rem, 2.4vw, 1.75rem);
  --text-2xl: clamp(1.75rem, 3.4vw, 2.375rem);
  --text-hero: clamp(2rem, 4.6vw, 3.125rem);

  --leading-tight: 1.25;
  --leading-normal: 1.65;
  --leading-prose: 1.8;

  /* 4. 间距阶梯与布局 */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --container-max: 1400px;
  --gutter: clamp(18px, 3.6vw, 48px);
  --header-height: 68px;

  /* 5. 圆角 */
  --radius-xs: 6px;
  --radius-sm: 9px;
  --radius-md: 13px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* 6. 阴影 */
  --shadow-xs: 0 1px 2px rgba(34, 31, 27, 0.05);
  --shadow-sm: 0 2px 10px rgba(34, 31, 27, 0.055), 0 1px 2px rgba(34, 31, 27, 0.04);
  --shadow-md: 0 10px 28px rgba(34, 31, 27, 0.085), 0 2px 6px rgba(34, 31, 27, 0.04);
  --shadow-lg: 0 22px 54px rgba(20, 18, 15, 0.22), 0 4px 14px rgba(20, 18, 15, 0.1);

  /* 7. 动效 */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 150ms;
  --dur-base: 220ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    /* 夜读松烟 (Dark) */
    --bg-canvas: #151412;
    --bg-surface: #1e1c19;
    --bg-elevated: #26231f;
    --bg-subtle: #2b2722;
    --bg-hover: #322e28;
    --bg-header: rgba(28, 26, 23, 0.9);
    --bg-backdrop: rgba(8, 7, 6, 0.84);
    --bg-darkroom: #0f0e0c;

    --ink-primary: #efeae0;
    --ink-secondary: #bab1a3;
    --ink-muted: #988f82;
    --ink-on-accent: #f8f5ee;

    --border-subtle: #312d27;
    --border-strong: #474138;
    --border-hover: #635a4d;

    --accent: #387564;
    --accent-hover: #438a76;
    --accent-ink: #92d4c2;
    --accent-soft: rgba(98, 179, 157, 0.16);
    --accent-border: #46786a;

    --seal: #d66858;
    --seal-soft: rgba(214, 104, 88, 0.16);

    --hero-bg: #182924;
    --hero-bg-deep: #111e1a;
    --hero-ink: #f0ebe1;
    --hero-muted: #a6beb4;
    --hero-line: rgba(166, 200, 186, 0.28);

    --success: #7cc9a6;
    --success-soft: rgba(124, 201, 166, 0.15);
    --warning: #e0b05e;
    --warning-soft: rgba(224, 176, 94, 0.16);
    --danger: #e47d72;
    --danger-soft: rgba(228, 125, 114, 0.16);
    --toast-bg: #27443c;
    --toast-error-bg: #7a2c24;

    --focus-ring: #6bbca7;
    --selection-bg: rgba(98, 179, 157, 0.28);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-sm: 0 3px 12px rgba(0, 0, 0, 0.28), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 12px 30px rgba(0, 0, 0, 0.38), 0 2px 8px rgba(0, 0, 0, 0.24);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.58), 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

/* ==========================================================================
   基础排版与重置
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-padding-top: calc(var(--header-height) + var(--space-6));
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink-primary);
  background-color: var(--bg-canvas);
  background-image:
    radial-gradient(ellipse 90% 45% at 12% 0%, var(--accent-soft), transparent 62%),
    radial-gradient(ellipse 65% 35% at 92% 6%, var(--seal-soft), transparent 58%);
  background-attachment: fixed;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--accent-ink);
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease-out);
}

a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

::selection {
  background: var(--selection-bg);
  color: var(--ink-primary);
}

img {
  display: block;
  max-width: 100%;
}

h1, h2, h3, p {
  margin: 0;
}

h1, h2, h3 {
  line-height: var(--leading-tight);
  color: var(--ink-primary);
}

h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
}

h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: -0.005em;
}

hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-6) 0;
}

/* ==========================================================================
   顶部栏与导航
   ========================================================================== */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.top-inner {
  max-width: var(--container-max);
  min-height: var(--header-height);
  margin: 0 auto;
  padding: var(--space-2) var(--gutter);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink-primary);
  text-decoration: none;
  min-width: max-content;
  border-radius: var(--radius-sm);
}

.brand:hover {
  color: var(--ink-primary);
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 10px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--dur-base) var(--ease-out);
}

.brand:hover .brand-mark {
  transform: translateY(-1px) rotate(-2deg);
}

.brand-copy {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.brand-copy b {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-primary);
}

.brand-copy > span {
  position: relative;
  padding-left: 10px;
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}

.brand-copy > span::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 1px;
  height: 12px;
  background: var(--border-strong);
}

.top-nav,
.actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.top-nav .button {
  min-height: 38px;
  padding: 6px 13px;
  font-size: var(--text-sm);
  border-radius: var(--radius-pill);
}

.top-nav .username {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  margin-left: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.top-nav .username::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--seal);
  flex: 0 0 6px;
}

/* ==========================================================================
   主容器与通用排版辅助
   ========================================================================== */

.shell {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: clamp(24px, 3.8vw, 48px) var(--gutter) 72px;
}

.heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.heading > div {
  min-width: 0;
}

.heading p {
  margin-top: 6px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}

.section-heading h3 {
  font-size: var(--text-md);
}

.muted {
  color: var(--ink-secondary);
}

.quiet {
  color: var(--ink-muted);
}

.small {
  font-size: var(--text-sm);
}

.kicker {
  display: block;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent-ink);
  margin-bottom: var(--space-1);
}

.stack {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.stack.tight {
  gap: var(--space-2);
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.stack > *,
.split > * {
  min-width: 0;
}

.full {
  grid-column: 1 / -1;
}

.stretch {
  justify-content: space-between;
}

.article {
  display: grid;
  gap: var(--space-6);
  max-width: 1040px;
}

/* ==========================================================================
   按钮体系
   ========================================================================== */

.button {
  min-height: 42px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--ink-primary);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow-xs);
  transition:
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.button:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--ink-primary);
}

.button:active {
  transform: scale(0.985);
}

.button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--ink-on-accent);
  box-shadow: 0 2px 8px rgba(42, 92, 79, 0.22);
}

.button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--ink-on-accent);
}

.button.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--ink-secondary);
}

.button.ghost:hover {
  background: var(--bg-subtle);
  border-color: transparent;
  color: var(--ink-primary);
}

.button.ghost.active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-ink);
  font-weight: 650;
}

.button.small {
  min-height: 36px;
  font-size: var(--text-sm);
  padding: 6px 12px;
}

.button.wide {
  width: 100%;
}

.arrow {
  font-size: 1.15em;
  line-height: 1;
  color: var(--ink-muted);
  transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

/* ==========================================================================
   面板、表单与折叠项
   ========================================================================== */

.panel,
.form-card {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 2.2vw, 24px);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.form-card {
  max-width: 860px;
}

.form-card.login-card {
  max-width: none;
  background: var(--bg-elevated);
  align-self: center;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field > label,
.field-label {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--ink-primary);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--ink-primary);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--border-hover);
}

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

.field textarea[readonly] {
  background: var(--bg-subtle);
  border-color: var(--border-subtle);
  line-height: var(--leading-prose);
}

.field input[type="file"] {
  padding: 6px 8px;
  cursor: pointer;
}

.field input[type="file"]::file-selector-button {
  border: 1px solid var(--accent-border);
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  margin-right: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.field input[type="file"]::file-selector-button:hover {
  background: var(--accent);
  color: var(--ink-on-accent);
  border-color: var(--accent);
}

.field textarea {
  resize: vertical;
  min-height: 88px;
  line-height: var(--leading-normal);
}

.field textarea.code,
.code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.55;
}

.field textarea.novel {
  min-height: 240px;
  line-height: var(--leading-prose);
}

.model-config-card {
  align-content: start;
}

.model-config-summary {
  overflow-wrap: anywhere;
}

.model-picker {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.model-picker .model-toggle {
  min-width: 44px;
  margin-inline-start: 6px;
  padding-inline: 0;
}

.model-options {
  position: absolute;
  z-index: 3;
  top: calc(100% + var(--space-1));
  inset-inline: 0;
  max-height: 15rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}

.model-options [role="option"] {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--ink-primary);
  font-size: var(--text-sm);
  text-align: start;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.model-options [role="option"]:hover,
.model-options [aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.model-option-note {
  display: block;
  margin-top: 2px;
}

.model-options-empty {
  padding: 10px 12px;
}

.model-check-status > .message {
  margin-top: var(--space-3);
  text-wrap: pretty;
}

.model-test-preview {
  width: min(100%, 14rem);
  height: auto;
  margin-top: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: var(--text-base);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* 折叠区 details / summary */
details.panel {
  padding: 0;
  overflow: hidden;
}

details.panel > summary {
  padding: 14px clamp(16px, 2.2vw, 24px);
}

details.panel > .details-body {
  margin-top: 0;
  padding: 0 clamp(16px, 2.2vw, 24px) clamp(16px, 2.2vw, 24px);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-4);
}

summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 44px;
  user-select: none;
}

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

summary::after {
  content: "▾";
  font-size: 13px;
  color: var(--ink-muted);
  transition: transform var(--dur-fast) var(--ease-out);
}

details[open] > summary::after {
  transform: rotate(180deg);
}

.details-body {
  margin-top: var(--space-3);
}

/* 提示条 */
.message {
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-left: 3px solid var(--accent);
  font-size: var(--text-sm);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.message.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-left-color: var(--danger);
}

.message.warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-left-color: var(--warning);
}

.message p + p {
  margin-top: 6px;
}

/* ==========================================================================
   登录 / 注册页
   ========================================================================== */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: stretch;
  max-width: 980px;
  margin: clamp(8px, 5vw, 56px) auto 0;
  min-height: 490px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.auth-intro {
  position: relative;
  min-height: 280px;
  overflow: hidden;
  padding: clamp(28px, 4.8vw, 54px);
  color: var(--hero-ink);
  background:
    radial-gradient(circle at 82% 18%, rgba(184, 68, 54, 0.2), transparent 44%),
    linear-gradient(155deg, var(--hero-bg) 0%, var(--hero-bg-deep) 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-6);
}

.auth-intro-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--space-3);
}

.auth-intro-copy::before {
  content: "神绘 · 漫研工坊";
  display: inline-flex;
  align-items: center;
  width: max-content;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(244, 239, 230, 0.24);
  background: rgba(244, 239, 230, 0.08);
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  color: var(--hero-muted);
}

.auth-intro h1 {
  font-family: var(--font-display);
  font-size: var(--text-hero);
  line-height: 1.22;
  letter-spacing: 0.04em;
  color: var(--hero-ink);
}

.auth-intro .quiet {
  color: var(--hero-muted);
  font-size: var(--text-base);
  letter-spacing: 0.04em;
}

.auth-body {
  padding: clamp(24px, 4vw, 46px);
  align-self: center;
  background: var(--bg-surface);
}

.auth-body h2 {
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

.auth-body button[type="submit"] {
  width: 100%;
  min-height: 46px;
  margin-top: var(--space-1);
  font-size: var(--text-base);
}

.auth-switch {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.auth-switch a {
  font-weight: 600;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.frame-motif {
  position: absolute;
  right: -28px;
  bottom: -82px;
  width: 248px;
  height: 316px;
  transform: rotate(-16deg);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  grid-template-rows: 1fr 1.15fr 0.9fr;
  gap: 9px;
  padding: 11px;
  border: 1px solid var(--hero-line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  opacity: 0.65;
}

.frame-motif i {
  display: block;
  border: 1px solid var(--hero-line);
  border-radius: 6px;
}

.frame-motif i:nth-child(1),
.frame-motif i:nth-child(4) {
  grid-column: span 2;
}

.frame-motif i:nth-child(3) {
  background: rgba(199, 75, 59, 0.42);
  border-color: rgba(235, 134, 118, 0.45);
}

/* ==========================================================================
   项目列表与空状态
   ========================================================================== */

.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr));
  gap: var(--space-5);
}

.project-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  min-height: 136px;
  gap: var(--space-4);
  align-items: center;
  background: var(--bg-surface);
  color: var(--ink-primary);
  text-decoration: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition:
    border-color var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.project-card:hover {
  border-color: var(--accent-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  color: var(--ink-primary);
}

.project-card:hover .arrow {
  color: var(--accent);
  transform: translate(2px, -2px);
}

.project-card > div {
  min-width: 0;
}

.project-card h2 {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.project-cover {
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-sm);
  width: 100%;
  object-fit: cover;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.project-card p {
  margin-top: 5px;
}

.panel-sign {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: 4px;
  padding: 6px;
  width: 38px;
  height: 48px;
  border: 1.25px solid var(--accent-border);
  border-radius: 5px;
  background: var(--bg-surface);
  transform: rotate(-5deg);
}

.panel-sign i {
  display: block;
  border: 1px solid var(--accent-border);
  border-radius: 1.5px;
}

.panel-sign i:first-child,
.panel-sign i:last-child {
  grid-column: span 2;
}

.panel-sign i:nth-child(3) {
  background: var(--seal-soft);
  border-color: var(--seal);
}

.project-cover:has(.panel-sign),
.art-empty:has(.panel-sign) {
  display: grid;
  place-items: center;
}

.empty {
  display: grid;
  justify-items: start;
  align-content: center;
  gap: var(--space-2);
  min-height: 180px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: clamp(22px, 3.2vw, 38px);
  background: var(--bg-surface);
  color: var(--ink-secondary);
}

.empty strong {
  color: var(--ink-primary);
  font-family: var(--font-display);
  font-size: var(--text-lg);
}

.empty.home-empty {
  min-height: 240px;
  grid-template-columns: 84px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-6);
}

.home-empty .art-empty {
  width: 84px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

/* ==========================================================================
   项目工作区与步骤侧栏
   ========================================================================== */

.project-title {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.project-title h1 {
  margin-top: var(--space-2);
}

.crumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.crumb a {
  text-decoration: none;
  color: var(--ink-secondary);
}

.crumb a:hover {
  color: var(--accent-ink);
  text-decoration: underline;
}

.project-layout {
  display: grid;
  grid-template-columns: 216px minmax(0, 1fr);
  align-items: start;
  gap: clamp(20px, 3vw, 40px);
}

.steps {
  display: grid;
  align-content: start;
  position: sticky;
  top: calc(var(--header-height) + var(--space-5));
  gap: 4px;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.step {
  position: relative;
  text-decoration: none;
  color: var(--ink-secondary);
  padding: 8px 11px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition:
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.step:hover {
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

.step[aria-current="step"] {
  color: var(--accent-ink);
  background: var(--accent-soft);
  font-weight: 650;
}

.step[aria-current="step"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--seal);
}

.step-index {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
}

.step[aria-current="step"] .step-index {
  color: var(--ink-on-accent);
  background: var(--accent);
  border-color: var(--accent);
}

.workspace {
  min-width: 0;
}

.workspace .heading {
  align-items: center;
  margin-bottom: var(--space-5);
}

.step-body {
  display: grid;
  gap: var(--space-5);
  min-width: 0;
}

.job-display {
  margin-bottom: var(--space-5);
}

.job-display:empty {
  display: none;
}

.auto-display {
  margin-bottom: var(--space-5);
}

.auto-display:empty {
  display: none;
}

.auto-panel.paused strong {
  color: var(--danger, #b4232a);
}

.auto-panel.done strong {
  color: var(--success, #1d7a46);
}

.auto-flagged summary {
  cursor: pointer;
  font-weight: 600;
}

.auto-flagged ul {
  margin: var(--space-2, 8px) 0 0;
  padding-left: 1.2em;
}

.auto-choice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  border-radius: 12px;
  margin: 8px 0 16px;
  cursor: pointer;
}

.auto-choice input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  flex: none;
}

.auto-choice > span {
  display: grid;
  gap: 4px;
}

.auto-line.paused {
  color: var(--danger, #b4232a);
}

.segmented {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.segmented a {
  text-decoration: none;
}

/* ==========================================================================
   分镜与待修双栏编辑器
   ========================================================================== */

.editor {
  display: grid;
  grid-template-columns: minmax(195px, 240px) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-5);
}

.page-picker {
  display: grid;
  gap: 6px;
  position: sticky;
  top: calc(var(--header-height) + var(--space-5));
  max-height: calc(100dvh - var(--header-height) - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.page-picker .button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 7px 11px;
  color: var(--ink-secondary);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  text-align: left;
  font-weight: 550;
}

.page-picker .button:hover {
  background: var(--bg-subtle);
  color: var(--ink-primary);
}

.page-picker .button.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-border);
  font-weight: 650;
}

.page-picker .page-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.page-picker .page-beat {
  font-size: var(--text-xs);
  min-width: max-content;
  font-weight: 500;
  color: var(--ink-muted);
}

.page-picker .button.active .page-beat {
  color: var(--accent-ink);
}

.panel-editor {
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: clamp(14px, 2vw, 20px);
  display: grid;
  gap: var(--space-4);
  box-shadow: var(--shadow-xs);
}

.panel-editor > h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-base);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.panel-editor > h3::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--accent);
  transform: rotate(45deg);
}

.panel-editor details {
  border-top: 1px dashed var(--border-subtle);
  padding-top: var(--space-2);
}

.dialog-copy {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   图片网格（设定图 / 试图 / 批量出图 / 导出成品）
   ========================================================================== */

.char-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: var(--space-4);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-4);
}

.tile {
  min-width: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    transform var(--dur-base) var(--ease-out);
}

.tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.tile figure {
  margin: 0;
  display: grid;
  gap: 0;
}

.tile figure > a,
.tile figure > button,
.tile figure > .art-empty {
  aspect-ratio: 3 / 4;
  width: 100%;
  max-height: 390px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg-subtle);
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0;
  color: var(--accent-ink);
}

.tile figure > button {
  cursor: zoom-in;
}

.tile figure > a img,
.tile figure > button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform var(--dur-base) var(--ease-out);
}

.tile figure > button:hover img,
.tile figure > a:hover img {
  transform: scale(1.025);
}

.tile figcaption,
.tile-meta {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.tile h3 {
  font-size: var(--text-base);
  overflow-wrap: anywhere;
}

.tile p {
  overflow-wrap: anywhere;
}

.tile details summary {
  min-height: 32px;
}

.tile details p {
  margin-top: 6px;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.tile .button {
  width: 100%;
}

.page-references {
  display: grid;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-reference {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  overflow-wrap: anywhere;
}

.reference-preview {
  flex: 0 0 76px;
  height: 56px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: zoom-in;
}

.reference-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ==========================================================================
   状态标签与进度条
   ========================================================================== */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: max-content;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  font-weight: 600;
  font-size: var(--text-xs);
  line-height: 1.3;
}

.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.72;
}

.status.good {
  background: var(--success-soft);
  color: var(--success);
}

.status.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.status.wait {
  background: var(--warning-soft);
  color: var(--warning);
}

.progress {
  display: grid;
  gap: 10px;
}

.progress progress {
  width: 100%;
  height: 9px;
  appearance: none;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--bg-subtle);
  border: 0;
  accent-color: var(--accent);
}

.progress progress::-webkit-progress-bar {
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
}

.progress progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: var(--radius-pill);
  transition: width var(--dur-base) var(--ease-out);
}

.progress progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: var(--radius-pill);
}

.repair-line {
  display: grid;
  grid-template-columns: minmax(0, 172px) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: start;
}

.repair-line .tile {
  align-self: start;
}

/* ==========================================================================
   弹窗、图库灯箱与 Toast
   ========================================================================== */

.dialog {
  width: min(calc(100% - 24px), 560px);
  max-height: calc(100dvh - 28px);
  padding: clamp(16px, 2.5vw, 24px);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--ink-primary);
  box-shadow: var(--shadow-lg);
}

.dialog:has(.lightbox) {
  width: min(calc(100% - 24px), 960px);
}

.dialog::backdrop {
  background: var(--bg-backdrop);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-surface);
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.lightbox {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  border-radius: var(--radius-md);
  background: var(--bg-darkroom);
  border: 1px solid var(--border-subtle);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-border) var(--bg-darkroom);
}

.lightbox > figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  min-height: 220px;
  margin: 0;
  scroll-snap-align: center;
  background: var(--bg-darkroom);
}

.lightbox img {
  width: auto;
  max-width: 100%;
  max-height: calc(100dvh - 178px);
  margin: auto;
  padding: var(--space-3);
  object-fit: contain;
}

.lightbox figcaption {
  width: 100%;
  padding: 10px var(--space-4);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  text-align: center;
}

.toast {
  position: fixed;
  z-index: 40;
  bottom: 24px;
  right: 24px;
  max-width: min(440px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--toast-bg);
  color: var(--ink-on-accent);
  font-size: var(--text-sm);
  font-weight: 550;
  box-shadow: var(--shadow-md);
  overflow-wrap: anywhere;
}

.toast.error {
  background: var(--toast-error-bg);
}

.loading {
  border: 1px solid var(--border-subtle);
  padding: 14px 20px;
  background: var(--bg-surface);
  color: var(--ink-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  width: fit-content;
}

.token {
  display: block;
  overflow-wrap: anywhere;
  user-select: all;
  font-family: var(--font-mono);
}

/* 列表（账号列表 / 切集点建议） */
.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.link-list li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
}

ol.link-list {
  counter-reset: cut-item;
}

ol.link-list li {
  counter-increment: cut-item;
  position: relative;
  padding-left: 38px;
}

ol.link-list li::before {
  content: counter(cut-item);
  position: absolute;
  left: 11px;
  top: 10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.link-list li p {
  margin-top: 4px;
}

/* ==========================================================================
   响应式适配 — 平板 / 窄屏 (<= 860px)
   ========================================================================== */

@media (max-width: 860px) {
  .project-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .steps {
    display: flex;
    position: static;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding: 6px;
    gap: 6px;
    scrollbar-width: thin;
  }

  .step {
    min-width: max-content;
    scroll-snap-align: start;
    padding: 8px 12px;
  }

  .step[aria-current="step"]::before {
    display: none;
  }

  .editor {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
  }

  .page-picker {
    position: static;
    display: flex;
    overflow-x: auto;
    max-height: none;
    padding: 6px;
    gap: 6px;
    scroll-snap-type: x proximity;
  }

  .page-picker .button {
    min-width: max-content;
    min-height: 44px;
    scroll-snap-align: start;
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
  }
}

/* ==========================================================================
   响应式适配 — 手机单列与底部顺手导航 (<= 640px，覆盖 390px)
   ========================================================================== */

@media (max-width: 640px) {
  html {
    scroll-padding-top: 4.5rem;
  }

  /* 取消顶栏 backdrop-filter，确保内部固定定位的底部导航不受包含块限制 */
  .top {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg-surface);
  }

  .top-inner {
    min-height: 58px;
    padding: 8px 16px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .brand-copy b {
    font-size: 19px;
  }

  /* 底部顺手导航栏（仅登录后有菜单项时显示） */
  .top-nav:not(:empty) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: flex;
    flex-wrap: nowrap;
    justify-content: stretch;
    gap: 4px;
    padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -4px 18px rgba(24, 21, 18, 0.08);
  }

  .top-nav .username {
    display: none;
  }

  .top-nav .button {
    flex: 1 1 0;
    min-height: 46px;
    padding: 8px 6px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
  }

  .shell {
    padding: 20px 16px 92px;
  }

  /* 所有触控按钮 >= 44px */
  .button,
  .button.small,
  .step,
  .page-picker .button,
  summary,
  .check {
    min-height: 44px;
  }

  .heading {
    align-items: stretch;
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
  }

  .heading > .actions {
    width: 100%;
  }

  .heading > .actions .button {
    flex: 1 1 auto;
  }

  .section-heading {
    align-items: flex-start;
  }

  .split,
  .project-list,
  .char-list,
  .repair-line {
    grid-template-columns: minmax(0, 1fr);
  }

  .project-card {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    min-height: 118px;
    padding: 12px 14px;
    gap: 12px;
  }

  .repair-line .tile {
    width: min(100%, 200px);
  }

  /* 手机端缩略图支持单张聚焦横滑预览，与 app.js 滚动保持协同 */
  .step-body > .gallery {
    grid-auto-flow: column;
    grid-auto-columns: minmax(216px, 76%);
    grid-template-columns: none;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 10px;
    margin-inline: -4px;
    padding-inline: 4px;
  }

  .gallery > .tile {
    scroll-snap-align: start;
  }

  .auth {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 2px;
    border-radius: var(--radius-lg);
    min-height: auto;
  }

  .auth-intro {
    min-height: 156px;
    padding: 22px 20px;
    gap: 0;
  }

  .auth-intro h1 {
    font-size: 30px;
  }

  .frame-motif {
    width: 142px;
    height: 184px;
    bottom: -74px;
    right: -12px;
  }

  .auth-body {
    padding: 22px 18px 24px;
  }

  .empty.home-empty {
    grid-template-columns: 60px minmax(0, 1fr);
    gap: 14px;
    min-height: 190px;
  }

  .home-empty .art-empty {
    width: 60px;
  }

  .dialog,
  .dialog:has(.lightbox) {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
    padding: 14px;
    border-radius: var(--radius-md);
  }

  .dialog-head .actions {
    gap: 6px;
  }

  .lightbox img {
    max-height: calc(100dvh - 170px);
    padding: 8px;
  }

  .toast {
    left: 16px;
    right: 16px;
    bottom: 74px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
.asset-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.asset-compare-image { min-width: 0; margin: 0; }
.asset-compare-image img, .inspection-image { display: block; width: 100%; height: auto; border-radius: 8px; }
.asset-compare-image figcaption { margin-bottom: 5px; }
