:root {
  --ink: #151515;
  --paper: #fff8e8;
  --panel: #ffffff;
  --muted: #665f54;
  --red: #e52520;
  --yellow: #ffd62e;
  --blue: #0867d8;
  --pink: #ff4aa4;
  --green: #38b26f;
  --shadow: 8px 8px 0 #151515;
  --thin-shadow: 4px 4px 0 #151515;
  --radius: 6px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.75;
}

a {
  color: inherit;
}

.site-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.top-strip {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 4px solid var(--ink);
  background: rgba(255, 248, 232, 0.96);
  backdrop-filter: blur(10px);
}

.top-strip-inner {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 950;
  letter-spacing: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 3px solid var(--ink);
  background: var(--yellow);
  box-shadow: 3px 3px 0 var(--ink);
  transform: rotate(-4deg);
}

.brand-title {
  font-size: clamp(1.05rem, 2vw, 1.35rem);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a {
  display: inline-block;
  padding: 6px 10px;
  border: 2px solid var(--ink);
  background: #fff;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 900;
  box-shadow: 2px 2px 0 var(--ink);
}

.nav-links a:hover,
.nav-links a:focus-visible {
  background: var(--yellow);
}

.hero {
  margin: 28px 0 32px;
  border: 5px solid var(--ink);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.cover-frame {
  position: relative;
  overflow: hidden;
  background: #fff;
}

.cover-frame img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.hero-caption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-top: 5px solid var(--ink);
  background: #fff;
}

.kicker {
  display: inline-block;
  padding: 4px 10px;
  border: 3px solid var(--ink);
  background: var(--yellow);
  font-weight: 950;
  box-shadow: 3px 3px 0 var(--ink);
}

h1,
h2,
h3 {
  letter-spacing: 0;
  line-height: 1.25;
}

h1 {
  margin: 10px 0 8px;
  font-size: 4rem;
  font-weight: 950;
}

h2 {
  margin: 0 0 16px;
  font-size: 2rem;
  font-weight: 950;
}

h3 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  font-weight: 950;
}

.lead {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 750;
}

.issue-meta {
  display: grid;
  gap: 6px;
  min-width: 190px;
  text-align: right;
  font-weight: 900;
}

.issue-meta span {
  display: block;
  padding: 5px 8px;
  border: 2px solid var(--ink);
  background: #f4f4f4;
}

.qr-trigger {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.qr-trigger:hover,
.qr-trigger:focus-visible {
  background: #fff;
}

.qr-trigger:focus-visible,
.qr-dialog-close:focus-visible,
.qr-dialog a:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 3px;
}

.qr-trigger img {
  display: block;
  width: 72px;
  height: 72px;
  border: 2px solid var(--ink);
  background: #fff;
}

.qr-trigger strong,
.qr-trigger small {
  display: block;
  line-height: 1.35;
}

.qr-trigger strong {
  font-size: 0.94rem;
  font-weight: 950;
}

.qr-trigger small {
  margin-top: 4px;
  font-size: 0.76rem;
  font-weight: 800;
}

.qr-dialog {
  width: min(92vw, 520px);
  max-width: none;
  padding: 0;
  border: 5px solid var(--ink);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  box-shadow: 10px 10px 0 var(--ink);
}

.qr-dialog::backdrop {
  background: rgba(21, 21, 21, 0.78);
}

.qr-dialog-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px;
  text-align: center;
}

.qr-dialog-card h2,
.qr-dialog-card p {
  margin: 0;
}

.qr-dialog-card p {
  max-width: 34ch;
  font-weight: 750;
}

.qr-dialog-card > img {
  display: block;
  width: min(68vw, 340px);
  height: auto;
  border: 4px solid var(--ink);
  background: #fff;
}

.qr-dialog-card > a {
  display: inline-block;
  padding: 10px 14px;
  border: 3px solid var(--ink);
  background: var(--yellow);
  font-weight: 950;
  text-decoration: none;
  box-shadow: 3px 3px 0 var(--ink);
}

.qr-dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 2rem;
  font-weight: 950;
  line-height: 1;
  cursor: pointer;
}

.unit-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 36px;
}

.unit-card {
  display: block;
  min-height: 168px;
  padding: 16px;
  border: 4px solid var(--ink);
  background: #fff;
  text-decoration: none;
  box-shadow: var(--thin-shadow);
  transform: rotate(var(--tilt, -1deg));
}

.unit-card:nth-child(even) {
  --tilt: 1deg;
}

.unit-card strong {
  display: block;
  font-size: 1.25rem;
  line-height: 1.25;
  font-weight: 950;
}

.unit-card span {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 750;
}

.unit-card:hover,
.unit-card:focus-visible {
  background: var(--yellow);
}

.manga-band {
  margin: 30px 0;
  padding: 18px;
  border: 5px solid var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}

.spread-image {
  display: block;
  width: 100%;
  border: 4px solid var(--ink);
  background: #fff;
}

.caption-note {
  margin: 10px 0 0;
  font-weight: 850;
  color: #34302a;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.55fr);
  gap: 22px;
  align-items: start;
}

.section {
  margin: 24px 0;
  padding: 22px;
  border: 4px solid var(--ink);
  background: #fff;
  box-shadow: var(--thin-shadow);
}

.section.hot {
  background: #fff1c7;
}

.section.blue {
  background: #dff0ff;
}

.section.green {
  background: #e6ffe9;
}

.impact {
  margin: 16px 0;
  padding: 18px;
  border: 5px solid var(--ink);
  background: var(--yellow);
  font-size: clamp(1.3rem, 3vw, 2rem);
  font-weight: 950;
  line-height: 1.35;
  box-shadow: var(--thin-shadow);
}

.steps {
  padding-left: 1.2rem;
  margin: 0;
}

.steps li {
  margin: 10px 0;
  font-weight: 730;
}

.check-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.check-list li {
  padding: 10px 12px;
  border: 3px solid var(--ink);
  background: #fff;
  font-weight: 760;
}

.check-list li::before {
  content: "✓";
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 8px;
  border: 2px solid var(--ink);
  background: var(--green);
  color: #fff;
  font-weight: 950;
}

.prompt-box {
  position: relative;
  margin: 18px 0 0;
  border: 4px solid var(--ink);
  background: #171717;
  color: #f9f2d3;
  box-shadow: var(--thin-shadow);
}

.prompt-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 3px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  font-weight: 950;
}

.copy-btn,
.copy-worksheet-btn,
.add-row-btn,
.remove-row-btn,
.export-btn,
.clear-btn {
  border: 3px solid var(--ink);
  background: #fff;
  color: var(--ink);
  padding: 7px 11px;
  font: inherit;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
}

.copy-btn:hover,
.copy-btn:focus-visible,
.copy-worksheet-btn:hover,
.copy-worksheet-btn:focus-visible,
.add-row-btn:hover,
.add-row-btn:focus-visible,
.remove-row-btn:hover,
.remove-row-btn:focus-visible,
.export-btn:hover,
.export-btn:focus-visible,
.clear-btn:hover,
.clear-btn:focus-visible {
  background: var(--yellow);
}

pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 1rem;
  line-height: 1.65;
}

.worksheet {
  margin: 24px 0 42px;
  padding: 20px;
  border: 5px solid var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}

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

.field {
  display: grid;
  gap: 7px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-weight: 950;
}

.field textarea,
.field input {
  width: 100%;
  min-height: 92px;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 0;
  font: inherit;
  resize: vertical;
  background: #fffdf7;
}

.field input {
  min-height: auto;
}

.worksheet-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.repeat-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 4px solid var(--ink);
}

.repeat-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.repeat-heading h3,
.repeat-heading p {
  margin: 0 0 8px;
}

.repeat-rows {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.repeat-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(130px, 0.7fr) minmax(0, 1.4fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 3px solid var(--ink);
  background: #fffdf7;
}

.repeat-field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.repeat-field label {
  font-size: 0.92rem;
  font-weight: 950;
}

.repeat-field input {
  width: 100%;
  min-width: 0;
  padding: 9px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: #fff;
  font: inherit;
}

.remove-row-btn {
  background: #fff;
}

.worksheet-status {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 6px solid var(--teal);
  background: #edf9f7;
  font-weight: 800;
}

.worksheet-status.is-error {
  border-left-color: var(--red);
  background: #fff0ed;
}

.source-table,
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  background: #fff;
}

.source-table th,
.source-table td,
.compare-table th,
.compare-table td {
  border: 3px solid var(--ink);
  padding: 10px;
  vertical-align: top;
}

.source-table th,
.compare-table th {
  background: var(--yellow);
  font-weight: 950;
}

.footer-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 32px 0 48px;
}

.footer-nav a {
  flex: 1;
  padding: 14px;
  border: 4px solid var(--ink);
  background: #fff;
  text-decoration: none;
  font-weight: 950;
  text-align: center;
  box-shadow: var(--thin-shadow);
}

.footer-nav a:hover,
.footer-nav a:focus-visible {
  background: var(--yellow);
}

.small-note {
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 650;
}

.print-note {
  margin: 24px 0;
  padding: 14px 16px;
  border: 3px dashed var(--ink);
  background: #fff;
  font-weight: 800;
}

.cover-collage {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  min-height: 360px;
  overflow: hidden;
  background: #fff;
}

.cover-collage img {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  object-fit: cover;
  border-right: 3px solid var(--ink);
}

.cover-collage img:last-child {
  border-right: 0;
}

.prose {
  min-width: 0;
  margin: 34px 0;
  padding: 12px 28px 28px;
  border-left: 6px solid var(--red);
  background: #fff;
}

.prose > h2 {
  margin: 34px -28px 18px;
  padding: 12px 28px;
  border-top: 4px solid var(--ink);
  border-bottom: 4px solid var(--ink);
  background: var(--yellow);
}

.prose > h2:first-child {
  margin-top: 0;
}

.prose h3 {
  margin-top: 28px;
  padding-left: 12px;
  border-left: 5px solid var(--blue);
}

.prose p,
.prose li,
.reference-content p,
.reference-content li {
  max-width: 78ch;
}

.prose blockquote {
  margin: 20px 0;
  padding: 14px 18px;
  border: 4px solid var(--ink);
  background: #e6ffe9;
  font-size: 1.15rem;
  font-weight: 800;
}

.prose table,
.reference-content table {
  width: 100%;
  margin: 18px 0 26px;
  border-collapse: collapse;
  background: #fff;
}

.prose th,
.prose td,
.reference-content th,
.reference-content td {
  padding: 11px 12px;
  border: 3px solid var(--ink);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.prose th,
.reference-content th {
  background: var(--yellow);
  text-align: left;
}

.prose a,
.reference-content a {
  color: #004f9f;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.reference-block {
  margin: 30px 0;
  border: 4px solid var(--ink);
  background: #fff;
  box-shadow: var(--thin-shadow);
}

.reference-block summary {
  padding: 14px 18px;
  background: #dff0ff;
  font-weight: 950;
  cursor: pointer;
}

.reference-block summary:focus-visible {
  outline: 4px solid var(--red);
  outline-offset: 2px;
}

.reference-content {
  min-width: 0;
  padding: 20px;
}

.reference-content h2 {
  font-size: 1.55rem;
}

.prompt-box code {
  font-family: Consolas, "Courier New", monospace;
}

@media (max-width: 980px) {
  .unit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .hero-caption {
    grid-template-columns: 1fr;
  }

  .issue-meta {
    text-align: left;
    min-width: 0;
  }

  .qr-trigger {
    width: min(100%, 300px);
  }

  .cover-collage {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cover-collage img:nth-child(n + 4) {
    display: none;
  }
}

@media (max-width: 680px) {
  .site-shell {
    width: min(100% - 20px, 1180px);
  }

  .top-strip-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    justify-content: flex-start;
    overflow-x: auto;
    width: 100%;
    padding-bottom: 4px;
  }

  .nav-links a {
    flex: 0 0 auto;
  }

  .unit-grid,
  .worksheet-grid {
    grid-template-columns: 1fr;
  }

  .repeat-heading,
  .repeat-row {
    grid-template-columns: 1fr;
  }

  .repeat-heading {
    display: grid;
  }

  .add-row-btn,
  .remove-row-btn {
    width: 100%;
  }

  .hero,
  .manga-band,
  .worksheet {
    box-shadow: 4px 4px 0 var(--ink);
  }

  .section {
    padding: 16px;
  }

  body {
    font-size: 16px;
  }

  h1 {
    font-size: 2.4rem;
  }

  h2 {
    font-size: 1.55rem;
  }

  h3 {
    font-size: 1.2rem;
  }

  .lead {
    font-size: 1.08rem;
  }

  .cover-collage {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 260px;
  }

  .cover-collage img:nth-child(n + 3) {
    display: none;
  }

  .prose {
    padding: 8px 14px 20px;
  }

  .prose > h2 {
    margin-right: -14px;
    margin-left: -14px;
    padding: 10px 14px;
  }

  .prose table,
  .reference-content table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    white-space: normal;
  }

  .footer-nav {
    flex-direction: column;
  }

  .qr-trigger {
    grid-template-columns: 64px minmax(0, 1fr);
    width: 100%;
  }

  .qr-trigger img {
    width: 64px;
    height: 64px;
  }

  .qr-dialog-card {
    padding: 64px 18px 22px;
  }
}

@media print {
  .top-strip,
  .copy-btn,
  .worksheet-actions,
  .footer-nav {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .site-shell {
    width: 100%;
  }

  .hero,
  .section,
  .worksheet,
  .manga-band {
    box-shadow: none;
    break-inside: avoid;
  }
}
