:root {
  --bg-top: #fcf7ec;
  --bg-bottom: #eaf0ec;
  --panel: rgba(255, 252, 246, 0.94);
  --panel-border: rgba(24, 43, 40, 0.14);
  --ink: #1a2a2a;
  --muted: #607173;
  --accent: #2f6f86;
  --accent-deep: #214d62;
  --warm-accent: #dd8a64;
  --line: rgba(26, 42, 42, 0.14);
  --soft-line: rgba(26, 42, 42, 0.1);
  --sheet-shadow: 0 30px 70px rgba(31, 42, 43, 0.17);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  background:
    radial-gradient(circle at 9% 11%, rgba(221, 138, 100, 0.18), transparent 20%),
    radial-gradient(circle at 86% 84%, rgba(66, 132, 116, 0.16), transparent 20%),
    linear-gradient(155deg, var(--bg-top), var(--bg-bottom));
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 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: 14px;
  padding: 24px;
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: 0 15px 40px rgba(32, 44, 45, 0.12);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-deep);
  font: 700 0.8rem/1 "Space Grotesk", sans-serif;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.panel-header {
  padding: 2px 2px 8px;
}

.top-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  background: rgba(47, 111, 134, 0.1);
  border: 1px solid rgba(47, 111, 134, 0.18);
  color: var(--accent-deep);
  font: 700 0.88rem/1 "Space Grotesk", sans-serif;
}

.secondary-back-link {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(26, 42, 42, 0.12);
  color: var(--ink);
}

.panel-header h1,
h2,
.sheet-title,
.sub-title,
.quiz-box h4 {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", serif;
}

.panel-header h1 {
  margin-bottom: 8px;
  font-size: 1.74rem;
  line-height: 1.25;
}

.panel-header p,
.hint,
.parse-notes,
.preview-header,
.sheet-meta,
.section-kicker {
  color: var(--muted);
}

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

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

.guidance-card {
  border-color: rgba(222, 138, 100, 0.35);
  background:
    linear-gradient(180deg, rgba(255, 250, 243, 0.94), rgba(255, 255, 255, 0.8)),
    radial-gradient(circle at 90% 20%, rgba(221, 138, 100, 0.16), transparent 35%);
}

.guidance-card h2 {
  font-size: 1.03rem;
}

.guidance-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
  font-size: 0.92rem;
  line-height: 1.6;
}

.guidance-list span {
  color: var(--accent-deep);
  font-weight: 700;
}

.parent-card {
  border-color: rgba(58, 111, 120, 0.28);
  background:
    linear-gradient(180deg, rgba(242, 250, 251, 0.94), rgba(255, 255, 255, 0.84)),
    radial-gradient(circle at 88% 18%, rgba(79, 145, 156, 0.12), transparent 36%);
}

.parent-card h2 {
  font-size: 1.01rem;
}

.parent-tips {
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  line-height: 1.55;
}

.parent-tips p {
  margin: 0;
}

.parent-tips span {
  color: var(--accent-deep);
  font-weight: 700;
}

.image-import-card {
  border-color: rgba(47, 111, 134, 0.28);
  background:
    linear-gradient(180deg, rgba(246, 252, 252, 0.94), rgba(255, 255, 255, 0.82)),
    radial-gradient(circle at 88% 12%, rgba(47, 111, 134, 0.12), transparent 34%);
}

.image-upload-box {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px dashed rgba(47, 111, 134, 0.42);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  cursor: pointer;
}

.image-upload-box span {
  color: var(--accent-deep);
  font-weight: 800;
}

.image-upload-box small {
  color: var(--muted);
  line-height: 1.55;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

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

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

textarea {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  border: 1px solid rgba(26, 42, 42, 0.18);
  border-radius: 14px;
  padding: 14px;
  color: var(--ink);
  font: 500 14px/1.65 "SFMono-Regular", "Consolas", monospace;
  background: rgba(255, 255, 255, 0.96);
}

textarea:focus {
  outline: 2px solid rgba(47, 111, 134, 0.2);
  border-color: rgba(47, 111, 134, 0.45);
}

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

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

button:disabled {
  cursor: wait;
  opacity: 0.72;
  transform: none;
}

.ghost-button,
.primary-button,
.secondary-button {
  border-radius: 999px;
  padding: 11px 16px;
  font: 700 0.9rem/1 "Space Grotesk", sans-serif;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  border: 1px solid rgba(26, 42, 42, 0.12);
}

.primary-button {
  flex: 1;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #f9feff;
  box-shadow: 0 11px 24px rgba(47, 111, 134, 0.24);
}

.secondary-button {
  background: #274a5b;
  color: #f2f7f9;
}

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

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

.parse-notes {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  line-height: 1.6;
}

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

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

.sheet {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 10.5mm 11.5mm 10mm;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(251, 248, 241, 0.95), rgba(255, 255, 255, 1) 70%),
    #ffffff;
  box-shadow: var(--sheet-shadow);
  display: grid;
  gap: 10px;
}

.sheet-header {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid rgba(26, 42, 42, 0.2);
  padding-bottom: 8px;
}

.sheet-title {
  font-size: 1.46rem;
}

.sheet-meta {
  margin: 0;
  font-size: 0.88rem;
}

.sheet-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sheet-badge,
.sheet-series {
  margin: 0;
  font: 700 0.72rem/1.2 "Space Grotesk", sans-serif;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.sheet-series {
  letter-spacing: 0.05em;
  color: #48656e;
}

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

.worksheet-meta-block {
  border: 1px solid rgba(26, 42, 42, 0.2);
  border-radius: 11px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.9);
  display: grid;
  gap: 8px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.meta-line {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
}

.meta-label {
  font-size: 0.79rem;
  color: #2f4549;
}

.write-line {
  border-bottom: 1px solid rgba(26, 42, 42, 0.58);
  min-height: 16px;
}

.learning-target-row {
  border-top: 1px dashed rgba(26, 42, 42, 0.24);
  padding-top: 6px;
}

.target-label {
  margin: 0;
  font: 700 0.78rem/1.2 "Space Grotesk", sans-serif;
  color: #274a5b;
  letter-spacing: 0.04em;
}

.target-copy {
  margin: 4px 0 0;
  font-size: 0.83rem;
  line-height: 1.5;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat-item {
  border: 1px solid rgba(26, 42, 42, 0.14);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(246, 251, 250, 0.9);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.stat-value {
  display: block;
  margin-top: 2px;
  font: 700 1rem/1 "Space Grotesk", sans-serif;
}

.study-guide {
  border: 1px solid rgba(221, 138, 100, 0.34);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 247, 238, 0.78);
}

.study-guide-title {
  margin: 0;
  font: 700 0.82rem/1.2 "Space Grotesk", sans-serif;
  color: #99583f;
  letter-spacing: 0.04em;
}

.study-guide-copy {
  margin: 4px 0 0;
  font-size: 0.84rem;
}

.completion-row {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 8px;
}

.completion-item {
  border: 1px solid rgba(26, 42, 42, 0.18);
  border-radius: 10px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.9);
}

.completion-title {
  margin: 0;
  font: 700 0.78rem/1.2 "Space Grotesk", sans-serif;
  color: #2f4549;
  letter-spacing: 0.03em;
}

.completion-options {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  font-size: 0.79rem;
  color: #3d5155;
}

.rating-item {
  display: grid;
  gap: 4px;
}

.rating-dots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rating-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(26, 42, 42, 0.52);
}

.parent-note {
  border: 1px solid rgba(58, 111, 120, 0.26);
  border-radius: 10px;
  padding: 7px 10px;
  background: rgba(244, 251, 252, 0.9);
}

.parent-note-title {
  margin: 0;
  font: 700 0.8rem/1.2 "Space Grotesk", sans-serif;
  color: #2b5e69;
  letter-spacing: 0.03em;
}

.parent-note-copy {
  margin: 4px 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
}

.section {
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  padding: 10px;
  break-inside: avoid;
}

.section-kicker {
  margin: 0 0 5px;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-family: "Space Grotesk", sans-serif;
}

.sub-title {
  margin-bottom: 8px;
  font-size: 1rem;
}

.section-cards {
  background: linear-gradient(180deg, rgba(242, 251, 247, 0.72), rgba(255, 255, 255, 0.94));
}

.section-practice {
  background: linear-gradient(180deg, rgba(255, 248, 240, 0.72), rgba(255, 255, 255, 0.94));
}

.section-quiz {
  background: linear-gradient(180deg, rgba(242, 246, 255, 0.72), rgba(255, 255, 255, 0.94));
}

.section-review {
  background: linear-gradient(180deg, rgba(245, 246, 249, 0.72), rgba(255, 255, 255, 0.94));
}

.word-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.word-card {
  border: 1px solid rgba(26, 42, 42, 0.16);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.98);
}

.word-en {
  display: block;
  font: 700 0.98rem/1.2 "Space Grotesk", sans-serif;
}

.word-meaning,
.word-note {
  display: block;
  margin-top: 4px;
  font-size: 0.86rem;
  line-height: 1.45;
}

.word-note {
  color: var(--muted);
}

.practice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 14px;
}

.practice-line {
  display: grid;
  grid-template-columns: minmax(92px, auto) minmax(120px, 1fr);
  gap: 5px 10px;
  align-items: center;
  font-size: 0.86rem;
}

.practice-word {
  font-weight: 700;
}

.syllable-hint {
  color: var(--muted);
  font-size: 0.78rem;
}

.practice-line .blank-line {
  grid-column: 1 / -1;
}

.blank-line {
  border-bottom: 1px solid rgba(26, 42, 42, 0.62);
  min-height: 18px;
}

.quiz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quiz-box {
  border: 1px solid rgba(26, 42, 42, 0.16);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.96);
}

.quiz-box h4 {
  margin: 0 0 6px;
  font-size: 0.84rem;
}

.quiz-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 5px;
  font-size: 0.82rem;
}

.quiz-item {
  display: grid;
  grid-template-columns: auto minmax(72px, 1fr);
  gap: 8px;
  align-items: center;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.95);
}

.review-table th,
.review-table td {
  border: 1px solid rgba(26, 42, 42, 0.22);
  padding: 4px 6px;
  text-align: left;
}

.review-table th {
  background: rgba(239, 244, 247, 0.85);
  font-weight: 700;
}

.review-table td:nth-child(1),
.review-table td:nth-child(4),
.review-table td:nth-child(5),
.review-table td:nth-child(6),
.review-table th:nth-child(1),
.review-table th:nth-child(4),
.review-table th:nth-child(5),
.review-table th:nth-child(6) {
  text-align: center;
}

.check-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(26, 42, 42, 0.52);
}

.teacher-feedback {
  border: 1px dashed rgba(26, 42, 42, 0.28);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.86);
  break-inside: avoid;
}

.feedback-title {
  margin: 0 0 6px;
  font: 700 0.8rem/1.2 "Space Grotesk", sans-serif;
  color: #2f4549;
  letter-spacing: 0.04em;
}

.feedback-lines {
  display: grid;
  gap: 8px;
}

.empty-state {
  border: 1px dashed rgba(26, 42, 42, 0.25);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.66);
}

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

  .control-panel {
    position: static;
  }

  .word-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meta-grid,
  .completion-row,
  .stats-row,
  .quiz-grid,
  .practice-grid {
    grid-template-columns: 1fr;
  }

  .sheet-brand-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 8.5mm;
  }

  body {
    background: #fff;
    color: #111;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

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

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

  .preview-stage {
    min-height: auto;
  }

  .sheet {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    background: #fff;
  }

  .section {
    border-color: rgba(0, 0, 0, 0.2);
    padding: 8px;
  }

  .parent-note {
    border-color: rgba(0, 0, 0, 0.3);
    background: #f3f8f8;
  }

  .worksheet-meta-block,
  .completion-item,
  .teacher-feedback,
  .stat-item {
    background: #fff;
    border-color: rgba(0, 0, 0, 0.28);
  }

  .sheet-title {
    font-size: 1.4rem;
  }

  .sheet-meta,
  .target-copy,
  .study-guide-copy,
  .parent-note-copy,
  .review-table,
  .practice-line,
  .quiz-list {
    font-size: 0.78rem;
  }

  .blank-line,
  .write-line {
    border-bottom-color: rgba(0, 0, 0, 0.8);
  }

  .check-dot,
  .rating-dot {
    border-color: rgba(0, 0, 0, 0.74);
  }

  .review-table th {
    background: #f1f1f1;
  }

  .section,
  .worksheet-meta-block,
  .completion-row,
  .teacher-feedback,
  .parent-note,
  .stats-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }
}
