/* ==========================================================================
   wechat-online UI — Minimal Neutral
   浅色 · 灰阶 · 无彩色装饰 · 工具向
   ========================================================================== */

:root {
  --primary: #171717;
  --primary-soft: #f5f5f5;
  --primary-strong: #0a0a0a;
  --secondary: #525252;
  --secondary-soft: #f5f5f5;
  --accent: #404040;
  --accent-soft: #f5f5f5;
  --accent-bright: #262626;
  --cta: #171717;
  --success: #15803d;
  --danger: #b91c1c;
  --warn: #a16207;

  --text: #171717;
  --text-muted: #525252;
  --text-soft: #737373;
  --text-inverse: #fafafa;

  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --surface-hover: #f0f0f0;
  --paper: #ffffff;
  --paper-strong: #ffffff;

  --line: #e5e5e5;
  --line-strong: #d4d4d4;
  --ring: #171717;
  --scrim: rgba(0, 0, 0, 0.4);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;

  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-glow: none;

  --font: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --font-display: var(--font);

  --topbar: 52px;
  --sidebar: 248px;
  --ease: ease;
  --ease-out: ease;
  --duration-fast: 120ms;
  --duration: 160ms;
  --duration-slow: 200ms;
  --z-scrim: 40;
  --z-toast: 90;
  --z-modal: 100;
  --z-busy: 110;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { background: var(--bg); color-scheme: light; }
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.studio-mesh { display: none; }

.login-view,
.app-view {
  position: relative;
  z-index: 1;
}

h1, h2, h3,
.toolbar-left h2,
.login-card h1,
.modal-head h2,
.pub-card-head h3,
.section-title {
  font-family: var(--font);
  letter-spacing: -0.01em;
  font-weight: 600;
}

button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* A11y */
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 200;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
}
.skip-link:focus { top: 12px; outline: 2px solid #fff; outline-offset: 2px; }
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) { outline: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid #a3a3a3;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration), border-color var(--duration), opacity var(--duration);
  touch-action: manipulation;
  user-select: none;
}
.btn:hover {
  background: var(--surface-2);
  border-color: #525252;
}
.btn:active {
  background: #ebebeb;
  border-color: #404040;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: 1.5px solid #0a0a0a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.btn-primary:hover {
  background: #262626;
  border-color: #000;
  color: #fff;
}
.btn-soft {
  background: #f5f5f5;
  border: 1.5px solid #a3a3a3;
  color: var(--text);
}
.btn-soft:hover {
  background: #ebebeb;
  border-color: #525252;
}
.btn-accent {
  background: var(--surface);
  border: 1.5px solid #737373;
  color: var(--text);
}
.btn-accent:hover {
  background: var(--surface-2);
  border-color: #404040;
}
.btn-ghost {
  background: var(--surface);
  border: 1.5px solid #d4d4d4;
  color: var(--text-muted);
  min-height: 32px;
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: #a3a3a3;
}
.btn-icon {
  width: 32px;
  min-width: 32px;
  padding: 0;
}
.btn-block { width: 100%; }
.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.75rem;
}
.btn.is-busy, button.is-busy,
.btn:disabled, button:disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* ---------- Fields ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}
.field > span { color: var(--text-muted); font-size: 0.8125rem; font-weight: 500; }
.field span em { color: var(--text); font-style: normal; }
.field input,
.field select,
.field textarea,
.control select,
input[type="password"],
input[type="text"],
select {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field textarea,
textarea {
  min-height: 120px;
  padding: 10px;
  line-height: 1.6;
  resize: vertical;
}
.field input::placeholder,
.field textarea::placeholder,
textarea::placeholder { color: #a3a3a3; }
.field input:focus,
.field select:focus,
.field textarea:focus,
.control select:focus,
input:focus,
textarea:focus {
  border-color: #737373;
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.06);
}
.field-hint {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-soft);
  font-weight: 400;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

/* ---------- Login ---------- */
.login-view {
  min-height: 100%;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}
.login-shell {
  width: min(380px, 100%);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.logo-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
}
.login-product {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
.login-tagline {
  font-size: 0.75rem;
  color: var(--text-soft);
  margin-top: 1px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 1.5rem 1.25rem;
}
.login-badge {
  display: inline-flex;
  margin-bottom: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.login-card h1 {
  margin: 0 0 0.4rem;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
}
.login-desc {
  margin: 0 0 1.1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.55;
}
.login-card .field { margin-bottom: 0.9rem; }
.login-card .btn-primary { width: 100%; margin-top: 0.15rem; }
.login-hint {
  margin: 0 0 10px;
  font-size: 0.78rem;
  line-height: 1.55;
}
.login-disclaimer {
  margin: 0 0 12px;
  font-size: 0.78rem;
  line-height: 1.55;
}
.login-card {
  max-width: 100%;
}
.login-shell {
  width: min(420px, 100%);
}
.error {
  min-height: 1.2em;
  margin-top: 0.65rem;
  color: var(--danger);
  font-size: 0.8125rem;
}
.login-foot {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-soft);
}

/* ---------- App shell ---------- */
.app-view {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--topbar) 1fr;
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  z-index: 20;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
}
.brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--primary);
  flex-shrink: 0;
}
.brand-text { font-size: 0.9rem; font-weight: 600; }
.brand-accent { color: var(--text-muted); font-weight: 500; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 顶栏独立 Tab（排版 / AI 生图）— 彩色，进站就能注意到 */
.top-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  padding: 3px;
  border-radius: 10px;
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  border: 1.5px solid #93c5fd;
  box-shadow:
    0 1px 2px rgba(37, 99, 235, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}
.top-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 78px;
  padding: 0 14px;
  border: 1.5px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-soft);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    color var(--duration-fast),
    background var(--duration-fast),
    border-color var(--duration-fast),
    box-shadow var(--duration-fast);
}
/* 排版：蓝色 */
.top-tab[data-page="layout"] {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.22);
}
.top-tab[data-page="layout"]:hover {
  color: #1e40af;
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(37, 99, 235, 0.4);
}
.top-tab[data-page="layout"].active {
  color: #fff;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  border-color: #1e40af;
  box-shadow:
    0 2px 8px rgba(37, 99, 235, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
/* AI 生图：紫色 */
.top-tab[data-page="gallery"] {
  color: #6d28d9;
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.22);
}
.top-tab[data-page="gallery"]:hover {
  color: #5b21b6;
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.4);
}
.top-tab[data-page="gallery"].active {
  color: #fff;
  background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
  border-color: #5b21b6;
  box-shadow:
    0 2px 8px rgba(124, 58, 237, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
@media (max-width: 900px) {
  .top-tab { min-width: 0; padding: 0 10px; }
  .brand-text { max-width: 8em; overflow: hidden; text-overflow: ellipsis; }
}

.status-pill,
.article-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
  max-width: 180px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
#article-chip-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.article-chip {
  color: var(--text);
  background: var(--surface);
}

/* ---------- Main ---------- */
.main-shell {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 0;
  height: 100%;
  position: relative;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow: auto;
  z-index: 15;
}
.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
.sidebar-kicker {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-soft);
  font-weight: 500;
}
.sidebar-title {
  margin-top: 2px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.sidebar-foot {
  margin-top: auto;
  padding: 10px 2px 2px;
  border-top: 1px solid var(--line);
}
.foot-line {
  font-size: 0.72rem;
  color: var(--text-soft);
  line-height: 1.45;
}

.article-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.article-item {
  display: flex;
  align-items: stretch;
  gap: 2px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.article-item:hover {
  background: var(--surface-2);
}
.article-item.is-active {
  background: var(--surface-2);
  border-color: var(--line);
}
.article-list .article-open {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 10px 8px 10px 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  min-height: 44px;
  color: inherit;
}
.article-list .article-open:hover {
  background: transparent;
  border-color: transparent;
}
.article-list .article-del {
  flex-shrink: 0;
  min-height: 32px;
  margin: 6px 4px 6px 0;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.7;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
}
.article-item:hover .article-del,
.article-item.is-active .article-del { opacity: 1; }
.article-list .article-del:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}
.article-list .t {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.article-list .s {
  display: block;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--text-soft);
}
.article-list .empty {
  padding: 24px 10px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.sidebar-scrim {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--scrim);
  z-index: var(--z-scrim);
}
.sidebar-toggle { display: none; }

@media (max-width: 960px) {
  .main-shell { grid-template-columns: 1fr; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: min(var(--sidebar), 88vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-soft);
    background: var(--surface);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-scrim:not(.hidden) { display: block; }
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-scroll {
  flex: 1;
  overflow: auto;
  padding: 16px;
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 48px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.workbench-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.toolbar-left h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.toolbar-sub {
  font-size: 0.75rem;
  color: var(--text-soft);
  font-weight: 400;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.control select {
  width: auto;
  min-width: 120px;
  min-height: 32px;
  padding: 4px 8px;
}

.btn-cta {
  width: 100%;
  max-width: 380px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  background: var(--primary);
  border: 1.5px solid #0a0a0a;
  color: #fff;
  box-shadow: none;
}
.btn-cta:hover {
  background: #262626;
  border-color: #000;
  color: #fff;
}
.btn-cta:active {
  background: #0a0a0a;
  border-color: #000;
}

/* 预览区「选择主题」：彩色 CTA，覆盖 .btn / .btn-cta 黑底灰边 */
.btn.btn-cta.theme-picker-btn {
  gap: 8px;
  justify-content: center;
  min-height: 44px;
  background-color: #2563eb;
  background-image: linear-gradient(
    135deg,
    #7c3aed 0%,
    #2563eb 38%,
    #0891b2 68%,
    #059669 100%
  );
  border: 2px solid #1e1b4b;
  color: #fff;
  box-shadow:
    0 2px 10px rgba(37, 99, 235, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  font-weight: 600;
}
.btn.btn-cta.theme-picker-btn:hover {
  background-color: #1d4ed8;
  background-image: linear-gradient(
    135deg,
    #6d28d9 0%,
    #1d4ed8 38%,
    #0e7490 68%,
    #047857 100%
  );
  border-color: #0f172a;
  color: #fff;
  box-shadow:
    0 4px 16px rgba(37, 99, 235, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}
.btn.btn-cta.theme-picker-btn:active {
  background-color: #1e40af;
  background-image: linear-gradient(
    135deg,
    #5b21b6 0%,
    #1e40af 38%,
    #155e75 68%,
    #065f46 100%
  );
  border-color: #0f172a;
  color: #fff;
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.22);
}
.btn.btn-cta.theme-picker-btn svg {
  flex-shrink: 0;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}
.theme-picker-label {
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}
.theme-picker-current {
  color: #1e1b4b;
  font-weight: 600;
  font-size: 0.75rem;
  max-width: 9em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.stat-pill {
  min-height: 26px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
}
.stat-pill.is-over {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

/* ---------- Editor ---------- */
.editor-banner {
  margin: 10px 12px 0;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.editor-surface {
  flex: 1;
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  outline: none;
  resize: none;
  padding: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.7;
  border-radius: var(--radius-md);
  transition: border-color 0.15s ease;
  font-family: var(--font);
}
@media (min-width: 768px) {
  .editor-surface { min-height: 380px; }
}
.editor-surface:focus {
  border-color: #a3a3a3;
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.05);
}
.editor-surface::placeholder { color: #a3a3a3; }

.split-pane {
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}
.layout-pane { grid-template-columns: 1.1fr 0.9fr; }
@media (max-width: 1100px) {
  .layout-pane {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .pane-preview { min-height: 480px; }
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.pane-form.panel,
.pane-paper.panel,
.pane-preview.panel { overflow: hidden; }
.pane-paper,
.pane-preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.pane-label-row { padding: 10px 12px 0; }
.pane-label {
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-soft);
}
.pane-paper .editor-surface {
  flex: 1;
  border-radius: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  box-shadow: none;
  background: #fff;
  min-height: 240px;
  color: var(--text);
}

/* Work body */
.work-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 160px 1fr;
  overflow: hidden;
}
@media (max-width: 720px) {
  .work-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .mode-rail {
    flex-direction: row;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .mode-tab {
    flex: 1;
    min-height: 64px !important;
    padding: 8px 10px !important;
  }
  .mode-tab-desc { display: none; }
}

.mode-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 2;
}
.mode-tab {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  min-height: 88px;
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--duration-fast), background var(--duration-fast), color var(--duration-fast);
}
.mode-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}
.mode-tab.active {
  background: var(--surface-2);
  border-color: #a3a3a3;
  color: var(--text);
}
.mode-tab-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  margin-bottom: 2px;
}
.mode-tab.active .mode-tab-icon {
  background: var(--primary);
  color: #fff;
}
.mode-tab-kicker {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.mode-tab.active .mode-tab-kicker { color: var(--text-muted); }
.mode-tab-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: inherit;
  line-height: 1.25;
}
.mode-tab-desc {
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--text-soft);
  font-weight: 400;
}
.mode-tab.active .mode-tab-desc { color: var(--text-muted); }

.work-panels {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.mode-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mode-view.hidden { display: none !important; }

.ai-work-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 12px;
  padding: 12px;
  overflow: hidden;
}
@media (max-width: 960px) {
  .ai-work-grid {
    grid-template-columns: 1fr;
    overflow: auto;
  }
}
.ai-form-panel {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
}
.ai-form-panel .section-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.ai-result-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ai-result-panel .pane-label-row.tight {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 4px;
}
.ai-editor {
  flex: 1;
  min-height: 240px;
  border: 0 !important;
  border-radius: 0 !important;
  border-top: 1px solid var(--line) !important;
  border-bottom: 1px solid var(--line) !important;
  box-shadow: none !important;
  background: #fff !important;
}
.layout-pane {
  flex: 1;
  min-height: 0;
  height: 100%;
}

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}
.action-bar-main {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-busy {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

/* Preview */
.pane-preview {
  padding: 10px;
  gap: 0;
}
.preview-bar {
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}
.preview-bar-top { margin-bottom: 8px; }
.preview-bar-bottom {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.preview-actions {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.preview-actions .btn-cta {
  width: 100%;
  max-width: none;
}
/* 刷新预览：蓝色，与绿色「复制富文本」并列 */
.btn-refresh-preview {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: #2563eb;
  border: 1.5px solid #1e3a8a;
  box-shadow:
    0 2px 8px rgba(37, 99, 235, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-refresh-preview:hover {
  background: #1d4ed8;
  border-color: #1e3a8a;
  color: #fff;
  box-shadow:
    0 4px 12px rgba(37, 99, 235, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.btn-refresh-preview:active {
  background: #1e40af;
  border-color: #172554;
  color: #fff;
}
/* 复制富文本：绿色强调，表示可直接带走排版结果 */
.btn-copy-rich {
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: #059669;
  border: 1.5px solid #064e3b;
  box-shadow:
    0 2px 8px rgba(5, 150, 105, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-copy-rich:hover {
  background: #047857;
  border-color: #022c22;
  color: #fff;
  box-shadow:
    0 4px 12px rgba(5, 150, 105, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-copy-rich:active {
  background: #065f46;
  border-color: #022c22;
  color: #fff;
}
.btn-copy-rich.is-copied {
  background: #0f766e;
  border-color: #115e59;
}
.preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.preview-meta {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.preview-device-tag {
  font-size: 0.68rem;
  color: var(--text-soft);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 500;
  flex-shrink: 0;
}
.phone-frame {
  flex: 1;
  min-height: 0;
  max-width: 360px;
  margin: 0 auto;
  width: 100%;
  background: #171717;
  border-radius: 16px;
  padding: 8px 6px 6px;
  border: 1px solid #262626;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
}
.phone-notch {
  width: 56px;
  height: 4px;
  border-radius: 999px;
  background: #404040;
  margin: 0 auto 6px;
  flex-shrink: 0;
}
#preview-frame {
  flex: 1;
  width: 100%;
  min-height: 240px;
  border: 0;
  border-radius: 10px;
  background: #fff;
}
@media (min-width: 1101px) {
  #preview-frame { min-height: 320px; }
}

/* Thumbs */
.thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.thumb {
  margin: 0;
  width: 120px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--surface);
}
.thumb img {
  display: block;
  width: 100%;
  height: 80px;
  object-fit: cover;
  background: var(--surface-2);
}
.thumb figcaption {
  font-size: 10px;
  color: var(--text-soft);
  padding: 5px 6px;
  word-break: break-all;
}
.thumb-empty {
  font-size: 0.8125rem;
  color: var(--text-soft);
  padding: 4px 0;
}

/* ---------- Publish / Gallery ---------- */
.publish-scroll { padding-top: 12px; }
.publish-layout {
  max-width: 68rem;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 12px;
}
.pub-wide { grid-column: 1 / -1; }
@media (max-width: 900px) {
  .publish-layout { grid-template-columns: 1fr; }
}
.pub-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text);
}
.pub-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pub-card h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}
.tag {
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--line);
}
.tag-warn {
  background: #fffbeb;
  color: var(--warn);
  border-color: #fde68a;
}

.gallery-scroll { padding: 12px 16px 20px; }
.gallery-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 12px;
  align-items: start;
  max-width: 1100px;
}
@media (max-width: 900px) {
  .gallery-layout { grid-template-columns: 1fr; }
}
.gallery-form-card textarea {
  width: 100%;
  min-height: 100px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font: inherit;
  line-height: 1.5;
  background: var(--surface);
  color: var(--text);
}
.gallery-form-card textarea:focus {
  outline: none;
  border-color: #737373;
  box-shadow: 0 0 0 3px rgba(23, 23, 23, 0.06);
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.gallery-empty {
  padding: 32px 12px;
  text-align: center;
  color: var(--text-soft);
  font-size: 0.875rem;
}
.gallery-empty.hidden { display: none; }
.gallery-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}
.gallery-card:hover {
  border-color: #a3a3a3;
}
.gallery-card-img-wrap {
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  overflow: hidden;
  cursor: zoom-in;
  position: relative;
}
.gallery-card-img-wrap::after {
  content: "点击放大";
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.gallery-card-img-wrap:hover::after { opacity: 1; }
.gallery-card-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease;
}
.gallery-card-img-wrap:hover img {
  transform: scale(1.03);
}

/* 图片放大灯箱 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-modal) + 10);
  display: grid;
  place-items: center;
  padding: 24px;
}
.lightbox.hidden { display: none !important; }
.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  cursor: zoom-out;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  background: rgba(255, 255, 255, 0.95) !important;
  border-color: #d4d4d4 !important;
  color: var(--text) !important;
}
.lightbox-img {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1200px);
  max-height: min(90vh, 900px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  background: #111;
  cursor: default;
}
.gallery-card-body {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.gallery-card-prompt {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-card-meta {
  font-size: 0.68rem;
  color: var(--text-soft);
  word-break: break-all;
}
.gallery-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.cover-stage {
  min-height: 160px;
  border-radius: var(--radius-md);
  border: 1px dashed var(--line-strong);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.cover-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  display: block;
}
.cover-empty {
  text-align: center;
  padding: 20px 12px;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.empty-sub {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-soft);
}
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.checklist {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 10px 12px;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text);
}
.checklist .row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.checklist .ok { color: var(--success); font-weight: 600; }
.checklist .no { color: var(--text-soft); }
.callout,
.callout.warn {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  line-height: 1.5;
}
.callout {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-muted);
}
.callout.warn {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--scrim);
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  max-height: min(88vh, 840px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  color: var(--text);
}
.modal-wide { width: min(920px, 100%); }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-head h2 {
  margin: 0 0 2px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.theme-card {
  text-align: left;
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.12s ease;
  color: inherit;
}
.theme-card:hover { border-color: #a3a3a3; }
.theme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.theme-card-swatch {
  height: 64px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.theme-card-swatch .mini-title {
  font-size: 0.8rem;
  font-weight: 600;
}
.theme-card-swatch .mini-line {
  height: 3px;
  width: 40%;
  border-radius: 2px;
}
.theme-card-dots { display: flex; gap: 5px; }
.theme-card-dots span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
}
.theme-card-body { padding: 10px 12px 12px; }
.theme-card-body .name {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 2px;
  color: var(--text);
}
.theme-card-body .blurb {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.theme-card-body .pick {
  margin-top: 8px;
  display: inline-flex;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 4px;
  padding: 2px 7px;
}

.help-steps {
  margin: 0 0 12px;
  padding-left: 1.1em;
}
.help-steps li { margin-bottom: 10px; }
.help-steps strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
}
.help-steps p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ---------- Busy / toast ---------- */
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-busy);
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.25);
  padding: 20px;
}
.busy-card {
  width: min(360px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 20px 16px 16px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
.spinner.sm { width: 14px; height: 14px; }
.spinner.lg {
  width: 28px;
  height: 28px;
  border-width: 2px;
  margin: 0 auto 10px;
  display: block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.busy-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.busy-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.busy-progress {
  margin-top: 12px;
  height: 2px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.busy-progress-bar {
  height: 100%;
  width: 40%;
  border-radius: inherit;
  background: var(--primary);
  animation: indet 1.1s ease-in-out infinite;
}
@keyframes indet {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  max-width: min(380px, 92vw);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.45;
  box-shadow: var(--shadow-soft);
  z-index: var(--z-toast);
  white-space: pre-wrap;
}
.toast.ok {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #14532d;
}
.toast.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

@media (prefers-reduced-motion: reduce) {
  .spinner, .busy-progress-bar { animation: none !important; }
  .btn, .top-tab, .mode-tab { transition: none !important; }
}
