:root {
  --bg: #14110e;
  --bg-soft: #1d1915;
  --bg-card: #221d18;
  --line: #352d25;
  --text: #ece4d8;
  --text-dim: #a59b8c;
  --accent: #e0a458;
  --accent-soft: #6b4f2a;
  --male: #6ba2e0;
  --female: #e07a9c;
  --danger: #e0635b;
  --radius: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  overscroll-behavior-y: none;
}
.app { max-width: 760px; margin: 0 auto; padding: 16px 16px 140px; }

h1 { font-size: 1.35rem; margin: 8px 0 2px; letter-spacing: .2px; }
.sub { color: var(--text-dim); font-size: .85rem; margin: 0 0 16px; }
.muted { color: var(--text-dim); }

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

label { display: block; font-size: .82rem; color: var(--text-dim); margin: 0 0 6px; }
input[type=text], textarea, select {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 1rem; font-family: inherit; resize: vertical;
}
textarea { min-height: 180px; line-height: 1.55; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

button {
  font: inherit; cursor: pointer; border: none; border-radius: 12px;
  padding: 12px 18px; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); transition: transform .05s ease, background .15s;
}
button:active { transform: scale(.97); }
button.primary { background: var(--accent); color: #221a0e; border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Stimmenauswahl */
.voices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.voice {
  text-align: left; padding: 12px 14px; border-radius: 12px; background: var(--bg-soft);
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px;
}
.voice.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.voice .vn { font-weight: 600; }
.voice .vg { font-size: .75rem; }
.voice .vg.maennlich { color: var(--male); }
.voice .vg.weiblich { color: var(--female); }
.voice .vnote { font-size: .72rem; color: var(--text-dim); }

.counter { font-size: .78rem; color: var(--text-dim); }
.warn { color: var(--danger); }

/* Engine-Umschalter */
.engine-switch { display: flex; gap: 8px; }
.eng { flex: 1; }
.eng.sel { background: var(--accent); color: #221a0e; border-color: transparent; font-weight: 600; }

/* Probe-hören-Knopf in der Stimmenkarte */
.vsel { cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.vprev { margin-top: 10px; width: 100%; font-size: .82rem; padding: 8px;
  background: var(--bg-card); border: 1px solid var(--accent-soft); color: var(--accent); }

/* Lesebereich */
#reader {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 1.18rem; line-height: 1.75; letter-spacing: .1px;
}
#reader p { margin: 0 0 1em; }
.w { cursor: pointer; border-radius: 4px; padding: 0 1px; transition: background .1s; }
.w.active { background: var(--accent); color: #221a0e; }
.w.read { color: var(--text-dim); }

/* Player-Leiste unten */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: linear-gradient(180deg, rgba(20,17,14,.4), var(--bg-soft) 38%);
  border-top: 1px solid var(--line); padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  backdrop-filter: blur(8px);
}
.player .inner { max-width: 760px; margin: 0 auto; }
.seek { width: 100%; accent-color: var(--accent); margin: 4px 0 2px; }
.times { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text-dim); }
.controls { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.controls .play { width: 56px; height: 56px; border-radius: 50%; font-size: 1.4rem; background: var(--accent); color: #221a0e; border: none; }
.icon-btn { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1rem; }
.note-btn { flex: 1; height: 52px; font-weight: 600; background: var(--bg-card); border: 1px solid var(--accent); color: var(--accent); }
.note-btn.armed { background: var(--accent); color: #221a0e; }
.speed { min-width: 64px; }

/* Trigger-Wort-Schalter */
.switch { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--text-dim); }
.switch input { width: 40px; height: 22px; }

/* Aufnahme-Overlay */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(10,8,6,.86);
  display: none; align-items: center; justify-content: center; padding: 24px;
}
.overlay.show { display: flex; }
.rec-box { background: var(--bg-card); border: 1px solid var(--accent); border-radius: 20px; padding: 28px; text-align: center; max-width: 360px; width: 100%; }
.pulse { width: 86px; height: 86px; border-radius: 50%; margin: 6px auto 14px; background: var(--danger); animation: pulse 1.1s infinite; display: grid; place-items: center; font-size: 1.6rem; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(224,99,91,.5);} 50% { box-shadow: 0 0 0 18px rgba(224,99,91,0);} }
.rec-time { font-size: 2rem; font-variant-numeric: tabular-nums; margin: 4px 0; }

/* Kommentarliste */
.comment { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; background: var(--bg-soft); }
.comment .meta { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--text-dim); }
.comment .jump { color: var(--accent); cursor: pointer; font-variant-numeric: tabular-nums; }
.comment .snip { font-size: .88rem; margin: 6px 0; color: var(--text); font-style: italic; }
.comment audio { width: 100%; height: 34px; margin-top: 4px; }
.comment .del { margin-left: auto; color: var(--text-dim); background: none; border: none; padding: 4px 8px; }

/* Bibliothek */
.lib-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.lib-item:last-child { border-bottom: none; }
.lib-item .t { font-weight: 600; }
.lib-item .d { font-size: .76rem; color: var(--text-dim); }
.lib-del { background: transparent; border: none; color: var(--text-dim); font-size: 1.05rem; padding: 6px 8px; }
.lib-del:hover { color: var(--danger); }

.hidden { display: none !important; }
.toast {
  position: fixed; bottom: 150px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--accent); color: var(--text);
  padding: 10px 16px; border-radius: 12px; z-index: 60; font-size: .9rem; opacity: 0;
  transition: opacity .2s; pointer-events: none; max-width: 90%;
}
.toast.show { opacity: 1; }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab { flex: 1; text-align: center; }
.tab.sel { border-color: var(--accent); color: var(--accent); }
