:root {
  --bg-top: #f4efe5;
  --bg-bottom: #dbe7e4;
  --panel: rgba(252, 249, 244, 0.92);
  --panel-border: rgba(28, 54, 48, 0.12);
  --ink: #1f2a2a;
  --muted: #5f6d6c;
  --accent: #b4512a;
  --accent-deep: #8f3616;
  --accent-soft: #efdfd6;
  --line: rgba(31, 42, 42, 0.12);
  --sheet-shadow: 0 30px 80px rgba(31, 42, 42, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Space Grotesk", "PingFang SC", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(180, 81, 42, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(25, 92, 78, 0.16), transparent 22%),
    linear-gradient(145deg, var(--bg-top), var(--bg-bottom));
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 440px) 1fr;
  gap: 24px;
  padding: 24px;
}

.control-panel,
.preview-stage {
  min-height: calc(100vh - 48px);
}

.control-panel {
  position: sticky;
  top: 24px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 60px rgba(31, 42, 42, 0.08);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent-deep);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
.sheet h1,
.sheet h2 {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.panel-copy,
.hint,
.parse-notes,
.preview-header,
.doc-date,
.doc-subtitle,
.doc-author,
.doc-footer {
  color: var(--muted);
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.55);
}

.compact-card {
  padding-bottom: 18px;
}

.section-title-row,
.action-row,
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.action-row {
  flex-wrap: wrap;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  border: 1px solid rgba(31, 42, 42, 0.16);
  border-radius: 18px;
  padding: 16px;
  color: var(--ink);
  font: 500 14px/1.7 "SFMono-Regular", "Consolas", monospace;
  background: rgba(255, 255, 255, 0.95);
}

button {
  border: none;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

.ghost-button,
.secondary-button,
.primary-button {
  border-radius: 999px;
  padding: 12px 16px;
  font: 700 0.92rem/1 "Space Grotesk", sans-serif;
  text-decoration: none;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.primary-button {
  flex: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fffaf6;
  box-shadow: 0 12px 30px rgba(180, 81, 42, 0.22);
}

.secondary-button {
  flex: 1;
  background: #173b38;
  color: #f3f7f5;
}

.action-row .ghost-button,
.action-row .secondary-button,
.action-row .primary-button {
  flex: 1 1 160px;
}

.upload-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.image-actions {
  display: flex;
  gap: 10px;
}

.speech-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 10px;
}

.audio-player-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgba(31, 42, 42, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.audio-player-box audio {
  width: 100%;
  min-height: 40px;
}

input[type="range"] {
  width: 100%;
}

select {
  width: 100%;
  border: 1px solid rgba(31, 42, 42, 0.16);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
  font: 500 14px/1.4 "Helvetica Neue", "PingFang SC", sans-serif;
}

.hidden-input {
  display: none;
}

.image-preview-box {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 140px;
  border: 1px dashed rgba(31, 42, 42, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  overflow: hidden;
}

.image-preview-box img {
  display: none;
  width: 100%;
  max-height: 240px;
  object-fit: contain;
}

.image-preview-box.has-image img {
  display: block;
}

.image-preview-box.has-image .image-empty {
  display: none;
}

.image-empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.preview-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.empty-state {
  width: 100%;
  padding: 48px 32px;
  border: 1px dashed rgba(31, 42, 42, 0.18);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 10px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.preview-header {
  padding: 0 8px;
  font-size: 0.92rem;
}

.sheet {
  width: 210mm;
  min-height: 297mm;
  height: 297mm;
  margin: 0 auto;
  padding: 12mm 14mm 10mm;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: var(--sheet-shadow);
  display: flex;
  flex-direction: column;
}

.preview-sheet {
  width: min(100%, 980px);
  min-height: 297mm;
  margin: 0 auto;
  padding: 12mm 14mm 14mm;
  border-radius: 20px;
  background: #ffffff;
  box-shadow: var(--sheet-shadow);
}

.print-stage {
  display: none;
}

.print-flow-root {
  width: 210mm;
  margin: 0 auto;
  padding: 12mm 14mm 10mm;
  background: white;
}

.print-sheet-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.print-document {
  min-height: calc(297mm - 36mm);
  display: flex;
  flex-direction: column;
}

.page-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.article-document {
  color: #111111;
}

.article-topline {
  margin-bottom: 26px;
}

.intro-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px;
  gap: 18px;
  align-items: start;
}

.intro-figure {
  margin: 0;
  width: 160px;
  max-width: 160px;
}

.intro-image {
  display: block;
  width: 100%;
  height: 110px;
  max-height: 110px;
  border-radius: 8px;
  object-fit: cover;
}

.cn-title {
  font-size: 1.78rem;
  line-height: 1.3;
  font-weight: 700;
}

.meta-line {
  margin: 6px 0 0;
  font: 400 0.94rem/1.35 "Helvetica Neue", "PingFang SC", sans-serif;
  color: #222222;
}

.cn-intro {
  margin-top: 8px;
}

.cn-intro p {
  margin: 0 0 8px;
  font: 400 1rem/1.62 "Noto Serif SC", "Songti SC", serif;
}

.article-main {
  flex: 1;
}

.print-vocab-block {
  break-before: page;
  page-break-before: always;
}

.en-title {
  margin: 28px 0 6px;
  font-size: 1.5rem;
  line-height: 1.32;
  font-weight: 700;
}

.article-author {
  margin: 0 0 14px;
  text-align: center;
  font: 400 0.86rem/1.4 "Helvetica Neue", Arial, sans-serif;
  color: #333333;
}

.en-body p {
  margin: 0 0 14px;
  font: 400 0.98rem/1.6 "Helvetica Neue", Arial, sans-serif;
  color: #111111;
}

.en-body p.reading-active {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(180, 81, 42, 0.12);
  box-shadow: inset 0 0 0 1px rgba(180, 81, 42, 0.18);
}

.vocab-block {
  margin-top: 28px;
}

.preview-vocab-note {
  margin: 28px 0 16px;
  padding-top: 16px;
  border-top: 1px dashed rgba(31, 42, 42, 0.22);
  font: 700 0.9rem/1.4 "Helvetica Neue", Arial, sans-serif;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.vocab-block h3 {
  margin: 0 0 14px;
  font: 700 1.08rem/1.35 "Noto Serif SC", "Songti SC", serif;
}

.vocab-list {
  column-count: 2;
  column-gap: 28px;
  column-fill: auto;
}

.vocab-item {
  display: inline-block;
  width: 100%;
  margin: 0 0 14px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.vocab-item p {
  margin: 0 0 6px;
  font: 400 0.94rem/1.65 "Noto Serif SC", "Songti SC", serif;
  color: #222222;
}

.vocab-index {
  font-weight: 700;
}

.article-footer {
  display: none;
}

.measure-stage {
  position: fixed;
  left: -99999px;
  top: 0;
  visibility: hidden;
  pointer-events: none;
}

.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.parse-notes {
  font-size: 0.92rem;
  line-height: 1.7;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    position: static;
  }

  .sheet {
    width: 100%;
    min-height: auto;
    height: auto;
  }

  .preview-sheet {
    width: 100%;
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 14px;
  }

  .control-panel {
    padding: 18px;
    border-radius: 22px;
  }

  .action-row,
  .speech-actions,
  .section-title-row,
  .preview-header,
  .doc-summary-block {
    grid-template-columns: 1fr;
    display: grid;
  }

  .sheet,
  .preview-sheet {
    padding: 16mm 10mm;
    border-radius: 22px;
  }

  .intro-layout {
    grid-template-columns: 1fr;
  }

  .intro-figure {
    width: 100%;
    max-width: 220px;
  }

  .cn-title,
  .en-title {
    font-size: 1.35rem;
  }

  .vocab-block {
    grid-template-columns: 1fr;
  }

  .vocab-list {
    column-count: 1;
  }
}

@page {
  size: A4;
  margin: 0;
}

@media print {
  body {
    background: white;
  }

  .no-print {
    display: none !important;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .preview-stage,
  .preview-sheet,
  .sheet,
  .print-sheet-stack {
    min-height: auto;
    margin: 0;
    width: auto;
  }

  .preview-stage {
    display: none;
  }

  .print-stage {
    display: block;
  }

  .print-flow-root {
    width: auto;
    margin: 0;
    padding: 12mm 14mm 10mm;
    box-shadow: none;
    background: white;
  }
}
