/* =========================================================
   cs voice2text – Oberfläche

   Farben, Flächen und Schatten kommen aus dem 3dtools-Design-System
   (`assets/ds-entry.css`). Hier stehen nur noch das Themenraster für
   Dunkel und die Bausteine der App. Siehe DESIGN-MIGRATION.md, Stufe 2.

   Farblogik: Navy arbeitet · Blau führt · Fundgrün bestätigt · Rot warnt.
   ========================================================= */
:root {
  /* Dunkles Thema. Die Werte stammen aus `templates/app-huelle/`,
     Abschnitt [data-thema="dunkel"]. Der helle Satz folgt in Stufe 5. */
  --s-page:        var(--navy-950);
  --s-card:        var(--navy-900);
  --s-sunken:      var(--navy-950);
  --s-fg:          var(--white);
  --s-body:        rgba(255, 255, 255, .78);
  --s-mute:        rgba(255, 255, 255, .45);
  --s-line:        rgba(255, 255, 255, .09);
  --s-line-strong: rgba(255, 255, 255, .16);
  --s-tool:        rgba(255, 255, 255, .09);
  --s-grid:        rgba(255, 255, 255, .05);

  /* Getönte Flächen: dieselben Systemfarben, auf dunklem Grund verdünnt.
     Über color-mix, damit kein Hex-Wert ein zweites Mal im Umlauf ist. */
  --s-accent-soft: color-mix(in srgb, var(--blue-500) 20%, transparent);
  --s-accent-firm: color-mix(in srgb, var(--blue-500) 45%, transparent);
  --s-danger-soft: color-mix(in srgb, var(--red-600)  22%, transparent);
  --s-danger-firm: color-mix(in srgb, var(--red-600)  55%, transparent);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --tr: all .25s cubic-bezier(.4, 0, .2, 1);
  --radius: 16px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%; height: 100svh;
  overflow: hidden;
  background: var(--s-page);
  font-family: var(--font);
  color: var(--s-fg);
  -webkit-text-size-adjust: 100%;
}

/* 40px-Konstruktionsraster in 5% Weiss – die einzige Textur des Systems */
body {
  background-image:
    linear-gradient(var(--s-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--s-grid) 1px, transparent 1px);
  background-size: 40px 40px;
  background-attachment: fixed;
}

.hidden { display: none !important; }

svg.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Fokus: 3px-Ring plus blaue Kontur, nie ein entferntes Outline */
button:focus-visible, a:focus-visible, input:focus-visible,
textarea:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

/* ------------------------------------------------------- Sperrbildschirm */
.lock-screen { height: 100svh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.lock-card {
  width: 100%; max-width: 340px; text-align: center;
  background: var(--s-card); border: 1px solid var(--s-line); border-radius: 24px;
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-2);
}
.lock-mark { width: 64px; height: 64px; display: block; margin: 0 auto .75rem; }
.lock-card h1 { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: -.025em; }
.lock-hint { color: var(--s-body); font-size: .875rem; margin: .35rem 0 1.25rem; }
.pin-input {
  width: 100%; text-align: center; font-size: 1.7rem; letter-spacing: .4em; font-family: var(--font);
  padding: .75rem; border-radius: 14px; border: 1px solid var(--s-line-strong);
  background: var(--s-sunken); color: var(--s-fg); outline: none;
}
.lock-error { color: var(--red-500); font-size: .85rem; margin-top: .75rem; }
/* Warnung muss als Warnung lesbar sein: getönte Fläche, heller Text darauf */
.lock-warn {
  color: var(--status-warning-bg); font-size: .75rem; margin-top: 1rem; line-height: 1.4;
  background: color-mix(in srgb, var(--amber-600) 28%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber-600) 55%, transparent);
  border-radius: 12px; padding: .5rem .7rem;
}
.lock-warn code { background: var(--s-sunken); padding: .1em .35em; border-radius: 5px; }
.btn-unlock {
  width: 100%; margin-top: 1rem; padding: .85rem; border: 0; border-radius: 14px;
  background: var(--action-primary-bg); color: var(--text-inverse);
  font-size: 1rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: var(--tr);
}
.btn-unlock:active { transform: scale(.97); background: var(--action-primary-bg-hover); }

/* ------------------------------------------------------------- App-Layout */
.app {
  display: flex; flex-direction: column;
  width: 100%; max-width: 560px; margin: 0 auto;
  height: 100svh;
  padding: calc(var(--safe-top) + .75rem) 1rem calc(var(--safe-bottom) + .75rem);
  gap: .7rem;
}

.app-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

/* Hülle-Regel 1: Zeichen 38px, 14px Abstand, Wortmarke in Archivo 800/19px/−0.025em.
   Die Firma tritt hier hinter den App-Namen zurück (DESIGN-MIGRATION.md, Frage 4). */
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark { width: 38px; height: 38px; flex: 0 0 auto; display: block; }
.brand-text { min-width: 0; }
.brand h1 {
  font-family: var(--font-display); font-weight: 800; font-size: 19px;
  line-height: 1.1; letter-spacing: -.025em; white-space: nowrap;
}
.brand-cs { font-weight: 500; opacity: .55; }
.subtitle { font-size: .72rem; color: var(--s-body); }
.header-actions { display: flex; gap: .4rem; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--s-line); background: var(--s-card);
  color: var(--s-body); cursor: pointer; transition: var(--tr);
}
.icon-btn:active { transform: scale(.93); color: var(--s-fg); }

/* ----------------------------------------------------- Übersetzungsleiste */
.translate-bar { display: flex; gap: .4rem; }
.chip {
  flex: 1; padding: .5rem .3rem; border-radius: 12px;
  border: 1px solid var(--s-line); background: var(--s-card);
  color: var(--s-fg); font-family: var(--font); font-size: .8rem; font-weight: 500;
  cursor: pointer; transition: var(--tr);
}
.chip:active { transform: scale(.95); border-color: var(--border-focus); }
.chip.is-busy { opacity: .55; animation: pulse 1s infinite; }
.chip-lang { flex: 0 0 auto; padding-inline: .75rem; color: var(--s-body); font-size: .72rem; letter-spacing: .04em; }

@keyframes pulse { 0%, 100% { opacity: .5 } 50% { opacity: 1 } }

/* ------------------------------------------------------------- Editor */
.editor-wrap {
  flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column;
  background: var(--s-card); border: 1px solid var(--s-line); border-radius: var(--radius);
  box-shadow: var(--shadow-1); overflow: hidden;
  transition: var(--tr);
}
body.is-recording .editor-wrap { border-color: var(--s-danger-firm); box-shadow: 0 0 0 3px var(--s-danger-soft); }

#editor {
  flex: 1; width: 100%; resize: none; border: 0; outline: none; background: transparent;
  color: var(--s-fg); font-family: var(--font); font-size: 1.02rem; line-height: 1.6;
  padding: 1rem; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
#editor::placeholder { color: var(--s-mute); }

.interim-overlay {
  position: absolute; left: .6rem; right: .6rem; bottom: 2.2rem;
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem; border-radius: 12px;
  background: var(--s-danger-soft); border: 1px solid var(--s-danger-firm);
  font-size: .78rem; color: var(--red-100);
}
#interim-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-timer { font-variant-numeric: tabular-nums; color: var(--red-100); }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red-500); flex: 0 0 auto; animation: dot 1.2s infinite; }
/* Ausnahme laut DESIGN-MIGRATION.md Frage 1: Dauerschleife nur für die
   Aufnahme, ausschliesslich über die Deckkraft – keine Skalierung. */
@keyframes dot { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

.meta-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .35rem .8rem .5rem; font-size: .68rem; color: var(--s-mute);
  border-top: 1px solid var(--s-line);
}
/* Fundgrün bestätigt Speichervorgänge – und sonst nichts (Frage 6) */
.meta-saved { color: var(--brand-fund); opacity: 0; transition: opacity .3s; }
.meta-saved.show { opacity: 1; }

/* --------------------------------------------------- Schnellzugriff-Chips */
.quick-blocks { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.quick-blocks::-webkit-scrollbar { display: none; }
.quick-blocks:empty { display: none; }
.qb {
  flex: 0 0 auto; max-width: 46vw; padding: .4rem .7rem; border-radius: 999px;
  border: 1px solid var(--s-line); background: var(--s-accent-soft);
  color: var(--s-fg); font-family: var(--font); font-size: .76rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; transition: var(--tr);
}
.qb:active { transform: scale(.94); background: var(--s-accent-firm); }

/* ---------------------------------------------------------- Aktionsleiste */
.actions {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem;
  padding: .55rem .6rem; border-radius: 20px;
  background: var(--s-card); border: 1px solid var(--s-line);
  box-shadow: var(--shadow-2);
}
.btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: 0; background: transparent; color: var(--s-body);
  font-family: var(--font); font-size: .6rem; cursor: pointer; transition: var(--tr);
  padding: .35rem .2rem; border-radius: 14px; flex: 1;
}
.btn:active { transform: scale(.92); color: var(--s-fg); }
.btn-label { letter-spacing: .01em; }
/* Gewöhnlicher Erfolg (kopiert, übersetzt) – nicht Fundgrün, das ist dem Speichern vorbehalten */
.btn.btn-success { color: var(--green-100); }

.btn-mic {
  flex: 0 0 auto; width: 62px; height: 62px; border-radius: 50%;
  background: var(--gradient-rim);
  color: var(--text-inverse); display: grid; place-items: center;
  box-shadow: var(--shadow-3);
  margin-top: -18px;
}
.btn-mic .ico { width: 26px; height: 26px; }
/* Rot ist Signal, nie Dekoration – deshalb flach statt mit Verlauf (Frage 3) */
body.is-recording .btn-mic {
  background: var(--action-signal-bg);
  box-shadow: 0 0 0 0 var(--s-danger-firm); animation: ring 1.6s infinite;
}
@keyframes ring {
  0%   { box-shadow: 0 0 0 0 var(--s-danger-firm) }
  70%  { box-shadow: 0 0 0 16px transparent }
  100% { box-shadow: 0 0 0 0 transparent }
}

/* ----------------------------------------------------------------- Sheets */
.sheet-backdrop {
  position: fixed; inset: 0; background: var(--overlay-scrim);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  z-index: 40; animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 560px; margin: 0 auto;
  max-height: 88svh; display: flex; flex-direction: column;
  background: var(--s-card);
  border: 1px solid var(--s-line); border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding-bottom: var(--safe-bottom);
  box-shadow: var(--shadow-4);
  animation: slideUp .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes slideUp { from { transform: translateY(100%) } to { transform: translateY(0) } }

.sheet-handle { width: 42px; height: 4px; border-radius: 4px; background: var(--s-line-strong); margin: .6rem auto .2rem; flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: .5rem 1.1rem .6rem; flex: 0 0 auto; }
.sheet-head h2 { font-size: 1rem; font-weight: 600; }
.sheet-close { width: 32px; height: 32px; border-radius: 10px; border: 1px solid var(--s-line); background: transparent; color: var(--s-body); font-size: .9rem; cursor: pointer; }
.sheet-tools { display: flex; gap: .5rem; padding: 0 1.1rem .6rem; flex: 0 0 auto; }
.sheet-tools input[type=search] {
  flex: 1; min-width: 0; padding: .6rem .8rem; border-radius: 12px;
  border: 1px solid var(--s-line); background: var(--s-sunken); color: var(--s-fg);
  font-family: var(--font); font-size: .88rem; outline: none;
}
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 1.1rem 1.1rem; flex: 1; min-height: 0; }
.sheet-foot-hint { padding: .5rem 1.1rem 1rem; font-size: .68rem; color: var(--s-mute); text-align: center; flex: 0 0 auto; }

.cat-row { display: flex; gap: .35rem; overflow-x: auto; padding: 0 1.1rem .6rem; scrollbar-width: none; flex: 0 0 auto; }
.cat-row::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; padding: .3rem .7rem; border-radius: 999px; font-size: .72rem;
  border: 1px solid var(--s-line); background: transparent; color: var(--s-body);
  font-family: var(--font); cursor: pointer;
}
/* Ausgewählter Zustand – Blau führt */
.cat.active { background: var(--action-accent-bg); border-color: var(--action-accent-bg); color: var(--text-inverse); }

/* Listeneinträge */
.item {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .75rem .8rem; margin-bottom: .5rem;
  border-radius: 14px; border: 1px solid var(--s-line); background: var(--s-tool);
  cursor: pointer; transition: var(--tr);
}
.item:active { transform: scale(.985); background: var(--s-accent-soft); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: .88rem; font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.item-title .tag { font-size: .6rem; font-weight: 500; color: var(--blue-300); background: var(--s-accent-soft); padding: .1rem .4rem; border-radius: 6px; }
.item-preview { font-size: .76rem; color: var(--s-body); margin-top: .2rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-meta { font-size: .64rem; color: var(--s-mute); margin-top: .3rem; }
.item-actions { display: flex; flex-direction: column; gap: .3rem; flex: 0 0 auto; }
.mini {
  width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--s-line);
  background: transparent; color: var(--s-body); font-size: .8rem; cursor: pointer; line-height: 1;
}
/* Angeheftet ist ein ausgewählter Zustand, keine Warnung – deshalb Blau statt Amber */
.mini.on { color: var(--blue-300); border-color: var(--s-accent-firm); }
.empty { text-align: center; color: var(--s-mute); font-size: .82rem; padding: 2rem 1rem; line-height: 1.6; }

/* Formulare */
.form label { display: block; font-size: .74rem; color: var(--s-body); margin-bottom: .8rem; }
.form input[type=text], .form textarea, .form select {
  display: block; width: 100%; margin-top: .3rem; padding: .7rem .8rem;
  border-radius: 12px; border: 1px solid var(--s-line); background: var(--s-sunken);
  color: var(--s-fg); font-family: var(--font); font-size: .92rem; outline: none; resize: vertical;
}
.form .hint { font-size: .7rem; color: var(--s-mute); line-height: 1.55; margin-bottom: .8rem; }
.form .hint code { background: var(--s-sunken); padding: .05em .3em; border-radius: 4px; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: .5rem; }

.form label.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--s-line); margin-bottom: 0; }
.switch-row span { display: flex; flex-direction: column; gap: .15rem; }
.switch-row b { font-size: .85rem; color: var(--s-fg); font-weight: 500; }
.switch-row small { font-size: .68rem; color: var(--s-mute); line-height: 1.4; }
.switch-row input[type=checkbox] { flex: 0 0 auto; width: 46px; height: 27px; appearance: none; -webkit-appearance: none; background: var(--s-tool); border-radius: 999px; position: relative; cursor: pointer; transition: var(--tr); }
.switch-row input[type=checkbox]::after { content: ''; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: var(--white); transition: var(--tr); }
.switch-row input[type=checkbox]:checked { background: var(--action-accent-bg); }
.switch-row input[type=checkbox]:checked::after { transform: translateX(19px); }

.btn-pill {
  padding: .55rem 1rem; border-radius: 12px; border: 1px solid var(--s-line-strong);
  background: var(--s-tool); color: var(--s-fg);
  font-family: var(--font); font-size: .82rem; font-weight: 500; cursor: pointer;
  text-decoration: none; display: inline-block; transition: var(--tr);
}
.btn-pill:active { transform: scale(.95); }
.btn-pill-primary { background: var(--action-accent-bg); border-color: var(--action-accent-bg); color: var(--text-inverse); }
.btn-pill-primary:active { background: var(--action-accent-bg-hover); }
.btn-pill-danger  { background: var(--action-signal-bg); border-color: var(--action-signal-bg); color: var(--text-inverse); }
.btn-pill-danger:active { background: var(--action-signal-bg-hover); }

/* Menü-Sheet */
.menu-list { display: flex; flex-direction: column; gap: .35rem; }
.menu-item {
  display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left;
  padding: .7rem .8rem; border-radius: 14px; border: 1px solid var(--s-line);
  background: var(--s-tool); color: var(--s-fg);
  font-family: var(--font); cursor: pointer; transition: var(--tr);
}
.menu-item:active { transform: scale(.98); background: var(--s-accent-soft); }
.menu-item > span { font-size: 1.15rem; flex: 0 0 auto; }
.menu-item b { display: block; font-size: .87rem; font-weight: 500; }
.menu-item small { font-size: .68rem; color: var(--s-mute); }
.menu-danger b { color: var(--red-500); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--overlay-scrim); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); padding: 1.5rem; }
.modal-card { width: 100%; max-width: 340px; background: var(--s-card); border: 1px solid var(--s-line); border-radius: 20px; padding: 1.25rem; box-shadow: var(--shadow-4); }
.modal-card p { font-size: .88rem; margin-bottom: .7rem; }
.modal-card input { width: 100%; padding: .7rem .8rem; border-radius: 12px; border: 1px solid var(--s-line-strong); background: var(--s-sunken); color: var(--s-fg); font-family: var(--font); font-size: .95rem; outline: none; }
.modal-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }

/* Toasts */
.toast-host { position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 96px); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: .4rem; pointer-events: none; }
.toast {
  max-width: 82vw; padding: .6rem 1rem; border-radius: 999px;
  background: var(--s-card); border: 1px solid var(--s-line-strong);
  color: var(--s-fg); font-size: .82rem; box-shadow: var(--shadow-3);
  animation: toastIn .22s ease; transition: opacity .3s, transform .3s;
}
.toast.out { opacity: 0; transform: translateY(8px); }
.toast.ok   { border-color: var(--status-success-fg); }
.toast.fund { border-color: var(--brand-fund); }        /* gespeichert */
.toast.err  { border-color: var(--action-signal-bg); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: translateY(0) } }

/* Grössere Displays: Aktionsleiste bekommt Beschriftungen mehr Luft */
@media (min-width: 480px) {
  .btn { font-size: .65rem; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
