:root {
  --bg: #faf8f3;
  --surface: #ffffff;
  --text: #2a2a2a;
  --text-soft: #6b6b6b;
  --text-faint: #9a9a9a;
  --accent: #c8333e;
  --accent-soft: #f5dee0;
  --pinyin: #b08850;
  --border: #ece8df;
  --shadow-sm: 0 1px 2px rgba(20, 14, 6, 0.04);
  --shadow-md: 0 1px 3px rgba(20, 14, 6, 0.04), 0 6px 16px rgba(20, 14, 6, 0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.han {
  font-family: "Noto Sans SC", "Noto Sans TC", "PingFang SC", "Microsoft YaHei",
    "Hiragino Sans GB", "Source Han Sans SC", sans-serif;
  font-feature-settings: "palt" 1;
}

.accent { color: var(--accent); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
  text-align: center;
  padding: 4rem 1.5rem 1.5rem;
}

header h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 0.4rem;
}

header h1 .han {
  margin-right: 0.5rem;
  font-weight: 500;
}

.tagline {
  color: var(--text-soft);
  font-size: 0.95rem;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.25rem 4rem;
}

.search-bar {
  position: sticky;
  top: 0.75rem;
  z-index: 10;
  margin: 1.5rem 0 1rem;
}

#q {
  display: block;
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

#q::placeholder { color: var(--text-faint); }

#q:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
}

.status {
  color: var(--text-soft);
  font-size: 0.85rem;
  padding: 0 0.25rem;
  margin: 0.25rem 0 1rem;
  min-height: 1.2em;
}

.results { list-style: none; }

.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.entry:hover {
  box-shadow: var(--shadow-md);
}

.entry-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.6rem 0.85rem;
  margin-bottom: 0.5rem;
}

.entry-simp {
  font-size: 1.85rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.entry-trad {
  font-size: 1.2rem;
  color: var(--text-soft);
  font-weight: 400;
}

.entry-trad-divider {
  color: var(--text-faint);
  font-size: 1rem;
}

.entry-trad.same { display: none; }
.entry-trad.same + .entry-trad-divider { display: none; }

.entry-pinyin {
  color: var(--pinyin);
  font-style: italic;
  font-size: 1.05rem;
  margin-bottom: 0.55rem;
  font-feature-settings: "ss01";
}

.entry-defs {
  list-style: none;
  counter-reset: def;
}

.entry-defs li {
  counter-increment: def;
  padding-left: 1.5rem;
  position: relative;
  margin-bottom: 0.2rem;
  color: var(--text);
  line-height: 1.55;
}

.entry-defs li::before {
  content: counter(def) ".";
  position: absolute;
  left: 0;
  color: var(--text-faint);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  top: 0.15em;
}

.empty {
  text-align: center;
  color: var(--text-soft);
  padding: 3rem 1rem;
  font-size: 0.95rem;
}

footer {
  text-align: center;
  padding: 2rem 1.5rem 3rem;
  color: var(--text-soft);
  font-size: 0.8rem;
}

footer a {
  color: var(--text-soft);
  text-decoration: underline;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}
footer a:hover { color: var(--accent); text-decoration-color: var(--accent-soft); }

@media (max-width: 480px) {
  header { padding: 2.5rem 1rem 1.25rem; }
  main { padding: 0 1rem 3rem; }
  .entry { padding: 1rem 1.15rem; }
  .entry-simp { font-size: 1.65rem; }
  .entry-trad { font-size: 1.1rem; }
}
