:root {
  color-scheme: light dark;
  --navy: #0b1e3f;
  --navy-2: #12305f;
  --bg: #f1f4f9;
  --card: #ffffff;
  --surface: #f5f7fb;
  --text: #14213d;
  --muted: #55607a;
  --accent: #0b57e3;
  --accent-contrast: #ffffff;
  --accent-soft: #e6eeff;
  --wotd: #c2410c;
  --wotd-soft: #fff1e6;
  --pill: #ffb703;
  --border: #dde3ee;
  --danger: #a11d2e;
  --hero: #dbe7ff;
  --shadow: 0 1px 2px rgba(11, 30, 63, .06), 0 8px 24px rgba(11, 30, 63, .07);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max: 72rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy: #08142b;
    --bg: #0d1220;
    --card: #151c2e;
    --surface: #1a2236;
    --text: #e8ebf2;
    --muted: #a3adc2;
    --accent: #7aa7ff;
    --accent-contrast: #0b1226;
    --accent-soft: #1d2a4a;
    --wotd: #ffb35c;
    --wotd-soft: #2a2016;
    --border: #27304a;
    --danger: #ff9aa6;
    --hero: #14213f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--sans);
}

main { flex: 1; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 1.25rem; }

a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 10;
  background: var(--accent); color: var(--accent-contrast);
  padding: .5rem 1rem; border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Header */
.site-header { background: var(--navy); color: #fff; }
.site-header :focus-visible, .site-footer :focus-visible { outline-color: #9ec1ff; }
.bar {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "logo nav" "search search";
  align-items: center;
  gap: .75rem 1rem;
  padding: .9rem 0 1rem;
}
.logo {
  grid-area: logo;
  display: inline-flex; align-items: center; gap: .6rem; justify-self: start;
  color: #fff; text-decoration: none;
  font: 700 1.1rem/1.15 var(--serif);
}
.logo img { display: block; border-radius: 9px; flex: none; }
.site-header nav { grid-area: nav; display: flex; gap: .15rem; }
.site-header nav a {
  color: #cfe0ff; text-decoration: none; font-weight: 600; font-size: .95rem;
  padding: .4rem .7rem; border-radius: 999px;
}
.site-header nav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.site-header nav a[aria-current="page"] { background: rgba(255, 255, 255, .18); color: #fff; }

.search { grid-area: search; position: relative; width: 100%; }
.search input {
  display: block; width: 100%;
  font: inherit; font-size: 1rem; line-height: 1.2;
  height: 42px; padding: 0 3.4rem 0 .9rem;
  color: #14213d; background: #fff;
  border: 1px solid transparent; border-radius: 5px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: #55607a; }
.search input:focus { outline: none; border-color: #6ea8ff; box-shadow: 0 0 0 3px rgba(110, 168, 255, .45); }
.search-btn {
  position: absolute; right: 0; top: 0; bottom: 0;
  display: grid; place-items: center;
  width: 46px; height: 42px; padding: 0; cursor: pointer;
  color: #fff; background: #0b57e3; border: 0; border-radius: 0 5px 5px 0;
}
.search-btn:hover { background: #0948bd; }
.search-btn svg { width: 1.2rem; height: 1.2rem; fill: currentColor; }

.tabs { display: flex; gap: .25rem; margin-top: -.25rem; }
.tabs a {
  padding: .65rem 1.15rem .55rem; color: #cfe0ff; text-decoration: none; font-weight: 700;
  border-bottom: 4px solid transparent;
}
.tabs a:hover { color: #fff; }
.tabs a[aria-current="true"] { color: #fff; border-bottom-color: #4d8dff; }

@media (min-width: 56rem) {
  .bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "logo search nav";
    gap: 2rem;
  }
  .logo { font-size: 1.2rem; }
  .search { max-width: 36rem; justify-self: center; }
}

/* Buttons */
.btn {
  display: inline-block; text-decoration: none;
  font: inherit; font-weight: 700; cursor: pointer;
  padding: .65rem 1.3rem;
  color: var(--accent-contrast); background: var(--accent);
  border: 2px solid var(--accent); border-radius: 999px;
}
.btn:hover { filter: brightness(1.1); }
.btn.wotd-btn { background: var(--wotd); border-color: var(--wotd); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.wotd-btn { color: #1b1206; } }

kbd {
  font: .8rem var(--sans); padding: .05rem .4rem;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--card);
}

/* Cards + sections */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.25rem 1.5rem; box-shadow: var(--shadow);
}
.card > h2, .section-title {
  margin: 0 0 .85rem; font: 800 1.05rem/1.2 var(--sans); letter-spacing: .01em;
}
.section { padding: 1.5rem 0 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.link-btn {
  font: inherit; font-size: .875rem; color: var(--accent);
  background: none; border: 0; padding: .25rem; cursor: pointer; text-decoration: underline;
}
.muted { color: var(--muted); }

/* Home */
.hero { background: linear-gradient(180deg, var(--hero), var(--bg)); padding: 2rem 0 .5rem; }
.hero h1 {
  margin: 0 0 .35rem;
  font: 700 clamp(1.8rem, 4.5vw, 2.6rem)/1.15 var(--serif); letter-spacing: -.01em;
}
.hero .intro { margin: 0 0 1.25rem; max-width: 40rem; color: var(--muted); font-size: 1.05rem; }
.hero .hint { margin: .85rem 0 0; font-size: .875rem; color: var(--muted); }

.wotd { border-top: 5px solid var(--wotd); padding: 1.5rem 1.75rem 1.75rem; }
.wotd-top { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin-bottom: .75rem; }
.card > h2.pill, .pill {
  margin: 0; display: inline-block; padding: .25rem .8rem; border-radius: 999px;
  background: var(--pill); color: #1b1f2a; font: 800 .8rem/1.3 var(--sans);
  letter-spacing: .06em; text-transform: uppercase;
}
.wotd-top time, .wotd .date { color: var(--muted); font-size: .9rem; }
.wotd .word { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1rem; font: 700 clamp(2.2rem, 6vw, 3.4rem)/1.1 var(--serif); }
.wotd .word a { color: var(--text); text-decoration: none; overflow-wrap: anywhere; }
.wotd .word a:hover { color: var(--wotd); }
.wotd .phon { color: var(--muted); font: 400 1.15rem var(--sans); }
.wotd .def { margin: .75rem 0 0; font-size: 1.2rem; max-width: 46rem; }
.wotd .pos { font-style: italic; font-weight: 700; color: var(--wotd); }
.wotd .more { margin-top: 1.1rem; }

.mini .word { margin: 0; font: 700 1.6rem/1.2 var(--serif); }
.mini .word a { color: var(--text); text-decoration: none; }
.mini .word a:hover { color: var(--accent); }
.mini .phon { color: var(--muted); font-size: .95rem; }
.mini .def { margin: .4rem 0 0; font-size: .95rem; }
.mini .pos { font-style: italic; font-weight: 700; color: var(--wotd); }
.mini .more { display: inline-block; margin-top: .6rem; font-weight: 700; font-size: .95rem; }
.side .wotd-mini { border-top: 4px solid var(--wotd); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); gap: 1.25rem; padding-top: 1.25rem; }
.grid2 .card { margin: 0; }

.rank { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.rank li { counter-increment: r; border-bottom: 1px solid var(--border); }
.rank li:last-child { border-bottom: 0; }
.rank a { display: flex; gap: .75rem; padding: .5rem 0; font-weight: 600; text-decoration: none; }
.rank a::before { content: counter(r); min-width: 1.4rem; color: var(--muted); font-weight: 700; }
.rank a:hover { text-decoration: underline; }

.letters { display: flex; flex-wrap: wrap; gap: .45rem; list-style: none; margin: 0; padding: 0; }
.letters a {
  display: grid; place-items: center; width: 2.6rem; height: 2.6rem;
  font-weight: 800; text-transform: uppercase; text-decoration: none;
  color: var(--accent); background: var(--card); border: 1px solid var(--border); border-radius: 10px;
}
.letters a:hover { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

.home-end { padding-bottom: 3rem; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 0; list-style: none; }
.chip {
  display: inline-block; padding: .3rem .85rem;
  color: var(--accent); background: var(--card);
  border: 1px solid var(--border); border-radius: 999px;
  text-decoration: none; font-size: .95rem; font-weight: 600;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* Word layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; padding: 1.5rem 0 3rem; align-items: start; }
.side { display: grid; gap: 1.25rem; }
@media (min-width: 60rem) {
  .layout { grid-template-columns: minmax(0, 1fr) 20rem; gap: 2rem; }
}

/* Entry */
#result {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.75rem 2rem 1.5rem; box-shadow: var(--shadow);
  min-width: 0;
}
.sub { margin: .35rem 0 0; color: var(--muted); }
.headword { font: 800 clamp(2.4rem, 7vw, 3.6rem)/1.05 var(--serif); margin: 0; letter-spacing: -.015em; overflow-wrap: anywhere; }
.phonetics { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: .85rem 0 0; padding: 0; list-style: none; }
.phonetics li { display: inline-flex; align-items: center; gap: .6rem; color: var(--muted); font-size: 1.15rem; }
.audio {
  display: inline-grid; place-items: center; flex: none;
  width: 2.5rem; height: 2.5rem; padding: 0; cursor: pointer;
  color: var(--accent-contrast); background: var(--accent);
  border: 0; border-radius: 50%;
}
.audio:hover { filter: brightness(1.12); }
.audio svg { width: 1.3rem; height: 1.3rem; fill: currentColor; }
.audio.on { box-shadow: 0 0 0 4px var(--accent-soft); }

.meaning { margin-top: 2rem; }
.meaning h2 {
  display: flex; align-items: center; gap: 1rem; margin: 0 0 .85rem;
  font: italic 700 1.35rem/1.2 var(--serif); color: var(--text);
}
.meaning h2::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.defs { margin: 0; padding-left: 1.7rem; }
.defs > li { margin-bottom: 1.1rem; padding-left: .3rem; }
.defs > li::marker { color: var(--text); font-weight: 800; }
.defs .def { margin: 0; font-size: 1.05rem; }
.defs .ex { margin: .35rem 0 0; color: var(--muted); font-style: italic; }
.rel { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .6rem; font-size: .9rem; }
.rel .label { color: var(--muted); font-weight: 700; margin-right: .25rem; }
.rel .chip { font-size: .85rem; padding: .15rem .7rem; }
.meaning > .rel {
  margin-top: 1rem; padding: .85rem 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
}
.meaning > .rel .chip { background: var(--card); }
.thes .rel { font-size: 1rem; }
.thes .rel .chip { font-size: .95rem; padding: .25rem .85rem; }

.sources { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .8rem; color: var(--muted); }
.sources p { margin: .25rem 0; overflow-wrap: anywhere; }

/* States */
.state { text-align: center; padding: 2rem 1rem; }
.state h2 { font: 700 1.6rem/1.2 var(--serif); margin: 0 0 .5rem; }
.state p { color: var(--muted); max-width: 32rem; margin: .5rem auto; }
.state .chips { justify-content: center; margin-top: 1rem; }
.state .btn { margin-top: 1rem; }
.state.error h2 { color: var(--danger); }

.skeleton .bar {
  height: 1rem; margin: .75rem 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--border) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton .bar.title { height: 3rem; width: 55%; }
.skeleton .bar.short { width: 35%; }
.skeleton .bar.mid { width: 80%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Text pages */
.pagewrap { padding-top: 1.75rem; padding-bottom: 3rem; }
.page { padding: 2rem 2.25rem 2.25rem; }
.page h1 { font: 700 clamp(2rem, 6vw, 2.6rem)/1.15 var(--serif); margin: 0 0 1rem; }
.page h2 { font: 700 1.35rem/1.3 var(--serif); margin: 2rem 0 .5rem; }
.page p, .page li { max-width: 42rem; }
.page .lead { font-size: 1.15rem; color: var(--muted); }

/* Footer */
.site-footer { background: var(--navy); color: #b9c8e6; padding: 2.5rem 0 1.25rem; font-size: .925rem; }
.site-footer a { color: #cfe0ff; }
.site-footer a:hover { color: #fff; }
.foot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 2rem; }
.foot-brand { grid-column: span 2; }
.foot-brand p { margin: .75rem 0 0; max-width: 24rem; }
.site-footer h2 { margin: 0 0 .6rem; color: #fff; font: 800 .8rem/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.foot-bottom { margin-top: 2rem; padding-top: 1.1rem; border-top: 1px solid rgba(255, 255, 255, .15); font-size: .85rem; }
.foot-bottom p { margin: .2rem 0; }

[hidden] { display: none !important; }

@media (max-width: 40rem) {
  .foot-brand { grid-column: 1 / -1; }
  #result { padding: 1.25rem 1.1rem 1.1rem; }
  .page { padding: 1.4rem 1.1rem 1.5rem; }
  .wotd { padding: 1.25rem 1.1rem 1.4rem; }
}
@media (max-width: 24rem) {
  .logo span { font-size: .95rem; }
  .site-header nav a { padding: .35rem .5rem; font-size: .9rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .skeleton .bar { animation: none; }
}
