:root {
  --ink: #1a1f1c;
  --ink-soft: #3d4740;
  --mute: #6b756e;
  --paper: #e8ece7;
  --paper-deep: #d5dcd4;
  --jade: #1f6b56;
  --jade-deep: #154a3c;
  --seal: #b83228;
  --line: rgba(26, 31, 28, 0.12);
  --glow: rgba(31, 107, 86, 0.14);
  --radius: 2px;
  --font-brand: "ZCOOL XiaoWei", "Noto Serif SC", serif;
  --font-display: "Noto Serif SC", "Songti SC", serif;
  --font-body: "Noto Sans SC", "PingFang SC", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--paper);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.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;
}

/* Atmosphere */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(120% 80% at 50% -10%, #f4f7f3 0%, transparent 55%),
    linear-gradient(165deg, #eef2ec 0%, #dde5db 48%, #d0dad0 100%);
}

.wash {
  position: absolute;
  border-radius: 50%;
  filter: blur(48px);
  opacity: 0.55;
  animation: drift 18s var(--ease) infinite alternate;
}

.wash-a {
  width: min(70vw, 640px);
  height: min(70vw, 640px);
  top: -12%;
  right: -8%;
  background: radial-gradient(circle, rgba(31, 107, 86, 0.22), transparent 68%);
}

.wash-b {
  width: min(55vw, 480px);
  height: min(55vw, 480px);
  bottom: 5%;
  left: -10%;
  background: radial-gradient(circle, rgba(184, 50, 40, 0.1), transparent 70%);
  animation-delay: -6s;
  animation-duration: 22s;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-3%, 4%, 0) scale(1.06); }
}

/* Stage */
.stage {
  position: relative;
  z-index: 1;
  width: min(720px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: clamp(4.5rem, 16vh, 8rem) 0 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Brand */
.brand {
  text-align: center;
  margin-bottom: clamp(2rem, 5vh, 3rem);
  animation: rise 0.9s var(--ease) both;
}

.brand-mark {
  margin: 0 0 0.35rem;
  font-family: var(--font-brand);
  font-size: clamp(3.5rem, 10vw, 5.5rem);
  line-height: 1;
  color: var(--jade);
  letter-spacing: 0.08em;
  opacity: 0.18;
  user-select: none;
  animation: ink-in 1.2s var(--ease) both;
}

.brand-name {
  margin: -1.15rem 0 0.55rem;
  font-family: var(--font-brand);
  font-size: clamp(1.85rem, 7.4vw, 2.8rem);
  font-weight: 400;
  letter-spacing: 0.14em;
  text-indent: 0.14em;
  color: var(--ink);
  line-height: 1.15;
}

.brand-tagline {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--mute);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes ink-in {
  from { opacity: 0; transform: scale(0.92); filter: blur(6px); }
  to { opacity: 0.18; transform: scale(1); filter: blur(0); }
}

/* Search */
.search {
  width: 100%;
  animation: rise 0.9s var(--ease) 0.12s both;
}

.search-field {
  display: flex;
  gap: 0;
  align-items: stretch;
  border-bottom: 1.5px solid var(--ink);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.search-field:focus-within {
  border-color: var(--jade);
  box-shadow: 0 10px 28px -18px var(--glow);
}

.search-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 1rem 0.25rem 1rem 0;
  font: 500 1.125rem/1.4 var(--font-display);
  color: var(--ink);
  letter-spacing: 0.06em;
}

.search-field input::placeholder {
  color: var(--mute);
  font-weight: 400;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.search-btn {
  flex-shrink: 0;
  border: 0;
  background: var(--jade);
  color: #f5f8f5;
  padding: 0 1.35rem;
  margin-bottom: 1px;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.28em;
  text-indent: 0.28em;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s var(--ease);
}

.search-btn:hover:not(:disabled) {
  background: var(--jade-deep);
}

.search-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.search-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.search-hint {
  margin: 0.85rem 0 0;
  font-size: 0.8125rem;
  color: var(--mute);
  letter-spacing: 0.08em;
  min-height: 1.25em;
}

.search-hint.is-ready {
  color: var(--jade);
}

.search-hint.is-error {
  color: var(--seal);
}

/* Results */
.results {
  width: 100%;
  margin-top: clamp(2rem, 5vh, 3rem);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.results[hidden] {
  display: none;
}

.status-card {
  padding: 1.5rem 0;
  text-align: center;
  color: var(--mute);
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  animation: rise 0.5s var(--ease) both;
}

.idiom {
  padding: 1.5rem 0 1.75rem;
  border-top: 1px solid var(--line);
  animation: rise 0.55s var(--ease) both;
}

.idiom:first-child {
  border-top: 0;
  padding-top: 0.25rem;
}

.idiom-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem 1.25rem;
  margin-bottom: 1rem;
}

.idiom-word {
  margin: 0;
  font-family: var(--font-brand);
  font-size: clamp(1.75rem, 4.5vw, 2.25rem);
  font-weight: 400;
  letter-spacing: 0.2em;
  color: var(--ink);
  line-height: 1.2;
}

.idiom-pinyin {
  margin: 0;
  font-size: 0.95rem;
  color: var(--jade);
  letter-spacing: 0.06em;
  font-weight: 500;
}

.idiom-body {
  display: grid;
  gap: 0.85rem;
}

.field {
  margin: 0;
  display: grid;
  grid-template-columns: 3.2em 1fr;
  gap: 0.75rem;
  align-items: start;
}

.field dt {
  font-family: var(--font-display);
  font-size: 0.8125rem;
  color: var(--seal);
  letter-spacing: 0.18em;
  padding-top: 0.15em;
}

.field dd {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  text-align: justify;
}

.results-meta {
  margin: 0;
  padding-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--mute);
  letter-spacing: 0.06em;
  text-align: right;
}

@media (max-width: 560px) {
  .stage {
    width: min(100% - 1.75rem, 720px);
    padding-top: clamp(3.25rem, 12vh, 5.5rem);
  }

  .search-field {
    flex-direction: column;
    border-bottom: 0;
    gap: 0.75rem;
  }

  .search-field:focus-within {
    box-shadow: none;
  }

  .search-field input {
    border-bottom: 1.5px solid var(--ink);
    padding-right: 0;
  }

  .search-field:focus-within input {
    border-color: var(--jade);
  }

  .search-btn {
    width: 100%;
    padding: 0.85rem 1rem;
    letter-spacing: 0.4em;
    text-indent: 0.4em;
  }

  .field {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }
}

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