:root {
  color-scheme: light;
  --paper: #f7efd9;
  --paper-deep: #eadbb8;
  --paper-light: #fffaf0;
  --ink: #17251f;
  --ink-soft: #30483e;
  --pine: #183b35;
  --pine-2: #245447;
  --cinnabar: #b83c2f;
  --cinnabar-dark: #81261f;
  --gold: #b47b24;
  --gold-light: #f4d58a;
  --jade: #2c7663;
  --line: #8b5f2b;
  --focus: #005fcc;
  --shadow: 0 18px 48px rgb(44 30 13 / 20%);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; overflow-x: hidden; color: var(--ink); line-height: 1.8; background: var(--paper) radial-gradient(circle at 20% 20%, rgb(255 255 255 / 42%) 0 1px, transparent 2px) 0 0 / 18px 18px; }
a { color: var(--cinnabar-dark); text-underline-offset: 4px; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; }
button, .button { min-height: 46px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; color: white; background: var(--cinnabar-dark); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.site-header { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px clamp(18px, 5vw, 76px); color: white; background: rgb(24 59 53 / 97%); border-bottom: 4px solid var(--gold); box-shadow: 0 8px 24px rgb(24 59 53 / 22%); }
.brand { color: white; font-weight: 900; letter-spacing: .08em; text-decoration: none; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 20px; }
.site-header nav a { color: white; font-weight: 800; text-decoration: none; }
.site-header nav a:hover { color: var(--gold-light); }

.hero { position: relative; min-height: min(780px, 82vh); display: grid; align-items: center; overflow: hidden; background: #efe1c4; border-bottom: 8px double var(--line); }
.hero-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; }
.hero::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgb(247 239 217 / 98%) 0%, rgb(247 239 217 / 92%) 34%, rgb(247 239 217 / 30%) 62%, transparent 78%); }
.hero-content { position: relative; z-index: 1; width: min(720px, 58vw); padding: clamp(70px, 9vw, 130px) clamp(22px, 7vw, 110px); }
.eyebrow { margin: 0 0 10px; color: var(--cinnabar-dark); font-size: .86rem; font-weight: 900; letter-spacing: .16em; text-transform: uppercase; }
.hero h1, .page-heading h1 { margin: 0; font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif; font-size: clamp(3rem, 6.5vw, 6.2rem); line-height: 1.08; letter-spacing: -.04em; }
.hero-copy { max-width: 650px; margin: 26px 0; font-size: clamp(1.05rem, 1.8vw, 1.3rem); font-weight: 700; }
.hero-cta { margin-bottom: 28px; }
.hero-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.hero-facts span { padding: 12px 14px; color: white; background: var(--pine); border: 2px solid var(--gold); border-radius: 4px 16px 4px 16px; box-shadow: 5px 5px 0 rgb(184 60 47 / 24%); }
.hero-facts strong { display: block; color: var(--gold-light); font-size: 1.8rem; line-height: 1; }

.curriculum-section, .info-section { padding: clamp(64px, 9vw, 120px) clamp(18px, 7vw, 110px); }
.section-heading { max-width: 850px; margin: 0 auto 42px; text-align: center; }
.section-heading h2, .info-section > h2 { margin: 0 0 18px; font-family: "Noto Serif TC", "Songti TC", serif; font-size: clamp(2rem, 4vw, 3.8rem); line-height: 1.2; }
.preview-grid { max-width: 1350px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 0 auto; }
.preview-grid article { overflow: hidden; background: var(--paper-light); border: 1px solid var(--line); border-radius: 4px 28px 4px 28px; box-shadow: var(--shadow); }
.preview-grid img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-bottom: 5px solid var(--cinnabar); }
.preview-grid article div { padding: 22px; }
.preview-grid span { color: var(--cinnabar-dark); font-weight: 900; }
.preview-grid h3 { margin: 4px 0 8px; font-family: "Noto Serif TC", "Songti TC", serif; font-size: 1.35rem; }
.preview-grid p { margin: 0; }

.app-shell, .admin-main, .verify-main { padding: clamp(42px, 7vw, 96px) clamp(14px, 5vw, 80px); }
.app-shell { background: linear-gradient(180deg, var(--pine) 0 240px, transparent 240px); }
.panel { max-width: 1240px; margin: 0 auto; padding: clamp(22px, 5vw, 58px); background: var(--paper-light); border: 2px solid var(--line); border-radius: 6px 34px 6px 34px; box-shadow: var(--shadow); }
.panel.narrow { max-width: 680px; }
.loading { min-height: 220px; display: grid; place-items: center; font-weight: 900; }
.info-section { background: var(--paper-deep); border-top: 8px double var(--line); }
.info-section > h2 { max-width: 820px; }
.info-grid, .module-grid, .completion-grid, .stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.info-grid article, .stats-grid article { padding: 24px; background: var(--paper-light); border: 1px solid var(--line); border-radius: 4px 18px; }
.notice { max-width: 900px; margin-top: 28px; padding: 18px 22px; color: white; background: var(--pine); border-left: 8px solid var(--cinnabar); }
.site-footer { display: flex; justify-content: space-between; gap: 20px; padding: 30px clamp(20px, 6vw, 90px); color: white; background: var(--pine); border-top: 5px solid var(--gold); }
.site-footer a { color: var(--gold-light); }

.enroll-layout { display: grid; grid-template-columns: .9fr 1.1fr; gap: clamp(28px, 6vw, 80px); align-items: start; }
.enroll-layout h2, .dashboard-head h2, .lesson-view h2, .page-heading h1 { margin-top: 0; }
.stack-form { display: grid; gap: 10px; }
.stack-form label, .search-form label { font-weight: 900; }
input, textarea { width: 100%; padding: 12px 14px; color: var(--ink); background: white; border: 2px solid var(--pine-2); border-radius: 6px; }
.check-line { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-weight: 600 !important; }
.check-line input { width: 22px; height: 22px; margin-top: 4px; flex: 0 0 auto; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border: 2px solid transparent; border-radius: 4px 14px; font-weight: 900; text-decoration: none; cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.button.primary { color: white; background: var(--cinnabar-dark); border-color: var(--cinnabar-dark); }
.button.secondary { color: var(--pine); background: var(--paper-light); border-color: var(--pine); }
.button.ghost { color: var(--pine); background: transparent; }
.button:hover { transform: translateY(-2px); box-shadow: 4px 4px 0 var(--gold); }
.button:disabled { opacity: .65; cursor: wait; transform: none; }
.file-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.alert { margin: 18px 0; padding: 14px 18px; background: white; border: 3px solid var(--jade); border-radius: 6px; }
.alert.error { border-color: var(--cinnabar); }
.alert.success { border-color: var(--jade); }

.dashboard-head, .admin-tools, .certificate-actions { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.time-card { margin: 24px 0 34px; padding: 22px; color: white; background: var(--pine); border-radius: 4px 20px; }
.time-card > div:first-child { display: flex; justify-content: space-between; gap: 20px; }
.time-card strong { color: var(--gold-light); font-size: 1.4rem; }
.progress { height: 15px; margin: 14px 0; overflow: hidden; background: #081b17; border: 1px solid var(--gold-light); border-radius: 99px; }
.progress span { display: block; height: 100%; background: var(--gold-light); }
.module-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 24px 0 34px; }
.module-card { display: grid; grid-template-columns: 42% 1fr; overflow: hidden; background: white; border: 2px solid var(--paper-deep); border-radius: 4px 24px; box-shadow: 0 10px 28px rgb(44 30 13 / 14%); }
.module-card.done { border-color: var(--jade); }
.module-card > img { width: 100%; height: 100%; min-height: 300px; object-fit: cover; }
.module-card-body { display: flex; flex-direction: column; padding: 22px; }
.module-card .button { margin-top: auto; }
.module-number { margin: 0; color: var(--cinnabar); font-weight: 900; letter-spacing: .1em; }
.module-card h3 { margin: 5px 0 10px; font-family: "Noto Serif TC", "Songti TC", serif; line-height: 1.35; }
.module-meta, .status-line { color: var(--pine-2); font-weight: 900; }
.completion-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 24px 0; }
.task-card { padding: 22px; text-align: left; color: white; background: var(--pine); border: 2px solid var(--gold); border-radius: 4px 18px; cursor: pointer; }
.task-card span, .task-card strong, .task-card small { display: block; }
.task-card span { color: var(--gold-light); font-weight: 900; }
.task-card strong { margin: 8px 0; font-size: 1.25rem; }
.task-card small { color: white; }
.checklist { display: grid; gap: 8px; padding: 0; list-style: none; }
.checklist li { padding: 10px 14px; background: white; border-left: 6px solid var(--cinnabar); }
.checklist li.complete { border-left-color: var(--jade); }
.checklist li.complete::before { content: "✓ "; color: var(--jade); font-weight: 900; }

.back-button { margin-bottom: 24px; padding: 8px 0; color: var(--cinnabar-dark); background: transparent; border: 0; font-weight: 900; cursor: pointer; }
.lesson-hero { position: relative; display: grid; grid-template-columns: 1.05fr .95fr; align-items: center; overflow: hidden; margin: 0 0 28px; color: white; background: var(--pine); border-radius: 4px 30px; }
.lesson-hero img { width: 100%; height: 100%; min-height: 400px; object-fit: cover; }
.lesson-hero figcaption { padding: clamp(24px, 5vw, 56px); }
.lesson-hero .eyebrow { color: var(--gold-light); }
.lesson-hero h2 { font-family: "Noto Serif TC", "Songti TC", serif; font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1.2; }
.objectives, .run-of-show, .lesson-section, .quiz-section, .source-box, .lesson-toc { max-width: 920px; margin: 28px auto; padding: clamp(22px, 4vw, 38px); background: white; border: 1px solid var(--line); border-radius: 4px 22px; }
.objectives { border-top: 8px solid var(--jade); }
.run-of-show { background: #f3ead2; border-left: 8px solid var(--gold); }
.lesson-toc { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; background: var(--paper-deep); }
.lesson-toc strong { grid-column: 1 / -1; font-size: 1.2rem; }
.lesson-section { position: relative; scroll-margin-top: 90px; }
.section-number { position: absolute; top: 18px; right: 24px; margin: 0; color: var(--paper-deep); font: 900 4rem/1 serif; }
.lesson-section h3 { position: relative; margin-top: 0; padding-right: 70px; color: var(--cinnabar-dark); font-family: "Noto Serif TC", "Songti TC", serif; font-size: 1.55rem; }
.case-study, .activity { margin-top: 22px; padding: 18px; border-radius: 4px 16px; }
.case-study { background: #e2efe8; border-left: 6px solid var(--jade); }
.activity { background: #f8e5cc; border-left: 6px solid var(--cinnabar); }
.evidence-section { margin: 34px 0; padding: clamp(20px, 4vw, 36px); background: #eef5ef; border: 2px solid var(--jade); border-radius: 4px 24px; }
.quality-check { display: grid; gap: 10px; padding: 18px; border: 2px solid var(--pine-2); }
.quality-check label { display: flex; gap: 10px; align-items: flex-start; }
.quality-check input { width: auto; margin-top: .45em; }
.honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
.source-box { display: grid; gap: 14px; background: var(--paper-deep); }
.source-box > strong { font-size: 1.3rem; }
.source-box article { padding: 14px 18px; background: var(--paper-light); border-left: 5px solid var(--gold); }
.source-box h4, .source-box p { margin: 0; }
.quiz-section { max-width: 1000px; border-top: 8px solid var(--cinnabar); }
.quiz-form { display: grid; gap: 20px; }
.quiz-progress { position: sticky; top: 72px; z-index: 5; display: flex; justify-content: space-between; gap: 20px; padding: 12px 16px; color: white; background: var(--pine); border-radius: 4px; }
.question-page { display: grid; gap: 18px; }
.quiz-form fieldset { padding: 20px; border: 2px solid var(--paper-deep); border-radius: 4px 16px; }
.quiz-form legend { max-width: 95%; padding: 0 8px; font-weight: 900; }
.quiz-form fieldset label { display: flex; gap: 10px; align-items: flex-start; margin: 9px 0; padding: 10px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; }
.quiz-form fieldset label:hover { background: var(--paper); border-color: var(--line); }
.quiz-form input[type=radio] { width: 20px; height: 20px; flex: 0 0 auto; margin-top: 4px; }
.quiz-nav { display: flex; justify-content: space-between; gap: 12px; }
.wide-form { max-width: 900px; margin: 0 auto; }

.page-heading { max-width: 1200px; margin: 0 auto 32px; }
.page-heading h1 { font-size: clamp(2.3rem, 6vw, 5rem); }
.admin-tools { align-items: end; }
.admin-tools > div { display: flex; flex-wrap: wrap; gap: 8px; }
.search-form { flex: 1; }
.search-form > div { display: flex; gap: 8px; }
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 24px 0; }
.stats-grid strong { display: block; color: var(--cinnabar-dark); font-size: 2rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 980px; border-collapse: collapse; background: white; }
caption { padding: 14px 0; text-align: left; font-size: 1.25rem; font-weight: 900; }
th, td { padding: 12px; text-align: left; vertical-align: top; border: 1px solid var(--line); }
th { color: white; background: var(--pine); }
details summary { color: var(--cinnabar-dark); cursor: pointer; font-weight: 900; }

.certificate-shell { max-width: 1050px; }
.certificate { min-height: 680px; padding: clamp(38px, 7vw, 86px); color: var(--ink); text-align: center; background: var(--paper-light); border: 14px double var(--line); box-shadow: var(--shadow); }
.certificate-kicker { letter-spacing: .2em; text-transform: uppercase; }
.certificate h2 { margin: 12px 0 24px; font-family: "Noto Serif TC", "Songti TC", serif; font-size: clamp(2.8rem, 7vw, 5.2rem); }
.certificate-name { display: block; margin: 8px 0; font-family: "Noto Serif TC", "Songti TC", serif; font-size: clamp(2.2rem, 6vw, 4rem); border-bottom: 2px solid var(--line); }
.certificate-copy { max-width: 720px; margin: 30px auto; font-size: 1.2rem; }
.certificate-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 50px; }
.certificate-code { margin-top: 45px; font-size: .82rem; overflow-wrap: anywhere; }
.verify-result { margin-top: 24px; padding: 22px; border: 3px solid var(--jade); border-radius: 4px 16px; background: white; }
.verify-result.valid h2 { color: var(--cinnabar-dark); }

@media (max-width: 1050px) {
  .hero-content { width: 68vw; }
  .preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .module-card { grid-template-columns: 1fr; }
  .module-card > img { min-height: 0; aspect-ratio: 3 / 2; }
}

@media (max-width: 760px) {
  .site-header, .site-footer, .dashboard-head, .admin-tools, .certificate-actions { align-items: stretch; flex-direction: column; }
  .site-header nav { gap: 12px; }
  .hero { min-height: 820px; align-items: end; }
  .hero-art { height: 54%; top: 0; object-position: 70% center; }
  .hero::after { background: linear-gradient(180deg, transparent 0%, rgb(247 239 217 / 40%) 38%, var(--paper) 55%); }
  .hero-content { width: 100%; padding: 360px 20px 48px; }
  .hero h1 { font-size: clamp(2.7rem, 13vw, 4.4rem); }
  .hero-facts { grid-template-columns: 1fr 1fr; }
  .preview-grid, .module-grid, .info-grid, .completion-grid, .stats-grid { grid-template-columns: 1fr; }
  .enroll-layout, .lesson-hero { grid-template-columns: 1fr; }
  .lesson-hero img { min-height: 0; aspect-ratio: 3 / 2; }
  .lesson-toc { grid-template-columns: 1fr; }
  .lesson-toc strong { grid-column: auto; }
  .search-form > div, .quiz-nav { flex-direction: column; }
  .panel { padding: 18px; border-radius: 4px 20px; }
  .certificate-meta { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  .site-header, .site-footer, .hero, .curriculum-section, .info-section, .certificate-actions { display: none !important; }
  .app-shell { padding: 0; background: white; }
  .panel, .certificate-shell { max-width: none; padding: 0; border: 0; box-shadow: none; background: white; }
  .certificate { min-height: 95vh; box-shadow: none; print-color-adjust: exact; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
