:root {
  --bg: #0d0f13;
  --panel: #161a21;
  --panel-2: #1d222b;
  --line: #2a313d;
  --text: #e8ecf2;
  --muted: #8a93a3;
  --accent: #ff5a3c;
  --accent-soft: #ff5a3c33;
  --active: #2ecc71;
  --sidebar-w: 320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar__header {
  padding: 18px 18px 10px;
}
.sidebar__header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: .5px;
}
.sidebar__sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sidebar__controls {
  display: flex;
  gap: 8px;
  padding: 0 18px 12px;
}

.btn-primary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.btn-primary:hover { filter: brightness(1.08); }

.btn-ghost {
  width: 42px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}
.btn-ghost:hover { border-color: var(--accent); }

.sidebar__filter {
  padding: 0 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#search {
  width: 100%;
  padding: 9px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
}
#search:focus { outline: none; border-color: var(--accent); }

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

/* ---------- Liste ---------- */
.entry-list {
  list-style: none;
  margin: 0;
  padding: 0 10px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.entry {
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 6px;
}
.entry:hover { background: var(--panel-2); }
.entry.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.entry.is-inactive { opacity: .45; }

.entry__top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.entry__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
}
.entry.is-active .entry__dot { background: var(--active); }

.entry__title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry__date {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  padding-left: 16px;
}
.entry__preview {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  padding-left: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar__status {
  padding: 10px 18px 14px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
}

/* ---------- Stage / Prompter ---------- */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.prompter {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: #000;
}

/* Lesehilfe-Linie */
.prompter__guide {
  position: absolute;
  left: 0; right: 0;
  top: 42%;
  height: 0;
  border-top: 2px solid var(--accent);
  box-shadow: 0 0 14px var(--accent);
  opacity: .55;
  z-index: 3;
  pointer-events: none;
}

.prompter__scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}
/* dezente Scrollbar */
.prompter__scroll::-webkit-scrollbar { width: 10px; }
.prompter__scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .18);
  border-radius: 6px;
}
.prompter__scroll::-webkit-scrollbar-track { background: transparent; }

.prompter__text {
  padding: 45vh 7.5% 60vh;
  margin: 0 auto;
  width: 85%;
  font-size: 64px;
  line-height: 1.45;
  font-weight: 600;
  white-space: pre-wrap;
  transition: transform .05s linear;
  will-change: transform;
}

/* Spiegelungen werden am .prompter__scroll gesetzt */
.prompter__scroll.mirror-h { transform: scaleX(-1); }
.prompter__scroll.mirror-v { transform: scaleY(-1); }
.prompter__scroll.mirror-h.mirror-v { transform: scale(-1, -1); }

.prompter__placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  padding: 20px;
}
.prompter__placeholder h2 { color: var(--text); font-weight: 600; }
.prompter__placeholder code {
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--text);
}

/* ---------- Immersiver Lesemodus ---------- */
/* Beim Abspielen alles ausblenden: nur das laufende Script bleibt sichtbar. */
.app.is-presenting { grid-template-columns: 1fr; }
.app.is-presenting .sidebar,
.app.is-presenting .toolbar { display: none; }

/* Hinweis: „Tippen, um die Steuerung einzublenden“ */
.tap-hint {
  position: absolute;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .6);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 22px;
  font-size: 14px;
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
}
.tap-hint.is-show { opacity: 1; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 20px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.play {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  flex: none;
}
.play:hover { filter: brightness(1.1); }
.play.is-playing { background: var(--panel-2); border: 1px solid var(--accent); color: var(--accent); }

.ctrl {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ctrl label {
  color: var(--muted);
  font-size: 13px;
  min-width: 42px;
}
.ctrl input[type="range"] { width: 130px; accent-color: var(--accent); }
.ctrl--narrow input[type="range"] { width: 90px; }
.ctrl .val {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text);
  min-width: 30px;
}

.toggles {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.tgl {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  cursor: pointer;
  font-size: 16px;
}
.tgl:hover { border-color: var(--accent); }
.tgl.is-on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.tgl--wide {
  width: auto;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
}

/* ---------- Editor-Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal[hidden] { display: none; }

.modal__box {
  width: min(1000px, 100%);
  height: min(900px, 95vh);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
  display: flex;
  flex-direction: column;
  max-height: 95vh;
}

.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal__head h3 { margin: 0; font-size: 17px; }
.modal__close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
}
.modal__close:hover { color: var(--text); }

.modal__body {
  padding: 18px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.fld { display: flex; flex-direction: column; gap: 6px; }
/* Text-Feld füllt den restlichen Platz im Modal */
.fld--grow { flex: 1; min-height: 0; }
.fld--grow textarea {
  flex: 1;
  min-height: 260px;
  resize: none;
}
.fld > span { font-size: 13px; color: var(--muted); }
.fld input[type="text"],
.fld textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: vertical;
}
.fld input:focus, .fld textarea:focus { outline: none; border-color: var(--accent); }

.fld-row { display: flex; gap: 14px; }
.fld-row .fld { flex: 1; }
.fld--check {
  flex: none;
  align-items: flex-start;
}
.fld--check input { width: 22px; height: 22px; accent-color: var(--accent); margin-top: 4px; }

.modal__foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.modal__foot .spacer { flex: 1; }

.btn-danger {
  padding: 9px 16px;
  background: transparent;
  color: #ff6b6b;
  border: 1px solid #ff6b6b55;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn-danger:hover { background: #ff6b6b22; }

.btn-ghost2 {
  padding: 9px 16px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}
.btn-ghost2:hover { border-color: var(--accent); }

.modal__foot .btn-primary { flex: none; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 42vh 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
  .prompter__text { font-size: 40px; }
}
