:root {
  --bg: #f4f6f5;
  --card: #ffffff;
  --ink: #18221f;
  --muted: #6a7b76;
  --line: #e3e9e7;
  --brand: #0f7a6b;
  --brand-dark: #0b5d51;
  --brand-soft: #e3f2ef;
  --accent: #f0a020;
  --danger: #d2453b;
  --ok: #1f9d63;
  --shadow: 0 6px 22px rgba(16, 40, 35, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px calc(14px) 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
}
.topbar .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,0.18);
  display: grid; place-items: center; font-size: 22px; flex: none;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .2px; }
.topbar .sub { font-size: 12px; opacity: .85; margin-top: 1px; }
.topbar .spacer { flex: 1; }
.topbar button.ghost {
  background: rgba(255,255,255,0.16); color: #fff; border: none;
  padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 600;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 6px; padding: 10px 14px; position: sticky; top: 68px;
  background: var(--bg); z-index: 15; border-bottom: 1px solid var(--line);
}
.tabs button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  font-weight: 600; font-size: 14px; padding: 9px 6px; border-radius: 12px;
}
.tabs button.active { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- Layout ---------- */
.page { padding: 16px 14px 90px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 18px 4px 8px; font-weight: 700; }

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

/* ---------- Lesson cards ---------- */
.lesson-media { border-radius: 14px; overflow: hidden; background: #000; margin-bottom: 12px; }
.lesson-media video, .lesson-media img { width: 100%; display: block; max-height: 60vh; object-fit: contain; background:#000; }
.lesson-media.youtube { position: relative; padding-top: 56.25%; height: 0; }
.lesson-media.youtube iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.lesson-title { font-size: 18px; font-weight: 700; margin: 2px 0 6px; }
.lesson-body { color: #33433e; white-space: pre-wrap; }
.meta { font-size: 12px; color: var(--muted); margin-top: 8px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge.todo { background: #fdeede; color: #a35e00; }
.badge.done { background: #e3f5ea; color: var(--ok); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 14px; font-weight: 700; font-size: 15px;
  padding: 13px 16px; width: 100%; cursor: pointer; transition: transform .05s ease;
}
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:disabled { background: #9cc4bd; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.soft { background: var(--brand-soft); color: var(--brand-dark); }
.btn.outline { background: #fff; color: var(--brand-dark); border: 1.5px solid var(--line); }
.btn.danger { background: #fde7e5; color: var(--danger); }
.btn.small { width: auto; padding: 9px 14px; font-size: 13px; border-radius: 11px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 16px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); }
select.mini { width: auto; padding: 7px 10px; font-size: 13px; border-radius: 10px; }
textarea { min-height: 90px; resize: vertical; }

.file-drop {
  display: block; box-sizing: border-box;
  border: 2px dashed var(--line); border-radius: 14px; padding: 22px; text-align: center;
  color: var(--muted); font-weight: 600; background: #fafcfb; cursor: pointer;
}
.file-drop.has { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
/* Datei-Feld unsichtbar, aber nicht display:none – sonst öffnet iOS Safari den Dialog nicht.
   Geclippt (statt off-screen), damit es das Layout nicht verschiebt. */
input[type=file] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); border: 0; opacity: 0;
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(120% 80% at 50% 0%, #16907e 0%, var(--brand-dark) 60%, #094a41 100%); }
.login-card { background: #fff; border-radius: 24px; padding: 28px 22px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-logo { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-size: 34px; margin: 0 auto 14px; }
.login-card h2 { text-align: center; margin: 0 0 2px; }
.login-card p.lead { text-align: center; color: var(--muted); margin: 0 0 20px; font-size: 14px; }

/* ---------- Overview ---------- */
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--ok); border-radius: 999px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { font-size: 12px; padding: 4px 9px; border-radius: 999px; background: #eef2f1; color: #44544f; }
.chip.seen { background: #e3f5ea; color: var(--ok); }
.chip.miss { background: #fde7e5; color: var(--danger); }

.comment { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.comment .who { font-weight: 700; font-size: 13px; }
.comment .when { font-size: 11px; color: var(--muted); }
.comment audio { width: 100%; margin-top: 6px; }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: none; }
.list-item .name { font-weight: 600; flex: 1; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #18221f; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); display: inline-block; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.fab {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: 22px;
  width: 58px; height: 58px; border-radius: 50%; background: var(--accent); color: #fff;
  border: none; font-size: 30px; box-shadow: 0 8px 24px rgba(240,160,32,.5); z-index: 30;
}

.modal-back { position: fixed; inset: 0; background: rgba(10,20,18,.45); z-index: 40; display: grid; align-items: end; }
.modal { background: #fff; width: 100%; max-width: 720px; margin: 0 auto; border-radius: 22px 22px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; }
.modal h3 { margin: 4px 0 16px; }
.modal .grip { width: 42px; height: 5px; background: var(--line); border-radius: 999px; margin: 2px auto 14px; }

/* ---------- Documents / signatures ---------- */
.doc-frame { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #fafcfb; margin-bottom: 12px; }
.doc-frame iframe { width: 100%; height: 52vh; border: 0; display: block; background: #fff; }
.doc-frame img { width: 100%; display: block; max-height: 60vh; object-fit: contain; background: #000; }
.doc-file-link { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; text-decoration: none; margin-bottom: 12px; }

.sig-canvas {
  width: 100%; height: 180px; border: 2px dashed var(--line); border-radius: 14px;
  background: #fff; touch-action: none; display: block;
}
.sig-canvas.has { border-style: solid; border-color: var(--brand); }
.sig-hint { font-size: 12px; color: var(--muted); margin: 6px 2px 12px; text-align: center; }
.sig-view { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: #fff; display: block; }

.chip[data-sig] { cursor: pointer; }
.chip[data-sig]:active { transform: scale(.96); }
