/* Google Fonts loaded via <link> in index.html — do NOT duplicate with @import */

:root {
  --primary: #FF2442;
  --primary-light: #FF5B71;
  --primary-glow: rgba(255, 36, 66, 0.4);
  --primary-subtle: rgba(255, 36, 66, 0.08);
  
  --bg-color: #F0F4F8;
  --text-main: #1E293B;
  --text-muted: #64748B;
  
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 12px 40px rgba(31, 38, 135, 0.06);
  --glass-highlight: inset 0 1px 1px rgba(255, 255, 255, 0.9);
  
  --panel-bg: rgba(255, 255, 255, 0.85);
  --input-bg: rgba(255, 255, 255, 0.9);
  
  --success: #10B981;
  
  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 10px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-display: 'Outfit', 'Inter', sans-serif;
  
  --trans-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --trans-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
.is-hidden { display: none !important; }

body {
  font-family: var(--font-sans);
  color: var(--text-main);
  background:
    linear-gradient(135deg, rgba(255, 36, 66, 0.04), transparent 28%),
    linear-gradient(180deg, #f8fafc 0%, var(--bg-color) 100%);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(100, 116, 139, 0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(100, 116, 139, 0.4); }

/* Typography */
h1, h2, h3, .gradient-text {
  font-family: var(--font-display);
}

.gradient-text {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Glass Utilities */
.glass-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--glass-highlight);
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0; z-index: 50;
  display: grid; align-items: center;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, auto) minmax(220px, 1fr);
  gap: 20px;
  min-height: 72px; padding: 0 40px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin-bottom: 24px;
}

.brand { display: flex; align-items: center; gap: 16px; font-size: 20px; }

.brand-logo-wrapper {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 12px; color: white;
  box-shadow: 0 8px 20px var(--primary-glow);
  transform: rotate(-5deg);
  transition: var(--trans-smooth);
}
.brand:hover .brand-logo-wrapper {
  transform: rotate(0) scale(1.05);
}
.brand-logo { width: 24px; height: 24px; }

.workflow-status {
  position: static;
  justify-self: center;
  max-width: min(460px, 42vw);
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 24px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.top-publisher-button {
  text-decoration: none;
  min-width: 138px;
  justify-content: center;
  white-space: nowrap;
  background: rgba(255, 36, 66, 0.1);
  border: 1px solid rgba(255, 36, 66, 0.34);
  color: var(--primary);
  box-shadow: 0 8px 22px rgba(255, 36, 66, 0.12);
}
.top-publisher-button::before {
  content: "↗";
  font-size: 14px;
  font-weight: 900;
}
.top-publisher-button:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(255, 36, 66, 0.22);
}

.settings { position: relative; flex: 0 0 auto; }
.settings summary {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border-radius: 999px;
  background: rgba(255, 255, 255, 0.88); border: 1px solid rgba(255, 36, 66, 0.14);
  cursor: pointer; transition: var(--trans-smooth);
  box-shadow: var(--glass-shadow); list-style: none;
  color: var(--text-main); font-family: var(--font-display); font-weight: 800; font-size: 14px;
}
.settings summary::-webkit-details-marker { display: none; }
.settings summary:hover {
  transform: translateY(-1px); background: white; border-color: rgba(255, 36, 66, 0.32);
  box-shadow: 0 12px 28px rgba(255, 36, 66, 0.14);
}
.settings summary svg {
  width: 18px; height: 18px; color: var(--primary);
}

.settings-panel {
  position: absolute; right: 0; top: calc(100% + 14px); z-index: 60;
  width: min(390px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 96px));
  padding: 18px; border-radius: 18px;
  display: flex; flex-direction: column; gap: 16px;
  overflow: auto;
  animation: scaleIn var(--trans-smooth);
  transform-origin: top right;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
}

.settings-panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 4px 2px 8px;
}
.settings-panel-head strong {
  font-family: var(--font-display); font-size: 20px; font-weight: 800;
}
.settings-panel-head span {
  color: var(--text-muted); font-size: 12px; font-weight: 600; padding-top: 4px;
}

.settings-group {
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px; background: rgba(248,250,252,0.72);
}
.settings-group legend { padding: 0 8px; color: var(--primary); font-size: 12px; font-weight: 900; letter-spacing: 0.5px; }

.settings-hint {
  margin: -2px 0 2px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.55;
}

.server-key-note {
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--primary-subtle); color: var(--primary);
  font-size: 13px; font-weight: 700; text-align: center;
}

.remember { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer; }
.remember input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

/* Key Notice */
.key-card {
  display: flex; align-items: center; justify-content: space-between;
  width: min(1680px, calc(100% - 80px)); margin: 0 auto 32px;
  padding: 32px 40px; border-radius: var(--radius-lg);
  position: relative; overflow: hidden;
  animation: fadeInUp 0.6s ease-out;
}
.key-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: linear-gradient(to bottom, var(--primary), var(--primary-light));
}
.key-card strong { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.key-card p { color: var(--text-muted); margin-top: 8px; font-size: 15px; }

/* Buttons */
button, .primary-button, .ghost-button {
  font-family: var(--font-display); font-weight: 700;
  cursor: pointer; border: none; outline: none;
  transition: var(--trans-smooth);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}

.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; padding: 0 28px; min-height: 48px;
  border-radius: var(--radius-md); box-shadow: 0 8px 24px var(--primary-glow);
  font-size: 15px;
}
.primary-button:hover:not(:disabled) {
  transform: translateY(-2px); box-shadow: 0 12px 32px rgba(255, 36, 66, 0.5);
}
.primary-button:active:not(:disabled) { transform: translateY(0); }
.primary-button:disabled,
.ghost-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none !important;
  box-shadow: none !important;
}
.primary-button.is-cancel-mode {
  background: linear-gradient(135deg, #334155, #64748B);
  box-shadow: 0 8px 24px rgba(51, 65, 85, 0.24);
}

.ghost-button {
  background: var(--glass-bg); border: 1px solid var(--glass-border);
  color: var(--text-main); padding: 0 24px; min-height: 44px;
  border-radius: var(--radius-md);
}
.ghost-button:hover {
  background: white; transform: translateY(-2px); box-shadow: var(--glass-shadow);
}

.ghost-button.top-publisher-button:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 14px 28px rgba(255, 36, 66, 0.22);
}

/* Workspace Layout */
.unified-workspace {
  display: grid; grid-template-columns: 420px 1fr 452px; gap: 32px;
  width: min(1680px, calc(100% - 80px)); margin: 0 auto 64px;
  align-items: start; animation: fadeInUp 0.8s ease-out;
}

.panel { border-radius: var(--radius-lg); padding: 36px; }

.command-panel { position: sticky; top: 104px; }
.output-panel { min-height: calc(100vh - 144px); display: flex; flex-direction: column; }
.preview-panel { min-height: calc(100vh - 144px); display: flex; flex-direction: column; align-items: center; position: sticky; top: 104px; }

/* Form Fields */
.logic-group { margin-bottom: 32px; }
.logic-group-title {
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  margin-bottom: 6px; display: flex; align-items: center; gap: 8px;
}
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white; font-size: 13px; font-weight: 800;
  box-shadow: 0 4px 12px var(--primary-glow);
}
.logic-group-desc {
  font-family: var(--font-sans); font-weight: 500; font-size: 13px;
  color: var(--text-muted); margin-bottom: 16px; padding-left: 32px;
}

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field span { font-weight: 600; font-size: 14px; }

input, select, textarea {
  width: 100%; background: var(--input-bg);
  border: 1px solid var(--glass-border); border-radius: var(--radius-md);
  padding: 14px 20px; font-family: var(--font-sans); font-size: 15px;
  color: var(--text-main); transition: border-color var(--trans-smooth), background-color var(--trans-smooth), box-shadow var(--trans-smooth); outline: none;
}
input:focus, select:focus, textarea:focus {
  background: white; border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-subtle);
}

.preset-bar {
  background: rgba(255,255,255,0.4); padding: 20px;
  border-radius: var(--radius-md); border: 1px solid var(--glass-border);
}

.preset-import {
  margin-bottom: 24px; padding: 20px;
  border-radius: var(--radius-md);
  animation: scaleIn 0.2s;
}
.preset-import-text {
  min-height: 200px; font-family: monospace; font-size: 13px;
}
.editor-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 16px; }

.demand-input { min-height: 140px; resize: vertical; }

.upload-button {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 60px;
  border: 2px dashed rgba(100, 116, 139, 0.3); border-radius: var(--radius-md);
  background: rgba(255,255,255,0.5); color: var(--text-muted);
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  cursor: pointer; transition: var(--trans-smooth); margin-top: 16px;
}
.upload-button:hover {
  border-color: var(--primary); color: var(--primary); background: var(--primary-subtle);
}
.upload-button input { display: none; }

.upload-rule { margin-top: 8px; color: var(--text-muted); font-size: 12px; text-align: center; }

.thumb-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 16px; }
.thumb {
  position: relative; width: 72px; height: 72px;
  border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: var(--glass-shadow);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px;
  border-radius: 50%; background: rgba(0,0,0,0.6); color: white;
  border: none; cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 12px; opacity: 0; transition: var(--trans-fast);
}
.thumb:hover button { opacity: 1; }
.thumb button:hover { background: var(--primary); }
.thumb button { opacity: 1; }

.auth-locked .app {
  pointer-events: none;
  user-select: none;
}
.auth-locked .app > * {
  opacity: 0.22;
}

.gen-btn { width: 100%; min-height: 64px; font-size: 18px; border-radius: var(--radius-md); margin-top: 24px; letter-spacing: 1px; }
.glow-effect { animation: none; }
@keyframes pulse-glow {
  0% { box-shadow: 0 8px 24px var(--primary-glow); }
  50% { box-shadow: 0 8px 32px rgba(255, 36, 66, 0.6); }
  100% { box-shadow: 0 8px 24px var(--primary-glow); }
}

.generation-steps {
  --step-line: rgba(148, 163, 184, 0.26);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  position: relative;
  min-height: 38px;
  margin: -4px 0 14px;
  padding: 0;
}
.generation-steps span {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 7px;
  min-width: 116px;
  min-height: 34px;
  padding: 0 12px;
  text-align: center;
  background: rgba(255,255,255,0.92);
  border-radius: 999px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  transition: var(--trans-smooth);
  overflow: hidden;
}
.generation-steps span::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.48;
  position: relative;
  z-index: 1;
}
.generation-steps span.is-active {
  background: white;
  border-color: rgba(255, 36, 66, 0.62);
  color: var(--primary);
  box-shadow: 0 8px 24px rgba(255, 36, 66, 0.12);
  transform: translateY(-1px);
}
.generation-steps span.is-active::after {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  width: 30%;
  height: 2px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: 0 0 8px rgba(255, 36, 66, 0.45);
  animation: step-border-line 1.65s linear infinite;
  pointer-events: none;
}
.generation-steps span.is-active::before {
  opacity: 1;
  box-shadow: 0 0 0 5px rgba(255, 36, 66, 0.1);
}
.generation-steps span.is-done {
  background: rgba(236, 253, 245, 0.94);
  border-color: rgba(16, 185, 129, 0.28);
  color: var(--success);
}
.generation-steps span.is-done::before {
  content: "✓";
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--success);
  color: white;
  font-size: 11px;
  opacity: 1;
}
.generation-steps span.is-pending {
  opacity: 0.72;
}

@keyframes step-border-line {
  0% {
    top: 0;
    left: 8%;
    width: 32%;
    height: 2px;
  }
  22% {
    top: 0;
    left: 60%;
    width: 32%;
    height: 2px;
  }
  25% {
    top: 8%;
    left: calc(100% - 2px);
    width: 2px;
    height: 32%;
  }
  47% {
    top: 60%;
    left: calc(100% - 2px);
    width: 2px;
    height: 32%;
  }
  50% {
    top: calc(100% - 2px);
    left: 60%;
    width: 32%;
    height: 2px;
  }
  72% {
    top: calc(100% - 2px);
    left: 8%;
    width: 32%;
    height: 2px;
  }
  75% {
    top: 60%;
    left: 0;
    width: 2px;
    height: 32%;
  }
  97% {
    top: 8%;
    left: 0;
    width: 2px;
    height: 32%;
  }
  100% {
    top: 0;
    left: 8%;
    width: 32%;
    height: 2px;
  }
}

/* Output Area */
.output-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; margin-bottom: 24px; padding-bottom: 24px; border-bottom: 1px solid var(--glass-border);
}
.output-toolbar p { color: var(--text-muted); font-size: 14px; margin-top: 4px; font-weight: 500; }
.output-toolbar strong { font-size: 22px; }
.output-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 0 0 auto;
}
.output-actions .primary-button,
.output-actions .ghost-button {
  min-width: 116px;
  min-height: 56px;
  padding: 0 16px;
  white-space: nowrap;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  font-size: 15px;
  letter-spacing: 0;
}

.text-copy-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 14px;
  margin-top: 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.storage-note {
  margin: -10px 0 12px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.58);
  border: 1px solid rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  transition: opacity var(--trans-fast), transform var(--trans-fast);
}
.storage-note[data-tone="warning"] {
  background: rgba(255, 247, 237, 0.86);
  border-color: rgba(249, 115, 22, 0.22);
  color: #9a3412;
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
}
.storage-note[data-tone="success"] {
  background: rgba(236, 253, 245, 0.48);
  border-color: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.draft-restore-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: -4px 0 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 36, 66, 0.18);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}
.draft-restore-bar strong {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  margin-bottom: 3px;
}
.draft-restore-bar span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
.draft-restore-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.draft-restore-actions .primary-button,
.draft-restore-actions .ghost-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 13px;
}

@media (max-width: 768px) {
  .output-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .output-actions {
    justify-content: stretch;
  }
  .output-actions .primary-button,
  .output-actions .ghost-button {
    flex: 1;
    min-width: 0;
  }
  .draft-restore-bar {
    align-items: stretch;
    flex-direction: column;
  }
  .draft-restore-actions {
    width: 100%;
  }
  .draft-restore-actions .primary-button,
  .draft-restore-actions .ghost-button {
    flex: 1;
  }
}

.phone-preview {
  width: 380px; height: 820px; background: white;
  border-radius: 48px; border: 12px solid #111;
  box-shadow: 0 32px 64px rgba(0,0,0,0.15), inset 0 0 0 2px rgba(255,255,255,0.5);
  position: relative; overflow: hidden; display: flex; flex-direction: column;
  animation: fadeInUp 0.6s ease-out;
}
.phone-preview::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 120px; height: 28px; background: #111; border-radius: 0 0 18px 18px; z-index: 10;
}
.phone-scroll { flex: 1; overflow-y: auto; background: white; }
.phone-scroll::-webkit-scrollbar { display: none; }

.side-results { display: flex; flex-direction: column; gap: 24px; height: 820px; }
.side-tabs { display: flex; background: rgba(255,255,255,0.6); padding: 8px; border-radius: var(--radius-md); gap: 8px; }
.side-tab {
  flex: 1; min-height: 48px; border-radius: 12px; font-family: var(--font-display);
  font-weight: 700; font-size: 15px; color: var(--text-muted);
  background: transparent; border: none; cursor: pointer; transition: var(--trans-fast);
}
.side-tab.is-active { background: white; color: var(--primary); box-shadow: 0 4px 16px rgba(0,0,0,0.06); }

.text-result-area, .image-storyboard {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; padding: 4px 8px 4px 4px;
}
.text-result-area::-webkit-scrollbar, .image-storyboard::-webkit-scrollbar, .text-card-scroll::-webkit-scrollbar { width: 6px; }
.text-result-area::-webkit-scrollbar-thumb, .image-storyboard::-webkit-scrollbar-thumb, .text-card-scroll::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }

.text-result-card, .story-card {
  background: white; border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border); padding: 24px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.04); transition: var(--trans-smooth); flex-shrink: 0;
  display: flex; flex-direction: column; max-height: 100%; overflow: hidden;
}
.text-result-card:hover, .story-card:hover {
  box-shadow: 0 16px 32px rgba(0,0,0,0.08); transform: translateY(-2px);
}
.text-result-card.is-selected { outline: 2px solid var(--primary); outline-offset: -1px; box-shadow: 0 12px 32px var(--primary-subtle); }

.version-badge {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; background: var(--bg-color); border-radius: var(--radius-md);
  margin: -8px -8px 20px -8px; font-weight: 700;
}
.planning-pill {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 36, 66, 0.08);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.text-section { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.text-section:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; color: var(--text-muted); font-weight: 600; font-size: 14px;
}
.text-section p { font-size: 15px; line-height: 1.8; color: var(--text-main); white-space: pre-wrap; }
.story-card { position: relative; display: grid; grid-template-columns: 100px 1fr; gap: 20px; padding: 20px 20px 20px 36px; }
.story-drag-handle {
  position: absolute;
  left: 10px;
  top: 18px;
  width: 18px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-muted);
  cursor: grab;
  font-weight: 900;
  line-height: 1;
}
.story-drag-handle:hover {
  background: var(--primary-subtle);
  color: var(--primary);
}
.story-thumb {
  width: 100px; aspect-ratio: 3/4; border-radius: var(--radius-sm);
  overflow: hidden; background: var(--bg-color); position: relative;
  display: flex; align-items: center; justify-content: center; font-weight: 800; color: #999;
}
.story-thumb .skeleton-shimmer {
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg, rgba(255,36,66,0.04) 25%, rgba(255,36,66,0.11) 50%, rgba(255,36,66,0.04) 75%);
}
.story-thumb-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(255,255,255,0.16);
}
.story-thumb-loader i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--primary);
  animation: preview-dot 0.9s ease-in-out infinite;
}
.story-thumb-loader i:nth-child(2) { animation-delay: 0.12s; }
.story-thumb-loader i:nth-child(3) { animation-delay: 0.24s; }
.story-card-skeleton {
  pointer-events: none;
}
.story-card-skeleton .story-thumb .skeleton-shimmer {
  width: 100%;
  height: 100%;
}
.story-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; transition: transform 0.5s ease; }
.story-thumb:hover img { transform: scale(1.05); }
.story-card strong { font-size: 16px; font-weight: 800; display: block; margin-bottom: 8px; }
.story-card p { font-size: 13px; color: var(--text-muted); line-height: 1.6; }
.story-card-actions { display: flex; gap: 10px; margin-top: 16px; }

.retry-btn, .img-download-btn, .apply-btn, .copy-btn, .regenerate-btn, .section-rewrite-btn, .story-move-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 36px; padding: 0 16px; border-radius: var(--radius-sm);
  font-family: var(--font-display); font-size: 13px; font-weight: 700;
  cursor: pointer; transition: var(--trans-fast); border: 1px solid var(--glass-border);
  background: var(--glass-bg); color: var(--text-main);
}
.apply-btn { background: var(--primary); color: white; border-color: var(--primary); }
.apply-btn:hover { background: var(--primary-light); box-shadow: 0 4px 12px var(--primary-glow); transform: translateY(-1px); }
.copy-btn:hover, .regenerate-btn:hover, .section-rewrite-btn:hover, .retry-btn:hover, .story-move-btn:hover:not(:disabled) {
  background: white; border-color: var(--primary); color: var(--primary);
}
.story-move-btn { min-height: 28px; padding: 0 10px; font-size: 12px; }
.retry-btn.is-cancel-retry {
  background: #334155;
  border-color: #334155;
  color: white;
}
.retry-btn.is-cancel-retry:hover {
  background: #475569;
  border-color: #475569;
  color: white;
}
.section-rewrite-btn { min-height: 28px; padding: 0 12px; font-size: 12px; border-radius: 6px; }

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; min-height: 200px; color: var(--text-muted); font-size: 14px; font-weight: 500;
  text-align: center; padding: 40px;
}

/* Mock Feed & Phone styling */
.phone-statusbar { padding: 16px 28px 10px; display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; z-index: 20; position: relative; }
.phone-system-icons { display: flex; gap: 5px; align-items: center; }
.phone-topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid rgba(0,0,0,0.05); }
.note-phone-topbar .phone-author { font-size: 15px; font-weight: 700; margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-dot { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--primary), #FF8A99); box-shadow: 0 2px 8px rgba(255,36,66,0.3); }
.phone-note-badge { flex: 0 0 auto; padding: 5px 10px; border-radius: 999px; background: rgba(255,36,66,0.08); color: var(--primary); font-size: 12px; font-weight: 800; }
.phone-search-bar { flex: 1; padding: 8px 16px; border-radius: 999px; background: #f5f5f5; color: #999; font-size: 13px; }
.phone-search-bar.is-skeleton { background: transparent; padding: 8px 0; }
.skeleton-search { width: 100px; height: 16px; border-radius: 8px; }
.phone-nav-tabs { display: flex; border-bottom: 1px solid rgba(0,0,0,0.05); }
.phone-nav-tabs span { flex: 1; text-align: center; padding: 14px 0; font-size: 14px; font-weight: 700; color: #999; position: relative; }
.phone-nav-tabs span.is-on { color: #111; font-size: 15px; }
.phone-nav-tabs span.is-on::after { content: ""; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 28px; height: 3px; border-radius: 2px; background: var(--primary); }

.phone-footer { display: flex; justify-content: space-around; padding: 12px 20px 24px; border-top: 1px solid rgba(0,0,0,0.05); background: white; }
.phone-action { display: flex; flex-direction: column; align-items: center; font-size: 12px; color: #999; font-weight: 600; gap: 4px; padding: 4px; }
.phone-action.is-on { color: #111; font-weight: 800; }
.xhs-add svg { width: 36px; height: 32px; border-radius: 8px; }

.note-footer { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px 24px; border-top: 1px solid rgba(0,0,0,0.05); gap: 16px; }
.note-comment-box { flex: 1; height: 36px; border-radius: 18px; background: #f5f5f5; color: #999; display: flex; align-items: center; padding: 0 16px; font-size: 13px; }

.mock-feed { padding: 10px; background: #f8f8f8; min-height: 100%; column-count: 2; column-gap: 10px; }
.mock-card { break-inside: avoid; margin-bottom: 10px; border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,0.05); }
.mock-card-img { width: 100%; background: #eee; }
.mock-card:nth-child(odd) .mock-card-img { aspect-ratio: 3/4; }
.mock-card:nth-child(even) .mock-card-img { aspect-ratio: 4/3; }
.mock-card:nth-child(1n) .mock-card-img { background: linear-gradient(135deg, #ff9a9e, #fecfef); }
.mock-card:nth-child(2n) .mock-card-img { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.mock-card-info { padding: 10px; }
.mock-card-title { height: 12px; border-radius: 4px; margin-bottom: 8px; background: #eee; }
.mock-card-title.wide { width: 85%; }
.mock-card-user { display: flex; align-items: center; gap: 6px; }
.mock-card-avatar { width: 18px; height: 18px; border-radius: 50%; background: #eee; }
.mock-card-name { height: 10px; width: 40px; border-radius: 3px; background: #eee; }

.phone-planning { padding: 0; background: #fff; }
.planning-image { aspect-ratio: 3 / 4; width: 100%; border-radius: 0; }
.planning-copy { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.combo-image { background: #f8f8f8; display: flex; align-items: center; justify-content: center; aspect-ratio: 3 / 4; position: relative; overflow: hidden; }
.combo-media-slot { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.combo-media-slot img { width: 100%; height: 100%; object-fit: cover; }
.combo-image.is-regenerating {
  background: linear-gradient(145deg, #fff7f8 0%, #ffffff 52%, #f8fafc 100%);
}
.combo-image.is-regenerating::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255,255,255,0.025) 44%, rgba(255, 36, 66, 0.015) 50%, rgba(255,255,255,0.03) 56%, transparent 100%);
  transform: translateX(-100%);
  animation: preview-sweep 3.4s ease-in-out infinite;
}
.preview-image-loading {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  height: 100%;
  padding: 28px;
  color: var(--text-main);
  text-align: center;
}
.preview-art-loader {
  position: relative;
  width: 62px;
  height: 18px;
}
.preview-art-loader::before {
  content: none;
}
.preview-art-loader::after {
  content: none;
}
.preview-art-loader i {
  position: absolute;
  bottom: 4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255,36,66,0.48);
  animation: preview-dot 1.25s ease-in-out infinite;
}
.preview-art-loader i:nth-child(1) { left: 16px; }
.preview-art-loader i:nth-child(2) { left: 28px; animation-delay: 0.14s; }
.preview-art-loader i:nth-child(3) { left: 40px; animation-delay: 0.28s; }
.preview-image-loading .loading-spinner {
  display: none;
}
.preview-image-loading strong {
  font-size: 15px;
  font-weight: 900;
  color: var(--primary);
}
.preview-image-loading span {
  max-width: 86%;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}
.combo-nav-btn {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 34px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(17,24,39,0.18);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-50%) scale(0.96);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
}
.combo-image:hover .combo-nav-btn { opacity: 1; transform: translateY(-50%) scale(1); }
.combo-nav-btn:hover { background: rgba(17,24,39,0.32); }
.combo-nav-prev { left: 12px; }
.combo-nav-next { right: 12px; }
.combo-dots {
  position: absolute;
  left: 50%;
  bottom: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translateX(-50%);
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(17,24,39,0.18);
}
.combo-dot {
  width: 6px;
  height: 6px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255,255,255,0.55);
  cursor: pointer;
}
.combo-dot.is-active { width: 16px; background: white; }
.combo-text { padding: 20px; }
.combo-title { font-size: 17px; font-weight: 600; color: #333; margin-bottom: 10px; line-height: 1.4; letter-spacing: 0.5px; }
.combo-body { font-size: 15px; color: #333; line-height: 1.6; white-space: pre-wrap; letter-spacing: 0.5px; }
/* Loading State & Skeletons */
.loading-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 60px 20px; height: 100%; }
.loading-spinner { width: 48px; height: 48px; border: 4px solid rgba(0,0,0,0.1); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
.loading-spinner.small { width: 24px; height: 24px; border-width: 3px; }
.loading-text { color: #999; font-size: 14px; font-weight: 700; animation: pulse-text 1.5s infinite; }

.skeleton-shimmer {
  background: linear-gradient(90deg, rgba(0,0,0,0.03) 25%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.03) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-sm);
}
.skeleton-card {
  background: rgba(255, 255, 255, 0.88); border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg); padding: 24px; display: flex; flex-direction: column; gap: 16px;
  margin-bottom: 20px; box-shadow: var(--glass-shadow);
}
.skeleton-title { height: 28px; width: 60%; }
.skeleton-line { height: 16px; width: 100%; }
.skeleton-line.short { width: 80%; }
.skeleton-img { width: 100%; aspect-ratio: 4/3; border-radius: var(--radius-md); }
.text-result-card.is-loading-text {
  min-height: 260px;
}
.text-result-card.is-loading-text .text-section {
  min-height: 72px;
}
.text-result-card.is-typing-text [data-text-title]::after,
.text-result-card.is-typing-text [data-text-body]::after {
  content: "";
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  border-radius: 2px;
  background: var(--primary);
  vertical-align: -0.12em;
  animation: caret-blink 0.9s steps(1, end) infinite;
}
.typing-skeleton {
  position: relative;
  min-height: 34px;
}
.typing-skeleton .typing-copy {
  position: relative;
  z-index: 2;
  display: inline-block;
  width: 0;
  max-width: max-content;
  color: var(--text-main);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  vertical-align: bottom;
  animation: typing-copy 2.8s steps(22, end) infinite;
}
.typing-skeleton .typing-caret {
  position: relative;
  z-index: 2;
  display: inline-block;
  width: 2px;
  height: 1.1em;
  margin-left: 3px;
  border-radius: 2px;
  background: var(--primary);
  vertical-align: -0.16em;
  animation: caret-blink 0.9s steps(1, end) infinite;
}
.text-skeleton-line {
  display: block;
  width: 100%;
  height: 16px;
  margin: 5px 0;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(15,23,42,0.035) 25%, rgba(255,36,66,0.10) 50%, rgba(15,23,42,0.035) 75%);
  background-size: 360% 100%;
  animation: shimmer 1.4s infinite linear;
}
.text-skeleton-line.title { width: 58%; height: 20px; }
.text-skeleton-line.medium { width: 86%; }
.text-skeleton-line.short { width: 62%; }
.typing-skeleton .text-skeleton-line {
  opacity: 0.42;
  margin-top: 9px;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-text { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@keyframes typing-copy {
  0%, 10% { width: 0; }
  48%, 78% { width: min(100%, 26em); }
  100% { width: 0; }
}
@keyframes caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes preview-sweep {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
@keyframes preview-dot {
  0%, 100% { transform: translateY(0); opacity: 0.42; }
  50% { transform: translateY(-5px); opacity: 0.9; }
}

/* Lightbox & Modal */
.lightbox { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.85); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius-sm); box-shadow: 0 32px 64px rgba(0,0,0,0.5); animation: scaleIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.lightbox-close { position: absolute; top: 32px; right: 32px; width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,0.1); color: white; font-size: 32px; border: 1px solid rgba(255,255,255,0.2); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--trans-smooth); }
.lightbox-close:hover { background: var(--primary); border-color: var(--primary); transform: rotate(90deg); }

.publisher-container { width: 90vw; height: 90vh; background: white; border-radius: var(--radius-lg); overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 32px 64px rgba(0,0,0,0.3); animation: scaleIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.publisher-header { padding: 20px 32px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; background: var(--bg-color); }
.publisher-iframe { flex: 1; border: none; width: 100%; background: #f5f5f5; }

/* Drag and Drop */
.story-card[draggable] { cursor: grab; }
.story-card[draggable]:active { cursor: grabbing; }
.story-card.is-dragging { opacity: 0.5; transform: scale(0.97); }
.story-card.is-over { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-subtle); transform: translateY(0); }
.story-card.has-error { border-color: rgba(239, 68, 68, 0.28); }
.story-card.shake-animation { animation: shake-card 0.36s ease-in-out; }

@keyframes shake-card {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

/* Auth Modal */
.auth-modal {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(240, 244, 248, 0.82);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.4s ease-out;
}
.auth-modal-content {
  width: min(420px, 90vw);
  padding: 40px;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: 0 32px 64px rgba(0,0,0,0.1);
}
.auth-error {
  margin: 14px 0 0;
  color: #dc2626;
  font-size: 13px;
  font-weight: 700;
}
@media (max-width: 1024px) {
  .unified-workspace { grid-template-columns: 1fr; } .command-panel { position: static; }
  .phone-preview { margin: 0 auto; transform: scale(1); }
}
@media (max-width: 768px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    padding: 12px 16px;
  }
  .brand { min-width: 0; }
  .brand strong { display: none; }
  .workflow-status {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    max-width: none;
    text-align: center;
    font-size: 12px;
    padding: 4px 12px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
  }
  .topbar-actions {
    grid-column: 2 / 4;
    grid-row: 1;
    gap: 8px;
  }
  .top-publisher-button {
    min-width: 0;
    padding: 0 12px;
    font-size: 12px;
  }
  .settings summary { width: 40px; height: 40px; }
  .unified-workspace, .key-card { width: calc(100% - 32px); padding: 24px; }
  .phone-preview { width: 100%; max-width: 400px; height: 800px; }
  .generation-steps { grid-template-columns: 1fr; gap: 8px; }
}

/* ── 图片序号角标：统一用于故事板缩略图和手机预览 ─────────────────── */
.img-index-badge {
  position: absolute;
  z-index: 3;
  right: 7px;
  bottom: 7px;
  background: rgba(17, 24, 39, 0.52);
  color: #fff;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  letter-spacing: 0.3px;
  pointer-events: none;
  white-space: nowrap;
}
/* 故事板缩略图内的角标 */
.story-thumb .img-index-badge {
  font-size: 10px;
  padding: 2px 6px;
}
/* 手机预览内角标 */
.combo-image .img-index-badge {
  right: 10px;
  bottom: 10px;
  font-size: 11px;
  padding: 3px 9px;
}
