/* ==========================================================================
   Product Poster Studio - 主样式表
   兼顾现代化 UI 控制台与高质量海报/卡片排版系统
   ========================================================================== */

:root {
  --ui-bg: #121316;
  --ui-surface: #1a1c23;
  --ui-surface-hover: #22252e;
  --ui-border: #2a2e3a;
  --ui-text: #e2e8f0;
  --ui-text-muted: #8e98a8;
  --ui-primary: #10b981;
  --ui-primary-hover: #059669;
  --ui-accent: #6366f1;
  --ui-radius: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* 海报排版专用字体族 */
  --poster-font-serif: "Songti SC", "SimSun", "STSong", "Noto Serif SC", "Source Han Serif SC", "MingLiU", serif;
  --poster-font-sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  --poster-font-kaiti: "Kaiti SC", "KaiTi", "STKaiti", "BiaoKai", serif;
  --poster-font-mono: "Fira Code", "JetBrains Mono", Consolas, Monaco, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--ui-bg);
  color: var(--ui-text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ================= Top Bar / Header ================= */
.app-header {
  height: 56px;
  background: var(--ui-surface);
  border-bottom: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 50;
}

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

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #10b981, #047857);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.brand-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #ffffff;
}

.brand-badge {
  font-size: 11px;
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-secondary {
  background: var(--ui-surface-hover);
  color: var(--ui-text);
  border-color: var(--ui-border);
}
.btn-secondary:hover {
  background: #2b303c;
  color: #fff;
}

.btn-primary {
  background: var(--ui-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--ui-primary-hover);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
}

.btn-accent {
  background: var(--ui-accent);
  color: #ffffff;
}
.btn-accent:hover {
  background: #4f46e5;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

/* ================= Main Workspace Layout ================= */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left: Sidebar Controls & Editor */
.editor-pane {
  width: 480px;
  background: var(--ui-surface);
  border-right: 1px solid var(--ui-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
}

.tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--ui-border);
  background: rgba(0, 0, 0, 0.15);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  color: var(--ui-text-muted);
  cursor: pointer;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn.active {
  color: #ffffff;
  border-bottom-color: var(--ui-primary);
  background: rgba(255, 255, 255, 0.02);
}

.tab-content {
  flex: 1;
  overflow-y: auto;
  display: none;
  padding: 16px;
}
.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Editor Tab */
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.editor-info {
  font-size: 12px;
  color: var(--ui-text-muted);
}

.markdown-textarea {
  width: 100%;
  flex: 1;
  min-height: 400px;
  background: #0f1013;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  color: #e2e8f0;
  padding: 14px;
  font-family: var(--poster-font-mono);
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
  transition: border-color 0.15s;
}
.markdown-textarea:focus {
  border-color: var(--ui-primary);
}

/* Design & Layout Tab Form */
.control-group {
  margin-bottom: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 18px;
}
.control-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--ui-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.control-row:last-child {
  margin-bottom: 0;
}

.control-label {
  font-size: 13px;
  color: var(--ui-text);
}

/* Preset Cards (Themes) */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.theme-pill {
  border: 1px solid var(--ui-border);
  border-radius: 6px;
  padding: 8px 6px;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}
.theme-pill:hover {
  border-color: #555c6e;
  transform: translateY(-1px);
}
.theme-pill.active {
  border-color: var(--ui-primary);
  background: rgba(16, 185, 129, 0.1);
  box-shadow: 0 0 0 1px var(--ui-primary);
}

.theme-preview-dot {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.theme-pill-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--ui-text);
  text-align: center;
}

/* Segmented Control */
.segmented-control {
  display: flex;
  background: #0f1013;
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--ui-border);
  width: 100%;
}

.segment-btn {
  flex: 1;
  text-align: center;
  padding: 6px 8px;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--ui-text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}
.segment-btn:hover {
  color: #fff;
}
.segment-btn.active {
  background: var(--ui-surface-hover);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Select & Sliders */
.form-select {
  background: #0f1013;
  border: 1px solid var(--ui-border);
  color: var(--ui-text);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  cursor: pointer;
  width: 160px;
}

.form-range-container {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  justify-content: flex-end;
}

.form-range {
  width: 120px;
  accent-color: var(--ui-primary);
  cursor: pointer;
}

.range-val {
  font-size: 12px;
  font-family: var(--poster-font-mono);
  color: var(--ui-text-muted);
  width: 38px;
  text-align: right;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #2b303c;
  transition: .2s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--ui-primary);
}
input:checked + .slider:before {
  transform: translateX(18px);
}

/* Color Picker Row */
.color-picker-input {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
}

/* ================= Right: Live Poster Canvas View ================= */
.preview-pane {
  flex: 1;
  background: #090a0c;
  overflow: auto;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin-bottom: 24px;
  background: rgba(26, 28, 35, 0.88);
  backdrop-filter: blur(10px);
  border: 1px solid var(--ui-border);
  padding: 6px 14px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.preview-stats {
  font-size: 12px;
  color: var(--ui-text-muted);
}
.preview-stats b {
  color: var(--ui-primary);
}

/* Cards Container (Grid / Stack) */
.cards-container {
  display: flex;
  flex-direction: column;
  gap: 40px;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

/* Continuous Long Mode (合并一张长图) */
.cards-container.mode-continuous {
  gap: 0;
}
.cards-container.mode-continuous .poster-card {
  border-radius: 0;
  box-shadow: none;
  border-bottom: 1px dashed rgba(0, 0, 0, 0.15);
}
.cards-container.mode-continuous .poster-card:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}
.cards-container.mode-continuous .poster-card:last-child {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  border-bottom: none;
}

/* ================= Poster Card Architecture ================= */
.poster-card {
  position: relative;
  background-color: var(--theme-bg);
  color: var(--theme-text);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, box-shadow 0.2s;
  /* 基础尺寸设定 (可在 JS 中根据比例动态设定) */
  width: 580px;
}

/* 卡片长宽比预设 */
.poster-card.ratio-3-4 {
  aspect-ratio: 3 / 4;
}
.poster-card.ratio-9-16 {
  aspect-ratio: 9 / 16;
}
.poster-card.ratio-1-1 {
  aspect-ratio: 1 / 1;
}
.poster-card.ratio-auto {
  aspect-ratio: auto;
  min-height: 400px;
}

.poster-inner {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 44px 40px;
}

/* 密度微调 */
.density-compact .poster-inner { padding: 32px 28px; }
.density-normal .poster-inner { padding: 44px 40px; }
.density-spacious .poster-inner { padding: 56px 52px; }

/* 字体家族类 */
.font-serif { font-family: var(--poster-font-serif); }
.font-sans { font-family: var(--poster-font-sans); }
.font-kaiti { font-family: var(--poster-font-kaiti); }

/* 对齐类 */
.align-left { text-align: left; }
.align-center { text-align: center; }
.align-justify { text-align: justify; }

/* ================= 封面专属排版 (参考图同款灵魂) ================= */
.cover-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.cover-header-tag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.cover-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 4px;
  background: var(--theme-badge-bg);
  color: var(--theme-badge-text);
  display: inline-block;
}

.cover-version {
  font-size: 13px;
  font-family: var(--poster-font-mono);
  letter-spacing: 0.08em;
  color: var(--theme-text-muted);
}

/* 巨幅主标题 (像参考图那样的 3x3 或折行大字) */
.cover-title-hero {
  font-size: 52px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.12em;
  margin: 20px 0 28px 0;
  color: var(--theme-accent);
  word-break: break-word;
  white-space: pre-line;
}

/* 优雅斜线装饰符 */
.divider-slash {
  width: 70px;
  height: 28px;
  position: relative;
  margin-bottom: 24px;
}
.divider-slash::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 50px;
  height: 1.5px;
  background: var(--theme-accent);
  transform: rotate(-30deg);
  transform-origin: left center;
  opacity: 0.85;
}

/* 封面副标与说明 */
.cover-desc {
  font-size: 16px;
  line-height: 2.0;
  letter-spacing: 0.06em;
  color: var(--theme-text);
  white-space: pre-line;
  max-width: 90%;
}

.cover-footer {
  margin-top: auto;
  padding-top: 30px;
  border-top: 1px solid var(--theme-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--theme-text-muted);
}

/* ================= 正文内容页排版 (功能卡片与说明) ================= */
.content-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--theme-border);
  margin-bottom: 24px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--theme-text-muted);
}

.content-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Markdown 元素在海报中的美化 */
.content-body h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--theme-accent);
  letter-spacing: 0.05em;
  line-height: 1.3;
  margin-top: 6px;
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.content-body h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--theme-text);
  letter-spacing: 0.03em;
  margin-top: 10px;
  margin-bottom: 4px;
}

.content-body p {
  font-size: 15px;
  line-height: 1.9;
  letter-spacing: 0.04em;
  color: var(--theme-text);
}

/* 列表美化 (可切换卡片形态) */
.content-body ul, .content-body ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content-body li {
  font-size: 14.5px;
  line-height: 1.8;
  letter-spacing: 0.03em;
  color: var(--theme-text);
}

/* 功能卡片化模式 (Card block list) */
.list-style-cards .content-body ul {
  padding-left: 0;
  list-style: none;
  gap: 12px;
}

.list-style-cards .content-body li {
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-card-border);
  border-radius: 6px;
  padding: 12px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

/* 引用块 (重点亮点/Tips) */
.content-body blockquote {
  margin: 10px 0;
  padding: 12px 18px;
  background: var(--theme-card-bg);
  border-left: 3px solid var(--theme-quote-border);
  border-radius: 0 6px 6px 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--theme-text-muted);
}
.content-body blockquote p {
  color: inherit;
  font-size: inherit;
}

/* 快捷键 / 代码块 */
.content-body code {
  font-family: var(--poster-font-mono);
  font-size: 13px;
  background: var(--theme-code-bg);
  color: var(--theme-code-text);
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid var(--theme-border);
}

.content-body pre {
  background: var(--theme-code-bg);
  border: 1px solid var(--theme-border);
  border-radius: 6px;
  padding: 12px 14px;
  overflow-x: auto;
  font-family: var(--poster-font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--theme-code-text);
}

/* 卡片页脚页码 */
.card-footer {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--theme-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  color: var(--theme-text-muted);
  font-family: var(--poster-font-mono);
}

/* 单张卡片浮动快捷操作按钮 */
.card-hover-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
  display: flex;
  gap: 6px;
  opacity: 0;
  transform: translateY(-4px);
  transition: all 0.2s ease;
}

.poster-card:hover .card-hover-actions {
  opacity: 1;
  transform: translateY(0);
}

.card-action-btn {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 5px 9px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}
.card-action-btn:hover {
  background: var(--ui-primary);
  border-color: var(--ui-primary);
}

/* Toast 提示浮窗 */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #fff;
  border: 1px solid #334155;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 导出进度蒙层 */
.export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: #fff;
}
.export-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--ui-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

