:root {
  --bg: #fff7ec;
  --fg: #3a2a1a;
  --muted: #8a7460;
  --card: #ffffff;
  --accent: #ff9f43;
  --accent-dark: #e8842a;
  --ok: #2ecc71;
  --danger: #e74c3c;
  --ring: rgba(255, 159, 67, .35);
  --radius: 22px;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--fg);
  min-height: 100dvh; display: flex; flex-direction: column;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; border: 0; color: inherit; background: none; }
button:disabled { opacity: .45; cursor: default; }
.hidden { display: none !important; }
.sr { position: absolute; left: -9999px; }

/* ---------- Kopf ---------- */
.top { display: flex; align-items: center; gap: 12px; padding: max(14px, env(safe-area-inset-top)) 16px 8px; }
.top h1 { font-size: 20px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .emoji { font-size: 30px; line-height: 1; }
.btn-small {
  padding: 10px 14px; border-radius: 14px; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.08);
  font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; min-height: 44px;
}
.btn-small:active { transform: scale(.97); }
.btn-small.primary { background: var(--accent); color: #fff; }
.btn-small.danger { color: var(--danger); }
.btn-small.ghost { background: transparent; box-shadow: none; color: var(--muted); }

/* ---------- Bücherliste ---------- */
.books { padding: 8px 16px 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.book-tile {
  border-radius: var(--radius); padding: 18px 14px; background: var(--card); text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.08); border-top: 10px solid var(--c, var(--accent));
  display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 150px; justify-content: center;
}
.book-tile:active { transform: scale(.97); }
.book-tile .emoji { font-size: 54px; line-height: 1; }
.book-tile .title { font-weight: 700; font-size: 17px; line-height: 1.2; }
.book-tile .meta { font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 60px 24px; font-size: 17px; line-height: 1.5; }

/* ---------- Player (Kind) ---------- */
.player { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 10px 20px 20px; }
.player .status { font-size: 22px; font-weight: 700; text-align: center; min-height: 30px; }
.player .sub { font-size: 16px; color: var(--muted); text-align: center; min-height: 22px; }
.bigbtn {
  width: min(72vw, 320px); height: min(72vw, 320px); border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffc37a, var(--accent) 60%, var(--accent-dark));
  box-shadow: 0 14px 40px rgba(232,132,42,.45), inset 0 -8px 0 rgba(0,0,0,.08);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 26px; font-weight: 800;
  position: relative; transition: transform .1s;
}
.bigbtn:active { transform: scale(.95); }
.bigbtn .icon { font-size: min(30vw, 130px); line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.2)); }
.bigbtn.playing::before, .bigbtn.playing::after {
  content: ""; position: absolute; inset: -12px; border-radius: 50%; border: 6px solid var(--ring);
  animation: pulse 1.6s ease-out infinite;
}
.bigbtn.playing::after { animation-delay: .8s; }
@keyframes pulse { 0% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }
.bigbtn.turning { background: radial-gradient(circle at 35% 30%, #a5d8ff, #54a0ff 60%, #2e6fd6); box-shadow: 0 14px 40px rgba(84,160,255,.45); animation: wiggle 1.2s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }
.bigbtn.done { background: radial-gradient(circle at 35% 30%, #8ff0b3, var(--ok) 60%, #1f9e55); box-shadow: 0 14px 40px rgba(46,204,113,.4); }
.dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; max-width: 320px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #e8dccb; display: block; }
.dots i.played { background: var(--accent); }
.dots i.current { background: var(--accent-dark); transform: scale(1.35); }
.bottom { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; padding: 0 16px max(18px, env(safe-area-inset-bottom)); }
.bottom .btn-small { font-size: 14px; }

/* ---------- Papa ---------- */
.papa main { padding: 0 16px 60px; max-width: 640px; width: 100%; margin: 0 auto; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.07); padding: 16px; margin: 12px 0; }
.card h2 { margin: 0 0 10px; font-size: 17px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
input[type=text], input[type=password] {
  font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 14px; border: 2px solid #eadfcf; background: #fff; width: 100%;
}
input:focus { outline: none; border-color: var(--accent); }
.emoji-row { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-row button { font-size: 26px; padding: 6px 8px; border-radius: 12px; background: #f7efe3; }
.emoji-row button.sel { background: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.pages { list-style: none; margin: 0; padding: 0; }
.page {
  display: grid; grid-template-columns: 44px 1fr; gap: 4px 8px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid #f0e6d8;
}
.page .acts { grid-column: 1 / -1; justify-content: flex-end; }
.page .n { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.page .info { font-size: 14px; color: var(--muted); }
.page .info b { color: var(--fg); font-size: 15px; }
.page .acts { display: flex; gap: 2px; flex-wrap: wrap; }
.page .acts button { padding: 8px 9px; font-size: 18px; border-radius: 10px; min-width: 40px; }
.page .acts button:active { background: #f7efe3; }
.rec-area { text-align: center; padding: 8px 0 4px; }
.recbtn {
  width: 150px; height: 150px; border-radius: 50%; margin: 6px auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--danger); color: #fff; font-weight: 800; font-size: 17px; box-shadow: 0 12px 30px rgba(231,76,60,.4); gap: 4px;
}
.recbtn .ico { font-size: 44px; line-height: 1; }
.recbtn.rec { background: #c0392b; animation: blink 1s infinite alternate; }
@keyframes blink { from { box-shadow: 0 12px 30px rgba(231,76,60,.4); } to { box-shadow: 0 0 0 16px rgba(231,76,60,.18); } }
.recbtn:active { transform: scale(.96); }
.timer { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 700; margin: 6px 0; min-height: 34px; }
.hint { color: var(--muted); font-size: 14px; line-height: 1.45; }
.preview { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.preview audio { width: 100%; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #3a2a1a; color: #fff;
  padding: 12px 18px; border-radius: 14px; font-size: 15px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 50; max-width: 90vw; text-align: center;
}
.toast.err { background: var(--danger); }
code.link { display: block; word-break: break-all; background: #f7efe3; padding: 10px; border-radius: 10px; font-size: 13px; user-select: all; -webkit-user-select: all; }

/* ---------- Kamera / Erkennung ---------- */
.book-tile.has-cover { padding-top: 12px; }
.book-tile .cover { width: 100%; max-width: 140px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; box-shadow: 0 4px 10px rgba(0,0,0,.15); background: #f0e6d8; }
.scan-hero { padding: 4px 16px 10px; }
.scan-big {
  width: 100%; border-radius: var(--radius); padding: 18px 16px; background: linear-gradient(135deg, #ffc37a, var(--accent));
  color: #fff; display: flex; align-items: center; gap: 14px; box-shadow: 0 10px 26px rgba(232,132,42,.35); font-weight: 800; font-size: 22px; text-align: left;
}
.scan-big .ico { font-size: 44px; line-height: 1; }
.scan-big small { display: block; font-weight: 600; font-size: 14px; opacity: .9; }
.scan-big > span:nth-child(2) { display: flex; flex-direction: column; }
.scan-big:active { transform: scale(.98); }
.scan-row { display: flex; gap: 10px; margin: 6px 0 10px; }
.scan-btn {
  flex: 1; border-radius: 16px; padding: 12px 8px; background: #f7efe3; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 700; font-size: 15px;
}
.scan-btn .ico { font-size: 30px; line-height: 1.1; }
.scan-btn small { font-weight: 500; color: var(--muted); font-size: 12px; }
.scan-btn:active { background: #efe3d0; }
.scan-status { margin: 6px 0 4px; padding: 8px 12px; border-radius: 12px; background: #f7efe3; color: var(--fg); }
.scan-status.busy::before { content: "⏳ "; }
.scan-hero .scan-status { margin-top: 10px; text-align: center; }
.cover-preview { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 6px 0; }
.cover-preview img { max-height: 200px; max-width: 100%; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.cover-preview.small img { max-height: 120px; }
.scanner { position: fixed; inset: 0; background: #000; z-index: 40; display: flex; flex-direction: column; }
.scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; left: 8%; right: 8%; top: 32%; height: 26%; border: 3px solid rgba(255,255,255,.9); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan-frame::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: rgba(255,80,80,.9); }
.scan-ui { position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 16px max(24px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.scan-text { color: #fff; font-weight: 600; text-align: center; text-shadow: 0 1px 4px rgba(0,0,0,.8); }

/* ---------- Durchgehende Aufnahme ---------- */
.cont-page { font-size: 30px; font-weight: 800; margin-top: 4px; }
.nextbtn {
  width: 100%; max-width: 360px; margin: 4px auto; padding: 22px 16px; border-radius: 26px; background: var(--ok); color: #fff;
  font-size: 24px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 12px; box-shadow: 0 12px 30px rgba(46,204,113,.4);
}
.nextbtn .ico { font-size: 34px; line-height: 1; }
.nextbtn:active { transform: scale(.97); }

/* ---------- Funkknopf ---------- */
.bigbtn.hit { filter: brightness(1.35); transform: scale(1.04); }
.radio-dot { font-size: 16px; opacity: .35; transition: opacity .2s, transform .2s; }
.radio-dot.hit { opacity: 1; transform: scale(1.5); }
