:root {
  --paper: #f3f5f7;
  --surface: #ffffff;
  --ink: #1b2430;
  --ink-soft: #4e5a68;
  --rule: #d5dbe2;
  --voice: #2f4bd8;
  --voice-ink: #ffffff;
  --verified: #1f7a5a;
  --estimate: #b9771a;
  --estimate-bg: #fbf1df;
  --focus: #2f4bd8;
  --font-ui: "Andika", "Segoe UI", system-ui, sans-serif;
  --font-ipa: "Gentium Book Plus", "Gentium Plus", "Charis SIL", "Doulos SIL", "Noto Serif", Georgia, serif;
  --measure: 46rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121820;
    --surface: #1a222c;
    --ink: #e6eaf0;
    --ink-soft: #a5b0bd;
    --rule: #2c3743;
    --voice: #8fa2ff;
    --voice-ink: #0e1430;
    --verified: #5fc39b;
    --estimate: #e8b45a;
    --estimate-bg: #2b2416;
    --focus: #8fa2ff;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 1.0625rem/1.55 var(--font-ui);
}
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 3.5rem) 1rem 9rem;
}

/* Kopf */
.masthead h1 {
  font-family: var(--font-ipa);
  font-weight: 400;
  font-size: clamp(2.1rem, 6vw, 3.2rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem;
  max-width: 14em;
}
.lede { margin: 0 0 1.75rem; color: var(--ink-soft); max-width: 36em; }

/* Suche */
.search { display: flex; gap: 0.5rem; align-items: stretch; }
.combo { position: relative; flex: 1; min-width: 0; }
.search input {
  width: 100%;
  font: 1.35rem/1.2 var(--font-ipa);
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  appearance: none;
}
.search input::placeholder { color: color-mix(in srgb, var(--ink-soft) 70%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.btn-search {
  font: 700 1rem var(--font-ui);
  border: 0;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  padding: 0 1.1rem;
  cursor: pointer;
}
.btn-search:hover { background: color-mix(in srgb, var(--ink) 85%, var(--voice)); }
@media (max-width: 30rem) {
  .search { flex-direction: column; }
  .btn-search { padding: 0.8rem; }
}
.suggestions {
  position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px);
  margin: 0; padding: 0.3rem; list-style: none;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  box-shadow: 0 10px 30px color-mix(in srgb, var(--ink) 14%, transparent);
  max-height: 60vh; overflow: auto;
}
.suggestions li {
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
  padding: 0.5rem 0.65rem; border-radius: 7px; cursor: pointer;
}
.suggestions li[aria-selected="true"], .suggestions li:hover { background: color-mix(in srgb, var(--voice) 12%, transparent); }
.s-name { font-family: var(--font-ipa); font-size: 1.15rem; }
.s-kind { font-size: 0.85rem; color: var(--ink-soft); white-space: nowrap; }
.hint { min-height: 1.4em; margin: 0.5rem 0 0; font-size: 0.92rem; color: var(--ink-soft); }

/* Einträge */
#results { margin-top: 1.5rem; }
.entry { margin: 0 0 3rem; }
.entry-head { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; }
.headword {
  font-family: var(--font-ipa);
  font-weight: 700;
  font-size: clamp(2rem, 5.5vw, 2.6rem);
  line-height: 1.1;
  margin: 0;
}
.role { color: var(--ink-soft); font-size: 0.95rem; }
.kurzinfo { margin: 0.35rem 0 1rem; max-width: 38em; }
.kurzinfo:empty { display: none; }

.variants { list-style: none; margin: 0; padding: 0; }
.variant {
  display: grid;
  grid-template-columns: 9.5rem 1fr;
  gap: 0.25rem 1.25rem;
  padding: 1rem 0 1.1rem 1rem;
  border-left: 4px solid var(--verified);
  margin-bottom: 0.9rem;
  background: var(--surface);
  border-radius: 0 10px 10px 0;
}
.variant.is-estimate {
  border-left: 4px dashed var(--estimate);
  background: repeating-linear-gradient(135deg, var(--surface) 0 12px, color-mix(in srgb, var(--estimate-bg) 75%, var(--surface)) 12px 24px);
}
.is-estimate .v-de, .is-partial .v-de { color: var(--ink-soft); }
.is-estimate .v-de::before, .is-partial .v-de::before { content: "≈ "; color: var(--estimate); font-weight: 700; }
.is-estimate .v-source {
  align-self: flex-start; font-weight: 700; color: var(--ink);
  background: var(--estimate-bg); box-shadow: inset 0 0 0 1.5px var(--estimate);
  border-radius: 999px; padding: 0.05rem 0.55rem;
}
.is-partial .v-source { color: var(--estimate); }
.ki-block { margin: 1.6rem 0 0; }
.ki-pending {
  display: flex; align-items: center; gap: 0.6rem;
  margin: 0.6rem 0 0; font-size: 0.95rem; color: var(--estimate); font-weight: 700;
}
.ki-pending::before {
  content: ""; width: 0.9em; height: 0.9em; border-radius: 50%; flex: none;
  border: 2.5px solid color-mix(in srgb, var(--estimate) 25%, transparent);
  border-top-color: var(--estimate);
  animation: spin 0.8s linear infinite;
}
.ki-pending[hidden] { display: none; }
.ki-title { font-size: 1.05rem; margin: 0 0 0.35rem; color: var(--estimate); }
.ki-title::before { content: "≈ "; }
.ki-warn { margin: 0 0 0.9rem; font-size: 0.92rem; color: var(--ink-soft); max-width: 38em; }
.ki-block.is-only { margin-top: 0.4rem; }
.ki-block.is-only .ki-warn { background: var(--estimate-bg); color: var(--ink); border-radius: 10px; padding: 0.7rem 0.9rem; }
.ki-block[hidden] { display: none; }
.variant.is-unsure .v-source::after { content: ""; }
.variant.is-picked { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--voice) 55%, transparent); }
@media (max-width: 34rem) {
  .variant { grid-template-columns: 1fr; padding-right: 0.9rem; }
}
.v-lang { display: flex; flex-direction: column; gap: 0.15rem; }
.v-langname { font-weight: 700; }
.v-source { font-size: 0.85rem; color: var(--verified); }
.v-freq { font-size: 0.85rem; color: var(--ink-soft); }
.v-main { min-width: 0; padding-right: 1rem; }

.ipa { font-family: var(--font-ipa); }
.v-ipa-line { margin: 0 0 0.55rem; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.2rem 0.7rem; }
.v-de {
  font-family: var(--font-ipa);
  font-size: clamp(1.7rem, 5vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}
.v-de.ipa { letter-spacing: 0; }
.sx { text-decoration: underline dotted; text-decoration-thickness: 2px; text-underline-offset: 0.18em; text-decoration-color: var(--estimate); cursor: help; }
.v-ipa { font-size: 1.05rem; color: var(--ink-soft); }
.v-notes { list-style: none; margin: 0 0 0.6rem; padding: 0; font-size: 0.88rem; color: var(--ink-soft); }
.v-notes li { padding-left: 0.9rem; position: relative; margin: 0.1rem 0; }
.v-notes li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 0.4rem; height: 2px; background: var(--estimate); }
.v-notes[hidden] { display: none; }
.v-ipa-label { font-size: 0.85rem; color: var(--ink-soft); }
.v-herkunft { margin: 0.6rem 0 0; color: var(--ink-soft); max-width: 36em; }
.v-herkunft:empty { display: none; }

.v-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }

/* Abspielknöpfe – das zentrale Bedienelement */
.play {
  --ring: var(--voice);
  display: inline-flex; align-items: center; gap: 0.45rem;
  font: 700 0.95rem var(--font-ui);
  border: 0; border-radius: 999px;
  padding: 0.45rem 0.95rem 0.45rem 0.7rem;
  background: var(--voice); color: var(--voice-ink);
  cursor: pointer; position: relative;
}
.play-icon {
  width: 0; height: 0;
  border-left: 0.62em solid currentColor;
  border-top: 0.38em solid transparent;
  border-bottom: 0.38em solid transparent;
}
.play-slow, .play-rec {
  background: transparent; color: var(--voice);
  box-shadow: inset 0 0 0 1.5px var(--voice);
  padding-left: 0.85rem;
}
.play-rec .play-icon { border-left-color: var(--voice); }
.play.is-loading { opacity: 0.7; cursor: progress; }
.play.is-playing::after {
  content: ""; position: absolute; inset: -4px; border-radius: inherit;
  box-shadow: 0 0 0 2px var(--ring);
  animation: pulse 1s ease-out infinite;
}
@keyframes pulse { from { opacity: 0.9; transform: scale(1); } to { opacity: 0; transform: scale(1.12); } }
@media (prefers-reduced-motion: reduce) { .play.is-playing::after { animation: none; opacity: 0.8; } }

.v-more { margin-top: 0.6rem; font-size: 0.92rem; }
.v-more summary, .rules summary { cursor: pointer; color: var(--ink-soft); }
.v-more-body { padding: 0.4rem 0 0; }
.v-more-body p { margin: 0.3rem 0; }
.v-more-body .ipa { font-size: 1.15rem; }
.v-pick { display: inline-flex; gap: 0.4rem; align-items: center; margin-top: 0.6rem; font-size: 0.9rem; color: var(--ink-soft); cursor: pointer; }
.v-pick[hidden] { display: none; }

.also { font-size: 0.92rem; color: var(--ink-soft); margin: 0.2rem 0 0.8rem; }
.also:empty { display: none; }
.rules { margin: 0.5rem 0 0; font-size: 0.95rem; }
.rules-body { padding: 0.6rem 0 0; display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.rules-body label { display: inline-flex; gap: 0.4rem; align-items: center; }
.rules-body select, .btn-small {
  font: 0.95rem var(--font-ui); color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--rule); border-radius: 8px; padding: 0.35rem 0.6rem;
}
.btn-small { cursor: pointer; border-color: var(--ink-soft); }
.rules-out { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; }
.rules-de { font-family: var(--font-ipa); font-size: 1.6rem; letter-spacing: 0.02em; }
.rules-ipa { color: var(--ink-soft); }
.rules-out .v-notes { flex-basis: 100%; }
.fineprint { flex-basis: 100%; margin: 0; font-size: 0.85rem; color: var(--ink-soft); }
.entry-foot { font-size: 0.85rem; color: var(--ink-soft); margin: 0.8rem 0 0; }
.entry-foot:empty { display: none; }

.notice {
  background: var(--estimate-bg); border-radius: 10px; padding: 0.7rem 0.9rem; margin: 0 0 1rem; font-size: 0.95rem;
}
/* Ladezustand */
.btn-search { display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem; }
.btn-search.is-busy { cursor: progress; background: color-mix(in srgb, var(--ink) 80%, var(--voice)); }
.spinner {
  width: 1em; height: 1em; border-radius: 50%;
  border: 2.5px solid color-mix(in srgb, var(--paper) 35%, transparent);
  border-top-color: var(--paper);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.load-status {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 700; color: var(--voice);
  margin: 0 0 0.7rem;
}
.load-status::before {
  content: ""; width: 0.9em; height: 0.9em; border-radius: 50%; flex: none;
  border: 2.5px solid color-mix(in srgb, var(--voice) 25%, transparent);
  border-top-color: var(--voice);
  animation: spin 0.8s linear infinite;
}
.variant.skeleton { border-left-color: var(--rule); }
.skeleton .v-main, .skeleton .v-lang { display: flex; flex-direction: column; gap: 0.6rem; }
.bar {
  display: block; height: 0.9rem; border-radius: 6px;
  background: linear-gradient(90deg, var(--rule) 0%, color-mix(in srgb, var(--rule) 40%, var(--surface)) 50%, var(--rule) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
.bar-xs { width: 45%; height: 0.7rem; }
.bar-s { width: 70%; }
.bar-l { width: 55%; height: 2rem; }
.bar-m { width: 80%; }
.bar-btn { width: 9rem; height: 2rem; border-radius: 999px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.entry.is-loading .headword { color: var(--ink-soft); }
.entry.is-loading .rules { display: none; }
@media (prefers-reduced-motion: reduce) {
  .spinner, .load-status::before { animation-duration: 2.4s; }
  .bar { animation: none; }
}
.empty { color: var(--ink-soft); }

/* Leiste „Ganzer Name“ */
.fullbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--ink); color: var(--paper);
  padding: 0.7rem 1rem calc(0.7rem + env(safe-area-inset-bottom));
}
.fullbar-inner { max-width: var(--measure); margin: 0 auto; display: flex; align-items: center; gap: 1rem; justify-content: space-between; flex-wrap: wrap; }
.fullbar-text { display: flex; flex-direction: column; min-width: 0; }
.fullbar-label { font-size: 0.8rem; opacity: 0.75; }
.fullbar-de { font-family: var(--font-ipa); font-size: 1.45rem; line-height: 1.2; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.fullbar-ipa { font-size: 0.9rem; opacity: 0.75; overflow-wrap: anywhere; }
.fullbar-src { font-size: 0.8rem; opacity: 0.75; }
.v-recnote { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--ink-soft); }
.fullbar-actions { display: flex; gap: 0.45rem; }
.fullbar .play { --voice: var(--paper); --voice-ink: var(--ink); }
.fullbar .play-slow { color: var(--paper); box-shadow: inset 0 0 0 1.5px var(--paper); background: transparent; }

.colophon { margin-top: 4rem; font-size: 0.88rem; color: var(--ink-soft); max-width: 40em; }
.colophon p { margin: 0 0 0.7rem; }
