:root {
  --bg: #F2EDE0;
  --surface: #FFFDF8;
  --surface-2: #E9E3D2;
  --line: #DDD5C2;
  --ink: #1B1740;
  --ink-2: #4B4870;
  --ink-3: #807C9E;
  --primary: #5B4BE1;
  --primary-ink: #FFFFFF;
  --primary-soft: #E7E4FB;
  --accent: #FF9F43;
  --accent-soft: #FFE7CF;
  --ok: #2E9E6A;
  --ok-soft: #DDF3E8;
  --danger: #D9534F;
  --shadow: 0 1px 2px rgba(27,23,64,.06), 0 4px 16px rgba(27,23,64,.06);
  --radius: 18px;
  --font-head: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, -apple-system, sans-serif; /* Systemschrift: keine Schriftarten von Dritten (Datenschutz) */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }

.app { max-width: 720px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 700 1.35rem var(--font-head); }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.streak { font-weight: 800; background: var(--accent-soft); color: var(--ink); padding: 4px 10px; border-radius: 999px; font-size: .9rem; }
.tier-badge { text-decoration: none; font-weight: 800; font-size: .8rem; letter-spacing: .04em; text-transform: uppercase; background: var(--primary); color: var(--primary-ink); padding: 5px 10px; border-radius: 999px; }

main { flex: 1; padding: 8px 16px calc(96px + env(safe-area-inset-bottom)); outline: none; }

/* Tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  max-width: 720px; margin: 0 auto;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--ink-3); font-size: .72rem; font-weight: 700; padding: 4px 0; border-radius: 12px; }
.tabbar a .ico { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.active { color: var(--primary); background: var(--primary-soft); }
.tabbar a.active .ico { stroke-width: 2.4; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.card.hero { background: var(--primary); color: var(--primary-ink); border: 0; }
.card.hero .muted { color: color-mix(in srgb, var(--primary-ink) 80%, transparent); }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 20px 0 10px; }
.section-title h2 { margin: 0; }
.stack > * + * { margin-top: 10px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.empty { text-align: center; padding: 28px 16px; color: var(--ink-2); }
.empty .big { font-size: 2.5rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 800; cursor: pointer; background: var(--surface-2); color: var(--ink); text-decoration: none; min-height: 44px; }
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.accent { background: var(--accent); color: #1B1740; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; cursor: pointer; font-size: 1.1rem; padding: 6px; border-radius: 10px; color: var(--ink-2); min-width: 36px; min-height: 36px; }
.icon-btn:hover { background: var(--surface-2); }

/* Forms */
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
input[type=text], input[type=date], input[type=number], input[type=time], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 1px; }
.hint { font-size: .8rem; color: var(--ink-3); margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--bg); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: .85rem; user-select: none; }
.chip input { display: none; }
.chip:has(input:checked) { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.seg { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; font-weight: 800; cursor: pointer; }
.seg button.on { background: var(--surface); box-shadow: var(--shadow); }

/* Tasks */
.task { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.task + .task { margin-top: 8px; }
.task .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.task .title { font-weight: 700; }
.task.done .title { text-decoration: line-through; color: var(--ink-3); }
.check { appearance: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); background: var(--bg); flex: none; cursor: pointer; display: grid; place-content: center; margin: 0; }
.check:checked { background: var(--ok); border-color: var(--ok); }
.check:checked::after { content: "✓"; color: #fff; font-weight: 900; font-size: 16px; line-height: 1; }
.tag { display: inline-block; font-size: .72rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); }
.tag.exam { background: var(--accent-soft); color: var(--ink); }

/* Progress */
.progress { height: 10px; background: color-mix(in srgb, var(--primary-ink) 25%, transparent); border-radius: 999px; overflow: hidden; }
.card:not(.hero) .progress { background: var(--surface-2); }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.stat { font: 700 2rem var(--font-head); line-height: 1; }

/* Week */
.week-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.day { padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 8px; }
.day.today { border: 2px solid var(--primary); }
.day.off { background: var(--surface-2); }
.day-label { font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); margin-bottom: 6px; display: flex; justify-content: space-between; }
.mini-task { display: flex; align-items: center; gap: 8px; font-size: .92rem; padding: 3px 0; }
.mini-task.done { color: var(--ink-3); text-decoration: line-through; }

/* Exams */
.exam-card { border-left: 6px solid var(--c, var(--primary)); }
.countdown { font: 700 1.6rem var(--font-head); line-height: 1; text-align: right; }
.countdown small { display: block; font: 700 .7rem var(--font-body); color: var(--ink-3); text-transform: uppercase; }

/* Grades */
.avg { font: 700 2.6rem var(--font-head); }
.grade-pill { font: 700 1rem var(--font-head); min-width: 44px; text-align: center; padding: 4px 8px; border-radius: 10px; background: var(--surface-2); }
.grade-pill.good { background: var(--ok-soft); }
.grade-pill.bad { background: color-mix(in srgb, var(--danger) 18%, transparent); }

/* Flashcards */
.flashcard { perspective: 1000px; height: 260px; cursor: pointer; margin-bottom: 12px; }
.flashcard .inner { position: relative; width: 100%; height: 100%; transition: transform .45s; transform-style: preserve-3d; }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); font: 600 1.3rem var(--font-head); }
.flashcard .back { transform: rotateY(180deg); background: var(--primary); color: var(--primary-ink); }
.flashcard .face small { font: 700 .75rem var(--font-body); text-transform: uppercase; letter-spacing: .06em; opacity: .7; margin-bottom: 10px; }
.quiz-opt { display: block; width: 100%; text-align: left; margin-bottom: 8px; padding: 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; }
.quiz-opt.right { border-color: var(--ok); background: var(--ok-soft); }
.quiz-opt.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* Plans */
.plans { display: grid; gap: 10px; }
.plan { position: relative; }
.plan.current { border: 2px solid var(--primary); }
.plan .price { font: 700 1.8rem var(--font-head); }
.plan ul { margin: 8px 0 12px; padding-left: 20px; }
.lock { text-align: center; }
.lock .big { font-size: 2.6rem; }

/* Modal & toast */
dialog { border: 0; border-radius: 22px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(18,16,42,.5); }
#modalBody { padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head h2 { margin: 0; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Onboarding */
.onboard { max-width: 480px; margin: 20px auto; }
.onboard .logo { width: 84px; height: 84px; margin: 0 auto 12px; display: block; }
.onboard h1 { text-align: center; font-size: 2rem; }
.slogan { text-align: center; color: var(--ink-2); font-size: 1.05rem; margin-bottom: 22px; }

@media (min-width: 560px) {
  .plans { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Icons */
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.empty .big, .lock .big { display: flex; justify-content: center; color: var(--primary); margin-bottom: 8px; }
.empty .big .ic, .lock .big .ic { width: 44px; height: 44px; stroke-width: 1.6; }
.streak { display: inline-flex; align-items: center; gap: 4px; }
.streak .ic, .hero .ic { color: var(--accent); }
.countdown .ic { width: 26px; height: 26px; color: var(--ok); }
#toast { display: inline-flex; align-items: center; gap: 8px; width: max-content; }
.feat { list-style: none; padding-left: 0 !important; }
.feat li { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 4px; }
.feat li .ic { color: var(--primary); margin-top: 2px; }
.icon-btn .ic { width: 22px; height: 22px; }
#planPreview .ic { color: var(--primary); }

/* Einheitliche Eingabefelder (auch iPhone) */
input[type=text], input[type=date], input[type=number], input[type=time], select {
  height: 48px; min-height: 48px; margin: 0; display: block; -webkit-appearance: none; appearance: none; line-height: 1.2;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 18px) 21px, calc(100% - 13px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .6; }
.field label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Fächer bei den Noten */
.subject-card { cursor: pointer; }
.subject-card .chev { color: var(--ink-3); }
.subject-head { display: flex; align-items: center; gap: 10px; }
.subject-head .swatch { width: 14px; height: 14px; border-radius: 50%; flex: none; }
.grade-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 4px; border-top: 1px solid var(--line); cursor: pointer; border-radius: 8px; }
.grade-row:hover { background: var(--surface-2); }
.stats-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 12px 0; }
.stats-row > div { background: var(--surface-2); border-radius: 12px; padding: 10px; text-align: center; }
.stats-row strong { display: block; font: 700 1.3rem var(--font-head); }

/* Einstellungen oben rechts */
.icon-link { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 999px; color: var(--ink-2); text-decoration: none; }
.icon-link .ic { width: 22px; height: 22px; }
.icon-link:hover, .icon-link.active { background: var(--primary-soft); color: var(--primary); }

/* Gratis-Testphase */
.trial { display: flex; gap: 8px; align-items: flex-start; background: var(--accent-soft); border-radius: 12px; padding: 8px 10px; margin: 8px 0 0; color: var(--ink); }
.trial .ic { color: var(--accent); margin-top: 2px; }

/* ---------- Version 1.1: Farbwahl, Notenziel, Fokus-Timer ---------- */
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatch-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; margin: 0; }
.swatch-pick input { position: absolute; opacity: 0; pointer-events: none; }
.swatch-pick span { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: #fff; box-shadow: inset 0 0 0 3px rgba(255,255,255,.0); transition: transform .15s; }
.swatch-pick span .ic { opacity: 0; width: 20px; height: 20px; }
.swatch-pick input:checked + span { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ink); }
.swatch-pick input:checked + span .ic { opacity: 1; }
.swatch-pick input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 3px; }
.swatch-pick small { font-size: .7rem; color: var(--ink-3); text-align: center; line-height: 1.1; }
.goal-box { background: var(--primary-soft); border-radius: 14px; padding: 12px 14px; margin: 4px 0 14px; }
.goal-box .ic { color: var(--primary); }
.goal-box select { background: var(--surface); }
.goal-result { margin: 10px 0 0; font-weight: 700; }
.goal-result.good { color: var(--ok); }
.goal-result.bad { color: var(--danger); }
.focus-card { display: flex; width: 100%; align-items: center; justify-content: space-between; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.focus-card > .row > .ic, .focus-card .row > .ic { color: var(--primary); width: 26px; height: 26px; flex: none; }
.focus-card.running { display: block; cursor: default; border: 2px solid var(--primary); }
.focus-time { font: 700 1.6rem var(--font-head); font-variant-numeric: tabular-nums; }

/* Logo in der gewählten Farbe */
.brand-logo .lg-bg { fill: var(--primary); }
.brand-logo .lg-check { stroke: var(--primary); }
.brand-logo { flex: none; display: block; }
