/* ============================================================
   童话故事创作坊 · Fairy Tale Studio
   日系极简 / 近中性灰白 / 巨大留白 / 1px 细线 / 无阴影无渐变
   ============================================================ */

:root {
  --c-primary: #7f7862;
  --c-secondary: #7a7792;
  --c-accent: #72629d;
  --c-bg: #fbfbf8;
  --c-surface: #ffffff;
  --c-text: #2c281b;
  --c-muted: #7a735c;
  --c-border: #e6e3db;

  --radius: 2px;
  --font: system-ui, -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  --maxw: 1080px;
  --gutter: clamp(20px, 5vw, 48px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  letter-spacing: .01em;
}

h1, h2, h3, h4 {
  margin: 0;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.3;
}

p { margin: 0; }
a { color: var(--c-accent); }
img { max-width: 100%; display: block; }

.container {
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--c-text);
  text-decoration: none;
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .06em;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border: 1px solid var(--c-accent);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--c-accent);
  font-size: 15px;
  line-height: 1;
}

.brand small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .22em;
  color: var(--c-muted);
  margin-top: 1px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 30px;
}

.nav a {
  position: relative;
  color: var(--c-muted);
  text-decoration: none;
  font-size: 14px;
  letter-spacing: .05em;
  padding: 8px 0;
  transition: color .2s ease;
}

.nav a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 1px;
  background: var(--c-accent);
  transition: width .25s ease;
}

.nav a:hover { color: var(--c-text); }
.nav a.active { color: var(--c-text); font-weight: 700; }
.nav a.active::after, .nav a:hover::after { width: 100%; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  width: 40px;
  height: 36px;
  cursor: pointer;
  position: relative;
}

.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  content: '';
  position: absolute;
  left: 11px;
  width: 16px;
  height: 1px;
  background: var(--c-text);
  transition: all .25s ease;
}

.nav-toggle span { top: 17px; }
.nav-toggle span::before { top: -5px; }
.nav-toggle span::after { top: 5px; }

.nav-open .nav-toggle span { background: transparent; }
.nav-open .nav-toggle span::before { top: 0; transform: rotate(45deg); }
.nav-open .nav-toggle span::after { top: 0; transform: rotate(-45deg); }

/* ---------- 英雄区 ---------- */
.hero {
  position: relative;
  overflow: hidden;
  text-align: center;
  padding: clamp(76px, 13vw, 150px) 0 clamp(70px, 11vw, 128px);
  border-bottom: 1px solid var(--c-border);
}

.hero-orn {
  position: absolute;
  top: 8%;
  right: 4%;
  font-size: clamp(180px, 30vw, 420px);
  font-weight: 800;
  color: var(--c-accent);
  opacity: .045;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  letter-spacing: .28em;
  color: var(--c-muted);
  margin-bottom: 34px;
}

.hero-eyebrow::before,
.hero-eyebrow::after {
  content: '';
  width: 34px;
  height: 1px;
  background: var(--c-primary);
}

.hero h1 {
  font-size: clamp(38px, 6.4vw, 68px);
  font-weight: 800;
  letter-spacing: .04em;
  line-height: 1.18;
}

.hero h1 em {
  font-style: normal;
  color: var(--c-accent);
  font-weight: 400;
  letter-spacing: .18em;
  font-size: .58em;
  display: block;
  margin-top: 18px;
}

.hero-sub {
  margin: 30px auto 0;
  max-width: 520px;
  color: var(--c-muted);
  font-size: 15px;
  line-height: 2;
}

.hero-actions {
  margin-top: 46px;
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* ---------- 通用区块 ---------- */
.section {
  padding: clamp(60px, 9vw, 116px) 0;
  border-bottom: 1px solid var(--c-border);
}

.section:last-of-type { border-bottom: none; }

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: 46px;
}

.sec-num {
  font-size: 12px;
  letter-spacing: .22em;
  color: var(--c-accent);
  flex: none;
}

.sec-title {
  font-size: clamp(21px, 2.8vw, 28px);
  font-weight: 700;
  letter-spacing: .06em;
}

.sec-sub {
  margin-left: auto;
  font-size: 13px;
  color: var(--c-muted);
  text-align: right;
  letter-spacing: .04em;
}

.sec-sub a {
  color: var(--c-primary);
  text-decoration: none;
  border-bottom: 1px solid var(--c-primary);
  padding-bottom: 2px;
  transition: color .2s ease, border-color .2s ease;
}

.sec-sub a:hover { color: var(--c-accent); border-color: var(--c-accent); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--c-text);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: .06em;
  text-decoration: none;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
}

.btn:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn:active { transform: translateY(1px); }

.btn-accent {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: #ffffff;
}

.btn-accent:hover { background: #65568c; border-color: #65568c; color: #ffffff; }

.btn-outline {
  border-color: var(--c-text);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
}

.btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- 模板卡片 ---------- */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.tpl-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 30px 28px 26px;
  display: flex;
  flex-direction: column;
  transition: border-color .25s ease, transform .25s ease;
}

.tpl-card:hover {
  border-color: var(--c-primary);
  transform: translateY(-4px);
}

.tpl-tag {
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--c-accent);
  margin-bottom: 16px;
}

.tpl-card h3 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .05em;
  margin-bottom: 6px;
}

.tpl-card .tpl-intro {
  font-size: 13px;
  color: var(--c-muted);
  line-height: 1.8;
  margin-bottom: 20px;
}

.tpl-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  border-top: 1px solid var(--c-border);
}

.tpl-list li {
  display: flex;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--c-border);
  font-size: 13.5px;
  line-height: 1.7;
}

.tpl-list .k {
  flex: none;
  width: 3.2em;
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--c-muted);
  padding-top: 2px;
}

.tpl-card .btn {
  margin-top: 22px;
  align-self: flex-start;
}

/* ---------- 创作步骤 ---------- */
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--c-border);
}

.step {
  padding: 30px 30px 8px 0;
  border-right: 1px solid var(--c-border);
}

.step:last-child { border-right: none; padding-right: 0; }

.step .n {
  font-size: 12px;
  letter-spacing: .24em;
  color: var(--c-accent);
  display: block;
  margin-bottom: 14px;
}

.step h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .04em;
  margin-bottom: 10px;
}

.step p {
  font-size: 13.5px;
  color: var(--c-muted);
  line-height: 1.9;
  max-width: 30ch;
}

/* ---------- 首页精选预览 ---------- */
.featured-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  border-top: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border);
}

.featured-item {
  padding: 26px 26px 24px 0;
  border-right: 1px solid var(--c-border);
  text-decoration: none;
  color: var(--c-text);
  transition: background .25s ease;
}

.featured-item:last-child { border-right: none; padding-right: 0; }
.featured-item:hover { background: var(--c-surface); }

.featured-item .cat {
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--c-secondary);
  display: block;
  margin-bottom: 12px;
}

.featured-item h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
  margin-bottom: 8px;
}

.featured-item p {
  font-size: 13px;
  color: var(--c-muted);
  line-height: 1.8;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 页脚 ---------- */
.site-footer {
  padding: 52px 0 64px;
}

.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
  border-top: 1px solid var(--c-border);
  padding-top: 30px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--c-muted);
}

.footer-inner strong {
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: .06em;
}

.footer-inner .links {
  display: flex;
  gap: 22px;
}

.footer-inner .links a {
  color: var(--c-muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s ease, border-color .2s ease;
}

.footer-inner .links a:hover {
  color: var(--c-accent);
  border-bottom-color: var(--c-accent);
}

/* ============================================================
   创作编辑器页
   ============================================================ */
.editor-wrap {
  padding: clamp(34px, 5vw, 64px) 0 90px;
}

.editor-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}

.editor-top h1 {
  font-size: clamp(24px, 3.4vw, 34px);
  font-weight: 800;
  letter-spacing: .05em;
}

.editor-top .meta-line {
  font-size: 13px;
  color: var(--c-muted);
  margin-top: 8px;
}

.save-status {
  font-size: 12.5px;
  color: var(--c-muted);
  letter-spacing: .08em;
  white-space: nowrap;
  padding-top: 10px;
}

.save-status .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-border);
  margin-right: 8px;
  vertical-align: 1px;
  transition: background .3s ease;
}

.save-status.saved .dot { background: var(--c-primary); }
.save-status.dirty .dot { background: var(--c-accent); }

.editor-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 28px;
  align-items: start;
}

/* 左侧模板面板 */
.tpl-panel {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  padding: 22px 20px;
}

.tpl-panel h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--c-accent);
  margin-bottom: 4px;
}

.tpl-panel .panel-sub {
  font-size: 12px;
  color: var(--c-muted);
  margin-bottom: 18px;
}

.pick-group { margin-bottom: 22px; }

.pick-group .pg-label {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 12px;
  letter-spacing: .16em;
  color: var(--c-muted);
  margin-bottom: 8px;
}

.pick-group .pg-label b {
  color: var(--c-text);
  font-weight: 700;
}

.pick-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--c-border);
}

.pick-list li {
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  font-size: 13.5px;
  line-height: 1.6;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
}

.pick-list li:hover { color: var(--c-primary); }

.pick-list li.selected {
  border-left-color: var(--c-accent);
  color: var(--c-accent);
  background: #f4f2fa;
  font-weight: 600;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

/* 右侧故事纸 */
.story-paper {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: clamp(26px, 4vw, 52px);
}

.story-paper .paper-label {
  font-size: 11px;
  letter-spacing: .24em;
  color: var(--c-muted);
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
}

.title-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--c-border);
  background: transparent;
  font-family: var(--font);
  font-size: clamp(20px, 2.6vw, 26px);
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--c-text);
  padding: 6px 2px 14px;
  margin-bottom: 26px;
  outline: none;
  transition: border-color .25s ease;
}

.title-input:focus { border-bottom-color: var(--c-accent); }
.title-input::placeholder { color: #b9b3a4; font-weight: 600; }

.story-input {
  width: 100%;
  min-height: 46vh;
  border: none;
  background: transparent;
  resize: vertical;
  font-family: var(--font);
  font-size: 16.5px;
  line-height: 2.05;
  color: var(--c-text);
  outline: none;
  padding: 2px;
}

.story-input::placeholder { color: #b9b3a4; }

.paper-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--c-border);
  font-size: 12px;
  color: var(--c-muted);
  line-height: 1.9;
  letter-spacing: .03em;
}

.gen-block {
  background: var(--c-bg);
  border-left: 2px solid var(--c-accent);
  padding: 16px 18px;
  margin: 0 0 20px;
  font-size: 14.5px;
  line-height: 2;
  color: var(--c-text);
  white-space: pre-wrap;
}

/* 工具条 */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.editor-toolbar .spacer { flex: 1; }

/* ============================================================
   精选故事页
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.filter-bar button {
  border: 1px solid var(--c-border);
  background: transparent;
  border-radius: var(--radius);
  padding: 7px 16px;
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: .08em;
  color: var(--c-muted);
  cursor: pointer;
  transition: all .2s ease;
}

.filter-bar button:hover { color: var(--c-primary); border-color: var(--c-primary); }
.filter-bar button.on { background: var(--c-text); border-color: var(--c-text); color: #fbfbf8; }

.story-list {
  border-top: 1px solid var(--c-border);
}

.story-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 24px;
  align-items: start;
  padding: 30px 0;
  border-bottom: 1px solid var(--c-border);
  cursor: pointer;
  transition: padding-left .25s ease;
}

.story-row:hover { padding-left: 10px; }

.story-row .idx {
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--c-accent);
  padding-top: 8px;
}

.story-row .info .cat {
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--c-secondary);
  display: block;
  margin-bottom: 8px;
}

.story-row .info h3 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .04em;
  margin-bottom: 8px;
}

.story-row .info .excerpt {
  font-size: 13.5px;
  color: var(--c-muted);
  line-height: 1.9;
  max-width: 68ch;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.story-row .meta-col {
  text-align: right;
  font-size: 12px;
  color: var(--c-muted);
  line-height: 2;
  white-space: nowrap;
}

.story-row .read-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 12.5px;
  letter-spacing: .1em;
  color: var(--c-primary);
  border-bottom: 1px solid var(--c-primary);
}

/* 阅读弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 24, .32);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-mask.open { display: flex; }

.modal-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  max-width: 680px;
  width: 100%;
  max-height: 84vh;
  overflow: auto;
  padding: clamp(26px, 5vw, 52px);
  animation: rise .28s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-box .cat {
  font-size: 11px;
  letter-spacing: .2em;
  color: var(--c-secondary);
}

.modal-box h2 {
  font-size: clamp(21px, 3vw, 28px);
  font-weight: 800;
  letter-spacing: .05em;
  margin: 10px 0 6px;
}

.modal-box .byline {
  font-size: 12.5px;
  color: var(--c-muted);
  margin-bottom: 26px;
}

.modal-box .fulltext {
  font-size: 15.5px;
  line-height: 2.1;
  white-space: pre-wrap;
  border-top: 1px solid var(--c-border);
  padding-top: 24px;
}

.modal-close {
  display: block;
  margin: 28px 0 0 auto;
  border: 1px solid var(--c-border);
  background: transparent;
  border-radius: var(--radius);
  padding: 8px 22px;
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: .1em;
  color: var(--c-muted);
  cursor: pointer;
  transition: all .2s ease;
}

.modal-close:hover { color: var(--c-accent); border-color: var(--c-accent); }

/* 空状态 */
.empty {
  padding: 80px 0;
  text-align: center;
  color: var(--c-muted);
  font-size: 14px;
  letter-spacing: .1em;
  border-bottom: 1px solid var(--c-border);
}

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .tpl-grid,
  .featured-row { grid-template-columns: 1fr; gap: 0; }

  .featured-item {
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    padding: 22px 0;
  }
  .featured-item:last-child { border-bottom: none; }

  .steps { grid-template-columns: 1fr; }
  .step { border-right: none; border-bottom: 1px solid var(--c-border); padding: 22px 0; }
  .step:last-child { border-bottom: none; }

  .editor-body { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    background: var(--c-bg);
    border-bottom: 1px solid var(--c-border);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px var(--gutter) 18px;
    display: none;
  }

  .nav-open .nav { display: flex; }

  .nav a { padding: 12px 2px; border-bottom: 1px solid var(--c-border); }
  .nav a::after { display: none; }

  .nav-toggle { display: block; }

  .story-row { grid-template-columns: 1fr; gap: 8px; }
  .story-row .meta-col { text-align: left; }
  .story-row .idx { padding-top: 0; }

  .sec-head { flex-wrap: wrap; }
  .sec-sub { margin-left: 0; text-align: left; width: 100%; }
}

/* ============================================================
   打印 / PDF 导出
   ============================================================ */
@media print {
  body { background: #fff; }

  .site-header,
  .site-footer,
  .editor-toolbar,
  .tpl-panel,
  .filter-bar,
  .modal-mask,
  .save-status,
  .paper-hint,
  .no-print { display: none !important; }

  .editor-wrap { padding: 0; }
  .editor-body { display: block; }

  .story-paper {
    border: none;
    padding: 0;
  }

  .story-paper .paper-label { display: none; }

  .title-input { border-bottom: none; }
  .story-input { min-height: 0; font-size: 14px; }

  @page { margin: 18mm 16mm; }
}
