/* Layout: App-Shell mit Kopfzeile, scrollendem Inhalt und Tab-Leiste unten; Karopapier-Anklang im Hintergrund */
:root {
  --bg: #f3f6f4; --grid: #e2e9e5; --surface: #ffffff; --surface-2: #eef3f0; --ink: #14201a; --muted: #5a6b62;
  --line: #d4ddd8; --pitch: #1d6b44; --pitch-ink: #ffffff; --pitch-soft: #dfeee5; --school: #2a4fa0; --school-soft: #e2e8f7;
  --amber: #a15c00; --amber-soft: #fbecd6; --red: #b42323; --red-soft: #f9dede; --head: #123d2a; --head-ink: #eaf4ee;
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1411; --grid: #141c17; --surface: #161f1a; --surface-2: #1c2721; --ink: #e5ede8; --muted: #93a39a;
    --line: #27332c; --pitch: #5cc48a; --pitch-ink: #07150d; --pitch-soft: #1a3324; --school: #8fabf0; --school-soft: #1c2640;
    --amber: #f0b45a; --amber-soft: #352816; --red: #f08a8a; --red-soft: #3a1c1c; --head: #0b2419; --head-ink: #dcebe2;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--body);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2, h3 { font-family: var(--display); font-stretch: 80%; margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
p { margin: 0; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.eyebrow { font: 600 .7rem/1.2 var(--body); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-left)); background: var(--head); }
.login-card { width: min(360px, 100%); background: var(--surface); border-radius: 16px; padding: 24px; display: grid; gap: 10px; }
.login-card h1 { font-size: 2.2rem; font-weight: 800; }
.login-card input { font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.err { color: var(--red); }

/* Shell */
.app { height: 100%; display: grid; grid-template-rows: auto 1fr auto; }
.top {
  background: var(--head); color: var(--head-ink); display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
}
.top .eyebrow { color: color-mix(in srgb, var(--head-ink) 70%, transparent); }
.top h1 { font-size: 1.6rem; font-weight: 800; line-height: 1.05; }
.top-r { display: flex; gap: 8px; align-items: center; }
.badge { font: 600 .75rem/1 var(--mono); padding: 6px 8px; border-radius: 6px; background: color-mix(in srgb, var(--head-ink) 14%, transparent); }
main { overflow-y: auto; overscroll-behavior: contain; }
.view { padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); display: grid; gap: 14px; align-content: start; max-width: 760px; margin: 0 auto; }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 10px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:active { background: var(--surface-2); }
.top .icon-btn:active { background: color-mix(in srgb, var(--head-ink) 14%, transparent); }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 11px 14px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--pitch); color: var(--pitch-ink); border-color: var(--pitch); }
.btn.wide { width: 100%; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--school); outline-offset: 2px; }

/* Tabs */
.tabs {
  display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line);
  padding: 4px max(4px, env(safe-area-inset-right)) calc(4px + env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
}
.tabs button { background: none; border: 0; display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: .7rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button[aria-current="page"] { color: var(--pitch); }

/* Karten */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.report { border-left: 4px solid var(--school); display: grid; gap: 6px; }
.now { display: grid; gap: 10px; }
.now-row { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.now h2 { font-size: 1.5rem; font-weight: 750; line-height: 1.15; margin-top: 2px; }
.countdown { font: 500 1.3rem/1 var(--mono); font-variant-numeric: tabular-nums; color: var(--pitch); white-space: nowrap; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.fill { height: 100%; width: 0; background: var(--pitch); transition: width .4s; }
.next { font-size: .9rem; color: var(--muted); }
.next b { color: var(--ink); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: 600 .8rem/1 var(--body); padding: 7px 10px; border-radius: 999px; background: var(--school-soft); color: var(--school); }
.chip.hot { background: var(--red-soft); color: var(--red); }
.quick { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.qbtn { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 12px; font-size: .85rem; font-weight: 600; cursor: pointer; }
.qbtn.strong { background: var(--pitch); color: var(--pitch-ink); border-color: var(--pitch); }
.day-nav { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.task {
  display: grid; grid-template-columns: 54px 4px 1fr auto; gap: 10px; align-items: start; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer;
}
.task .t { font: 500 .82rem/1.35 var(--mono); font-variant-numeric: tabular-nums; color: var(--muted); }
.task .stripe { width: 4px; align-self: stretch; border-radius: 2px; background: var(--line); }
.task .ti { font-weight: 600; line-height: 1.3; }
.task .de { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.task .st { font: 600 .65rem/1 var(--body); letter-spacing: .06em; text-transform: uppercase; padding: 4px 6px; border-radius: 4px; align-self: center; }
.task.now-task { border-color: var(--pitch); box-shadow: inset 0 0 0 1px var(--pitch); }
.task.done .ti { text-decoration: line-through; color: var(--muted); }
.task.minor { padding: 6px 12px; background: transparent; border-style: dashed; }
.task.minor .ti { font-weight: 500; font-size: .88rem; color: var(--muted); }
.c-schule, .c-unterricht { background: var(--school) !important; }
.c-fussball { background: var(--pitch) !important; }
.c-qol { background: var(--amber) !important; }
.c-schlaf { background: var(--muted) !important; }
.c-termin { background: var(--red) !important; }
.st.erledigt { background: var(--pitch-soft); color: var(--pitch); }
.st.teilweise { background: var(--amber-soft); color: var(--amber); }
.st.ausgefallen, .st.verschoben { background: var(--red-soft); color: var(--red); }

/* Chat */
.chat-view { height: 100%; grid-template-rows: 1fr auto auto; padding-bottom: 8px; gap: 8px; }
main:has(#v-chat:not([hidden])) { overflow: hidden; }
.msgs { overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 0 8px; min-height: 0; }
.msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--pitch); color: var(--pitch-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.assistant p + p, .msg.assistant ul, .msg.assistant ol { margin-top: 8px; }
.msg.assistant ul, .msg.assistant ol { padding-left: 20px; margin-bottom: 0; }
.msg img { max-width: 100%; border-radius: 8px; display: block; margin-bottom: 6px; }
.toolchip { align-self: flex-start; font: 500 .75rem/1 var(--mono); color: var(--muted); padding: 4px 8px; border-left: 2px solid var(--pitch); }
.typing { align-self: flex-start; color: var(--muted); font-size: .85rem; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.composer { display: grid; grid-template-columns: auto 1fr auto auto; gap: 4px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 4px; }
.composer textarea { border: 0; background: transparent; color: var(--ink); font: inherit; resize: none; padding: 9px 4px; max-height: 140px; outline: none; }
.mic.rec { color: #fff; background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .7; } }
.send { color: var(--pitch); }
.pending-imgs { display: flex; gap: 6px; flex-wrap: wrap; }
.pending-imgs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }

/* Woche */
.toggle { display: flex; gap: 8px; align-items: center; font-size: .88rem; color: var(--muted); }
.wday { display: grid; gap: 6px; margin-bottom: 14px; }
.wday h3 { font-size: 1.05rem; display: flex; gap: 8px; align-items: baseline; }
.wday h3 .eyebrow { font-family: var(--body); font-stretch: normal; }
.wday.today h3 { color: var(--pitch); }
.wrow { display: grid; grid-template-columns: 82px 4px 1fr; gap: 10px; font-size: .88rem; align-items: start; }
.wrow .t { font: 500 .78rem/1.5 var(--mono); color: var(--muted); }
.wrow .stripe { width: 4px; align-self: stretch; border-radius: 2px; background: var(--line); }
.wrow.done .ti { text-decoration: line-through; color: var(--muted); }

/* Noten */
.sec { font-size: 1.15rem; margin-top: 6px; }
.grades { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.g { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 4px; align-content: start; min-width: 0; }
.g .n { font: 800 2rem/1 var(--display); font-stretch: 80%; font-variant-numeric: tabular-nums; }
.g .n.good { color: var(--pitch); } .g .n.mid { color: var(--amber); } .g .n.bad { color: var(--red); }
.g .why { font-size: .78rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.g svg.spark { width: 100%; height: 26px; }
.g svg.spark path { stroke: var(--muted); stroke-width: 1.5; fill: none; }
.g svg.spark circle { fill: var(--ink); stroke: none; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.row:last-child { border-bottom: 0; }
.row .v { font: 500 .9rem var(--mono); font-variant-numeric: tabular-nums; }
.mem summary { cursor: pointer; font-weight: 600; }
.mem ul { margin: 10px 0 0; padding-left: 18px; display: grid; gap: 4px; font-size: .88rem; }

/* Notizen */
.note { display: grid; gap: 4px; cursor: pointer; }
.note .cat { font: 600 .66rem/1 var(--body); letter-spacing: .08em; text-transform: uppercase; color: var(--pitch); }

/* Sheet & Toast */
.sheet-bg { position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--surface); border-radius: 18px 18px 0 0;
  max-height: 85vh; overflow-y: auto; display: grid; gap: 12px;
  padding: 18px max(16px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.sheet h3 { font-size: 1.3rem; }
.sheet .acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sheet img { max-width: 100%; border-radius: 10px; }
.sheet pre { white-space: pre-wrap; font: .88rem/1.5 var(--body); background: var(--surface-2); padding: 12px; border-radius: 10px; margin: 0; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: .9rem; max-width: calc(100% - 32px);
}
@media (prefers-reduced-motion: reduce) { .fill { transition: none; } .mic.rec { animation: none; } }
