/* Apple-Stil: SF-Systemschrift, HIG-Schriftgrößen, Systemfarben, gruppierte Listen */
:root {
  --bg: #f2f2f7; --surface: #ffffff; --fill: rgba(118,118,128,.12); --fill-2: rgba(118,118,128,.08);
  --label: #000000; --label-2: rgba(60,60,67,.6); --label-3: rgba(60,60,67,.3);
  --sep: rgba(60,60,67,.29); --material: rgba(242,242,247,.78);
  --blue: #007aff; --red: #ff3b30; --orange: #ff9500; --green: #34c759; --indigo: #5856d6; --gray: #8e8e93;
  --red-soft: rgba(255,59,48,.12); --orange-soft: rgba(255,149,0,.14); --green-soft: rgba(52,199,89,.14);
  --blue-soft: rgba(0,122,255,.12); --gray-soft: rgba(142,142,147,.14);
  --r: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000; --surface: #1c1c1e; --fill: rgba(118,118,128,.24); --fill-2: rgba(118,118,128,.16);
    --label: #ffffff; --label-2: rgba(235,235,245,.6); --label-3: rgba(235,235,245,.3);
    --sep: rgba(84,84,88,.65); --material: rgba(18,18,20,.78);
    --blue: #0a84ff; --red: #ff453a; --orange: #ff9f0a; --green: #30d158; --indigo: #5e5ce6; --gray: #8e8e93;
    --red-soft: rgba(255,69,58,.2); --orange-soft: rgba(255,159,10,.2); --green-soft: rgba(48,209,88,.18);
    --blue-soft: rgba(10,132,255,.2); --gray-soft: rgba(142,142,147,.22);
    color-scheme: dark;
  }
}

/* Schriftgrößen nach Apple HIG */
.t-large  { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: -.4px; }
.t-title2 { font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -.26px; }
.t-title3 { font-size: 20px; line-height: 25px; font-weight: 600; letter-spacing: -.45px; }
.t-head   { font-size: 17px; line-height: 22px; font-weight: 600; letter-spacing: -.43px; }
.t-body   { font-size: 17px; line-height: 22px; letter-spacing: -.43px; }
.t-callout{ font-size: 16px; line-height: 21px; letter-spacing: -.31px; }
.t-sub    { font-size: 15px; line-height: 20px; letter-spacing: -.23px; }
.t-foot   { font-size: 13px; line-height: 18px; letter-spacing: -.08px; }
.t-cap    { font-size: 12px; line-height: 16px; }
.muted { color: var(--label-2); }

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--label); font-size: 17px; line-height: 22px; letter-spacing: -.43px; }
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
svg.i { width: 1em; height: 1em; vertical-align: -.125em; flex: none; }

/* Kopfbereich mit Material-Unschärfe */
.top { position: sticky; top: 0; z-index: 10; background: var(--material);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.sync { display: flex; align-items: center; gap: 10px; }
.btn-plain { background: none; border: 0; color: var(--blue); cursor: pointer; padding: 4px 0; display: inline-flex; gap: 6px; align-items: center; }
.btn-plain:disabled { color: var(--label-3); cursor: default; }
.btn-tinted { background: var(--blue-soft); color: var(--blue); border: 0; border-radius: 999px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 15px; }

/* Segmentsteuerung */
.seg { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 7px; padding: 6px 10px; cursor: pointer; font-size: 13px; line-height: 18px; font-weight: 500; white-space: nowrap; }
.seg button.on { background: var(--surface); box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg button.on { background: #636366; } }
nav.seg { max-width: 760px; margin: 0 auto; }
.nav-wrap { padding: 0 16px 10px; }

main.wrap { padding-top: 8px; padding-bottom: 64px; }
h1.t-large { margin: 14px 0 12px; }

/* Gruppierte Listen */
.section-h { margin: 26px 0 7px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section-h .t-foot { text-transform: uppercase; color: var(--label-2); padding-left: 16px; }
.group { background: var(--surface); border-radius: var(--r); overflow: hidden; }
.row { display: flex; gap: 12px; padding: 11px 16px; position: relative; align-items: flex-start; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: var(--inset, 16px); border-top: .5px solid var(--sep); }
.row.center { align-items: center; }
.row .grow { flex: 1; min-width: 0; }
.group-foot { color: var(--label-2); padding: 7px 16px 0; font-size: 13px; line-height: 18px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--gray)); flex: none; margin-top: 6px; }

/* Suche & Auswahl */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.search { flex: 1; min-width: 180px; display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 10px; padding: 7px 10px; color: var(--label-2); }
.search input { border: 0; background: none; outline: none; flex: 1; font-size: 17px; color: var(--label); }
.select { appearance: none; -webkit-appearance: none; background: var(--fill); border: 0; border-radius: 10px; padding: 7px 30px 7px 12px; font-size: 15px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238e8e93' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; }
.select.full { width: 100%; }
.seg.small { margin: 10px 0 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.seg.small::-webkit-scrollbar { display: none; }
.seg.small button { flex: 1 0 auto; }

/* Neuigkeiten */
.item-meta { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item-course { font-weight: 600; font-size: 15px; line-height: 20px; letter-spacing: -.23px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-kind { color: var(--label-2); font-size: 13px; line-height: 18px; display: inline-flex; gap: 4px; align-items: center; }
.item-title { font-size: 16px; line-height: 21px; letter-spacing: -.31px; margin-top: 3px; overflow-wrap: anywhere; }
.item-text { font-size: 16px; line-height: 21px; letter-spacing: -.31px; margin-top: 4px; white-space: pre-line; overflow-wrap: anywhere; }
.item-text.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.item-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; align-items: center; font-size: 13px; line-height: 18px; color: var(--label-2); }
.row.alert { background: var(--red-soft); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--fill-2); color: var(--label); border-radius: 8px; padding: 4px 9px; font-size: 13px; line-height: 18px; max-width: 100%; }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover { text-decoration: none; background: var(--fill); }
.more { background: none; border: 0; color: var(--blue); padding: 0; cursor: pointer; font-size: 15px; margin-top: 2px; }
.forum-list { margin: 6px 0 0; padding: 0; list-style: none; }
.forum-list li { font-size: 15px; line-height: 20px; padding: 3px 0; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
.disclose { color: var(--blue); font-size: 15px; display: inline-flex; gap: 4px; align-items: center; }
details[open] .chev { transform: rotate(90deg); }
.chev { transition: transform .2s; }

/* Symbol-Kacheln in Neuigkeiten (gleiche Breite wie die Dateisymbole) */
.ktile { width: 36px; height: 36px; border-radius: 9px; flex: none; display: grid; place-items: center; color: #fff; font-size: 20px; margin-top: 2px; }
.ktile.orange { background: var(--orange); } .ktile.blue { background: var(--blue); } .ktile.green { background: var(--green); }
.ktile.indigo { background: var(--indigo); } .ktile.gray { background: var(--gray); } .ktile.red { background: var(--red); }
.row-sub { margin-top: 1px; }
.mini-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; margin-right: 6px; vertical-align: 0; }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.row-head .file-name { min-width: 0; }
.row-head .t-foot { flex: none; }
/* eingeklappt: 3 Zeilen fließender Text; aufgeklappt: mit Absätzen */
.row-text { font-size: 15px; line-height: 20px; color: var(--label); margin-top: 5px; white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.row.open .row-text { white-space: pre-line; display: block; -webkit-line-clamp: unset; overflow: visible; }
.row-extra { display: none; margin-top: 8px; font-size: 13px; line-height: 18px; }
.row.open .row-extra { display: block; }
[data-expand] { cursor: pointer; -webkit-tap-highlight-color: transparent; }

/* Anhänge in Neuigkeiten: wie Dateizeilen (Symbol/Vorschau + Name) */
.att-list { display: grid; gap: 6px; margin-top: 8px; }
.att-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; background: var(--fill-2); border-radius: 10px; color: var(--label); min-width: 0; }
.att-item:hover { text-decoration: none; background: var(--fill); }
.att-item .ftile { width: 30px; height: 38px; font-size: 8px; padding-bottom: 4px; }
.att-item .ftile::after { width: 9px; height: 9px; }
.att-name { font-size: 15px; line-height: 20px; letter-spacing: -.23px; overflow-wrap: anywhere; }

.fach-h { display: flex; align-items: center; margin: 14px 0 6px; padding-left: 16px; font-size: 13px; line-height: 18px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--label-2); }
.fach-h .mini-dot { width: 9px; height: 9px; }
.section-h + .fach-h { margin-top: 4px; }

/* Pillen (Status) */
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 9px; font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap; background: var(--gray-soft); color: var(--label-2); }
.pill.Ausfall { background: var(--red-soft); color: var(--red); }
.pill.Vertretung { background: var(--orange-soft); color: var(--orange); }
.pill.Raumänderung { background: var(--blue-soft); color: var(--blue); }
.pill.Selbstlernzeit { background: var(--green-soft); color: var(--green); }

/* „Für dich“-Karte */
.foryou { background: var(--surface); border-radius: var(--r); padding: 14px 16px 6px; margin-top: 4px; }
.foryou h2 { margin: 0 0 4px; display: flex; gap: 8px; align-items: center; }
.foryou h2 .i { color: var(--red); }
.foryou .row { padding-left: 0; padding-right: 0; --inset: 0px; }
.period { width: 46px; flex: none; text-align: center; }
.period b { display: block; font-size: 20px; line-height: 25px; font-weight: 600; letter-spacing: -.45px; }
.period small { color: var(--label-2); font-size: 11px; line-height: 13px; text-transform: uppercase; }

/* Vertretungsplan */
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 28px 0 8px; padding: 0 4px; }
.plan-head.past { opacity: .5; }
.tbl-wrap { overflow-x: auto; padding: 0 16px 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 18px; }
th, td { text-align: left; padding: 6px 8px 6px 0; border-bottom: .5px solid var(--sep); vertical-align: top; }
th { color: var(--label-2); font-weight: 500; font-size: 12px; }
tr.mine td { color: var(--blue); font-weight: 600; }
.notes { margin: 0; padding: 0 16px 12px; list-style: none; font-size: 13px; line-height: 18px; color: var(--label-2); }
.notes li { padding: 2px 0; }
.ocr-text { white-space: pre-line; font-size: 15px; line-height: 20px; }

/* Dateien */
.ftile { width: 36px; height: 44px; border-radius: 7px; flex: none; display: grid; place-items: end center; padding-bottom: 6px; font-size: 9px; font-weight: 700; letter-spacing: .3px; color: #fff; background: var(--gray); position: relative; }
.ftile::after { content: ""; position: absolute; top: 0; right: 0; width: 11px; height: 11px; background: linear-gradient(225deg, var(--bg) 50%, rgba(0,0,0,.18) 50%); border-bottom-left-radius: 3px; }
.ftile.pdf { background: #e5463c; } .ftile.doc { background: #2b6fd6; } .ftile.xls { background: #1f9d55; }
.ftile.ppt { background: #e07a1f; } .ftile.link { background: var(--indigo); }
.ftile.thumb { background-color: var(--fill); background-size: cover; background-position: center; padding: 0; }
.ftile.thumb::after { display: none; }
.file-name { font-size: 16px; line-height: 21px; letter-spacing: -.31px; overflow-wrap: anywhere; color: var(--label); }
a.row:hover { text-decoration: none; background: var(--fill-2); }

/* Einstellungen */
.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; background: var(--fill); border-radius: 999px; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); transition: transform .2s; }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: .4; }
.switch-col { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.switch-col small { font-size: 11px; line-height: 13px; color: var(--label-2); }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; background: var(--fill-2); border-radius: 6px; padding: 2px 6px; overflow-wrap: anywhere; }
.seg.mini { flex: none; }
.seg.mini button { padding: 4px 9px; font-size: 12px; }
.empty { color: var(--label-2); text-align: center; padding: 48px 16px; font-size: 15px; }
.steps { margin: 0; padding-left: 20px; font-size: 15px; line-height: 22px; }

.name-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rename { color: var(--label-3); padding: 2px; font-size: 15px; }
.rename:hover { color: var(--blue); }
.rename-input { flex: 1; min-width: 0; border: 0; outline: none; background: var(--fill); border-radius: 8px; padding: 5px 9px; font-size: 16px; line-height: 21px; }

.thread { display: block; padding: 0; }
.thread-sum { display: flex; gap: 12px; padding: 11px 16px; align-items: center; }
.thread-prev { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(180deg, #a5abb6, #858a94); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 16px; flex: none; }
.bubbles { padding: 4px 16px 14px 66px; display: grid; gap: 8px; }
.bubble { background: var(--fill-2); border-radius: 14px; padding: 8px 12px; }
.bubble .item-text { margin-top: 2px; }
.bubble .chip { margin-top: 6px; }

/* Datei-Betrachter */
body.viewer-open { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
.viewer-bar { display: flex; align-items: center; gap: 12px; padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  background: var(--material); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep); }
.viewer-title { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-share { font-size: 22px; }
.viewer-body { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 12px; }
.viewer-page { background: #fff; border-radius: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.18); flex: none; }
.viewer-img { max-width: 100%; height: auto; border-radius: 6px; }
.viewer-other { text-align: center; max-width: 420px; margin: 48px auto; display: grid; gap: 14px; justify-items: center; }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { background: var(--surface); border-radius: 16px; padding: 28px 24px; display: grid; gap: 14px; width: min(360px, 100%); }
.login-box h1 { margin: 0 0 4px; font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: .36px; }
.login-box input { padding: 11px 12px; border: 0; border-radius: 10px; background: var(--fill); font-size: 17px; }
.login-box button { padding: 12px; border: 0; border-radius: 12px; background: var(--blue); color: #fff; cursor: pointer; font-size: 17px; font-weight: 600; }
.error { color: var(--red); margin: 0; font-size: 15px; }

/* Nichts darf breiter als der Bildschirm werden (sonst zoomt das iPhone heraus) */
.bubbles { grid-template-columns: minmax(0, 1fr); }
.bubble, .item-text, .t-cap { min-width: 0; overflow-wrap: anywhere; }
#tabs .ti { display: none; }
.top { padding-top: env(safe-area-inset-top); }

@media (max-width: 520px) {
  .t-large { font-size: 30px; line-height: 36px; }
  .hide-sm { display: none; }
}

/* iPhone: Bereichsauswahl als Tab-Leiste unten, wie in iOS-Apps */
@media (max-width: 600px) {
  .top { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }  /* sonst hängt die Leiste am Kopf */
  .nav-wrap { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 0 0 env(safe-area-inset-bottom);
    background: var(--material); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    border-top: .5px solid var(--sep); }
  nav.seg { background: none; border-radius: 0; padding: 5px 4px 3px; gap: 0; }
  nav.seg button { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; padding: 2px 0;
    font-size: 10px; line-height: 12px; font-weight: 500; color: var(--gray); background: none; box-shadow: none; }
  nav.seg button.on { color: var(--blue); font-weight: 600; background: none; box-shadow: none; }
  nav.seg button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  #tabs .ti { display: block; width: 25px; height: 25px; }
  main.wrap { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
}
