@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;500;600;700;900&family=Playfair+Display:ital,wght@1,700&display=swap');

:root {
  --paper: #f7f2e8;
  --paper-deep: #eee5d4;
  --ink: #172b35;
  --muted: #657177;
  --orange: #e85f32;
  --orange-dark: #c84924;
  --line: rgba(23, 43, 53, .17);
  --white: #fffdf8;
  --shadow: 0 24px 65px rgba(38, 49, 47, .10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans TC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .34;
  z-index: -1;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 220 220' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
}
.site-header {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 27px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 800; letter-spacing: .08em; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 50%; color: var(--paper); background: var(--ink); font-size: 16px; }
.header-note { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .18em; }
main { width: min(920px, calc(100% - 40px)); margin: 0 auto; }
.hero { padding: clamp(78px, 11vw, 130px) 0 68px; text-align: center; }
.eyebrow { margin: 0 0 20px; color: var(--orange); font-size: 12px; font-weight: 800; letter-spacing: .24em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(48px, 8vw, 82px); font-weight: 900; line-height: 1.12; letter-spacing: -.055em; }
h1 em { color: var(--orange); font-family: "Playfair Display", "Noto Serif TC", serif; font-weight: 700; }
.intro { width: min(590px, 100%); margin: 26px auto 36px; color: var(--muted); font-size: 16px; line-height: 1.9; }
.search-shell {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 12px;
  align-items: center;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 8px 8px 8px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--white);
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.search-shell:focus-within { border-color: var(--orange); box-shadow: 0 24px 65px rgba(232, 95, 50, .14); }
.search-icon { color: var(--orange); font-size: 27px; line-height: 1; transform: rotate(-20deg); }
.search-shell input { width: 100%; min-width: 0; padding: 14px 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 17px; }
.search-shell input::placeholder { color: #9ca2a1; }
.search-shell button {
  border: 0;
  border-radius: 12px;
  padding: 14px 23px;
  color: white;
  background: var(--orange);
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .2s;
}
.search-shell button:hover { background: var(--orange-dark); transform: translateY(-1px); }
.quick-words { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 19px; color: var(--muted); font-size: 12px; }
.quick-words button { padding: 0; border: 0; border-bottom: 1px solid #b5afa4; background: transparent; cursor: pointer; }
.quick-words button:hover { color: var(--orange); border-color: var(--orange); }
.status { min-height: 0; text-align: center; }
.status:not(:empty) { margin: -24px 0 45px; }
.loader { display: inline-flex; align-items: center; gap: 12px; color: var(--muted); }
.loader::before { content: ""; width: 19px; height: 19px; border: 2px solid var(--line); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; }
.error { display: inline-block; max-width: 600px; padding: 17px 22px; border: 1px solid rgba(232,95,50,.25); border-radius: 12px; color: #8d351c; background: rgba(255,255,255,.5); }
@keyframes spin { to { transform: rotate(360deg); } }
.result-card { margin-bottom: 52px; padding: clamp(28px, 6vw, 58px); border: 1px solid var(--line); border-radius: 25px; background: rgba(255,253,248,.8); box-shadow: var(--shadow); animation: rise .42s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.result-top { display: flex; justify-content: space-between; gap: 25px; padding-bottom: 35px; border-bottom: 1px solid var(--line); }
.translation { margin: 0 0 5px; color: var(--orange); font-size: 17px; font-weight: 700; }
.word-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 14px; }
.word-line h2 { margin: 0; font-size: clamp(38px, 7vw, 62px); line-height: 1.15; letter-spacing: -.04em; }
.phonetic { color: var(--muted); font-size: 16px; }
.speak-button { align-self: center; display: flex; align-items: center; gap: 10px; padding: 13px 18px; border: 1px solid var(--ink); border-radius: 999px; background: transparent; font-weight: 700; cursor: pointer; transition: color .2s, background .2s; }
.speak-button:hover, .speak-button.playing { color: var(--paper); background: var(--ink); }
.sound-bars { display: flex; align-items: center; gap: 2px; height: 15px; }
.sound-bars i { display: block; width: 2px; border-radius: 2px; background: currentColor; }
.sound-bars i:nth-child(1) { height: 7px; }.sound-bars i:nth-child(2) { height: 14px; }.sound-bars i:nth-child(3) { height: 9px; }
.playing .sound-bars i { animation: bars .55s ease-in-out infinite alternate; }
.playing .sound-bars i:nth-child(2) { animation-delay: -.2s; }.playing .sound-bars i:nth-child(3) { animation-delay: -.35s; }
@keyframes bars { to { height: 4px; } }
.meaning { display: grid; grid-template-columns: 130px 1fr; gap: 28px; padding: 34px 0; border-bottom: 1px solid var(--line); }
.meaning:last-child { padding-bottom: 10px; border: 0; }
.part-of-speech { color: var(--orange); font-family: "Playfair Display", serif; font-size: 17px; font-style: italic; }
.definition-list { margin: 0; padding-left: 22px; }
.definition-list li { padding-left: 8px; margin-bottom: 24px; line-height: 1.75; }
.definition-list li:last-child { margin-bottom: 0; }
.definition-list li::marker { color: var(--orange); font-weight: 700; }
.zh-definition { margin: 0 0 5px; font-weight: 600; }
.en-definition { margin: 0; color: var(--muted); font-size: 13px; }
.example { margin: 10px 0 0; padding-left: 13px; border-left: 2px solid var(--paper-deep); color: #59666b; font-size: 13px; font-style: italic; }
.source-note { margin-top: 25px; color: var(--muted); font-size: 11px; text-align: right; }
.source-note a { color: inherit; }
.recent { margin: 75px 0 100px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 20px; }
.section-heading button { padding: 0; border: 0; color: var(--muted); background: transparent; font-size: 12px; cursor: pointer; }
.recent-list { display: flex; flex-wrap: wrap; gap: 10px; }
.recent-list button { padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.38); cursor: pointer; transition: border-color .2s, transform .2s; }
.recent-list button:hover { border-color: var(--orange); transform: translateY(-2px); }
footer { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 30px 0 40px; display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
footer span { color: var(--orange); }
.credits { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 640px) {
  .site-header, main, footer { width: min(100% - 28px, 920px); }
  .site-header { padding: 18px 0; }
  .hero { padding: 68px 0 50px; }
  h1 { font-size: clamp(43px, 13vw, 58px); }
  .intro { font-size: 14px; }
  .search-shell { grid-template-columns: 22px 1fr; padding: 8px 9px 8px 16px; }
  .search-shell button { grid-column: 1 / -1; width: 100%; }
  .search-icon { font-size: 22px; }
  .result-top { align-items: flex-end; }
  .speak-button span:last-child { display: none; }
  .speak-button { padding: 14px; }
  .meaning { grid-template-columns: 1fr; gap: 12px; }
  footer { display: block; }
  .credits { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
