:root {
  --bg: #1c1c1e;
  --bar: #2c2c2e;
  --card: #2c2c2e;
  --card2: #3a3a3c;
  --fg: #f2f2f7;
  --muted: #8e8e93;
  --accent: #0a84ff;
  --ok: #30d158;
  --warn: #ffd60a;
  --danger: #ff453a;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

.topbar {
  background: var(--bar);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  padding-top: calc(8px + var(--sat));
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 17px; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon {
  background: var(--card2); border: 0; border-radius: 10px; color: var(--fg);
  width: 40px; height: 36px; font-size: 22px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.chip { background: var(--card2); border: 0; border-radius: 18px; padding: 6px 12px; font-size: 14px; color: var(--fg); }

.view { flex: 1; width: 100%; max-width: 600px; margin: 0 auto; padding: 16px 16px calc(24px + var(--sab)); }
h1 { font-size: 26px; margin: 4px 0 12px; }
h2 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 22px 0 8px; }
p { margin: 8px 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

.btn {
  display: block; width: 100%; border: 0; border-radius: 14px; padding: 14px 16px;
  background: var(--card2); color: var(--fg); font-size: 17px; font-weight: 600; text-align: center;
}
.btn + .btn { margin-top: 10px; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); color: #042a0f; }
.btn.subtle { background: transparent; color: var(--accent); font-weight: 500; }
.btn:disabled { opacity: .4; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; margin: 0; }

/* Listen */
.list { background: var(--card); border-radius: 14px; overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: none; border: 0; border-bottom: 1px solid #3d3d41; color: var(--fg);
}
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item .name { font-weight: 600; }
.item .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item .chev { color: var(--muted); font-size: 22px; }
.bar { height: 6px; background: #48484a; border-radius: 3px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.bar > i.warn { background: var(--warn); }

/* Login */
.users { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.user {
  background: var(--card); border: 0; border-radius: 18px; padding: 22px 10px; color: var(--fg);
  display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 18px; font-weight: 600;
}
.avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 700;
}
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 18px 0 22px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.pin-dots i.on { background: var(--fg); border-color: var(--fg); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-10px) } 40% { transform: translateX(10px) } 60% { transform: translateX(-8px) } 80% { transform: translateX(8px) } }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 300px; margin: 0 auto; }
.keypad button { height: 64px; border-radius: 32px; border: 0; background: var(--card2); color: var(--fg); font-size: 26px; }
.keypad button:active { background: var(--accent); }
.keypad .ghost { background: transparent; font-size: 20px; }
.error { color: var(--danger); min-height: 1.4em; text-align: center; margin-top: 12px; }

/* Home */
.hero { display: flex; align-items: center; gap: 16px; background: var(--card); border-radius: 18px; padding: 14px 16px; }
.ring { position: relative; width: 84px; height: 84px; flex: 0 0 auto; }
.ring svg { transform: rotate(-90deg); width: 84px; height: 84px; }
.ring circle { fill: none; stroke-width: 8; }
.ring .track { stroke: #48484a; }
.ring .prog { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .5s; }
.ring .prog.done { stroke: var(--ok); }
.ring .txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; }
.hero .grow { flex: 1; }
.hero .big { font-size: 20px; font-weight: 700; }
.streak { font-size: 15px; color: var(--muted); margin-top: 4px; }

/* Lektion */
.seg { display: flex; background: var(--card); border-radius: 12px; padding: 3px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); padding: 9px 6px; border-radius: 10px; font-size: 15px; font-weight: 600; }
.seg button.on { background: var(--card2); color: var(--fg); }
.stats { display: flex; gap: 8px; margin: 12px 0; }
.stat { flex: 1; background: var(--card); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
table.words { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 14px; overflow: hidden; }
table.words td { padding: 10px 12px; border-bottom: 1px solid #3d3d41; vertical-align: top; }
table.words tr:last-child td { border-bottom: 0; }
table.words td:first-child { color: var(--muted); width: 45%; }
.speak { background: none; border: 0; color: var(--accent); font-size: 18px; padding: 0 6px; }
.box { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: #48484a; margin-right: 2px; }
.box.on { background: var(--ok); }

/* Runde */
.progress { height: 6px; background: #48484a; border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.card {
  background: var(--card); border-radius: 20px; padding: 26px 20px; text-align: center; min-height: 190px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px;
}
.card .label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.card .prompt { font-size: 32px; font-weight: 700; line-height: 1.2; word-break: break-word; }
.card .hint { color: var(--muted); font-size: 15px; }
.card.right { background: #1f3b26; }
.card.wrong { background: #3f2224; }
.answer-input {
  width: 100%; margin-top: 14px; padding: 14px; font-size: 22px; border-radius: 14px; border: 2px solid var(--card2);
  background: var(--card); color: var(--fg); text-align: center; outline: none;
}
.answer-input:focus { border-color: var(--accent); }
.answer-input.wrong { border-color: var(--danger); color: var(--danger); text-decoration: line-through; }
.accents { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.accents button { border: 0; background: var(--card2); color: var(--fg); border-radius: 8px; min-width: 38px; height: 38px; font-size: 18px; }
.feedback { margin-top: 14px; border-radius: 14px; padding: 14px 16px; }
.feedback.right { background: #1f3b26; color: var(--ok); font-weight: 700; }
.feedback.wrong { background: #3f2224; }
.feedback .exp { font-size: 24px; font-weight: 700; color: var(--fg); margin-top: 4px; }
.feedback .yours { color: var(--muted); font-size: 15px; text-decoration: line-through; }
.result { text-align: center; padding: 20px 0; }
.result .score { font-size: 64px; font-weight: 800; line-height: 1; margin: 10px 0; }
.result .score.good { color: var(--ok); }
.result .score.mid { color: var(--warn); }
.result .score.bad { color: var(--danger); }

/* Einstellungen */
.field { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px; }
.field input[type=number] { width: 80px; background: var(--card2); border: 0; border-radius: 8px; padding: 8px; text-align: center; font-size: 18px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%);
  background: #f2f2f7; color: #1c1c1e; padding: 10px 16px; border-radius: 12px; font-size: 15px; font-weight: 600;
  max-width: calc(100% - 32px); z-index: 10; box-shadow: 0 6px 24px rgba(0,0,0,.5);
}
.install { background: var(--card); border-radius: 14px; padding: 12px 14px; font-size: 14px; color: var(--muted); margin-top: 20px; }
