:root {
  --bg: #0b0f14;
  --panel: rgba(12, 17, 23, 0.78);
  --panel-solid: #0e141b;
  --line: rgba(148, 168, 190, 0.18);
  --line-strong: rgba(200, 170, 110, 0.42);
  --gold: #c8aa6e;
  --gold-bright: #e4c78d;
  --ink: #eef2f7;
  --ink-dim: #9aa7b6;
  --ink-faint: #6c7a8a;
  --link: #63c9ff;
  --radius: 12px;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); }

/* ---------- background artwork ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.stage__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity 700ms ease;
  filter: saturate(0.9) contrast(1.02);
}

.stage__art.is-on { opacity: 0.55; }

.stage__scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(11, 15, 20, 0.42) 0%, rgba(11, 15, 20, 0.9) 62%, rgba(11, 15, 20, 0.98) 100%),
    linear-gradient(180deg, rgba(11, 15, 20, 0.55) 0%, rgba(11, 15, 20, 0.86) 46%, rgba(9, 12, 16, 0.98) 100%);
}

/* ---------- layout ---------- */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  align-content: center;
  gap: 26px;
  min-height: 100vh;
  min-height: 100dvh;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 26px 20px 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: #16110a;
  background: linear-gradient(160deg, var(--gold-bright), var(--gold));
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.brand__mark svg { width: 19px; height: 19px; }

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand__text strong {
  font-size: 0.9375rem;
  letter-spacing: 0.06em;
}

.brand__text span {
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.modes {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(9, 13, 18, 0.72);
}

.mode {
  appearance: none;
  border: 0;
  border-radius: 7px;
  padding: 7px 13px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-dim);
  background: transparent;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}

.mode:hover { background: rgba(255, 255, 255, 0.06); color: var(--ink); }

.mode[aria-current="true"] {
  color: #16110a;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
}

/* ---------- search ---------- */
.finder { display: grid; gap: 16px; }

.finder__title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.25;
  font-weight: 700;
}

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 62px;
  padding: 0 8px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.45);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field:focus-within {
  border-color: var(--gold);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(200, 170, 110, 0.18);
}

.field__icon {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--ink-faint);
}

.field__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.0625rem;
  outline: none;
}

.field__input::placeholder { color: var(--ink-faint); }

.field__submit {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 46px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #16110a;
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  cursor: pointer;
  transition: filter 160ms ease;
}

.field__submit:hover { filter: brightness(1.06); }
.field__submit svg { width: 17px; height: 17px; }

/* ---------- meta row ---------- */
.meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meta__status {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-faint);
}

.meta__tools {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.keys { display: inline-flex; gap: 4px; }

.keys kbd {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink-faint);
  font-family: var(--font);
  font-size: 0.6875rem;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.8125rem;
  color: var(--ink-dim);
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle__track {
  display: inline-flex;
  align-items: center;
  width: 34px;
  height: 19px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: background 160ms ease;
}

.toggle__thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #cfd8e3;
  transition: transform 160ms ease, background 160ms ease;
}

.toggle input:checked + .toggle__track { background: rgba(200, 170, 110, 0.55); }
.toggle input:checked + .toggle__track .toggle__thumb { transform: translateX(15px); background: #fff6e4; }
.toggle input:focus-visible + .toggle__track { box-shadow: 0 0 0 3px rgba(200, 170, 110, 0.28); }

/* ---------- results ---------- */
.results {
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  backdrop-filter: blur(10px);
  max-height: min(46vh, 420px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.results[hidden] { display: none; }

.result {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms ease;
}

.result + .result { margin-top: 2px; }
.result:hover { background: rgba(255, 255, 255, 0.04); }

.result[aria-selected="true"] {
  background: rgba(200, 170, 110, 0.14);
  box-shadow: inset 0 0 0 1px rgba(200, 170, 110, 0.34);
}

.result__art {
  width: 44px;
  height: 44px;
  border-radius: 7px;
  object-fit: cover;
  background: #1a222c;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.result__body { min-width: 0; display: grid; gap: 3px; }

.result__name {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.result__cn {
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
}

.result__en {
  font-size: 0.75rem;
  color: var(--ink-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.tag {
  padding: 1px 7px;
  border: 1px solid rgba(200, 170, 110, 0.3);
  border-radius: 999px;
  font-size: 0.6875rem;
  color: var(--gold-bright);
  background: rgba(200, 170, 110, 0.08);
  white-space: nowrap;
}

.tag--muted {
  border-color: var(--line);
  color: var(--ink-faint);
  background: transparent;
}

.result__path {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.6875rem;
  color: var(--link);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 140ms ease, max-height 140ms ease;
  word-break: break-all;
}

.result[aria-selected="true"] .result__path {
  opacity: 1;
  max-height: 2.4em;
}

.empty {
  padding: 22px 14px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--ink-dim);
}

.empty code {
  font-family: var(--mono);
  color: var(--gold-bright);
}

/* ---------- footer / plain pages ---------- */
.footer {
  position: relative;
  z-index: 1;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 0 20px 26px;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.footer p { margin: 0; }

.page-plain { display: grid; place-items: center; }

.plain {
  width: min(100%, 560px);
  margin: 12vh auto;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-solid);
}

.plain h1 { margin: 0 0 10px; font-size: 1.375rem; }
.plain p { color: var(--ink-dim); font-size: 0.875rem; }

.plain__list {
  margin: 16px 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

@media (max-width: 640px) {
  .app { gap: 20px; padding: 20px 16px 26px; }
  .finder__title { font-size: 1.375rem; }
  .field { height: 58px; }
  .field__submit { padding: 0 13px; }
  .field__submit span { display: none; }
  .field__submit svg { width: 20px; height: 20px; }
  .meta { flex-direction: column; align-items: flex-start; gap: 8px; }
  .meta__tools { width: 100%; justify-content: space-between; }
  .results { max-height: 52vh; }
  .result { grid-template-columns: 40px minmax(0, 1fr); }
  .result__art { width: 40px; height: 40px; }
  .result__tags { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
