/* Layout: schmale Kopfzeile, darunter ein Arbeitsbereich mit Spalten (Text | Übersetzung | Wortanalyse),
   die auf schmalen Bildschirmen untereinander stehen. Farben: Dolomitenkalk, Blau/Grün der ladinischen Fahne,
   „Enrosadira“-Rosa nur als Markierung für angeklickte Wörter. */
:root {
  --bg: #eef1f3;
  --surface: #ffffff;
  --surface-2: #f6f8f9;
  --ink: #18212b;
  --muted: #5a6875;
  --line: #d5dce2;
  --accent: #1d5c99;
  --accent-ink: #ffffff;
  --green: #2c7347;
  --rose: #f4dde1;
  --rose-ink: #8a2f45;
  --warn-bg: #fff4dc;
  --warn-ink: #7a5300;
  --error-bg: #fde7e7;
  --error-ink: #9b1c1c;

  --font-ui: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --font-text: "Spectral", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --radius: 10px;
  --shadow: 0 1px 2px rgb(24 33 43 / 6%), 0 4px 16px rgb(24 33 43 / 5%);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11161c; --surface: #19212a; --surface-2: #1e2731; --ink: #e5ebf0; --muted: #94a3b0; --line: #2c3743;
    --accent: #6ea8e2; --accent-ink: #0d1520; --green: #72c493; --rose: #4a2832; --rose-ink: #f2b8c6;
    --warn-bg: #3a2f14; --warn-ink: #f3cf7a; --error-bg: #3d1a1a; --error-ink: #f6a6a6;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11161c; --surface: #19212a; --surface-2: #1e2731; --ink: #e5ebf0; --muted: #94a3b0; --line: #2c3743;
  --accent: #6ea8e2; --accent-ink: #0d1520; --green: #72c493; --rose: #4a2832; --rose-ink: #f2b8c6;
  --warn-bg: #3a2f14; --warn-ink: #f3cf7a; --error-bg: #3d1a1a; --error-ink: #f6a6a6;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font-ui);
  min-height: 100vh;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 12px clamp(16px, 4vw, 40px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { font: 600 22px/1 var(--font-text); letter-spacing: -0.01em; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.flag { display: inline-flex; flex-direction: column; width: 18px; height: 13px; border-radius: 2px; overflow: hidden; align-self: center; border: 1px solid var(--line); }
.flag i { flex: 1; }
.flag i:nth-child(1) { background: #2a6cb3; }
.flag i:nth-child(2) { background: #ffffff; }
.flag i:nth-child(3) { background: #2f8a4f; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500;
}
.nav a:hover { color: var(--ink); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent); }

.page { max-width: 1320px; margin: 0 auto; padding-inline: clamp(16px, 4vw, 40px); padding-block: 24px 48px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font: 600 clamp(24px, 3vw, 32px)/1.15 var(--font-text); margin: 0; text-wrap: balance; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 65ch; }
.data-status { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Bausteine ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 0;
}
.panel-head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.panel-body { padding: 14px 16px; }
.label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

select, input[type="search"], input[type="text"] {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
select { padding-right: 28px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px;
  padding: 7px 12px; cursor: pointer; font-weight: 500;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); border-color: var(--line); }
.icon-btn { width: 34px; height: 34px; padding: 0; }
.btn-primary .kbd { color: inherit; border-color: currentColor; opacity: 0.75; }
.btn-link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.kbd { font: 11px var(--font-mono); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--muted); }

.notice { border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.notice.warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice.error { background: var(--error-bg); color: var(--error-ink); }
.muted { color: var(--muted); }
.grow { flex: 1; }
.small { font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; font: 500 11.5px/1.6 var(--font-mono);
  padding: 0 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.chip.lang-lld { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, var(--line)); }
.chip.lang-deu, .chip.lang-ita { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; display: inline-block; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* ---------- Übersetzer ---------- */
.lang-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.lang-bar select { min-width: 0; font-weight: 600; }
.translator {
  display: grid; gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(280px, 340px);
  align-items: start;
}
@media (max-width: 1100px) { .translator { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .analysis { grid-column: 1 / -1; } }
@media (max-width: 720px) { .translator { grid-template-columns: minmax(0, 1fr); } }

.io textarea, .io .output {
  display: block; width: 100%; min-height: 240px; border: 0; resize: vertical; background: transparent;
  padding: 16px; font: 19px/1.6 var(--font-text); outline: none;
}
.io textarea::placeholder { color: var(--muted); }
.io .output { white-space: pre-wrap; overflow-wrap: anywhere; }
.io .output.placeholder { color: var(--muted); font-style: italic; }
.io-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-top: 1px solid var(--line); }
.io-foot .grow { flex: 1; }
.count { font: 12px var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.mode-badge { font-size: 12px; color: var(--muted); }
.mode-badge b { color: var(--ink); font-weight: 600; }

.w { cursor: pointer; border-radius: 3px; transition: background-color 0.12s; }
.w:hover { background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); }
.w.active { background: var(--rose); color: var(--rose-ink); }
.w.w-unknown { text-decoration: underline wavy var(--error-ink); text-decoration-thickness: 1.5px; text-underline-offset: 5px; }
.w.w-accent { text-decoration: underline wavy var(--warn-ink); text-decoration-thickness: 1.5px; text-underline-offset: 5px; }
/* Satz für Satz: Fortschrittsleiste, einblendende Sätze, Platzhalter für den nächsten Satz */
.io { position: relative; }
.progress { position: absolute; top: 0; left: 0; right: 0; height: 3px; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.progress span { display: block; height: 100%; width: var(--p, 0%); background: var(--accent); transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1); }
.progress.indeterminate span { width: 30%; animation: progress-run 1.3s ease-in-out infinite; }
@keyframes progress-run { from { transform: translateX(-110%); } to { transform: translateX(360%); } }
.stream-s { animation: stream-in 0.45s ease-out both; }
@keyframes stream-in { from { opacity: 0; filter: blur(3px); } to { opacity: 1; filter: none; } }
.stream-pending {
  display: inline-block; width: 7em; max-width: 60%; height: 0.95em; margin-left: 0.15em; vertical-align: -0.12em; border-radius: 5px;
  background: linear-gradient(90deg, var(--surface-2) 15%, color-mix(in srgb, var(--accent) 30%, var(--surface-2)) 50%, var(--surface-2) 85%); background-size: 250% 100%;
  animation: stream-shimmer 1.4s linear infinite;
}
.output.streaming > .stream-pending:first-child { margin-left: 0; }
@keyframes stream-shimmer { from { background-position: 125% 0; } to { background-position: -125% 0; } }
@media (prefers-reduced-motion: reduce) {
  .stream-s, .stream-pending, .progress.indeterminate span { animation: none; }
  .progress span { transition: none; }
}
.io .output[contenteditable] { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius) var(--radius) 0 0; cursor: text; }

/* Prüfung mit Micurá-Daten */
.check { border-top: 1px solid var(--line); display: grid; gap: 10px; font-size: 14px; }
.check-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.check-head .label { margin-right: 4px; }
.pill { font: 600 12px/1.7 var(--font-ui); padding: 0 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.pill.ok { color: var(--green); }
.pill.bad { color: var(--error-ink); background: var(--error-bg); border-color: transparent; }
.pill.warn { color: var(--warn-ink); background: var(--warn-bg); border-color: transparent; }
.check ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.check li { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.check li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transform: translateY(-1px); }
.check li.unknown::before { background: var(--error-ink); }
.check li.accent::before, .check li.missing::before { background: var(--warn-ink); }
.check .ladin { font-family: var(--font-text); font-weight: 600; }
.check .sugg { font-family: var(--font-text); }
.check button.sugg { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.gloss-token { display: inline-flex; flex-direction: column; vertical-align: top; margin: 0 2px 10px; }
.gloss-token .src { font: 13px var(--font-ui); color: var(--muted); }
.gloss-token .tr { font-family: var(--font-text); }
.gloss-token .tr.missing { color: var(--muted); }

/* ---------- Wortanalyse ---------- */
.analysis .panel-body { display: grid; gap: 14px; }
.analysis-empty { color: var(--muted); font-size: 14px; }
.lemma-card { display: grid; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.lemma-card:last-child { border-bottom: 0; padding-bottom: 0; }
.lemma-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lemma-title .hw { font: 600 21px/1.2 var(--font-text); }
.grammar-tags { display: flex; flex-direction: column; gap: 3px; margin: 0; padding: 0; list-style: none; }
.grammar-tags li { font-size: 13px; padding: 4px 8px; background: var(--surface-2); border-radius: 6px; }
.summary-line { font-family: var(--font-text); font-size: 15.5px; }
.summary-line .lang { font: 600 11px var(--font-mono); color: var(--muted); margin-right: 4px; text-transform: uppercase; }

/* ---------- Wörterbuch ---------- */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search-bar input[type="search"] { flex: 1 1 260px; min-width: 0; font-size: 17px; padding: 10px 14px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.segmented span { display: block; padding: 7px 11px; font-size: 13px; color: var(--muted); cursor: pointer; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-ink); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.dict { display: grid; gap: 16px; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); align-items: start; }
@media (max-width: 820px) { .dict { grid-template-columns: minmax(0, 1fr); } }
.results { max-height: calc(100vh - 220px); overflow: auto; }
@media (max-width: 820px) { .results { max-height: 320px; } }
.results ul { list-style: none; margin: 0; padding: 0; }
.results li button {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; width: 100%; text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
}
.results li button:hover { background: var(--surface-2); }
.results li button[aria-selected="true"] { background: var(--rose); color: var(--rose-ink); }
.results .r-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.results .r-hw { font: 600 16.5px/1.3 var(--font-text); }
.results .r-sum { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results li button[aria-selected="true"] .r-sum { color: inherit; opacity: 0.85; }
.results .group-label { padding: 8px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }

/* Eintrag */
.entry { padding: clamp(16px, 3vw, 28px); }
.entry-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.entry-head h2 { font: 600 clamp(28px, 4vw, 38px)/1.1 var(--font-text); margin: 0; letter-spacing: -0.01em; }
.entry-head sup { font-size: 0.45em; color: var(--muted); }
.entry-tabs { display: flex; gap: 4px; margin: 16px 0 8px; border-bottom: 1px solid var(--line); }
.entry-tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.entry-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.subentry { margin-top: 18px; }
.subentry-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.subentry-head .pos { font: 500 13px var(--font-mono); color: var(--green); }
.subentry-head .morph { font-family: var(--font-text); color: var(--muted); }
.subentry-head .su-form { font: 600 17px var(--font-text); }
.senses { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.sense { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 4px; }
.sense-n { font: 600 13px/1.9 var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.sense-desc { font-style: italic; color: var(--muted); font-family: var(--font-text); }
.usage { font: 11.5px var(--font-mono); color: var(--rose-ink); background: var(--rose); padding: 0 6px; border-radius: 4px; margin-right: 6px; }
.trs { font: 17.5px/1.55 var(--font-text); }
.trs a { color: var(--ink); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.trs a:hover { color: var(--accent); }
.tr-meta { font: 12px var(--font-mono); color: var(--muted); margin-left: 3px; }  /* auch bei festen Wendungen (vorher klebte „loc.v.“ am Wort) */
.phrases { list-style: none; margin: 6px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--line); display: grid; gap: 4px; }
.phrases li { font-family: var(--font-text); font-size: 15.5px; }
.phrases .ph-src { font-weight: 600; }
.phrases .ph-tr { color: var(--muted); }
.section-title { margin: 26px 0 8px; font: 600 12px var(--font-ui); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
details.locutions summary { cursor: pointer; }
.loc-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.loc-list li { font-family: var(--font-text); }
.loc-form { font-weight: 600; }
.see-also { display: flex; flex-wrap: wrap; gap: 6px; }
.source-note { margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }

/* Konjugation */
.conj { margin-top: 10px; display: grid; gap: 14px; }
.conj-mood h4 { margin: 0 0 6px; font: 600 15px var(--font-text); }
.conj-tenses { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.conj-tense { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.conj-tense .label { display: block; margin-bottom: 4px; }
.conj-tense table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.conj-tense td { padding: 1px 0; vertical-align: top; }
.conj-tense td.p { color: var(--muted); padding-right: 8px; white-space: nowrap; font-size: 12.5px; }
.conj-tense td.f { font-family: var(--font-text); font-weight: 600; font-size: 15px; }
.conj-tense tr.hit td.f { color: var(--rose-ink); background: var(--rose); }

.empty-state { padding: 32px 20px; text-align: center; color: var(--muted); }
.empty-state .big { font: 600 22px var(--font-text); color: var(--ink); margin-bottom: 6px; }
.examples { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 12px; }

.footer { max-width: 1320px; margin: 0 auto; padding-inline: clamp(16px, 4vw, 40px); padding-block: 0 32px; font-size: 12.5px; color: var(--muted); }

/* Vergleich zweier Übersetzungsmotoren */
.alternatives { border-top: 1px solid var(--line); display: grid; gap: 10px; }
.alt { display: grid; gap: 2px; }
.alt-text { font: 17px/1.55 var(--font-text); color: var(--muted); }

/* Automatische Micurá-Korrekturen */
.w.w-fixed { text-decoration: underline solid var(--green); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.fix-note { color: var(--green); font-weight: 600; cursor: help; }

/* ---------- Handy (18.10.2026) ---------- */
.engine-field { display: contents; }
.mode-badge:empty { display: none; }
@media (hover: none) { .kbd { display: none; } }  /* „Strg+Enter“ ergibt auf dem Handy keinen Sinn */
@media (max-width: 720px) {
  .topbar { flex-wrap: nowrap; gap: 10px; padding-block: 10px; }
  .brand { min-width: 0; gap: 8px; overflow: hidden; }
  .flag { flex-shrink: 0; }
  .brand-mark { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .brand-sub { display: none; }
  .nav { flex-shrink: 0; }
  .nav a { padding: 5px 10px; font-size: 14px; }
  .page { padding-block: 16px 32px; }
  .page-head { margin-bottom: 12px; gap: 6px; }
  .page-head p { font-size: 14px; }
  /* Sprachwahl als Raster: [Von] ⇄ [Nach], darunter der Motor über die ganze Breite */
  .lang-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; position: relative; }
  .lang-bar > .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .lang-bar select { width: 100%; }
  .lang-bar .grow { display: none; }
  .engine-field { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
  .engine-field .label { flex-shrink: 0; }
  .engine-field select { flex: 1; min-width: 0; }
  .translator { gap: 12px; }
  .io textarea, .io .output { min-height: 140px; padding: 14px; font-size: 18px; }
  /* unter der Übersetzung: erst die Herkunft („Eigenes Modell · DE → LAD“), darunter die Knöpfe rechts */
  .io-foot .mode-badge { flex: 1 1 100%; }
  .io-foot .btn { padding: 8px 12px; }
  .stream-pending { width: 5em; }
}
@media (max-width: 430px) { .brand-pre { display: none; } }  /* „Ladin Gherdëina“ -> „Gherdëina“ */
@media (max-width: 380px) {
  .brand-mark { font-size: 16px; }
  .nav { gap: 2px; }
  .nav a { padding: 5px 8px; font-size: 13.5px; }
}
