/* ==========================================================================
   FISI Lernportal - Stylesheet (von Hand geschrieben, keine externen Quellen)
   Design "Lesesaal bei Nacht": ruhige, dunkle Arbeitsflaechen, klare
   Typografie, ein Akzent (Gelb) fuer Aktionen/Fokus, pro Fach eine
   Zweitfarbe (--fach) nur fuer Icons und Hinweise.
   Responsive bis 360 px, WCAG-AA-Kontraste, prefers-reduced-motion.
   Schriften lokal in css/fonts (SIL Open Font License, siehe LICENSE-*.txt).
   ========================================================================== */

/* ---------- Schriften ---------- */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("fonts/atkinson-hyperlegible-next-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Flaechen (von dunkel nach hell) */
  --bg:          #0a0c11;
  --bg-2:        #0d1016;
  --surface:     #11151d;
  --surface-2:   #161b25;
  --surface-3:   #1d2330;
  --glass:       var(--surface);   /* Alias fuer aeltere Regeln */
  --solid:       var(--surface);
  --line:        rgba(255, 255, 255, .08);
  --line-hi:     rgba(255, 255, 255, .15);

  /* Text */
  --text:        #eef0f5;      /* auf --surface ca. 16:1 */
  --text-muted:  #aab2c3;      /* auf --surface ca. 8.6:1 */
  --text-dim:    #8b94a8;      /* auf --surface ca. 5.7:1 */

  /* Akzent: nur fuer Aktionen, Fokus, aktive Zustaende */
  --accent:      #ffd23f;
  --accent-2:    #ffb020;
  --accent-ink:  #17130a;      /* Text auf Gelb, ca. 13:1 */
  --accent-soft: rgba(255, 210, 63, .12);
  --fach:        #ffd23f;      /* wird pro Fach/Kachel ueberschrieben */

  /* Typ-Farben (hell auf dunkler Tonflaeche, alle >= 7:1 auf --surface) */
  --t-pdf:   #ff8f85;
  --t-word:  #8fb8ff;
  --t-bild:  #7ee2a8;
  --t-html:  #ffb86b;
  --t-css:   #cfb0ff;
  --t-andere:#c9cfdb;

  --radius:   14px;
  --radius-m: 11px;
  --radius-s: 8px;
  --shadow:   0 18px 40px -18px rgba(0, 0, 0, .7);
  --gutter:   clamp(16px, 4vw, 32px);
  --maxw:     1200px;
  --ease:     cubic-bezier(.2, .8, .2, 1);

  --font-display: "Bricolage Grotesque", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
  scrollbar-color: #2b3243 var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: rgba(255, 210, 63, .32); color: #fff; }
input, textarea { caret-color: var(--accent); }

img { max-width: 100%; height: auto; }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: #ffe68a; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* SVG-Icons (Linien-Icons, Farbe ueber currentColor) */
.icon {
  width: 1em; height: 1em;
  flex: none;
  display: inline-block;
  vertical-align: -.125em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Hintergrund: ruhiges Licht von oben, Fachfarbe nur als Hauch ---------- */
.aurora {
  position: fixed; inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(1100px 520px at 50% -14%, color-mix(in srgb, var(--fach) 9%, transparent), transparent 72%),
    radial-gradient(900px 600px at 50% -20%, #121829 0%, transparent 70%),
    var(--bg);
}
.aurora span { display: none; }

/* ---------- Scroll-Fortschritt ---------- */
.scroll-progress {
  position: fixed; left: 0; top: 0; right: 0;
  height: 2px; z-index: 70;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(var(--progress, 0));
}

/* Spotlight, folgt der Maus (--mx/--my setzt main.js) - nur sehr dezent */
.tile::after, .file::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, -200%),
              color-mix(in srgb, var(--fach) 7%, transparent), transparent 65%);
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
  z-index: 0;
}
.tile:hover::after, .file:hover::after { opacity: 1; }

/* ---------- Skip-Link ---------- */
.skip-link {
  position: absolute;
  left: 16px; top: -100px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  padding: .6rem 1rem;
  border-radius: var(--radius-s);
  text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--accent-ink); }

/* ---------- Kopfzeile ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 12, 17, .86);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px);
          backdrop-filter: blur(14px);
}
.site-header .wrap {
  max-width: 1440px;
  display: flex;
  align-items: center;
  gap: 1rem 1.75rem;
  min-height: 64px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  flex: none;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.01em;
  text-decoration: none;
}
.brand:hover { color: var(--text); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-display);
  font-size: .8rem;
  font-weight: 800;
  letter-spacing: .02em;
}
.brand small {
  color: var(--text-dim);
  font-family: var(--font);
  font-size: .85rem;
  font-weight: 400;
  margin-left: .2rem;
}

.main-nav { min-width: 0; flex: 1; }
.main-nav ul {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .1rem;
}
.main-nav a {
  position: relative;
  display: block;
  padding: .45rem .6rem;
  border-radius: var(--radius-s);
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color .2s ease, background-color .2s ease;
}
.main-nav a:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.main-nav a[aria-current="page"] { color: var(--text); font-weight: 700; }
.main-nav a[aria-current="page"]::after {
  content: "";
  position: absolute; left: .6rem; right: .6rem; bottom: .12rem;
  height: 2px; border-radius: 2px;
  background: var(--fach);
}

@media (max-width: 1320px) {
  .brand small { display: none; }
}
@media (max-width: 1180px) {
  .site-header .wrap { flex-wrap: wrap; padding-block: .5rem 0; gap: .25rem; min-height: 0; }
  .main-nav { flex-basis: 100%; }
  .main-nav ul {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    scrollbar-width: none;
    padding: .1rem 2.5rem .35rem .1rem;
    margin-inline: -.6rem;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
            mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .main-nav ul::-webkit-scrollbar { display: none; }
}

/* ---------- Hauptbereich ---------- */
main { flex: 1; padding-block: 2.5rem 4rem; }
main:focus { outline: none; }

h1, h2, h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  margin: 0 0 .5rem;
  text-wrap: balance;
}
h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 3rem); letter-spacing: -.03em; font-weight: 700; }
h2 { font-size: 1.35rem; letter-spacing: -.015em; font-weight: 650; }
h3 { font-size: 1.05rem; font-weight: 650; }
p  { margin: 0 0 1rem; }

.lead { color: var(--text-muted); font-size: 1.08rem; max-width: 65ch; text-wrap: pretty; }
.accent { color: var(--accent); }
.grad { color: var(--accent); }

.breadcrumb {
  font-size: .9rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
}
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: .4rem; color: var(--text-dim); opacity: .6; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; }
.breadcrumb [aria-current] { color: var(--text); }

/* ---------- Startseite: Hero (offene Flaeche, keine Karte) ---------- */
.hero {
  position: relative;
  padding: clamp(.5rem, 2vw, 1.5rem) 0 clamp(1.5rem, 3vw, 2.5rem);
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
}
.eyebrow, .lernheft-eyebrow { display: none; }

.hero h1 { margin-bottom: 1.1rem; }
.hero-small {
  display: block;
  font-family: var(--font);
  font-size: clamp(1rem, .92rem + .4vw, 1.2rem);
  font-weight: 600;
  letter-spacing: 0;
  color: var(--text-muted);
  margin-bottom: .45rem;
}
.hero-big {
  display: block;
  font-size: clamp(2.3rem, 1.1rem + 4.6vw, 4.6rem);
  line-height: 1;
  letter-spacing: -.04em;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.hero .lead { font-size: clamp(1.02rem, .96rem + .3vw, 1.18rem); margin-bottom: 0; }

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 0;
  margin: 1.9rem 0 2.1rem;
  padding: 0;
  list-style: none;
}
.stats li {
  display: grid;
  align-content: start;
  gap: .1rem;
  padding: 0 1.75rem;
  border-left: 1px solid var(--line-hi);
  color: var(--text-dim);
  font-size: .9rem;
  line-height: 1.3;
}
.stats li:first-child { padding-left: 0; border-left: 0; }
.stats .icon { display: none; }
.stats strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* ---------- Suche ---------- */
.search-label { display: block; font-weight: 700; margin-bottom: .55rem; }
.search-box {
  position: relative; max-width: 680px;
  border-radius: var(--radius-m);
  background: var(--surface);
  border: 1px solid var(--line-hi);
  transition: border-color .2s ease, box-shadow .2s ease;
}
.search-box:hover { border-color: rgba(255, 255, 255, .24); }
.search-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 210, 63, .18);
}
.search-box input {
  width: 100%;
  padding: .9rem 1rem .9rem 2.9rem;
  border: 0;
  border-radius: calc(var(--radius-m) - 1px);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
}
.search-box input::placeholder { color: var(--text-dim); }
.search-box input:focus { outline: none; }
.search-box .search-icon {
  position: absolute; left: 1rem; top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  color: var(--text-dim);
  font-size: 1.1rem;
  pointer-events: none;
}
.search-box:focus-within .search-icon { color: var(--accent); }
.search-hint { color: var(--text-dim); font-size: .88rem; margin: .65rem 0 0; }
kbd {
  font-family: var(--mono); font-size: .78rem;
  padding: .05rem .4rem; border-radius: 5px;
  border: 1px solid var(--line-hi); border-bottom-width: 2px;
  background: var(--surface-2); color: var(--text-muted);
}

.search-results { margin-bottom: 3rem; }
.search-results[hidden] { display: none; }
.results-head {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: .5rem 1rem; margin-bottom: .9rem;
}
.results-head h2 { margin: 0; }
.results-count { color: var(--text-muted); margin: 0; font-variant-numeric: tabular-nums; }
mark { background: rgba(255, 210, 63, .85); color: var(--accent-ink); border-radius: 3px; padding: 0 .12em; }

/* ---------- Abschnittstitel ---------- */
.section-title {
  display: flex; align-items: center; gap: 1rem;
  margin: 0 0 1.1rem;
  font-size: clamp(1.3rem, 1.15rem + .5vw, 1.6rem);
  font-weight: 650;
  letter-spacing: -.02em;
}
.section-title::after {
  content: ""; flex: 1; height: 1px;
  background: var(--line);
}

/* ---------- Kacheln ---------- */
.tiles {
  list-style: none; margin: 0 0 3.25rem; padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.tiles > li { display: flex; animation: rise .55s var(--ease) both; }
.tiles > li:nth-child(2) { animation-delay: .04s; }
.tiles > li:nth-child(3) { animation-delay: .08s; }
.tiles > li:nth-child(4) { animation-delay: .12s; }
.tiles > li:nth-child(5) { animation-delay: .16s; }
.tiles > li:nth-child(6) { animation-delay: .20s; }
.tiles > li:nth-child(7) { animation-delay: .24s; }
.tiles > li:nth-child(8) { animation-delay: .28s; }
.tiles > li:nth-child(9) { animation-delay: .32s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Raster in der Kachel: Kopf, Titel, Text (dehnt sich), Teile, Fusszeile.
   So stehen Fusszeilen benachbarter Kacheln immer auf gleicher Hoehe. */
.tile {
  position: relative;
  isolation: isolate;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto 1fr auto auto;
  padding: 1.25rem 1.3rem 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: border-color .25s ease, background-color .25s ease, transform .3s var(--ease);
}
.tile > * { position: relative; z-index: 1; grid-column: 1 / -1; }
.tile:hover, .tile:focus-visible {
  color: var(--text);
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--fach) 40%, var(--line-hi));
  transform: translateY(-2px);
}
.tile-top {
  grid-row: 1;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  margin-bottom: 1rem;
}
.tile-emoji {
  display: inline-grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 11px;
  background: color-mix(in srgb, var(--fach) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--fach) 30%, transparent);
  color: var(--fach);
  font-size: 1.35rem;
  line-height: 1;
}
.tile-count {
  color: var(--text-dim);
  font-size: .82rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tile h3 {
  grid-row: 2;
  font-size: 1.28rem; font-weight: 650; letter-spacing: -.02em;
  margin-bottom: .4rem;
}
.tile p {
  grid-row: 3;
  color: var(--text-muted); font-size: .94rem; line-height: 1.55;
  margin-bottom: 1rem;
}
.tile-parts {
  grid-row: 4;
  display: flex; flex-wrap: wrap; gap: .35rem;
  list-style: none; padding: 0; margin: 0 0 1.1rem;
}
.tile-parts li {
  font-size: .76rem; color: var(--text-muted);
  background: rgba(255, 255, 255, .035);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .06rem .5rem;
}
/* Fusszeile: Lernheft-Hinweis links, "Oeffnen" rechts, eine durchgehende Linie */
.tile-lernheft, .tile-go {
  grid-row: 5;
  display: flex; align-items: center; gap: .4rem;
  min-height: 3rem;
  margin: 0 -1.3rem;
  border-top: 1px solid var(--line);
  font-size: .84rem;
}
.tile-lernheft {
  grid-column: 1;
  padding-left: 1.3rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 0;
}
.tile-lernheft .icon { color: var(--fach); font-size: 1rem; }
.tile-go {
  grid-column: 2;
  justify-content: flex-end;
  padding: 0 1.3rem 0 1rem;
  margin-left: 0;
  color: var(--text-muted);
  font-weight: 700;
  transition: color .2s ease, gap .3s var(--ease);
}
.tile:not(:has(.tile-lernheft)) .tile-go { grid-column: 1 / -1; margin-left: -1.3rem; }
.tile:hover .tile-go, .tile:focus-visible .tile-go { color: var(--accent); gap: .65rem; }

/* Schnellzugriff */
.quick { list-style: none; margin: 0 0 2.25rem; padding: 0; display: flex; flex-wrap: wrap; gap: .55rem; }
.quick a {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .55rem .95rem;
  border: 1px solid var(--line-hi); border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--text); text-decoration: none; font-size: .92rem; font-weight: 500;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease;
}
.quick a .icon, .quick a > span[aria-hidden] { color: var(--text-dim); }
.quick a:hover { border-color: rgba(255, 255, 255, .3); background: var(--surface-2); color: var(--text); }
.quick a:hover .icon { color: var(--accent); }

/* ---------- Gesamt-Lernheft (IHK) ---------- */
.lernheft {
  position: relative; isolation: isolate;
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem 1.35rem;
  margin: 0 0 1.75rem; padding: 1.2rem 1.35rem;
  border: 1px solid color-mix(in srgb, var(--fach) 28%, var(--line));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--fach) 5%, var(--surface));
}
.lernheft-icon {
  display: grid; place-items: center; flex: none;
  width: 52px; height: 52px; border-radius: 12px;
  font-size: 1.55rem; line-height: 1;
  color: var(--fach);
  background: color-mix(in srgb, var(--fach) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--fach) 32%, transparent);
}
.lernheft-text { flex: 1 1 320px; min-width: 0; }
.lernheft h2 { margin: 0 0 .3rem; font-size: 1.25rem; }
.lernheft-text p:last-child { margin: 0; color: var(--text-muted); font-size: .93rem; max-width: 72ch; }
.lernheft-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.section-sub { margin: -.45rem 0 1rem; color: var(--text-dim); font-size: .93rem; max-width: 72ch; }
.quick.lernhefte a .icon, .quick.lernhefte a > span[aria-hidden] { color: var(--fach); }
.quick.lernhefte a:hover { border-color: color-mix(in srgb, var(--fach) 60%, transparent); }
.quick.lernhefte a:hover .icon { color: var(--fach); }

/* ---------- Fachseite ---------- */
.page-head {
  position: relative;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1.1rem 1.25rem;
  margin-bottom: 1.75rem;
  padding: 0 0 1.6rem;
  border-bottom: 1px solid var(--line);
}
.page-head .tile-emoji { width: 60px; height: 60px; font-size: 1.85rem; border-radius: 14px; }
.page-head > div { min-width: 0; flex: 1; }
.page-head h1 { color: var(--text); margin-bottom: .45rem; overflow-wrap: anywhere; }
.page-head .lead { margin-bottom: .4rem; }
.page-head .meta { color: var(--text-dim); font-size: .9rem; margin: 0; overflow-wrap: anywhere; }
code {
  font-family: var(--mono); font-size: .84em;
  padding: .05rem .35rem; border-radius: 5px;
  background: rgba(255, 255, 255, .06); color: var(--text-muted);
}

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .5rem;
  margin: 0 0 1rem;
}
.toolbar[hidden] { display: none; }
.toolbar .toolbar { margin: 0; }
.toolbar-label { color: var(--text-muted); font-size: .9rem; margin-right: .2rem; }
.chip {
  font: inherit; font-size: .875rem; font-weight: 600;
  padding: .34rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--line-hi);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
}
.chip:hover { color: var(--text); border-color: rgba(255, 255, 255, .32); }
.chip[aria-pressed="true"] {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* Tabs mit Unterstreichung */
.tabs {
  position: sticky; top: var(--header-h, 64px); z-index: 20;
  margin: 0 calc(var(--gutter) * -1) 1.5rem;
  padding: 0 var(--gutter);
  background: rgba(10, 12, 17, .9);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.tabs ul {
  list-style: none; margin: 0; padding: 0;
  display: flex; gap: .15rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs ul::-webkit-scrollbar { display: none; }
.tabs li { flex: none; }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .85rem .9rem .8rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  transition: color .2s ease;
}
.tab::after {
  content: "";
  position: absolute; left: .7rem; right: .7rem; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .3s var(--ease);
}
.tab:hover { color: var(--text); }
.tab:hover::after { transform: scaleX(.3); background: var(--line-hi); }
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after { transform: scaleX(1); background: var(--accent); }
.tab:focus-visible { outline-offset: -4px; }
.count {
  font-size: .74rem; font-weight: 700;
  min-width: 1.7em; text-align: center;
  padding: .04rem .42rem; border-radius: 999px;
  background: var(--surface-3); color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.tab[aria-selected="true"] .count { color: var(--text); background: rgba(255, 255, 255, .12); }

.panel { margin-bottom: 2.75rem; scroll-margin-top: 130px; }
.panel:focus { outline: none; }
.panel:focus-visible { outline: 2px dashed var(--accent); outline-offset: 6px; }
.js .panel:not([hidden]) { animation: fade .3s var(--ease) both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.panel-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1rem; margin-bottom: .9rem; }
.panel-head h2 { margin: 0; }
.panel-head p { margin: 0; color: var(--text-muted); font-size: .93rem; }
.js .panel[hidden] { display: none; }
.js .panel-head h2 { font-size: 1.05rem; color: var(--text-muted); font-weight: 600; }
.empty-note { color: var(--text-muted); font-style: italic; padding: 1rem; border: 1px dashed var(--line-hi); border-radius: var(--radius-m); }
.empty-note[hidden] { display: none; }

/* ---------- Dateiliste ---------- */
.files { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.file {
  --tc: var(--t-andere);
  position: relative;
  isolation: isolate;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem;
  padding: .85rem 1rem;
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color .2s ease, background-color .2s ease, box-shadow .2s ease;
}
.file > * { position: relative; z-index: 1; }
.file[data-typ="pdf"]  { --tc: var(--t-pdf); }
.file[data-typ="word"] { --tc: var(--t-word); }
.file[data-typ="bild"] { --tc: var(--t-bild); }
.file[data-typ="html"] { --tc: var(--t-html); }
.file[data-typ="css"]  { --tc: var(--t-css); }
.file:hover { border-color: var(--line-hi); background: var(--surface-2); }
.file.is-previewing {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--surface-2);
}
.file[hidden] { display: none; }
.files > .file { animation: rise .45s var(--ease) both; }
.file-main { display: flex; align-items: flex-start; gap: .9rem; min-width: 0; flex: 1; }
.file-icon {
  flex: none; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  color: var(--tc);
  background: color-mix(in srgb, var(--tc) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--tc) 30%, transparent);
  font-size: 1.15rem; line-height: 1;
}
.file-body { min-width: 0; }
.file-title {
  font-family: var(--font);
  font-size: 1rem; font-weight: 700; letter-spacing: 0;
  margin: 0 0 .3rem; overflow-wrap: anywhere;
}
.file-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem;
  margin: 0; color: var(--text-muted); font-size: .84rem;
  font-variant-numeric: tabular-nums;
}
.file-name { font-family: var(--mono); font-size: .74rem; color: var(--text-dim); overflow-wrap: anywhere; }
.file-fach { color: var(--text-muted); }
.file-fach a { color: var(--text-muted); }
.file-fach a:hover { color: var(--accent); }
.file-actions { display: flex; flex-wrap: wrap; gap: .45rem; flex: none; }

/* Badges: ruhige Pillen, normale Schreibweise */
.badge {
  --bc: var(--t-andere);
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; font-weight: 600; letter-spacing: 0;
  padding: .08rem .55rem; border-radius: 999px;
  color: var(--bc);
  background: color-mix(in srgb, var(--bc) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--bc) 28%, transparent);
  line-height: 1.45;
  white-space: nowrap;
}
.badge-pdf::before, .badge-word::before, .badge-bild::before, .badge-html::before, .badge-css::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.badge-pdf  { --bc: var(--t-pdf); }
.badge-word { --bc: var(--t-word); }
.badge-bild { --bc: var(--t-bild); }
.badge-html { --bc: var(--t-html); }
.badge-css  { --bc: var(--t-css); }
.badge-ihk  { --bc: var(--accent); font-weight: 700; }
.badge-state { font-weight: 600; border-style: dashed; background: transparent; }
.badge-leer        { --bc: #cbd0da; }
.badge-ausfuellbar { --bc: #9be7ff; }
.badge-ausgefuellt { --bc: #7ee2a8; }
.badge-korrigiert  { --bc: #ffcf8a; }
.badge-markiert    { --bc: #ffe066; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 40px;
  padding: .42rem .9rem;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-hi);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .9rem; font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease, background-color .2s ease;
}
.btn .icon { font-size: 1.05em; }
.btn:hover { border-color: rgba(255, 255, 255, .32); background: var(--surface-3); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn[hidden] { display: none; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
}
.btn-primary:hover { background: #ffe066; border-color: #ffe066; color: var(--accent-ink); }
/* In Listen wiederholt sich "Ansehen" in jeder Zeile: dort ruhig, Akzent erst beim Hover */
.file .btn-primary {
  background: var(--surface-2);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line-hi));
  color: var(--accent);
}
.file .btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-preview {
  border-color: color-mix(in srgb, var(--fach) 42%, transparent);
  background: color-mix(in srgb, var(--fach) 9%, var(--surface-2));
}
.btn-preview .icon { color: var(--fach); }
.btn-preview:hover { border-color: var(--fach); background: color-mix(in srgb, var(--fach) 17%, var(--surface-2)); }

/* ---------- Web-Uebungen-Gruppen ---------- */
.groups { display: grid; gap: .75rem; }
.group {
  position: relative;
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  background: var(--bg-2);
}
.group > * { position: relative; z-index: 1; }
.group > summary {
  display: flex; align-items: center; flex-wrap: wrap; gap: .4rem .65rem;
  padding: .85rem 1rem;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 1.02rem;
  list-style: none;
  border-radius: var(--radius-m);
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before {
  content: "";
  width: .5em; height: .5em;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(-45deg);
  margin-right: .2rem;
  transition: transform .25s var(--ease);
  flex: none;
}
.group[open] > summary::before { transform: rotate(45deg) translate(-2px, -2px); }
.group > summary:hover { background: rgba(255, 255, 255, .03); }
.group-note { font-family: var(--font); font-weight: 400; color: var(--text-muted); font-size: .88rem; }
.group > .files { padding: 0 .75rem .75rem; }
.group-new {
  font-family: var(--font);
  font-size: .74rem; font-weight: 700; letter-spacing: 0;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid rgba(255, 210, 63, .35);
  border-radius: 999px; padding: .02rem .5rem;
}

.note {
  position: relative;
  border: 1px solid var(--line-hi);
  background: var(--surface);
  padding: .85rem 1rem;
  border-radius: var(--radius-m);
  color: var(--text-muted);
  font-size: .93rem;
  margin-bottom: 1rem;
}
.note p { max-width: 80ch; }
.note p:last-child { margin: 0; }

/* ---------- Fusszeile ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg);
  color: var(--text-dim);
  font-size: .86rem;
  padding-block: 1.5rem;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 1.5rem; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- Nach oben ---------- */
.to-top {
  position: fixed;
  right: 16px; bottom: 16px;
  z-index: 60;
  display: inline-grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line-hi);
  background: var(--surface-3);
  color: var(--text);
  font-size: 1.2rem; font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .25s ease, transform .25s var(--ease), border-color .2s ease, color .2s ease;
}
.to-top.is-visible { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { border-color: var(--accent); color: var(--accent); }
.to-top:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 12px; }

/* ==========================================================================
   Live-Vorschau (Dialog)
   ========================================================================== */
html.pv-open { overflow: hidden; }

.pv-dialog {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(1040px, 62vw);
  max-width: 100vw;
  height: 100dvh; max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-hi);
  border-radius: 18px 0 0 18px;
  color: var(--text);
  background: #0d1118;
  box-shadow: -30px 0 80px -20px rgba(0, 0, 0, .8);
  overflow: hidden;
}
.pv-dialog[open] { display: flex; flex-direction: column; animation: pv-in .32s var(--ease) both; }
.pv-dialog::backdrop {
  background: rgba(3, 4, 8, .55);
}
@keyframes pv-in { from { opacity: 0; transform: translateX(32px); } to { opacity: 1; transform: none; } }

.pv-dialog > * { position: relative; z-index: 1; }
.pv-head {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: 1rem 1rem .9rem 1.25rem;
  border-bottom: 1px solid var(--line);
}
.pv-headtext { min-width: 0; flex: 1; }
.pv-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin: 0 0 .3rem; font-size: .82rem; color: var(--text-muted); }
.pv-pos, .pv-size { font-variant-numeric: tabular-nums; }
.pv-title {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, .98rem + .5vw, 1.4rem); font-weight: 650; letter-spacing: -.02em;
  margin: 0; overflow-wrap: anywhere;
}
.pv-name { font-family: var(--mono); font-size: .74rem; color: var(--text-dim); overflow-wrap: anywhere; margin: .25rem 0 0; }
.pv-tools { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: flex-end; flex: none; }
.pv-close {
  width: 40px; height: 40px; flex: none;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-s);
  border: 1px solid var(--line-hi);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.35rem; line-height: 1;
  cursor: pointer;
  transition: background-color .2s ease, border-color .2s ease;
}
.pv-close:hover { background: var(--surface-3); border-color: rgba(255, 255, 255, .32); }

.pv-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: .75rem;
  border-radius: 12px;
  background: #1a1e29;
  border: 1px solid var(--line);
  overflow: hidden;
}
.pv-stage iframe, .pv-stage .pv-img-wrap {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  border: 0;
}
.pv-stage iframe { display: block; }
.pv-stage iframe.pv-light { background: #fff; }
.pv-img-wrap {
  display: grid; place-items: center;
  padding: 1rem;
  background:
    conic-gradient(#1f2433 25%, #181c28 0 50%, #1f2433 0 75%, #181c28 0) 0 0 / 24px 24px;
}
.pv-img-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: var(--shadow); }

.pv-loading {
  position: absolute; inset: 0; z-index: 2;
  display: grid; place-content: center; justify-items: center; gap: .8rem;
  background: rgba(16, 19, 28, .94);
  color: var(--text-muted);
  font-weight: 600;
  transition: opacity .3s ease;
}
.pv-loading[hidden] { display: none; }
.pv-spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, .1);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pv-fallback {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-content: center; justify-items: center; gap: .6rem;
  padding: 1.5rem; text-align: center;
  background: var(--surface);
}
.pv-fallback[hidden] { display: none; }
.pv-fallback p { margin: 0; color: var(--text-muted); max-width: 46ch; }
.pv-fallback strong { color: var(--text); font-size: 1.1rem; }
.pv-fallback .pv-fb-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .4rem; }

.pv-foot {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem 1rem;
  padding: 0 .75rem .8rem;
  flex-wrap: wrap;
}
.pv-hint { margin: 0; color: var(--text-dim); font-size: .82rem; flex: 1; min-width: 12rem; text-align: center; }
.pv-hint a { color: var(--text-muted); }
.pv-nav { min-width: 7.5rem; }
.pv-nav[disabled] { opacity: .45; cursor: default; transform: none; border-color: var(--line-hi); color: var(--text-muted); background: var(--surface-2); }

/* Split-Gefuehl auf grossen Bildschirmen: Liste links bleibt sichtbar */
@media (min-width: 1100px) {
  .pv-dialog::backdrop { background: linear-gradient(90deg, rgba(3,4,8,.2), rgba(3,4,8,.55)); }
}
/* Tablet / Handy: Vollbild */
@media (max-width: 860px) {
  .pv-dialog { width: 100vw; border-radius: 0; border-left: 0; }
  @keyframes pv-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
}
@media (max-width: 560px) {
  .pv-head { flex-wrap: wrap; padding: .8rem .8rem .7rem 1rem; }
  .pv-headtext { flex-basis: calc(100% - 52px); }
  .pv-tools { order: 3; flex-basis: 100%; justify-content: stretch; }
  .pv-tools .btn { flex: 1; }
  .pv-stage { margin: .5rem; }
  .pv-foot { padding: 0 .5rem .6rem; }
  .pv-nav { flex: 1; min-width: 0; }
  .pv-hint { order: 3; flex-basis: 100%; }
  .pv-hint .pv-keys { display: none; }
}

/* ---------- Tablet ---------- */
@media (max-width: 1020px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Handy ---------- */
@media (max-width: 640px) {
  main { padding-block: 1.5rem 2.75rem; }
  .file { flex-direction: column; align-items: stretch; padding: .85rem; }
  .file-actions { padding-left: calc(40px + .9rem); }
  .file-actions .btn { flex: 1; padding-inline: .6rem; }
  .tiles { grid-template-columns: 1fr; }
  .tab { padding: .7rem .7rem .65rem; }
  .stats { gap: 1rem 0; }
  .stats li { padding: 0 1.1rem; }
  .stats strong { font-size: 1.55rem; }
  .page-head .tile-emoji { width: 52px; height: 52px; font-size: 1.6rem; }
}
@media (max-width: 420px) {
  .file-actions { padding-left: 0; }
  .stats li { flex: 1 1 40%; padding: 0 .9rem; }
  .stats li:nth-child(odd) { padding-left: 0; border-left: 0; }
}

/* ---------- Bewegung reduzieren ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

@media print {
  .site-header, .toolbar, .tabs, .to-top, .file-actions, .skip-link, .aurora, .scroll-progress, .pv-dialog { display: none !important; }
  body, .hero, .tile, .file, .page-head, .lernheft, .group, .note { background: #fff !important; color: #000 !important; border-color: #ccc !important; }
  .panel[hidden] { display: block !important; }
  :root { --text: #000; --text-muted: #222; --text-dim: #444; }
  .grad, .page-head h1, .tile p, .lead { color: #000 !important; }
  .badge, code { background: #fff !important; color: #000 !important; border: 1px solid #999 !important; }
}
