/* ==========================================================================
   Youman AI — product chrome
   Register: product. The artwork is the hero; the shell stays quiet.
   Identity: warm-gray canvas, white working surfaces, purple = creation/AI,
   green = service health. Serif display reserved for the home hero only.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f4f4f2;
  --surface: #ffffff;
  --surface-soft: #ececeb;
  --surface-sunken: #f6f6f5;

  /* Ink ramp — body/secondary text stays ≥ 4.5:1 on white and on --bg */
  --ink: #16171a;
  --ink-soft: #34373d;
  --text-2: #54575e;
  --text-3: #6b6e75;
  --text-disabled: #9b9ea4;

  /* Lines */
  --line: rgba(22, 23, 26, 0.1);
  --line-strong: rgba(22, 23, 26, 0.19);

  /* Brand */
  --purple: #7c5cff;
  --purple-text: #5638ec;
  --purple-tint: rgba(124, 92, 255, 0.1);
  --purple-tint-strong: rgba(124, 92, 255, 0.18);
  --purple-band: #ddd3f8;

  /* Status */
  --green-text: #0b7a61;
  --green-dot: #1da765;
  --red-dot: #d2554d;

  /* Radius scale: controls < cards < panels; pills for actions */
  --r-control: 9px;
  --r-card: 12px;
  --r-panel: 16px;
  --r-pill: 999px;

  /* Two shadow levels only */
  --shadow-sm: 0 1px 2px rgba(22, 23, 26, 0.05), 0 4px 14px rgba(22, 23, 26, 0.05);
  --shadow-lg: 0 4px 12px rgba(22, 23, 26, 0.08), 0 24px 56px rgba(22, 23, 26, 0.16);

  /* Semantic z-index scale */
  --z-sticky: 20;
  --z-overlay: 40;
  --z-modal: 60;
  --z-menu: 70;
  --z-toast: 80;

  /* Motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-panel: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  line-height: 1.5;
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

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

i[data-lucide] {
  width: 17px;
  height: 17px;
  stroke-width: 2;
}

h1,
h2,
p {
  margin-top: 0;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

/* Shared scrollbars */
.history-list::-webkit-scrollbar,
.comic-grid::-webkit-scrollbar,
.view::-webkit-scrollbar,
.dialogue-list::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.history-list::-webkit-scrollbar-thumb,
.comic-grid::-webkit-scrollbar-thumb,
.view::-webkit-scrollbar-thumb,
.dialogue-list::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: var(--r-pill);
  background: rgba(68, 70, 78, 0.22);
  background-clip: padding-box;
}

.history-list::-webkit-scrollbar-thumb:hover,
.comic-grid::-webkit-scrollbar-thumb:hover,
.view::-webkit-scrollbar-thumb:hover {
  background: rgba(68, 70, 78, 0.36);
  background-clip: padding-box;
}

/* ==========================================================================
   Promo bar
   ========================================================================== */

.promo-bar {
  height: 36px;
  padding: 0 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--ink);
  background: var(--purple-band);
  font-size: 12px;
  font-weight: 600;
}

.promo-bar strong {
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.85);
  color: var(--purple-text);
  font-size: 11.5px;
  font-weight: 650;
}

.promo-cta {
  padding: 3px 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.92);
  color: var(--purple-text);
  font-size: 11.5px;
  font-weight: 650;
  transition: background 150ms ease, transform 140ms var(--ease-out), box-shadow 150ms ease;
}

.promo-cta:hover {
  background: #fff;
  box-shadow: 0 2px 8px rgba(86, 56, 236, 0.18);
}

.promo-cta:active {
  transform: scale(0.96);
}

/* ==========================================================================
   App shell + sidebar
   ========================================================================== */

.app-shell {
  --sidebar-motion-duration: 320ms;
  --sidebar-motion-ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  height: calc(100vh - 36px);
  min-height: 0;
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  overflow: hidden;
  transition: grid-template-columns var(--sidebar-motion-duration) var(--sidebar-motion-ease);
}

.app-shell.collapsed {
  --sidebar-motion-duration: 220ms;
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  height: auto;
  min-height: 0;
  margin: 12px 0 12px 12px;
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid rgba(22, 23, 26, 0.08);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 2px rgba(22, 23, 26, 0.04), 0 18px 48px rgba(22, 23, 26, 0.1);
  overflow: hidden;
  transform: translate3d(0, 0, 0);
  transform-origin: left center;
  transition:
    margin var(--sidebar-motion-duration) var(--sidebar-motion-ease),
    padding var(--sidebar-motion-duration) var(--sidebar-motion-ease),
    border-color var(--sidebar-motion-duration) var(--sidebar-motion-ease),
    border-radius var(--sidebar-motion-duration) var(--sidebar-motion-ease),
    background-color var(--sidebar-motion-duration) var(--sidebar-motion-ease);
}

.brand {
  position: relative;
  height: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 6px;
  border-radius: 12px;
  cursor: pointer;
  isolation: isolate;
}

.brand::before {
  content: "";
  position: absolute;
  inset: -4px -6px;
  z-index: -1;
  border-radius: 16px;
  background: transparent;
  transition: background 160ms ease, box-shadow 160ms ease, transform 180ms var(--ease-out);
}

.brand:hover::before {
  background: rgba(22, 23, 26, 0.045);
}

.brand-lockup {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transform-origin: left center;
  transition: opacity 160ms ease, transform 280ms var(--ease-out);
}

.brand-logo {
  position: relative;
  width: 28px;
  height: 28px;
  flex: none;
  transition: opacity 150ms ease, transform 180ms var(--ease-out);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: grayscale(1) brightness(0);
}

.brand-wordmark {
  width: 60px;
  height: 28px;
  display: block;
  object-fit: contain;
  object-position: left center;
}

.brand strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-control);
  color: var(--text-3);
  background: transparent;
  transition: background 150ms ease, color 150ms ease, transform 140ms var(--ease-out);
}

.icon-button:hover {
  color: var(--ink);
  background: rgba(22, 23, 26, 0.06);
}

.brand:hover .icon-button {
  color: var(--ink);
  background: rgba(22, 23, 26, 0.06);
}

.nav-list {
  display: grid;
  gap: 4px;
}

.quick-create,
.nav-item {
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 9px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 13px;
  font-weight: 550;
  text-align: left;
  transition: color 150ms ease, background 150ms ease, transform 140ms var(--ease-out), box-shadow 150ms ease;
}

.quick-create span,
.nav-item span,
.history-head {
  white-space: nowrap;
}

.quick-create {
  color: var(--purple-text);
  background: var(--purple-tint);
  font-weight: 600;
}

.quick-create:hover {
  background: var(--purple-tint-strong);
}

.nav-item:hover {
  color: var(--ink);
  background: rgba(22, 23, 26, 0.05);
}

.nav-item.active {
  color: var(--ink);
  background: rgba(22, 23, 26, 0.055);
  box-shadow: none;
  font-weight: 600;
}

.quick-create:active,
.nav-item:active,
.ghost-action:active,
.primary-action:active,
.agent-button:active,
.icon-button:active,
.history-card:active,
.history-project:active,
.project-card:active,
.comic-card button:active {
  transform: scale(0.98);
}

.history-head {
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 600;
}

.history-head small {
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 550;
}

.history-card {
  width: 100%;
  min-height: 50px;
  padding: 8px 10px;
  display: grid;
  align-content: center;
  gap: 3px;
  border-radius: var(--r-card);
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  transition: background 150ms ease, border-color 150ms ease, transform 140ms var(--ease-out);
}

.history-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-sunken);
}

.history-card span,
.history-card small,
.history-project strong,
.history-project small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card span {
  font-size: 12.5px;
  font-weight: 600;
}

.history-card small {
  color: var(--text-3);
  font-size: 11px;
}

/* 有项目时统一使用带缩略图和操作菜单的项目行；空列表才显示引导卡。 */
.sidebar:has(.history-list:not(:empty)) .history-card {
  display: none;
}

.history-list {
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  margin-top: -4px;
  padding: 0 0 8px;
}

.history-list::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.history-project-item {
  position: relative;
  width: 100%;
  flex: 0 0 auto;
}

.history-project {
  width: 100%;
  min-height: 48px;
  padding: 5px 34px 5px 6px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  align-items: center;
  border-radius: 10px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 140ms ease, transform 140ms var(--ease-out);
}

.history-project:focus-visible {
  outline: 2px solid rgba(117, 87, 255, 0.42);
  outline-offset: -2px;
}

.history-project-item:hover .history-project,
.history-project-item:focus-within .history-project,
.history-project-item.menu-open .history-project {
  background: rgba(22, 23, 26, 0.05);
}

.history-project-item.pinned .history-project {
  background: rgba(22, 23, 26, 0.045);
}

.history-project-more {
  position: absolute;
  top: 50%;
  right: 6px;
  z-index: 1;
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: var(--text-2);
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.96);
  transition: opacity 140ms ease, background 140ms ease, color 140ms ease, transform 140ms var(--ease-out);
}

.history-project-more i,
.history-project-more svg {
  width: 16px;
  height: 16px;
}

.history-project-item:hover .history-project-more,
.history-project-item:focus-within .history-project-more,
.history-project-item.menu-open .history-project-more {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.history-project-more:hover,
.history-project-more:focus-visible {
  color: var(--ink);
  background: rgba(22, 23, 26, 0.09);
}

.history-project-more:active {
  transform: translateY(-50%) scale(0.94);
}

.history-project.renaming ~ .history-project-more {
  display: none;
}

@media (hover: none) {
  .history-project-more {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(-50%);
  }
}

.history-project img,
.history-project > span {
  grid-row: 1 / 3;
  width: 36px;
  height: 36px;
  border-radius: 7px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--purple-tint), rgba(22, 23, 26, 0.05)), var(--surface-soft);
}

.history-project strong {
  font-size: 12px;
  font-weight: 600;
}

.history-project small {
  color: var(--text-3);
  font-size: 11px;
}

.history-project.renaming {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px rgba(117, 87, 255, 0.26);
  transform: none;
}

.project-name-input {
  width: 100%;
  min-width: 0;
  padding: 2px 6px;
  border: 1px solid var(--purple);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 600;
  outline: none;
}

/* 多话小说分组（系列文件夹） */
.history-series-head {
  width: 100%;
  display: grid;
  grid-template-columns: 16px 18px minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 6px;
  padding: 6px;
  border-radius: 9px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 160ms ease;
}

.history-series-head:hover {
  background: rgba(22, 23, 26, 0.05);
}

.series-chevron,
.series-folder {
  width: 16px;
  height: 16px;
}

.series-chevron {
  color: var(--text-3);
  transition: transform 180ms var(--ease-out);
}

.series-folder {
  color: var(--purple);
}

.history-series.collapsed .series-chevron {
  transform: rotate(-90deg);
}

.series-name {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.series-count {
  color: var(--text-3);
  font-size: 11px;
  white-space: nowrap;
}

.series-rename {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--text-3);
  background: transparent;
  opacity: 0;
  transition: opacity 140ms ease, background 140ms ease, color 140ms ease;
}

.series-rename i {
  width: 13px;
  height: 13px;
}

.history-series-head:hover .series-rename,
.series-rename:focus-visible {
  opacity: 1;
}

.series-rename:hover {
  background: rgba(22, 23, 26, 0.08);
  color: var(--ink);
}

.series-name-input {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--purple);
  border-radius: 6px;
  padding: 2px 6px;
  width: 100%;
  min-width: 0;
  outline: none;
}

.history-series-eps {
  display: flex;
  flex-direction: column;
  margin-left: 15px;
  padding-left: 7px;
  border-left: 1.5px solid var(--line);
}

.history-series.collapsed .history-series-eps {
  display: none;
}

.history-project.episode {
  min-height: 46px;
  grid-template-columns: 30px minmax(0, 1fr);
  column-gap: 8px;
}

.history-project.episode img,
.history-project.episode > span {
  width: 30px;
  height: 30px;
}

/* Sidebar collapse */
.app-shell.collapsed .brand strong,
.app-shell.collapsed .brand-lockup .brand-wordmark,
.app-shell.collapsed .quick-create span,
.app-shell.collapsed .nav-item span,
.app-shell.collapsed .history-head,
.app-shell.collapsed .history-card,
.app-shell.collapsed .history-list {
  display: none;
}

.app-shell.collapsed .sidebar {
  position: relative;
  z-index: calc(var(--z-menu) + 1);
  min-width: 0;
  margin: 0;
  padding: 0;
  gap: 0;
  overflow: visible;
  border-color: transparent;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  transform: translate3d(0, 0, 0);
}

/* Collapsed rail: logo and expand button share one 56px hot zone and crossfade
   in place — no lateral movement, so hover never drops between the two. */
.app-shell.collapsed .brand {
  position: fixed;
  top: 13px;
  left: 45px;
  z-index: calc(var(--z-menu) + 1);
  width: 56px;
  height: 56px;
  display: block;
  transform: translateX(0);
}

.app-shell.collapsed .brand::before {
  inset: 0;
  border-radius: 16px;
  background: transparent;
  box-shadow: none;
}

.app-shell.collapsed .brand:hover::before,
.app-shell.collapsed .brand:has(.icon-button:focus-visible)::before {
  background: transparent;
  box-shadow: none;
}

.app-shell.collapsed .brand-lockup {
  position: absolute;
  inset: 8px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  gap: 0;
  opacity: 1;
  transform: scale(1);
  transition: opacity 150ms ease, transform 150ms var(--ease-out);
}

.app-shell.collapsed .brand-logo {
  width: 36px;
  height: 36px;
  opacity: 1;
  transform: none;
}

.app-shell.collapsed .brand .icon-button {
  position: absolute;
  inset: 9px;
  width: 38px;
  height: 38px;
  display: inline-grid;
  border-radius: 10px;
  color: var(--ink);
  background: #f0f0f0;
  border: 0;
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
  transition: opacity 160ms ease, transform 180ms var(--ease-out), background 150ms ease, color 150ms ease;
}

.app-shell.collapsed .brand .icon-button:hover {
  color: var(--ink);
  background: #ebebeb;
}

.app-shell.collapsed .brand .icon-button i,
.app-shell.collapsed .brand .icon-button svg {
  width: 20px;
  height: 20px;
}

.app-shell.collapsed .brand:hover .brand-lockup,
.app-shell.collapsed .brand:has(.icon-button:focus-visible) .brand-lockup {
  opacity: 0;
  transform: scale(0.92);
}

.app-shell.collapsed .brand:hover .icon-button,
.app-shell.collapsed .brand .icon-button:focus-visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* Tooltip appears after a short dwell, not on first touch */
.app-shell.collapsed .brand .icon-button::after {
  content: "展开历史";
  position: absolute;
  left: 48px;
  top: 50%;
  width: max-content;
  padding: 7px 10px;
  border-radius: 7px;
  color: #fff;
  background: #202127;
  font-size: 12px;
  font-weight: 550;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) translateX(-4px);
  transition: opacity 140ms ease 0ms, transform 160ms var(--ease-out) 0ms;
}

.app-shell.collapsed .brand .icon-button:hover::after,
.app-shell.collapsed .brand .icon-button:focus-visible::after {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
  transition-delay: 350ms, 350ms;
}

.app-shell.collapsed .quick-create,
.app-shell.collapsed .nav-item {
  display: none;
}

.app-shell.collapsed .board-header > div {
  padding-left: 70px;
}

/* ==========================================================================
   Main stage + topbar
   ========================================================================== */

.main-stage {
  min-width: 0;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: 52px 1fr;
  overflow: hidden;
  /* Subtle halftone-dot texture: a quiet nod to print comics */
  background:
    radial-gradient(circle, rgba(22, 23, 26, 0.05) 1px, transparent 1.5px) 0 0 / 10px 10px,
    linear-gradient(#f8f8f7, #efefed);
}

.topbar {
  position: relative;
  z-index: var(--z-menu);
  padding: 0 clamp(20px, 2.6vw, 42px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  transform: translateY(5px);
}

body:has(.recharge-modal:not(.hidden)) .topbar,
body:has(.recharge-modal:not(.hidden)) .app-shell.collapsed .brand {
  visibility: hidden;
  pointer-events: none;
}

.credit-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.credit-pill {
  min-height: 40px;
  padding: 3px 17px 3px 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--r-pill);
  color: var(--purple-text);
  background: rgba(237, 230, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.1), 0 8px 22px rgba(124, 92, 255, 0.1);
  font-size: 13.2px;
  font-weight: 650;
  cursor: default;
}

/* 接入真实积分后（live）积分球可点击，进入兑换码充值 */
.credit-pill.live {
  cursor: pointer;
  transition: background 150ms ease, box-shadow 150ms ease, transform 140ms var(--ease-out);
}

.credit-pill.live:hover {
  background: rgba(231, 222, 255, 0.98);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.18), 0 12px 28px rgba(124, 92, 255, 0.16);
}

.credit-pill.live:active {
  transform: scale(0.97);
}

.credit-orb {
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 50%;
  object-fit: cover;
  clip-path: circle(47% at 50% 50%);
  box-shadow: 0 2px 8px rgba(124, 92, 255, 0.18);
}

.credit-pill strong {
  font-size: 13.2px;
  font-weight: 650;
}

.credit-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: var(--z-menu);
  width: min(300px, calc(100vw - 40px));
  max-height: min(420px, calc(100vh - 110px));
  padding: 20px;
  overflow: auto;
  border: 1px solid rgba(22, 23, 26, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 52px rgba(22, 23, 26, 0.14), 0 1px 2px rgba(22, 23, 26, 0.04);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transform-origin: top right;
  transition: opacity 180ms ease, transform 220ms var(--ease-panel);
}

.credit-wrap:hover .credit-popover,
.credit-wrap:focus-within .credit-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.credit-popover-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.credit-popover-head span,
.credit-ledger-title {
  color: #66738a;
  font-size: 12px;
  font-weight: 550;
}

.credit-popover-head strong {
  color: var(--purple-text);
  font-size: 26px;
  line-height: 1;
  font-weight: 720;
}

.credit-popover-rule {
  height: 1px;
  margin: 18px 0 16px;
  background: var(--line);
}

.credit-ledger-title {
  margin-bottom: 14px;
}

.credit-ledger-list {
  display: grid;
  gap: 13px;
}

.credit-ledger-list p {
  margin: 0;
  color: var(--text-3);
  font-size: 11px;
}

.credit-ledger-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
}

.credit-ledger-item strong {
  display: block;
  overflow: hidden;
  color: #202837;
  font-size: 12px;
  font-weight: 620;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.credit-ledger-item time {
  display: block;
  margin-top: 4px;
  color: #8a97ad;
  font-size: 11px;
  line-height: 1.2;
}

.credit-ledger-delta {
  color: #66738a;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.credit-ledger-delta.positive {
  color: var(--purple-text);
}

.agent-button {
  position: relative;
  min-height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  color: var(--text-2);
  background: var(--surface);
  transition: border-color 150ms ease, background 150ms ease, transform 140ms var(--ease-out);
}

.agent-button:hover {
  border-color: var(--line-strong);
}

.agent-button.connected {
  color: var(--green-text);
}

.agent-button strong {
  font-size: 12px;
  font-weight: 600;
}

.agent-button i {
  width: 14px;
  height: 14px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-pill);
  background: var(--red-dot);
  box-shadow: 0 0 0 3px rgba(210, 85, 77, 0.14);
}

.agent-button.connected .status-dot {
  background: var(--green-dot);
  box-shadow: 0 0 0 3px rgba(29, 167, 101, 0.16);
}

.agent-button.checking .status-dot {
  animation: statusPulse 900ms linear infinite;
}

@keyframes statusPulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.85);
    opacity: 0.42;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ==========================================================================
   View stack
   ========================================================================== */

.view-stack {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  overflow: auto;
  overscroll-behavior: contain;
}

.view.active {
  display: block;
  animation: viewIn 200ms var(--ease-out);
}

.home-view.active,
.wait-view.active {
  animation: none;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   Home
   ========================================================================== */

.home-view {
  padding: 36px clamp(30px, 5vw, 84px) 72px;
}

.home-center {
  width: 100%;
  margin: 0 auto;
  display: grid;
  justify-items: center;
}

.hero-copy {
  width: min(660px, 100%);
  margin: 0 auto;
  text-align: center;
}

.hero-copy h1 {
  margin-bottom: 12px;
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif CJK SC", ui-serif, Georgia, serif;
  font-size: clamp(34px, 3.5vw, 46px);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.hero-copy p {
  margin-bottom: 36px;
  color: var(--text-2);
  font-size: 14.5px;
  line-height: 1.65;
}

/* Latin words in the hero set in italic serif, Xiaoyunque-style */
.hero-copy h1 em {
  padding: 0 0.04em;
  font-family: Georgia, "Times New Roman", ui-serif, serif;
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0;
}

/* Hand-drawn ellipse around the subtitle keyword */
.hero-copy p .circled {
  position: relative;
  color: var(--ink);
  font-weight: 550;
}

.hero-copy p .circled::after {
  content: "";
  position: absolute;
  inset: -4px -9px -6px;
  border: 1.5px solid rgba(124, 92, 255, 0.55);
  border-radius: 50%;
  transform: rotate(-2.5deg);
  pointer-events: none;
}

.home-view.active .hero-copy,
.home-view.active .upload-panel,
.home-view.active .copyright-tip,
.home-view.active .home-projects {
  animation: homeItemIn 280ms var(--ease-out) both;
}

.home-view.active .upload-panel {
  animation-delay: 60ms;
}

.home-view.active .copyright-tip {
  animation-delay: 100ms;
}

.home-view.active .home-projects {
  animation-delay: 130ms;
}

@keyframes homeItemIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Upload panel: Xiaoyunque-style folder tabs.
   The tab row is taller than its visible band; the white body overlaps the
   bottom 20px, so the active tab (z3) merges into it while inactive tabs
   (z1) stay behind. Concave "wings" (radial-gradient masks) round the
   junction, and the body's top corner on the inactive side reveals the gray
   tab behind it — that notch is what reads as a folder. */
.upload-panel {
  --tab-bg: #e8eaeb;
  --tab-bg-hover: #dcdfe1;
  position: relative;
  width: min(660px, 100%);
  margin: 0 auto;
  overflow: visible;
  border-radius: var(--r-panel);
  background: transparent;
  filter: drop-shadow(0 16px 32px rgba(22, 23, 26, 0.07));
}

.input-tabs {
  position: relative;
  z-index: 1;
  height: 64px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 0;
}

.input-tabs button {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px 20px;
  color: var(--text-2);
  background: var(--tab-bg);
  font-size: 13px;
  font-weight: 600;
  transition: background 200ms ease, color 200ms ease;
}

.input-tabs button:first-of-type {
  border-top-left-radius: var(--r-panel);
}

.input-tabs button:last-of-type {
  border-top-right-radius: var(--r-panel);
}

.input-tabs button:not(.active):hover {
  color: var(--ink);
  background: var(--tab-bg-hover);
}

.input-tabs button.active {
  z-index: 3;
  color: var(--ink);
  background: var(--surface);
  border-radius: 14px 14px 0 0;
}

.input-tabs button:first-of-type.active {
  border-top-left-radius: var(--r-panel);
}

.input-tabs button:last-of-type.active {
  border-top-right-radius: var(--r-panel);
}

.input-tabs button i {
  width: 15px;
  height: 15px;
}

/* Concave wings: white squares masked to a quarter-curve, sitting at the
   visible band's bottom line, joining the active tab edge to the body. */
.input-tabs button.active::before,
.input-tabs button.active::after {
  content: "";
  position: absolute;
  bottom: 20px;
  width: 16px;
  height: 16px;
  background: var(--surface);
  pointer-events: none;
}

.input-tabs button.active::after {
  right: -16px;
  -webkit-mask: radial-gradient(circle 16px at 100% 0, transparent 15.5px, #000 16px);
  mask: radial-gradient(circle 16px at 100% 0, transparent 15.5px, #000 16px);
}

.input-tabs button.active::before {
  left: -16px;
  -webkit-mask: radial-gradient(circle 16px at 0 0, transparent 15.5px, #000 16px);
  mask: radial-gradient(circle 16px at 0 0, transparent 15.5px, #000 16px);
}

.input-tabs button:first-of-type.active::before,
.input-tabs button:last-of-type.active::after {
  display: none;
}

/* Legacy sliding indicator: replaced by the folder-tab treatment */
.tab-indicator {
  display: none;
}

.drop-zone {
  position: relative;
  z-index: 2;
  margin: -20px 0 0;
  padding: 12px 12px 0;
  border-radius: 0 14px 0 0;
  background: var(--surface);
}

.upload-panel.upload-active .drop-zone {
  border-radius: 14px 0 0 0;
}

#novelInput {
  width: 100%;
  min-height: clamp(190px, 23vh, 252px);
  padding: clamp(16px, 2vw, 22px);
  resize: vertical;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-card);
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-size: 13.5px;
  line-height: 1.8;
  text-align: left;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

#novelInput:focus {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.18);
}

#novelInput::placeholder {
  color: var(--text-3);
}

.drop-zone.drag-over #novelInput {
  border-color: rgba(124, 92, 255, 0.66);
  box-shadow: inset 0 0 0 2px rgba(124, 92, 255, 0.14);
}

.drop-hint {
  position: absolute;
  inset: 12px 12px 4px;
  display: grid;
  place-items: center;
  gap: 8px;
  border-radius: 10px;
  color: var(--purple-text);
  background: rgba(244, 240, 255, 0.94);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 150ms ease, transform 170ms var(--ease-out);
}

.drop-zone.drag-over .drop-hint {
  opacity: 1;
  transform: translateY(0);
}

.form-actions {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 62px;
  padding: 13px 12px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  border-radius: 0 0 var(--r-panel) var(--r-panel);
  background: var(--surface);
}

.form-actions .ghost-action i,
.form-actions .primary-action i,
.form-actions .ghost-action svg,
.form-actions .primary-action svg {
  width: 15px;
  height: 15px;
}

/* Action vocabulary: one ghost, one primary. Pills are the brand shape. */
.ghost-action,
.primary-action {
  min-height: 34px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 600;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 140ms var(--ease-out);
}

.ghost-action {
  border: 1px solid var(--line-strong);
  color: var(--ink);
  background: var(--surface);
}

.ghost-action:hover {
  border-color: rgba(22, 23, 26, 0.32);
  background: var(--surface-sunken);
}

.primary-action {
  color: #fff;
  background: var(--ink);
}

.primary-action:not(:disabled):hover {
  background: #2c2d33;
}

.primary-action.is-loading i {
  animation: spin 760ms linear infinite;
}

.comic-generate-action {
  position: relative;
  min-height: 40px;
  padding: 0 18px;
  overflow: hidden;
  isolation: isolate;
  color: #211f2a;
  background: #f7efff;
  box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8), 0 10px 26px rgba(124, 92, 255, 0.16);
  transition:
    color 150ms ease,
    background 150ms ease,
    box-shadow 180ms ease,
    transform 140ms var(--ease-out);
}

.comic-generate-action::before,
.comic-generate-action::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.comic-generate-action::before {
  background: linear-gradient(100deg, #d8dcff 0%, #ddbaff 48%, #f6bfd7 100%);
}

.comic-generate-action::after {
  inset: -12px;
  background: linear-gradient(100deg, #8b7dff 0%, #bf79ff 48%, #ff7cab 100%);
  opacity: 0.24;
  filter: blur(14px);
  transition: opacity 500ms ease;
}

.comic-generate-action > * {
  position: relative;
  z-index: 1;
}

.comic-generate-action i,
.comic-generate-action svg {
  color: currentColor;
}

.comic-generate-action:not(:disabled):hover {
  color: #17151f;
  background: #f7efff;
  box-shadow: 0 1px 1px rgba(255, 255, 255, 0.9), 0 12px 30px rgba(124, 92, 255, 0.22);
  transform: translateY(-1px);
}

.comic-generate-action:not(:disabled):hover::after {
  opacity: 0.48;
}

.comic-generate-action:not(:disabled):active {
  transform: translateY(0) scale(0.98);
}

.comic-generate-action:disabled {
  color: rgba(33, 31, 42, 0.5);
  background: #eeeaf4;
  box-shadow: none;
}

.comic-generate-action:disabled::before {
  opacity: 0.5;
}

.comic-generate-action:disabled::after {
  opacity: 0.12;
}

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

/* 按话生成：话数选择 + 积分预估（积分计费开启时显示在输入区下方） */
.plan-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px 0;
  background: var(--surface);
}

.episode-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.episode-picker > span {
  margin-right: 2px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 550;
}

.episode-picker button {
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--text-2);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease, transform 140ms var(--ease-out);
}

.episode-picker button:hover {
  border-color: rgba(22, 23, 26, 0.32);
}

.episode-picker button:active {
  transform: scale(0.97);
}

.episode-picker button.active {
  border-color: var(--purple);
  color: var(--purple-text);
  background: var(--purple-tint);
}

.episode-picker button.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.plan-estimate {
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
  text-align: right;
}

.plan-estimate.warn {
  color: #b8362f;
}

/* 漫画风格选择 */
.style-picker {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px 0;
  background: var(--surface);
}

.style-picker-label {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 550;
}

.style-options {
  display: inline-flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: wrap;
}

.style-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, transform 140ms var(--ease-out), box-shadow 150ms ease;
}

.style-card:hover {
  border-color: rgba(22, 23, 26, 0.32);
}

.style-card:active {
  transform: scale(0.98);
}

.style-card.active {
  border-color: var(--purple);
  background: var(--purple-tint);
  box-shadow: inset 0 0 0 1px var(--purple);
}

.style-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 46px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px var(--line);
}

/* 韩系言情缩略图：默认柔粉渐变占位；若放了 assets/styles/korean-romance.jpg 则优先显示该图 */
.style-thumb-korean {
  background-image: url("./assets/styles/korean-romance.jpg"),
    linear-gradient(160deg, #ffd9d2, #f5aebd 55%, #c98ba0);
  background-size: 100% auto, cover;
  background-position: center center, center;
  background-repeat: no-repeat;
}

.style-thumb-cel-pop {
  position: relative;
  background:
    radial-gradient(circle at 56% 34%, #fff6e7 0 9px, transparent 9.8px),
    radial-gradient(circle at 51% 31%, #463126 0 12px, transparent 12.8px),
    linear-gradient(135deg, transparent 0 25%, rgba(55, 159, 244, 0.92) 25% 39%, transparent 39%),
    linear-gradient(36deg, transparent 0 36%, rgba(255, 85, 147, 0.9) 36% 48%, transparent 48%),
    linear-gradient(150deg, #fff 0 34%, #ffe59a 34% 51%, #7ec8ff 51% 67%, #fff 67% 100%);
  overflow: hidden;
}

.style-thumb-cel-pop::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 18px;
  width: 24px;
  height: 23px;
  border: 1.5px solid rgba(55, 59, 65, 0.42);
  border-radius: 50% 50% 44% 46%;
  box-shadow:
    13px -10px 0 -8px rgba(55, 59, 65, 0.42),
    19px -2px 0 -9px rgba(55, 59, 65, 0.42);
  opacity: 0.72;
}

.style-thumb-cel-pop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 24% 72%, rgba(255, 198, 47, 0.75) 0 1.6px, transparent 1.8px),
    radial-gradient(circle at 76% 22%, rgba(255, 94, 147, 0.85) 0 2px, transparent 2.2px),
    linear-gradient(90deg, transparent 0 47%, rgba(255, 255, 255, 0.82) 47% 52%, transparent 52%);
  background-size: 8px 8px, auto, auto;
  mix-blend-mode: screen;
}

/* 国风水彩缩略图：优先用真实样张 guofeng-watercolor.jpg；
   未放图时自动回退到手绘水彩 SVG 色块，再回退到渐变。把图片存到
   app/web/assets/styles/guofeng-watercolor.jpg 即自动生效，无需改代码。 */
.style-thumb-guofeng {
  background-image: url("./assets/styles/guofeng-watercolor.jpg"),
    url("./assets/styles/guofeng-watercolor.svg"),
    linear-gradient(160deg, #f3efe2, #cfe0c4 52%, #9bbf9e);
  background-size: cover;
  background-position: center top;
}

.style-thumb-emotion-q {
  background:
    radial-gradient(circle at 50% 39%, #4d4b50 0 3px, transparent 3.4px),
    radial-gradient(circle at 34% 53%, rgba(242, 170, 158, 0.88) 0 5px, transparent 5.8px),
    radial-gradient(circle at 66% 53%, rgba(242, 170, 158, 0.78) 0 4px, transparent 5px),
    radial-gradient(circle at 50% 47%, #fff7ed 0 16px, transparent 16.8px),
    radial-gradient(circle at 50% 26%, #716f72 0 17px, transparent 18px),
    radial-gradient(circle at 28% 73%, rgba(255, 248, 224, 0.92) 0 12px, transparent 13px),
    radial-gradient(circle at 78% 76%, rgba(255, 248, 224, 0.85) 0 15px, transparent 16px),
    linear-gradient(160deg, #c7d4e8 0%, #eaf0f6 55%, #fff5d8 100%);
  position: relative;
}

.style-thumb-emotion-q::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(71, 76, 86, 0.16) 0.7px, transparent 0.8px);
  background-size: 5px 5px;
  opacity: 0.32;
}

.style-thumb-auto {
  background: var(--purple-tint-strong);
  color: var(--purple-text);
}

.style-thumb-auto i,
.style-thumb-auto svg {
  width: 18px;
  height: 18px;
}

.style-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.2;
}

.style-name {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.style-card.active .style-name {
  color: var(--purple-text);
}

.style-tag {
  color: var(--text-3);
  font-size: 11px;
}

.copyright-tip {
  width: min(660px, 100%);
  margin: 20px 0 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-3);
  font-size: 12px;
  font-weight: 450;
}

.site-records {
  padding: 28px 0 8px;
  display: flex;
  justify-content: center;
  gap: 16px;
  color: var(--text-3);
  font-size: 12px;
}

.site-records a {
  color: inherit;
}

.site-records a:hover {
  color: var(--ink);
}

.copyright-tip i {
  width: 15px;
  height: 15px;
  flex: none;
}

/* Home projects */
.home-projects {
  width: 100%;
  margin-top: 0;
}

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

.project-tabs {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 14px;
  font-weight: 600;
}

.project-tabs strong {
  position: relative;
  font-weight: 650;
}

.project-tabs strong::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -7px;
  height: 2px;
  border-radius: var(--r-pill);
  background: var(--ink);
}

.project-tabs span {
  color: var(--text-3);
  font-weight: 500;
}

.project-section-head button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--text-2);
  background: transparent;
  font-size: 12.5px;
  font-weight: 550;
  border-radius: var(--r-control);
  transition: color 150ms ease;
}

.project-section-head button:hover {
  color: var(--ink);
}

.project-section-head button i {
  width: 15px;
  height: 15px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(184px, 1fr));
  gap: 14px;
}

.project-card {
  min-height: 172px;
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  transition: transform 150ms var(--ease-out), border-color 150ms ease, box-shadow 150ms ease;
}

.project-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.project-card.empty {
  border-style: dashed;
  background: transparent;
}

.project-cover {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background:
    radial-gradient(circle, rgba(22, 23, 26, 0.07) 1px, transparent 1.5px) 0 0 / 12px 12px,
    var(--surface-soft);
}

.project-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.project-cover em {
  width: 40px;
  height: 40px;
  border: 2px dashed rgba(22, 23, 26, 0.14);
  border-radius: var(--r-pill);
}

.project-card strong {
  overflow: hidden;
  font-size: 12.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-card small {
  color: var(--text-3);
  font-size: 11.5px;
}

/* ==========================================================================
   Waiting view
   ========================================================================== */

.wait-view {
  display: none;
  place-items: center;
  padding: 40px;
}

.wait-view.active {
  display: grid;
}

.progress-panel {
  width: min(520px, 92vw);
  padding: 28px 32px;
  display: grid;
  justify-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: center;
  animation: panelIn 240ms var(--ease-out) both;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loading-animation {
  width: 104px;
  height: 104px;
  display: grid;
  place-items: center;
}

.loading-animation svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brush-fallback {
  width: 60px;
  height: 60px;
  border-radius: var(--r-panel);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.9), rgba(22, 23, 26, 0.9));
  animation: brushPulse 1200ms var(--ease-in-out) infinite;
}

@keyframes brushPulse {
  0%,
  100% {
    transform: rotate(-5deg) scale(0.94);
    opacity: 0.72;
  }

  50% {
    transform: rotate(4deg) scale(1);
    opacity: 1;
  }
}

.progress-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 19px;
  font-weight: 650;
  line-height: 1.3;
}

.animated-status-title {
  position: relative;
  min-height: 26px;
  padding: 0 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  white-space: nowrap;
  isolation: isolate;
}

.animated-status-copy {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  overflow: hidden;
}

.animated-status-letter {
  display: inline-block;
  opacity: 0;
  transform: translate3d(0, 13px, 0);
  transform-origin: center bottom;
  animation: statusLetterIn 260ms var(--ease-out) both;
  animation-delay: var(--letter-delay, 0ms);
}

@keyframes statusLetterIn {
  from {
    opacity: 0;
    transform: translate3d(0, 13px, 0);
  }

  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.progress-panel p {
  margin: 0;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.generation-phases {
  width: 100%;
  display: grid;
  gap: 6px;
  margin: 4px 0 2px;
  text-align: left;
}

.generation-phase {
  width: 100%;
  min-height: 54px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  grid-template-rows: auto 4px;
  align-items: center;
  column-gap: 8px;
  row-gap: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-sunken);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.generation-phase.current {
  border-color: rgba(117, 87, 255, 0.28);
  background: var(--purple-tint);
}

.generation-phase-index {
  width: 22px;
  height: 22px;
  display: inline-grid;
  grid-row: 1 / 3;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--text-3);
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
}

.generation-phase.current .generation-phase-index,
.generation-phase.completed .generation-phase-index {
  border-color: var(--purple);
  color: #fff;
  background: var(--purple);
}

.generation-phase strong {
  min-width: 0;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.25;
}

.generation-phase.pending strong,
.generation-phase.pending .generation-phase-meta {
  color: var(--text-3);
}

.generation-phase-meta {
  min-width: 0;
  color: var(--text-2);
  font-size: 11.5px;
  line-height: 1.25;
  text-align: right;
}

.generation-phase-track {
  height: 4px;
  grid-column: 2 / 4;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: rgba(22, 23, 26, 0.08);
}

.generation-phase-track span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--purple);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 240ms var(--ease-out);
}

.progress-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: rgba(22, 23, 26, 0.08);
}

.overall-progress {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
}

.progress-track span {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--purple);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 220ms var(--ease-out);
}

.progress-track span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  transform: translateX(-100%);
  animation: progressSheen 1200ms linear infinite;
}

@keyframes progressSheen {
  to {
    transform: translateX(100%);
  }
}

/* 生成途中查看已完成页的入口：紫色 = 创作动作 */
.peek-board {
  min-height: 34px;
  margin-top: 2px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--purple-tint-strong);
  border-radius: var(--r-pill);
  color: var(--purple-text);
  background: var(--purple-tint);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 150ms ease, border-color 150ms ease, transform 140ms var(--ease-out);
}

.peek-board:hover {
  border-color: var(--purple);
  background: var(--purple-tint-strong);
}

.peek-board:active {
  transform: scale(0.98);
}

.peek-board i {
  width: 14px;
  height: 14px;
}

.retry-generation {
  min-height: 32px;
  margin-top: 2px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  color: var(--text-2);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease, transform 140ms var(--ease-out);
}

.retry-generation:active {
  transform: scale(0.98);
}

.retry-generation i,
.retry-generation svg {
  width: 14px;
  height: 14px;
}

.retry-generation {
  color: #fff;
  border-color: var(--ink);
  background: var(--ink);
}

.retry-generation:hover {
  border-color: #2c2d33;
  background: #2c2d33;
}

/* Active-generation states in history */
.history-project.generating {
  position: relative;
  overflow: hidden;
  background: rgba(124, 92, 255, 0.07);
}

.history-project.generating > span {
  display: grid;
  place-items: center;
  color: var(--purple-text);
  background: var(--purple-tint);
}

.history-project.generating > span svg {
  width: 17px;
  height: 17px;
  animation: spin 1s linear infinite;
}

.history-project.generating > em {
  position: absolute;
  right: 34px;
  bottom: 3px;
  left: 50px;
  height: 2px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: rgba(124, 92, 255, 0.16);
}

.history-project.generating > em::after {
  content: "";
  display: block;
  width: var(--progress);
  height: 100%;
  border-radius: inherit;
  background: var(--purple);
  transition: width 220ms var(--ease-out);
}

.generating-cover {
  border-style: solid;
  border-color: rgba(124, 92, 255, 0.4);
  animation: brushPulse 1200ms var(--ease-in-out) infinite;
}

/* ==========================================================================
   Comic board
   ========================================================================== */

.board-view {
  --live-strip-height: 0px;
  padding: 0 clamp(16px, 2.5vw, 34px) 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scroll-padding-block: 16px 24px;
}

.board-view.live-generation {
  --live-strip-height: 54px;
}

.board-header {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.board-header h2 {
  margin: 0 0 2px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 650;
  line-height: 1.2;
}

.board-header p {
  margin: 0;
  color: var(--text-3);
  font-size: 12px;
}

.board-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.board-actions .ghost-action,
.board-actions .primary-action {
  min-height: 32px;
  padding: 0 13px;
  font-size: 12px;
}

.board-actions .ghost-action i,
.board-actions .primary-action i,
.board-actions .ghost-action svg,
.board-actions .primary-action svg {
  width: 14px;
  height: 14px;
}

.live-progress-strip {
  min-height: 44px;
  margin: -2px 0 10px;
  padding: 8px 10px 8px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, 18%) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--purple-tint-strong);
  border-radius: var(--r-card);
  color: var(--purple-text);
  background: linear-gradient(135deg, var(--purple-tint), rgba(255, 255, 255, 0.92));
  box-shadow: var(--shadow-sm);
}

.live-progress-copy {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.live-progress-copy .inline-spinner {
  width: 20px;
  height: 20px;
  border-width: 2.5px;
  flex: 0 0 20px;
}

.live-progress-copy div {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.live-progress-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-progress-copy span {
  overflow: hidden;
  color: var(--text-2);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-progress-meter {
  height: 5px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: rgba(124, 92, 255, 0.17);
}

.live-progress-meter span {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--purple);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 220ms var(--ease-out);
}

.live-progress-strip .ghost-action {
  min-height: 30px;
  padding: 0 10px;
  border-color: rgba(124, 92, 255, 0.26);
  color: var(--purple-text);
  background: rgba(255, 255, 255, 0.72);
  font-size: 11.5px;
  white-space: nowrap;
}

.live-progress-strip .ghost-action i,
.live-progress-strip .ghost-action svg {
  width: 13px;
  height: 13px;
}

.board-layout {
  height: calc(100% - 60px - var(--live-strip-height));
  min-height: 0;
  display: grid;
  grid-template-columns: 172px minmax(0, 1fr);
  gap: 14px;
}

.comic-grid {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  padding: 2px 4px 24px 2px;
}

.comic-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  opacity: 1;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms var(--ease-out);
}

.comic-card.entering {
  opacity: 1;
  animation: cardIn 220ms var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 28ms);
}

.comic-card.entering:nth-child(n + 9) {
  opacity: 1;
  animation: none;
}

.comic-card:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.comic-card.selected {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-tint);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.comic-card button {
  position: relative;
  width: 100%;
  padding: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  transition: transform 140ms var(--ease-out);
}

.comic-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  background: var(--surface-soft);
}

.empty-page {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  color: var(--text-3);
  background:
    radial-gradient(circle, rgba(22, 23, 26, 0.07) 1px, transparent 1.5px) 0 0 / 12px 12px,
    var(--surface-soft);
  font-weight: 600;
}

.empty-page strong {
  color: inherit;
  font-size: 12px;
  font-weight: 650;
}

.live-empty-page {
  color: var(--purple-text);
  background:
    radial-gradient(circle, rgba(124, 92, 255, 0.16) 1px, transparent 1.5px) 0 0 / 12px 12px,
    var(--purple-tint);
}

.live-page-spinner {
  width: 20px;
  height: 20px;
  display: block;
  border: 2.5px solid rgba(124, 92, 255, 0.2);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.comic-card.generated {
  border-color: rgba(34, 160, 93, 0.24);
}

.comic-card.pending {
  border-color: rgba(124, 92, 255, 0.2);
}

.comic-card footer {
  min-height: 40px;
  padding: 7px 9px;
  display: grid;
  align-content: center;
  gap: 2px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 11px;
}

.comic-card strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Per-page regeneration overlay: scoped to the card, footer stays visible */
.page-reroll-overlay {
  position: absolute;
  inset: 0 0 40px;
  z-index: 2;
  padding: 14px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.comic-card.rerolling .page-reroll-overlay {
  opacity: 1;
}

.page-reroll-overlay strong {
  font-size: 12.5px;
  line-height: 1.2;
}

.page-reroll-overlay small {
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 550;
}

.inline-spinner {
  width: 24px;
  height: 24px;
  display: inline-block;
  border: 3px solid var(--purple-tint-strong);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.page-reroll-bar {
  width: min(118px, 80%);
  height: 4px;
  overflow: hidden;
  border-radius: var(--r-pill);
  background: rgba(22, 23, 26, 0.08);
}

.page-reroll-bar span {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--purple);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 220ms var(--ease-out);
}

/* Reader: the artwork owns this surface */
.reader-panel {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.reader-panel img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: var(--surface);
  opacity: 1;
  transition: opacity 150ms ease, transform 170ms var(--ease-out);
}

.reader-panel.changing img {
  opacity: 0;
  transform: scale(0.995);
}

.reader-ai-label {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  padding: 5px 8px;
  border-radius: 4px;
  color: #fff;
  background: rgba(0, 0, 0, 0.68);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  pointer-events: none;
}

/* 还未生成的页：空白画布上播放绘制动画 */
.reader-pending {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  padding: 24px;
  background: var(--surface);
  pointer-events: none;
}

.reader-pending-art {
  width: 150px;
  height: 150px;
  display: grid;
  place-items: center;
}

.reader-pending-art svg {
  width: 100%;
  height: 100%;
  display: block;
}

.reader-pending-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
}

.reader-pending-meta {
  margin: 0;
  font-size: 12px;
  color: var(--text-2);
}

/* Edge click zones: no visible labels over artwork (spec 7.3) */
.reader-nav {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 50%;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: transparent;
  opacity: 0;
}

.reader-nav:focus-visible {
  opacity: 1;
  outline: 2px solid var(--purple);
  outline-offset: -4px;
  border-radius: var(--r-card);
}

.reader-nav-prev {
  left: 0;
}

.reader-nav-next {
  right: 0;
}

.reader-nav span {
  display: none;
}

.reader-nav:disabled {
  pointer-events: none;
}

.reader-version-badge {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 4;
  padding: 6px 11px;
  border: 1px solid var(--purple-tint-strong);
  border-radius: var(--r-pill);
  color: var(--purple-text);
  background: rgba(243, 239, 255, 0.95);
  font-size: 11.5px;
  font-weight: 600;
  pointer-events: none;
}

/* 重绘前/后对比切换按钮（顶栏标题右侧）：仅在有「重绘前旧图」时显示 */
.board-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.reader-version-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--purple-tint-strong);
  border-radius: var(--r-pill);
  color: var(--purple-text);
  background: var(--purple-tint);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 140ms var(--ease-out),
    border-color 140ms var(--ease-out),
    color 140ms var(--ease-out),
    transform 140ms var(--ease-out);
}

.reader-version-toggle i,
.reader-version-toggle svg {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
}

.reader-version-toggle svg {
  display: block;
  stroke-width: 2.35;
}

.reader-version-toggle:hover,
.reader-version-toggle.active {
  background: var(--purple);
  color: #fff;
  border-color: var(--purple);
}

.reader-version-toggle:active {
  transform: scale(0.97);
}

.reader-meta {
  display: none;
}

.dialogue-list {
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

/* Right-click version menu */
.page-version-menu {
  position: fixed;
  z-index: var(--z-menu);
  width: 196px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.page-version-menu button {
  width: 100%;
  padding: 8px 10px;
  display: grid;
  gap: 2px;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.page-version-menu button:hover,
.page-version-menu button:focus-visible {
  outline: 0;
  background: var(--surface-sunken);
}

.page-version-menu strong {
  font-size: 12.5px;
  font-weight: 600;
}

.page-version-menu span {
  color: var(--text-3);
  font-size: 11px;
}

.project-context-menu {
  position: fixed;
  z-index: var(--z-menu);
  width: 156px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.project-context-menu button {
  width: 100%;
  min-height: 34px;
  padding: 0 9px;
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: center;
  column-gap: 8px;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  font-size: 12.5px;
  font-weight: 560;
  transition: background 140ms ease, color 140ms ease, transform 120ms var(--ease-out);
}

.project-context-menu button:active:not(:disabled) {
  transform: scale(0.98);
}

.project-context-menu button:hover,
.project-context-menu button:focus-visible {
  outline: 0;
  background: var(--surface-sunken);
}

.project-context-menu button:disabled {
  color: var(--text-3);
  cursor: not-allowed;
  opacity: 0.65;
}

.project-context-menu button.danger:not(:disabled) {
  color: #d33b3b;
}

.project-context-menu button.danger:not(:disabled):hover,
.project-context-menu button.danger:not(:disabled):focus-visible {
  background: rgba(211, 59, 59, 0.08);
}

.project-context-menu i,
.project-context-menu svg {
  width: 15px;
  height: 15px;
}

/* Page version preview */
.version-preview-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 3);
  padding: 28px;
  display: grid;
  place-items: center;
  background: rgba(22, 23, 26, 0.48);
}

.version-preview-dialog {
  width: min(980px, 94vw);
  max-height: min(760px, 88vh);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.version-preview-dialog header {
  min-height: 72px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.version-preview-dialog h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.version-preview-dialog p {
  margin: 4px 0 0;
  color: var(--text-2);
  font-size: 12.5px;
}

.version-preview-grid {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  background: var(--surface-sunken);
}

.version-preview-card {
  overflow: hidden;
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  transition: border-color 150ms var(--ease-out), box-shadow 150ms var(--ease-out), transform 150ms var(--ease-out);
}

.version-preview-card:hover,
.version-preview-card:focus-visible {
  outline: 0;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-tint);
  transform: translateY(-1px);
}

.version-preview-card.active {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-tint-strong);
}

.version-preview-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: top;
  background: var(--surface-soft);
}

.version-preview-card span {
  min-height: 38px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
}

/* Scoped loading while the current page regenerates */
.reader-page-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.6);
}

.reader-page-loading-card {
  width: min(340px, 82%);
  padding: 24px;
  display: grid;
  justify-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: center;
}

.reader-page-loading-card strong {
  font-size: 15px;
  font-weight: 650;
}

.reader-page-loading-card p {
  margin: 0;
  color: var(--text-2);
  font-size: 12.5px;
}

/* ==========================================================================
   Local edit modal
   ========================================================================== */

body.modal-open {
  overflow: hidden;
}

.local-edit-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-menu) + 2);
  padding: 28px;
  display: grid;
  place-items: center;
  background: rgba(22, 23, 26, 0.44);
}

.local-edit-dialog {
  width: min(1180px, 96vw);
  max-height: 94vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.local-edit-dialog > header {
  min-height: 72px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.local-edit-dialog h2 {
  margin: 0 0 2px;
  font-size: 17px;
  font-weight: 650;
}

.local-edit-dialog header p {
  margin: 0;
  color: var(--text-2);
  font-size: 12.5px;
}

.local-edit-workspace {
  min-height: 0;
  padding: 18px;
  overflow: auto;
  display: grid;
  grid-template-rows: minmax(320px, 1fr) auto;
  gap: 14px;
  background: var(--bg);
}

.local-edit-media {
  position: relative;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background:
    linear-gradient(45deg, rgba(22, 23, 26, 0.04) 25%, transparent 25%, transparent 75%, rgba(22, 23, 26, 0.04) 75%) 0 0 / 20px 20px,
    var(--surface);
}

.local-edit-media > img {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
}

.local-edit-media > canvas {
  position: absolute;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  cursor: crosshair;
  touch-action: none;
}

/* 分镜重绘：检测出的分镜框叠在画布上，点选即填入遮罩；位置由 JS 对齐到画布显示区域 */
.panel-boxes {
  position: absolute;
  z-index: 1;
  pointer-events: none;
}

.panel-boxes.active {
  pointer-events: auto;
}

.panel-box {
  position: absolute;
  border: 2px dashed rgba(124, 92, 255, 0.5);
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  padding: 0;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  -webkit-tap-highlight-color: transparent;
}

/* 悬停（未选中）：高亮边框 + 轻填充 + “点击框选”气泡提示 */
.panel-box:not(.selected):hover {
  background: rgba(124, 92, 255, 0.1);
  border-style: solid;
  border-color: rgba(124, 92, 255, 0.95);
}

.panel-box:not(.selected):hover::after {
  content: "点击框选";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(124, 92, 255, 0.28);
  pointer-events: none;
  white-space: nowrap;
}

/* 选中：淡紫粉填充（遮罩层在下，这里再叠一层确保清晰）+ 实线描边 + 柔光 */
.panel-box.selected {
  border: 2px solid var(--purple);
  background: rgba(208, 142, 224, 0.16);
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.25), 0 6px 18px rgba(124, 92, 255, 0.22);
}

.panel-box.selected:hover::after {
  content: "再次点击取消";
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  color: var(--purple);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(124, 92, 255, 0.22);
  pointer-events: none;
  white-space: nowrap;
}

/* 四角微调手柄：仅选中分镜显示，可拖拽改变框选范围 */
.panel-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid var(--purple);
  border-radius: 4px;
  box-shadow: 0 1px 5px rgba(22, 23, 26, 0.25);
  touch-action: none;
  z-index: 3;
}

.panel-handle.tl { left: -8px; top: -8px; cursor: nwse-resize; }
.panel-handle.tr { right: -8px; top: -8px; cursor: nesw-resize; }
.panel-handle.bl { left: -8px; bottom: -8px; cursor: nesw-resize; }
.panel-handle.br { right: -8px; bottom: -8px; cursor: nwse-resize; }

.local-edit-tools {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 2;
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-sm);
}

.local-edit-tools button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink-soft);
  background: transparent;
  transition: color 150ms ease, background 150ms ease;
}

.local-edit-tools button:hover,
.local-edit-tools button.active {
  color: var(--purple-text);
  background: var(--purple-tint);
}

.local-edit-tools label {
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 550;
}

.local-edit-tools input {
  width: 100px;
  accent-color: var(--purple);
}

.local-edit-compose {
  padding: 12px;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--surface);
}

.local-edit-compose textarea {
  min-height: 82px;
  padding: 12px 14px;
  resize: vertical;
  border: 0;
  outline: 0;
  border-radius: var(--r-control);
  color: var(--ink);
  background: var(--surface-sunken);
  font-size: 13px;
  line-height: 1.6;
  transition: box-shadow 150ms ease;
}

.local-edit-compose textarea:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1.5px rgba(124, 92, 255, 0.45);
}

.local-edit-compose textarea::placeholder {
  color: var(--text-3);
}

.local-edit-compose > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.local-edit-compose > div > span {
  color: var(--text-2);
  font-size: 12px;
}

/* 局部修改/分镜重绘动作按钮（参考即梦"✦ N"）：只显示积分球图标 + 数字，无文字。
   默认未涂选时灰色无彩；涂选区域后（.is-active）才上淡彩渐变并点亮积分球。 */
.local-edit-submit {
  gap: 5px;
  min-height: 34px;
  padding: 0 14px 0 8px;
  border: 0;
  color: #9aa0ab;
  background-image: none;
  background-color: #ececed;
  box-shadow: none;
  transition: background-color 250ms ease, color 250ms ease, box-shadow 300ms ease;
}

.local-edit-submit .credit-orb {
  width: 18px;
  height: 18px;
  box-shadow: none;
  filter: grayscale(1) opacity(0.6);
  transition: filter 250ms ease;
}

.local-edit-submit b {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.local-edit-submit:not(.is-active):hover {
  background-color: #e3e3e6;
}

/* 涂选后：淡彩渐变 + 彩色积分球 */
.local-edit-submit.is-active {
  color: #3f3f46;
  background-color: transparent;
  background-image: linear-gradient(110deg, #c3caf9, #ddc6f7 50%, #f8c8e3);
  box-shadow: 0 4px 14px rgba(168, 139, 240, 0.24);
}

.local-edit-submit.is-active .credit-orb {
  filter: none;
}

.local-edit-submit.is-active:hover {
  background-image: linear-gradient(110deg, #c3caf9, #ddc6f7 50%, #f8c8e3);
  box-shadow: 0 8px 24px rgba(168, 139, 240, 0.4);
}

.local-edit-submit.is-active:active {
  transform: scale(0.98);
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: var(--z-toast);
  min-height: 40px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-pill);
  color: #fff;
  background: #202127;
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  font-weight: 550;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 170ms ease, transform 200ms var(--ease-out);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==========================================================================
   Auth（AUTH_MODE=on 时的登录 / 注册门）
   ========================================================================== */

.auth-view {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle, rgba(22, 23, 26, 0.05) 1px, transparent 1.5px) 0 0 / 14px 14px,
    linear-gradient(#f8f8f7, #efefed);
}

.auth-panel {
  width: min(380px, 94vw);
  padding: 30px 28px 24px;
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: center;
  animation: panelIn 240ms var(--ease-out) both;
}

.auth-brand {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-brand-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
  filter: grayscale(1) brightness(0);
}

.auth-brand-wordmark {
  width: 60px;
  height: 28px;
  object-fit: contain;
}

.auth-panel h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.auth-sub {
  margin: 0 0 14px;
  color: var(--text-2);
  font-size: 12.5px;
}

.auth-panel form {
  display: grid;
  gap: 12px;
  text-align: left;
}

.auth-field {
  display: grid;
  gap: 6px;
}

.auth-field span {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.auth-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.auth-field input:focus {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 0 0 2px var(--purple-tint);
}

.auth-field input::placeholder {
  color: var(--text-3);
}

.auth-field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  min-height: 104px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.auth-field textarea:focus {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 0 0 2px var(--purple-tint);
}

.auth-field textarea::placeholder {
  color: var(--text-3);
}

.auth-turnstile {
  display: flex;
  justify-content: center;
  min-height: 65px;
}

.auth-turnstile.hidden {
  display: none;
}

.auth-turnstile > div {
  min-height: 65px;
}

.auth-error {
  margin: 0;
  color: #b8362f;
  font-size: 12.5px;
  text-align: left;
}

.auth-submit {
  width: 100%;
  min-height: 38px;
  margin-top: 2px;
}

.auth-forgot {
  justify-self: end;
  margin-top: -7px;
  padding: 2px 0;
  color: var(--text-2);
  background: transparent;
  font-size: 12.5px;
}

.auth-forgot:hover {
  color: var(--purple-text);
}

.auth-switch {
  margin-top: 12px;
  justify-self: center;
  padding: 4px 6px;
  border-radius: var(--r-control);
  color: var(--purple-text);
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  transition: color 150ms ease;
}

.auth-switch:hover {
  color: var(--purple);
}

/* 兑换弹窗里的计价说明 */
.redeem-pricing {
  margin: 14px 0 0;
  color: var(--text-3);
  font-size: 11.5px;
  text-align: center;
}

/* 顶栏登录态：未登录显示登录按钮，登录后显示头像 + 下拉用户菜单 */
.login-button {
  min-height: 32px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  color: #fff;
  background: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  transition: background 150ms ease, transform 140ms var(--ease-out);
}

.login-button:hover {
  background: #2c2d33;
}

.login-button:active {
  transform: scale(0.98);
}

.user-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.avatar-button {
  width: 40px;
  height: 40px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(22, 23, 26, 0.1);
  border-radius: var(--r-pill);
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(22, 23, 26, 0.08);
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 140ms var(--ease-out);
}

.avatar-button:hover {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-tint), 0 8px 18px rgba(124, 92, 255, 0.14);
}

.avatar-button:active {
  transform: scale(0.96);
}

.avatar-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: var(--z-menu);
  width: 232px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.user-menu-head {
  margin-bottom: 4px;
  padding: 10px 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.user-menu-head img {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: var(--r-pill);
  object-fit: cover;
}

.user-menu-id {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.user-menu-id strong {
  overflow: hidden;
  font-size: 13.5px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-id small {
  overflow: hidden;
  color: var(--text-3);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu > button {
  width: 100%;
  min-height: 38px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px;
  color: var(--ink-soft);
  background: transparent;
  font-size: 13px;
  font-weight: 550;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.user-menu > button:hover {
  color: var(--ink);
  background: var(--surface-sunken);
}

.user-menu > button.danger {
  color: #b42318;
}

.user-menu > button.danger:hover {
  color: #8f1d14;
  background: #fff1f0;
}

.auth-agree a {
  color: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-support-link {
  display: block;
  margin-top: 12px;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-support-link:hover {
  color: var(--ink);
}

.user-menu > button i {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 228px minmax(0, 1fr);
  }

  .board-layout {
    grid-template-columns: 160px minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .promo-bar {
    height: auto;
    min-height: 40px;
    padding: 8px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .app-shell,
  .app-shell.collapsed {
    display: block;
    height: calc(100vh - 40px);
    overflow: hidden;
  }

  .sidebar {
    height: auto;
    min-height: auto;
    margin: 10px;
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    background: var(--surface);
  }

  .brand {
    grid-template-columns: minmax(0, 1fr) 32px;
  }

  .app-shell.collapsed .brand strong,
  .app-shell.collapsed .brand-lockup .brand-wordmark,
  .app-shell.collapsed .brand .icon-button {
    display: block;
  }

  .app-shell.collapsed .sidebar {
    min-height: 0;
    margin: 10px;
    padding: 12px;
    display: grid;
    gap: 10px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--r-panel);
    background: var(--surface);
    transform: none;
  }

  .app-shell.collapsed .brand {
    position: static;
    width: auto;
    height: 40px;
    display: grid;
  }

  .app-shell.collapsed .brand-lockup {
    position: static;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    opacity: 1;
    transform: none;
  }

  .app-shell.collapsed .brand-logo {
    width: 32px;
    height: 32px;
  }

  /* The hover-swap is a desktop affordance; on narrow widths the toggle is
     always visible next to the wordmark. */
  .app-shell.collapsed .brand .icon-button {
    position: static;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: var(--r-control);
    background: transparent;
    box-shadow: none;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  .app-shell.collapsed .brand:hover .brand-lockup {
    opacity: 1;
    transform: none;
  }

  .app-shell.collapsed .brand .icon-button::after {
    display: none;
  }

  .history-head,
  .history-card,
  .history-list {
    display: none;
  }

  .nav-list,
  .app-shell.collapsed .nav-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .quick-create {
    display: none;
  }

  .nav-item,
  .app-shell.collapsed .nav-item {
    width: auto;
    min-height: 40px;
    padding: 0 10px;
    display: flex;
    justify-content: center;
  }

  .app-shell.collapsed .nav-item span {
    display: inline;
  }

  .main-stage {
    height: calc(100vh - 146px);
    min-height: 0;
    grid-template-rows: 56px 1fr;
  }

  .topbar {
    padding: 0 14px;
  }

  .credit-pill {
    display: none;
  }

  .home-view {
    padding: 28px 18px 52px;
  }

  .hero-copy h1 {
    font-size: 34px;
  }

  .hero-copy p {
    margin-bottom: 30px;
    font-size: 14px;
  }

  .form-actions {
    min-height: auto;
    padding: 0 10px 12px;
    flex-wrap: wrap;
  }

  .form-actions .ghost-action,
  .form-actions .primary-action {
    flex: 1 1 150px;
  }

  .copyright-tip {
    margin: 18px 0 34px;
    text-align: center;
  }

  .project-section-head {
    align-items: flex-start;
  }

  .project-grid {
    grid-template-columns: 1fr;
  }

  .wait-view {
    padding: 22px 14px;
  }

  .progress-panel {
    width: min(100%, 520px);
    padding: 28px 22px;
  }

  .generation-phase {
    grid-template-columns: 24px minmax(0, 1fr);
    grid-template-rows: auto auto 4px;
  }

  .generation-phase-index {
    grid-row: 1 / 4;
  }

  .generation-phase-meta,
  .generation-phase-track {
    grid-column: 2;
    text-align: left;
  }

  .animated-status-title {
    max-width: 100%;
    white-space: normal;
  }

  .animated-status-copy {
    flex-wrap: wrap;
  }

  .board-view {
    padding: 0 14px 24px;
  }

  .board-header {
    min-height: auto;
    padding: 12px 0 14px;
    align-items: flex-start;
    flex-direction: column;
  }

  .app-shell.collapsed .board-header > div {
    padding-left: 0;
  }

  .board-actions {
    justify-content: flex-start;
  }

  .board-view.live-generation {
    --live-strip-height: 0px;
  }

  .live-progress-strip {
    margin: 0 0 12px;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .live-progress-strip .ghost-action {
    width: max-content;
  }

  .board-layout {
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

  .comic-grid {
    max-height: none;
    grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  }

  .comic-card img,
  .empty-page {
    aspect-ratio: 9 / 14;
  }

  .reader-panel {
    height: 72vh;
  }

  .local-edit-modal {
    padding: 8px;
  }

  .local-edit-dialog {
    width: 100%;
    max-height: 98vh;
  }

  .local-edit-workspace {
    padding: 10px;
  }

  .local-edit-tools {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .local-edit-tools label {
    flex: 1;
  }

  .local-edit-tools input {
    width: 100%;
  }

  .local-edit-compose > div {
    align-items: stretch;
    flex-direction: column;
  }
}

/* ==========================================================================
   登录弹窗 v2 —— 即梦风格（白色大卡片 + 浅色蒙层 + 灰底输入框 + 协议勾选）
   切换回旧版：删除 <body> 上的 auth-ui-v2 类即可，下方规则全部失效。
   ========================================================================== */

body.auth-ui-v2 .auth-view {
  background: rgba(246, 246, 245, 0.72);
  backdrop-filter: blur(10px) saturate(1.05);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
}

body.auth-ui-v2 .auth-panel {
  position: relative;
  width: min(440px, 94vw);
  padding: 36px 36px 30px;
  gap: 0;
  border: 0;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(22, 23, 26, 0.06), 0 32px 80px rgba(22, 23, 26, 0.14);
  text-align: left;
}

body.auth-ui-v2 .auth-brand {
  margin-bottom: 22px;
  justify-content: flex-start;
  gap: 7px;
}

body.auth-ui-v2 .auth-brand-logo {
  width: 24px;
  height: 24px;
}

body.auth-ui-v2 .auth-brand-wordmark {
  width: 48px;
  height: 22px;
}

body.auth-ui-v2 .auth-panel h2 {
  margin-bottom: 24px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* 即梦无副标题：隐藏说明行，信息浓缩进标题 */
body.auth-ui-v2 .auth-sub {
  display: none;
}

body.auth-ui-v2 .auth-panel form {
  gap: 16px;
}

body.auth-ui-v2 .auth-field {
  gap: 9px;
}

body.auth-ui-v2 .auth-field span {
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
}

body.auth-ui-v2 .auth-field input {
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f5f5f4;
  font-size: 14px;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

body.auth-ui-v2 .auth-field input:hover {
  background: #f0f0ef;
}

body.auth-ui-v2 .auth-field input:focus {
  border-color: rgba(124, 92, 255, 0.55);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--purple-tint);
}

body.auth-ui-v2 .auth-field textarea {
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f5f5f4;
  font-size: 14px;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

body.auth-ui-v2 .auth-field textarea:hover {
  background: #f0f0ef;
}

body.auth-ui-v2 .auth-field textarea:focus {
  border-color: rgba(124, 92, 255, 0.55);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--purple-tint);
}

body.auth-ui-v2 .auth-submit {
  min-height: 46px;
  margin-top: 6px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}

/* 未勾选协议时的置灰态：用确定的灰色而不是全局半透明 */
body.auth-ui-v2 .auth-submit:disabled {
  opacity: 1;
  color: #a2a5ab;
  background: #ececeb;
}

body.auth-ui-v2 .auth-agree {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.55;
  cursor: pointer;
  user-select: none;
}

body.auth-ui-v2 .auth-agree input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex: none;
  accent-color: var(--purple);
  cursor: pointer;
}

body.auth-ui-v2 .auth-agree strong {
  color: var(--ink);
  font-weight: 600;
}

body.auth-ui-v2 .auth-switch {
  margin-top: 16px;
  font-size: 13px;
}

/* 旧版界面不显示协议行（保持原样可随时切回） */
body:not(.auth-ui-v2) .auth-agree {
  display: none;
}


/* 登录弹窗右上角关闭：未登录浏览是允许的，所以弹窗可关 */
.auth-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

body:not(.auth-ui-v2) .auth-close {
  display: none;
}

/* 生成后续模式选择 */
.continue-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-menu) + 1);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(22, 23, 26, 0.42);
  animation: fadeIn 160ms ease;
}

.continue-dialog {
  width: min(560px, 94vw);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-panel);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: panelIn 220ms var(--ease-out) both;
}

.continue-dialog > header {
  padding: 18px 20px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.continue-dialog h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 650;
}

.continue-dialog p {
  max-width: 430px;
  margin: 0;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.5;
}

.continue-options {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.continue-option {
  width: 100%;
  min-height: 86px;
  padding: 14px;
  display: grid;
  grid-template-columns: 38px 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 4px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 140ms var(--ease-out), box-shadow 160ms ease;
}

.continue-option i,
.continue-option svg {
  grid-row: 1 / span 2;
  width: 24px;
  height: 24px;
  justify-self: center;
  color: var(--purple);
}

.continue-option strong {
  font-size: 14px;
  font-weight: 650;
}

.continue-option span {
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.45;
}

.continue-option:hover {
  border-color: var(--purple);
  background: var(--purple-tint);
  box-shadow: 0 10px 28px rgba(124, 92, 255, 0.12);
  transform: translateY(-1px);
}

.continue-option:active {
  transform: scale(0.99);
}

/* ==========================================================================
   充值 / 会员弹窗（参考即梦充值页：用户头 + 周期切换 + 会员卡片 + 兑换码）
   ========================================================================== */

.recharge-modal {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-menu) + 1);
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(22, 23, 26, 0.46);
  animation: fadeIn 160ms ease;
}

.recharge-dialog {
  width: min(1140px, 96vw);
  max-height: 92vh;
  overflow: hidden auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: panelIn 240ms var(--ease-out) both;
}

.recharge-dialog::-webkit-scrollbar {
  display: none;
}

.recharge-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.recharge-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.recharge-avatar {
  width: 42px;
  height: 42px;
  border-radius: var(--r-pill);
  object-fit: cover;
  background: var(--surface-soft);
}

.recharge-user-id {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.recharge-user-id strong {
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}

.recharge-user-id span {
  font-size: 12px;
  color: var(--text-3);
}

.recharge-user-id span b {
  color: var(--purple-text);
  font-weight: 650;
}

.recharge-close {
  flex: none;
}

.recharge-body {
  padding: 24px 26px 28px;
}

.recharge-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: var(--ink);
}

.recharge-subtitle {
  margin: 0 0 20px;
  font-size: 12.5px;
  color: var(--text-3);
  text-align: center;
}

/* 周期分段控件 */
.recharge-cycle {
  display: flex;
  width: fit-content;
  gap: 4px;
  margin: 0 auto 22px;
  padding: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-sunken);
}

.recharge-cycle button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 18px;
  border-radius: var(--r-pill);
  color: var(--text-2);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.recharge-cycle button em {
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  color: #d2554d;
}

.recharge-cycle button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.recharge-cycle button.active em {
  color: #d2554d;
}

.recharge-speed-note {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto 18px;
  padding: 10px 14px;
  border: 1px solid rgba(111, 82, 237, 0.18);
  border-radius: 8px;
  background: var(--purple-tint);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.55;
}

.recharge-speed-note i {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--purple-text);
}

.recharge-speed-note strong {
  color: var(--ink);
  font-weight: 720;
}

/* 会员卡片网格 */
.recharge-tiers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(224px, 1fr));
  gap: 14px;
}

.recharge-card {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 22px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms var(--ease-out);
}

.recharge-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.recharge-card.recommended {
  border-color: rgba(124, 92, 255, 0.5);
  box-shadow: 0 0 0 1px rgba(124, 92, 255, 0.35), var(--shadow-sm);
}

.recharge-card-flag {
  position: absolute;
  top: -10px;
  left: 20px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, #7c5cff, #9a7dff);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.recharge-credits-chip {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 14px;
  padding: 5px 11px;
  border-radius: var(--r-pill);
  background: var(--purple-tint);
  color: var(--purple-text);
  font-size: 12px;
  font-weight: 650;
}

.recharge-credits-chip img {
  width: 14px;
  height: 14px;
}

.recharge-card-name {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 650;
  color: var(--ink);
}

.recharge-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}

.recharge-price .amount {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.recharge-price .amount .yuan {
  font-size: 18px;
  font-weight: 700;
}

.recharge-price .per {
  font-size: 12px;
  color: var(--text-3);
}

.recharge-card-unit {
  margin: 0 0 16px;
  font-size: 11.5px;
  color: var(--text-3);
}

.recharge-card-unit del {
  margin-right: 6px;
  color: var(--faint, #b5b7bd);
}

.recharge-buy {
  width: 100%;
  min-height: 42px;
  margin-bottom: 16px;
  border-radius: 12px;
  color: #fff;
  background: var(--ink);
  font-size: 13.5px;
  font-weight: 650;
  transition: background 150ms ease, transform 140ms var(--ease-out);
}

.recharge-buy:hover {
  background: #2c2d33;
}

.recharge-buy:active {
  transform: scale(0.99);
}

.recharge-card.recommended .recharge-buy {
  background: linear-gradient(90deg, #6a48f5, #8d6bff);
}

.recharge-card.recommended .recharge-buy:hover {
  background: linear-gradient(90deg, #5d3bef, #7f5bff);
}

.recharge-buy.is-current {
  color: var(--text-2);
  background: var(--surface-soft);
  cursor: default;
}

.recharge-buy.is-current:hover {
  background: var(--surface-soft);
}

.recharge-perks {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recharge-perks li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.recharge-perks li i {
  width: 15px;
  height: 15px;
  flex: none;
  color: var(--purple-text);
}

.recharge-perks li.is-speed {
  align-items: flex-start;
  color: var(--ink);
  font-weight: 650;
  line-height: 1.45;
}

.recharge-perks li.is-speed i {
  margin-top: 1px;
}

.recharge-perks li .perk-tag {
  margin-left: auto;
  padding: 1px 8px;
  border-radius: var(--r-pill);
  background: var(--purple-tint);
  color: var(--purple-text);
  font-size: 10.5px;
  font-weight: 650;
}

/* 兑换码区 */
.recharge-redeem {
  margin-top: 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-sunken);
}

.recharge-redeem-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.recharge-redeem-head strong {
  font-size: 13.5px;
  font-weight: 650;
  color: var(--ink);
}

.recharge-redeem-head span {
  font-size: 12px;
  color: var(--text-3);
}

.recharge-redeem-form {
  display: flex;
  gap: 10px;
}

.recharge-redeem-form input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: none;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
  letter-spacing: 0.04em;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.recharge-redeem-form input:focus {
  border-color: rgba(124, 92, 255, 0.55);
  box-shadow: 0 0 0 2px var(--purple-tint);
}

.recharge-redeem-form .ghost-action {
  flex: none;
  min-height: 40px;
  padding: 0 22px;
}

.recharge-redeem-error {
  margin: 10px 0 0;
  font-size: 12px;
  color: #b8362f;
}

.recharge-foot {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--text-3);
  text-align: center;
  line-height: 1.6;
}

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

@media (max-width: 720px) {
  .version-preview-modal {
    padding: 12px;
  }

  .version-preview-dialog {
    width: 100%;
    max-height: 92vh;
  }

  .version-preview-dialog header {
    min-height: 64px;
    padding: 14px;
  }

  .version-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    padding: 12px;
  }

  .recharge-modal {
    padding: 0;
  }

  .recharge-dialog {
    width: 100%;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }

  .recharge-tiers {
    grid-template-columns: 1fr;
  }
}

/* 试看完成后的开通会员引导横幅 */
.preview-upsell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 14px 18px;
  border: 1px solid var(--purple-tint-strong);
  border-radius: var(--radius-card, 14px);
  background: linear-gradient(135deg, var(--purple-tint), var(--surface-soft));
}

.preview-upsell.hidden {
  display: none;
}

.preview-upsell-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 220px;
}

.preview-upsell-text strong {
  color: var(--purple-text);
  font-size: 14px;
}

.preview-upsell-text span {
  color: var(--text-2);
  font-size: 13px;
}

.preview-upsell .primary-action {
  flex-shrink: 0;
}

.preview-upsell-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

@media (prefers-reduced-motion: reduce) {
  .animated-status-letter {
    opacity: 1;
    transform: none;
    animation: none;
  }
}
/* Vercel public test build: keep the core input -> progress -> reader flow only. */
.promo-bar .test-mode-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.13);
  font-size: 11px;
  font-weight: 600;
}

.promo-bar .test-mode-badge.hidden {
  display: none;
}

body.vercel-test-mode #creditWrap,
body.vercel-test-mode #promoCta,
body.vercel-test-mode #rerollPageButton,
body.vercel-test-mode #panelRedrawButton,
body.vercel-test-mode #readerVersionToggle,
body.vercel-test-mode #readerVersionBadge,
body.vercel-test-mode #pageVersionMenu,
body.vercel-test-mode #versionPreviewModal,
body.vercel-test-mode #localEditModal,
body.vercel-test-mode #previewLink,
body.vercel-test-mode #previewUpsell,
body.vercel-test-mode #continueEpisodeButton,
body.vercel-test-mode #exportButton,
body.vercel-test-mode .history-project-more {
  display: none !important;
}

body.vercel-test-mode .topbar {
  min-height: 18px;
}
