:root {
  --bg: #0c0d0f;
  --panel: #111214;
  --panel-2: #15171a;
  --text: #e5e5e5;
  --text-dim: #9aa3b2;
  --accent: #c7d2fe;
  --accent-2: #e0e7ff;
  --border: #2a2a2a;
  --line: #1e1e1e;
  --font-ui: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, Arial, sans-serif;
  --font-word-accent: "Lilex", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { scrollbar-gutter: stable both-edges; overflow-y: scroll; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  line-height: 1.5;
}

.container { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1.5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-2); text-decoration: underline; }
.muted { color: var(--text-dim); }

.site-header {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  padding-top: 3.2rem;
}
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  background: linear-gradient(180deg, rgba(12,13,15,.96), rgba(12,13,15,.9));
  backdrop-filter: saturate(120%) blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: .65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand {
  font-family: var(--font-word-accent);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  text-decoration: none;
}
.brand:hover { color: var(--accent-2); text-decoration: none; }

.search-row { margin: 0; width: 100%; }
.search-controls {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.search-controls input[type="text"] {
  flex: 1 1 320px;
  min-width: 220px;
  background: #1a1c1f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: .6rem;
  padding: .65rem .95rem;
  font-size: 16px;
  outline: none;
}
.search-controls input[type="text"]:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}
.btn {
  padding: .56rem .9rem;
  border-radius: .6rem;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  color: var(--text);
  font-family: var(--font-ui);
  font-size: .92rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  background: linear-gradient(180deg, rgba(255,255,255,.09), rgba(255,255,255,.03));
}
.btn:disabled {
  opacity: .55;
  cursor: wait;
}
.btn--tiny {
  padding: .34rem .62rem;
  font-size: .82rem;
  border-radius: .5rem;
}

.pin-toggle {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  color: var(--text-dim);
  font-size: .86rem;
  user-select: none;
}
.pin-toggle input { accent-color: var(--accent); }

.typeahead {
  display: none;
  list-style: none;
  padding: 0;
  margin: .35rem 0 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .6rem;
  overflow: hidden;
  width: min(720px, 100%);
}
.typeahead__item { border-top: 1px solid var(--line); }
.typeahead__item--first { border-top: 0; }
.typeahead__link { display: block; padding: .6rem .8rem; color: var(--text); text-decoration: none; }
.typeahead__link:hover { background: var(--panel-2); }
.typeahead__line { font-weight: 700; }
.typeahead__pos { color: var(--text-dim); font-weight: 600; }
.typeahead__snip { color: var(--text-dim); margin-top: .1rem; font-size: .9rem; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .95rem 1rem;
}
.word-stack-shell { display: grid; gap: .85rem; }
.word-stack-empty h2 { margin: 0 0 .3rem; font-size: 1.02rem; }
.word-stack-empty p { margin: 0; }
.word-stack { display: grid; gap: .8rem; }
.word-stack .word-card {
  position: relative;
  background: linear-gradient(180deg, color-mix(in srgb, var(--panel) 90%, white 10%), var(--panel));
}
.word-stack .word-card:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -8px;
  height: 1px;
  background: color-mix(in srgb, var(--line) 84%, var(--text) 16%);
  opacity: .85;
}

.word-card { display: grid; gap: .75rem; }
.word-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .8rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: .5rem;
}
.word-card__term {
  margin: 0;
  font-family: var(--font-word-accent);
  font-size: 1.45rem;
  line-height: 1.15;
  color: var(--text);
}
.word-card__meta {
  margin-top: .2rem;
  color: var(--text-dim);
  font-size: .92rem;
}
.word-card__ipa {
  font-family: var(--font-word-accent);
  letter-spacing: .01em;
}
.word-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  justify-content: flex-end;
}
.btn--appreciate {
  border-color: color-mix(in srgb, var(--accent) 32%, var(--border));
}
.btn--appreciate.is-on {
  border-color: color-mix(in srgb, #34d399 58%, var(--border));
  background: color-mix(in srgb, #34d399 14%, transparent);
  color: #d1fae5;
}
.word-card__block { display: grid; gap: .35rem; }
.word-card__block h3 {
  margin: 0;
  font-size: .84rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.word-card__text {
  white-space: pre-wrap;
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}
.word-card__chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.word-card__chips span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .22rem .6rem;
  font-size: .86rem;
  color: var(--text-dim);
}
.word-card__toggle {
  justify-self: start;
}
.word-card__cta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}
.word-card__foot {
  border-top: 1px solid var(--line);
  padding-top: .45rem;
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  align-items: center;
  font-size: .82rem;
  color: var(--text-dim);
}
.word-card__saved {
  display: inline-flex;
  align-items: center;
  border: 1px solid color-mix(in srgb, #34d399 58%, var(--border));
  border-radius: 999px;
  padding: .12rem .46rem;
  color: #d1fae5;
  background: color-mix(in srgb, #34d399 14%, transparent);
}
.word-card__also { color: var(--text-dim); }
.word-card__also a { font-size: .82rem; }

.fineprint {
  max-width: 1100px;
  margin: 1.25rem auto 2rem;
  padding: 0 1.5rem;
  color: var(--text-dim);
  font-size: .85rem;
  text-align: center;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  background: rgba(17, 18, 20, .94);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: .45rem .65rem;
  z-index: 12000;
  font-size: .86rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 880px) {
  .word-card__head {
    flex-direction: column;
    align-items: flex-start;
  }
  .word-card__actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .site-header { padding-top: 5.45rem; }
  .topbar-content {
    align-items: flex-start;
    flex-direction: column;
    gap: .4rem;
  }
  .ecosystem-nav {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    padding-bottom: .1rem;
  }
  .container { padding: 1rem .9rem; }
  .search-controls input[type="text"] {
    min-width: 0;
    width: 100%;
    flex-basis: 100%;
  }
  .typeahead { width: 100%; }
}
