:root {
  --ink: #17343b;
  --ink-soft: #244b52;
  --teal: #0f6b6d;
  --teal-pale: #e3f0ed;
  --terracotta: #c95f45;
  --terracotta-pale: #f7e7df;
  --mustard: #e1a72f;
  --mustard-pale: #fbf1d7;
  --blue: #315c7d;
  --paper: #fffdf8;
  --cream: #f4eee2;
  --canvas: #e7ece9;
  --line: #cbd6d1;
  --muted: #647477;
  --white: #ffffff;
  --shadow: 0 18px 48px rgb(23 52 59 / 12%);
  font-family: "Noto Sans TC", "PingFang HK", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 86px; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--canvas); font-size: 16px; line-height: 1.65; }
body, button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[lang="es"] { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid rgb(225 167 47 / 60%); outline-offset: 3px; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 200; padding: 9px 13px; color: var(--white); background: var(--ink); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.site-header { position: sticky; top: 0; z-index: 90; display: flex; min-height: 72px; align-items: center; gap: 24px; padding: 10px max(22px, calc((100vw - 1320px) / 2)); color: var(--white); background: var(--ink); border-bottom: 4px solid var(--mustard); }
.site-brand { display: flex; align-items: center; gap: 11px; margin-right: auto; text-decoration: none; }
.brand-mark { display: grid; width: 43px; height: 43px; place-items: center; color: var(--ink); background: var(--mustard); border-radius: 11px; font-weight: 950; letter-spacing: .04em; }
.site-brand strong, .site-brand small { display: block; }
.site-brand strong { font-size: 15px; letter-spacing: .01em; }
.site-brand small { margin-top: 1px; color: #cddbd7; font-size: 11px; }
.site-header nav { display: flex; align-items: center; gap: 6px; }
.site-header nav a { padding: 8px 12px; color: #d7e3e0; border-radius: 7px; text-decoration: none; font-size: 14px; font-weight: 750; }
.site-header nav a:hover, .site-header nav a.active { color: var(--white); background: rgb(255 255 255 / 11%); }

main { width: min(1360px, 100%); margin: 0 auto; padding: 34px 24px 76px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(390px, .96fr); min-height: 680px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.hero-copy { display: flex; min-width: 0; flex-direction: column; justify-content: center; padding: clamp(44px, 6vw, 86px); }
.eyebrow { margin: 0 0 18px; color: var(--terracotta); font-size: 12px; font-weight: 900; letter-spacing: .16em; }
.hero h1 { max-width: 720px; margin: 0; color: var(--ink); font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif; font-size: clamp(58px, 6.7vw, 96px); line-height: 1.06; letter-spacing: -.035em; }
.hero-lead { max-width: 650px; margin: 27px 0 0; color: var(--ink-soft); font-size: clamp(17px, 1.5vw, 20px); line-height: 1.85; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 34px; }
.hero-stats div { padding: 16px 17px; background: var(--cream); border-top: 4px solid var(--mustard); border-radius: 0 0 11px 11px; }
.hero-stats div:nth-child(2) { border-top-color: var(--terracotta); }
.hero-stats div:nth-child(3) { border-top-color: var(--teal); }
.hero-stats strong, .hero-stats span { display: block; }
.hero-stats strong { font-size: 24px; line-height: 1.25; }
.hero-stats span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.primary-action, .secondary-action { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: 10px 18px; border-radius: 9px; cursor: pointer; font-weight: 850; text-decoration: none; }
.primary-action { color: var(--white); background: var(--teal); border: 1px solid var(--teal); }
.primary-action:hover { background: #0b595b; }
.secondary-action { color: var(--teal); background: transparent; border: 1px solid #7aa19d; }
.secondary-action:hover { background: var(--teal-pale); }
.scope-note { max-width: 620px; margin: 24px 0 0; padding-top: 17px; color: var(--muted); border-top: 1px solid var(--line); font-size: 12px; }
.hero-art { position: relative; min-width: 0; min-height: 540px; margin: 0; overflow: hidden; background: #eedbbd; }
.hero-art img { width: 100%; height: 100%; object-fit: cover; object-position: 48% 50%; }
.hero-art figcaption { position: absolute; right: 20px; bottom: 20px; max-width: 260px; padding: 10px 13px; color: var(--ink); background: rgb(255 253 248 / 91%); border-left: 4px solid var(--terracotta); font-size: 12px; font-weight: 750; }

.library { display: grid; grid-template-columns: 300px minmax(0, 1fr); align-items: start; gap: 24px; margin-top: 34px; }
.chapter-panel { position: sticky; top: 92px; max-height: calc(100vh - 112px); overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 10px 30px rgb(23 52 59 / 7%); }
.chapter-panel-heading { padding: 24px 22px 19px; background: var(--teal); }
.chapter-panel-heading p { margin: 0 0 4px; color: #cfe8e4; font-size: 10px; font-weight: 900; letter-spacing: .15em; }
.chapter-panel-heading h2 { margin: 0; color: var(--white); font-size: 24px; }
.chapter-panel-heading span { display: block; margin-top: 6px; color: #d8ebe7; font-size: 12px; }
.chapter-nav { max-height: calc(100vh - 265px); overflow-y: auto; padding: 10px; scrollbar-color: #9cb8b2 transparent; }
.chapter-nav button { display: grid; width: 100%; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 9px; min-height: 51px; padding: 8px 9px; color: var(--ink-soft); background: transparent; border: 0; border-bottom: 1px solid #e5ebe8; cursor: pointer; text-align: left; }
.chapter-nav button:last-child { border-bottom: 0; }
.chapter-nav button:hover { background: #f3f7f5; }
.chapter-nav button.active { color: var(--ink); background: var(--mustard-pale); box-shadow: inset 4px 0 0 var(--mustard); }
.chapter-nav .nav-number { display: grid; width: 30px; height: 30px; place-items: center; color: var(--teal); background: var(--teal-pale); border-radius: 8px; font-size: 11px; font-weight: 900; }
.chapter-nav button.active .nav-number { color: var(--ink); background: var(--mustard); }
.chapter-nav .nav-label { min-width: 0; font-size: 13px; font-weight: 800; line-height: 1.35; }
.chapter-nav .nav-count { color: var(--muted); font-size: 10px; }
.chapter-select-label, .chapter-select { display: none; }

.reader { min-width: 0; }
.reader-toolbar { display: flex; align-items: end; gap: 12px; padding: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px rgb(23 52 59 / 6%); }
.search-box { display: block; min-width: 0; flex: 1; }
.search-box span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 11px; font-weight: 850; }
.search-box input { width: 100%; min-height: 48px; padding: 10px 14px; color: var(--ink); background: var(--white); border: 1px solid #aebeba; border-radius: 9px; font-size: 16px; }
.search-box input::placeholder { color: #889694; }
.view-switch { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; border: 1px solid #aebeba; border-radius: 9px; }
.view-switch button { min-height: 46px; padding: 8px 13px; background: var(--white); border: 0; cursor: pointer; font-size: 13px; font-weight: 800; }
.view-switch button + button { border-left: 1px solid #aebeba; }
.view-switch button.active { color: var(--white); background: var(--ink); }
.search-status { min-height: 26px; margin: 8px 3px 0; color: var(--muted); font-size: 12px; }

.chapter-header { position: relative; overflow: hidden; padding: clamp(28px, 4vw, 48px); color: var(--white); background: var(--ink); border-radius: 16px; }
.chapter-header::after { content: attr(data-number); position: absolute; right: 22px; bottom: -30px; color: rgb(255 255 255 / 8%); font-family: Georgia, serif; font-size: 140px; font-weight: 900; line-height: 1; }
.chapter-kicker { position: relative; z-index: 1; margin: 0 0 7px; color: #bad7d3; font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.chapter-header h2 { position: relative; z-index: 1; max-width: 740px; margin: 0; font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif; font-size: clamp(34px, 4vw, 54px); line-height: 1.2; }
.chapter-header > p:last-child { position: relative; z-index: 1; max-width: 780px; margin: 14px 0 0; color: #d7e6e3; font-size: 15px; }
.expression-box { margin-top: 15px; padding: 19px 20px; background: var(--mustard-pale); border-left: 5px solid var(--mustard); border-radius: 0 11px 11px 0; }
.expression-box h3 { margin: 0 0 10px; font-size: 16px; }
.expression-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px 18px; margin: 0; }
.expression-list div { min-width: 0; padding-top: 8px; border-top: 1px solid #dcc58c; }
.expression-list dt { color: var(--ink); font-weight: 850; }
.expression-list dd { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

.vocabulary-group { margin-top: 18px; padding: 22px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.group-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding-bottom: 11px; border-bottom: 1px solid var(--line); }
.group-heading h3 { margin: 0; font-size: 21px; }
.group-heading span { flex: 0 0 auto; color: var(--terracotta); font-size: 11px; font-weight: 900; }
.vocabulary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.vocab-card { min-width: 0; overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: 10px; }
.vocab-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 15px 10px; background: #f2f7f5; border-bottom: 1px solid #dce7e3; }
.vocab-card-head strong { color: #174f46; font-size: 19px; line-height: 1.35; }
.vocab-card-head span { flex: 0 0 auto; max-width: 108px; padding: 3px 7px; color: var(--muted); background: var(--white); border: 1px solid var(--line); border-radius: 999px; font-size: 9px; text-align: center; }
.vocab-card-body { padding: 12px 15px 14px; }
.vocab-meaning { margin: 0; color: var(--ink); font-weight: 800; }
.vocab-usage { margin: 8px 0 0; padding-top: 8px; color: var(--muted); border-top: 1px dashed var(--line); font-size: 12px; }
.vocab-usage .usage-label { color: var(--terracotta); font-weight: 850; }

.reader.list-view .vocabulary-grid { grid-template-columns: 1fr; gap: 0; }
.reader.list-view .vocab-card { display: grid; grid-template-columns: minmax(210px, .8fr) minmax(0, 1fr); border-width: 0 0 1px; border-radius: 0; }
.reader.list-view .vocab-card:first-child { border-top: 1px solid var(--line); }
.reader.list-view .vocab-card-head { align-items: center; background: transparent; border: 0; }
.reader.list-view .vocab-card-body { display: grid; grid-template-columns: minmax(150px, .55fr) minmax(0, 1fr); align-items: center; gap: 15px; }
.reader.list-view .vocab-usage { margin: 0; padding: 0; border: 0; }

.number-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.number-grid .vocab-card-head strong { font-size: 24px; }
.number-grid .vocab-meaning { color: var(--teal); font-size: 17px; }

.search-results-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 27px 30px; background: var(--ink); border-radius: 15px; color: var(--white); }
.search-results-header p { margin: 0 0 5px; color: #c2d8d4; font-size: 11px; font-weight: 900; letter-spacing: .13em; }
.search-results-header h2 { margin: 0; font-size: clamp(28px, 4vw, 42px); }
.search-results-header strong { color: var(--mustard); font-size: 18px; }
.result-context { margin: 0 0 7px; color: var(--terracotta); font-size: 10px; font-weight: 900; }
.load-more { display: flex; min-height: 48px; align-items: center; justify-content: center; margin: 18px auto 0; padding: 10px 20px; color: var(--white); background: var(--teal); border: 1px solid var(--teal); border-radius: 9px; cursor: pointer; font-weight: 850; }
.empty-results, .loading-panel { display: grid; min-height: 320px; place-content: center; justify-items: center; padding: 30px; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 15px; text-align: center; }
.empty-results strong, .loading-panel strong { color: var(--ink); font-size: 22px; }
.empty-results span, .loading-panel span { margin-top: 7px; }

.top-button { position: fixed; right: 22px; bottom: 22px; z-index: 70; display: none; min-height: 44px; padding: 9px 14px; color: var(--white); background: var(--ink); border: 1px solid #59757a; border-radius: 9px; cursor: pointer; font-size: 12px; font-weight: 850; box-shadow: 0 9px 24px rgb(23 52 59 / 20%); }
.top-button.visible { display: inline-flex; align-items: center; }
.site-footer { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 30px max(24px, calc((100vw - 1320px) / 2)); color: #d7e3e0; background: var(--ink); }
.site-footer p { margin: 0; font-size: 12px; }
.site-footer strong, .site-footer span { display: block; }
.site-footer strong { color: var(--white); font-size: 14px; }
.noscript { margin: 0; padding: 16px; color: #7f251f; background: #fbe4df; text-align: center; }

@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr .78fr; min-height: 610px; }
  .hero-copy { padding: 50px 42px; }
  .hero h1 { font-size: clamp(54px, 7vw, 74px); }
  .library { grid-template-columns: 260px minmax(0, 1fr); }
  .number-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 840px) {
  html { scroll-padding-top: 76px; }
  .site-header { min-height: 66px; padding-inline: 16px; }
  .site-brand small { display: none; }
  .site-header nav a { padding-inline: 8px; font-size: 12px; }
  main { padding: 20px 14px 64px; }
  .hero { grid-template-columns: 1fr; min-height: 0; }
  .hero-copy { order: 2; padding: 38px 30px 43px; }
  .hero h1 { font-size: clamp(47px, 12vw, 68px); }
  .hero-art { min-height: 430px; max-height: 58vh; }
  .hero-art img { object-position: 50% 57%; }
  .library { grid-template-columns: 1fr; }
  .chapter-panel { position: relative; top: auto; max-height: none; overflow: visible; }
  .chapter-panel-heading { padding: 19px; }
  .chapter-nav { display: none; }
  .chapter-select-label { display: block; padding: 13px 16px 5px; color: var(--muted); font-size: 11px; font-weight: 850; }
  .chapter-select { display: block; width: calc(100% - 28px); min-height: 48px; margin: 0 14px 14px; padding: 8px 10px; color: var(--ink); background: var(--white); border: 1px solid #aebeba; border-radius: 8px; }
  .chapter-header::after { font-size: 110px; }
}

@media (max-width: 620px) {
  body { font-size: 15px; }
  .site-header { gap: 10px; }
  .site-brand { min-width: 0; }
  .brand-mark { width: 38px; height: 38px; border-radius: 9px; font-size: 13px; }
  .site-brand strong { font-size: 13px; }
  .site-header nav a:first-child { display: none; }
  .hero-copy { padding: 32px 22px 36px; }
  .hero-art { height: 300px; min-height: 300px; max-height: 300px; }
  .hero-art img { object-position: 50% 55%; }
  .hero-art figcaption { right: 12px; bottom: 12px; width: calc(100% - 24px); max-width: none; }
  .hero-lead { margin-top: 20px; font-size: 16px; }
  .hero-stats { grid-template-columns: 1fr; margin-top: 24px; }
  .hero-stats div { display: grid; grid-template-columns: 95px minmax(0, 1fr); align-items: center; gap: 10px; padding: 11px 14px; border-top: 0; border-left: 4px solid var(--mustard); border-radius: 0 9px 9px 0; }
  .hero-stats div:nth-child(2) { border-left-color: var(--terracotta); }
  .hero-stats div:nth-child(3) { border-left-color: var(--teal); }
  .hero-stats span { margin: 0; }
  .hero-actions, .primary-action, .secondary-action { width: 100%; }
  .reader-toolbar { align-items: stretch; flex-direction: column; padding: 14px; }
  .view-switch { width: 100%; }
  .vocabulary-grid, .number-grid, .expression-list { grid-template-columns: 1fr; }
  .vocabulary-group { padding: 17px 14px; }
  .chapter-header { padding: 27px 21px; }
  .chapter-header h2 { font-size: 32px; }
  .chapter-header::after { right: 12px; font-size: 88px; }
  .vocab-card-head strong { font-size: 18px; }
  .reader.list-view .vocab-card { display: block; }
  .reader.list-view .vocab-card-body { display: block; }
  .reader.list-view .vocab-usage { margin-top: 7px; padding-top: 7px; border-top: 1px dashed var(--line); }
  .search-results-header { display: block; padding: 23px 21px; }
  .search-results-header strong { display: block; margin-top: 7px; }
  .top-button { right: 12px; bottom: 12px; }
  .site-footer { align-items: flex-start; flex-direction: column; padding: 27px 20px; }
}

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

@media print {
  .site-header, .hero-actions, .chapter-panel, .reader-toolbar, .top-button, .site-footer { display: none !important; }
  body, :root { color: #000; background: #fff; }
  main { width: 100%; padding: 0; }
  .hero { display: block; min-height: 0; box-shadow: none; border: 0; }
  .hero-art { display: none; }
  .hero-copy { padding: 20mm; }
  .library { display: block; margin: 0; }
  .reader { width: 100%; }
  .chapter-header, .vocabulary-group, .expression-box { break-inside: avoid; box-shadow: none; }
  .vocab-card { break-inside: avoid; }
}
