/* Handy-Ansicht (unter 768 px). Alles hier gilt NUR auf schmalen Bildschirmen: Elemente mit
   .m-only sind sonst unsichtbar, der Desktop bleibt pixelgleich (Vergleich per Screenshot).
   Freigegebenes Mock-up: claude.ai/artifact/CNWNYoWsCL5eYTJ5qAG6ms */
.m-only { display: none; }

@media (max-width: 767px) {
  :root {
    --m-navy: #111827; --m-navy2: #0b1020; --m-line: #e2e8f0; --m-surface: #f8fafc; --m-ink: #0f172a;
    --m-ink2: #475569; --m-ink3: #64748b; --m-blue: #2952e3; --m-blue-soft: #eef2ff; --m-ok: #15803d;
    --m-safe-b: env(safe-area-inset-bottom, 0px);
  }
  .m-hide { display: none !important; }

  /* Knöpfe mit Symbol: 44 px Touch-Fläche */
  .m-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 10px;
    border: 0; background: transparent; color: inherit; cursor: pointer; text-decoration: none; }
  .m-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
    stroke-linecap: round; stroke-linejoin: round; }
  .m-icon:focus-visible, .m-sheet a:focus-visible, .m-sheet button:focus-visible { outline: 2px solid var(--m-blue); outline-offset: 2px; }

  /* Bottom-Sheet (<dialog>) */
  .m-sheet { position: fixed; inset: auto 0 0 0; margin: 0; width: 100%; max-width: none; max-height: 82dvh;
    border: 0; border-radius: 22px 22px 0 0; padding: 8px 18px calc(18px + var(--m-safe-b));
    background: #fff; color: var(--m-ink); box-shadow: 0 -20px 40px -20px rgb(0 0 0 / .4); overflow-y: auto;
    overscroll-behavior: contain; font-family: "Ubuntu Sans", system-ui, sans-serif; }
  .m-sheet::backdrop { background: rgb(11 16 32 / .45); }
  .m-sheet[open] { display: grid; gap: 12px; align-content: start; }
  .m-grab { width: 40px; height: 5px; border-radius: 3px; background: var(--m-line); justify-self: center; }
  .m-sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .m-sheet-head h2 { margin: 0; font: 700 18px "Ubuntu Sans", system-ui, sans-serif; }
  @media (prefers-reduced-motion: no-preference) {
    .m-sheet[open] { animation: m-up .2s ease-out; }
    @keyframes m-up { from { transform: translateY(24px); opacity: .6; } }
  }

  /* ---------- Kursleser ---------- */
  body[data-m="reader"] .site-top { display: none; }
  body[data-m="reader"] { padding-bottom: calc(68px + var(--m-safe-b)); }
  .m-rhead { display: block; position: sticky; top: 0; z-index: 30; background: rgb(255 255 255 / .97);
    border-bottom: 1px solid var(--m-line); padding-top: env(safe-area-inset-top, 0px);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
  .m-rhead-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; color: var(--m-ink); }
  .m-rhead-t { min-width: 0; flex: 1; }
  .m-rhead-t small { display: block; font: 500 11.5px "JetBrains Mono", ui-monospace, monospace; color: var(--m-ink3);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-rhead-t b { display: block; font: 700 15px/1.3 "Ubuntu Sans", system-ui, sans-serif; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  .m-prog { height: 3px; background: var(--m-line); }
  .m-prog i { display: block; height: 100%; width: 0; background: var(--m-blue); }
  body[data-m="reader"] main > .wrap { padding-top: 20px; }
  body[data-m="reader"] .course-prose { font-size: 17px; line-height: 1.65; }
  body[data-m="reader"] .course-prose :is(h2, h3) { scroll-margin-top: 72px; }
  body[data-m="reader"] .course-prose h2 { font-size: 22px; line-height: 1.25; margin-top: 2.25rem; }

  /* Codeblöcke randlos mit Kopf und „Kopieren“ */
  .course-prose div.sourceCode, .course-prose > pre { margin-inline: -16px; }
  .course-prose div.sourceCode pre, .course-prose pre { border-radius: 0; }
  .course-prose div.sourceCode > pre { margin-top: 0; }
  .m-codebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 16px -16px 0;
    padding: 6px 8px 6px 16px; background: var(--m-navy2); border-bottom: 1px solid #1d2742;
    font: 500 11.5px "JetBrains Mono", ui-monospace, monospace; color: #8fa0c8; }
  div.sourceCode > .m-codebar { margin: 0; }
  .m-codebar + pre { margin-top: 0 !important; }
  .m-copy { min-height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid #2d3a5c; background: #141d34;
    color: #e5e9f5; font: 600 12.5px "Ubuntu Sans", system-ui, sans-serif; display: inline-flex; gap: 6px;
    align-items: center; cursor: pointer; }
  .m-copy svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
    stroke-linejoin: round; }

  /* Zweispaltige Optionstabellen als Karten */
  .course-prose table.m-cards { display: grid; gap: 8px; overflow: visible; font-size: 15px; }
  .course-prose table.m-cards thead { display: none; }
  .course-prose table.m-cards :is(tbody, tr) { display: grid; gap: 8px; }
  .course-prose table.m-cards tr { gap: 2px; border: 1px solid var(--m-line); border-radius: 12px; padding: 10px 12px; }
  .course-prose table.m-cards td { display: block; border: 0; padding: 0; }
  .course-prose table.m-cards td:first-child code { background: none; padding: 0; color: var(--m-blue); font-weight: 600; }

  /* Erledigt-Knopf groß genug für den Daumen */
  body[data-m="reader"] .drill-progress :is(.btn, .btn-secondary) { min-height: 44px; }

  /* Vor/Zurück-Leiste unten */
  .m-pager { display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    grid-template-columns: 52px 1fr 52px; gap: 8px; align-items: center;
    padding: 8px 12px calc(8px + var(--m-safe-b)); background: rgb(255 255 255 / .97);
    border-top: 1px solid var(--m-line); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
  .m-pager .m-icon { width: 52px; height: 48px; border: 1px solid var(--m-line); color: var(--m-ink); }
  .m-pager .m-icon[aria-disabled="true"] { opacity: .35; pointer-events: none; }
  .m-pager-mid { height: 48px; min-width: 0; border-radius: 12px; border: 1px solid var(--m-line); background: #fff;
    display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 10px; color: var(--m-ink);
    font: 600 14px "Ubuntu Sans", system-ui, sans-serif; cursor: pointer; }
  .m-pager-mid span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-pager-mid small { color: var(--m-ink3); font: 500 12px "JetBrains Mono", ui-monospace, monospace; flex: none; }

  /* Inhaltsverzeichnis */
  .m-toc { display: grid; gap: 2px; }
  .m-toc a { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; min-height: 48px;
    padding: 6px 8px; border-radius: 10px; color: var(--m-ink); text-decoration: none; font-size: 15px; }
  .m-toc .m-st { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--m-line); }
  .m-toc a.done .m-st { background: var(--m-ok); border-color: var(--m-ok); }
  .m-toc a[aria-current="page"] { background: var(--m-blue-soft); font-weight: 600; }
  .m-toc a[aria-current="page"] .m-st { border-color: var(--m-blue); border-width: 5px; }
  .m-toc-sub { display: grid; }
  .m-toc-sub a { grid-template-columns: 1fr; min-height: 44px; padding-left: 22px; font-size: 14px; color: var(--m-ink2); }
  .m-toc-sub a[aria-current="location"] { color: var(--m-blue); font-weight: 600; }
}

/* ---------- Etappe 2: Tab-Leiste, kompakter Kopf, Eingaben, Touch-Ziele ---------- */
@media (max-width: 767px) {
  /* Kopf bleibt stehen; Menü-Knopf und Aufklapp-Navigation ersetzt die Tab-Leiste */
  .site-top { position: sticky; top: 0; padding-top: env(safe-area-inset-top, 0px); }
  .site-top .site-wrap { flex-wrap: nowrap; padding-top: 8px; padding-bottom: 8px; }
  .site-toggle, .site-collapse, .site-js .site-collapse.open { display: none !important; }
  .site-brand { min-height: 44px; min-width: 0; }
  .site-brand span { min-width: 0; }
  .site-brand b { white-space: nowrap; font-size: 16px; }
  .site-brand small { display: none; }
  .site-logo { height: 38px; }
  .site-mark { height: 30px; }
  .m-top-act { display: flex; align-items: center; gap: 4px; margin-left: auto; flex: none; }
  .m-top-act .site-lang { display: inline-grid; place-items: center; min-width: 44px; min-height: 44px; }
  .m-top-act .site-btn { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 8px; }

  /* Tab-Leiste unten, über der Home-Leiste des iPhones */
  body { padding-bottom: calc(60px + var(--m-safe-b)); }
  .m-tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 40; background: rgb(255 255 255 / .96); border-top: 1px solid var(--m-line);
    padding: 4px max(4px, env(safe-area-inset-right, 0px)) calc(4px + var(--m-safe-b)) max(4px, env(safe-area-inset-left, 0px));
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); font-family: "Ubuntu Sans", system-ui, sans-serif; }
  .m-tabbar a { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 52px;
    font: 500 11px/1.2 "Ubuntu Sans", system-ui, sans-serif; color: var(--m-ink3); text-decoration: none;
    -webkit-tap-highlight-color: transparent; }
  .m-tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7;
    stroke-linecap: round; stroke-linejoin: round; }
  .m-tabbar a[aria-current] { color: var(--m-blue); font-weight: 700; }
  .m-tabbar a[aria-current] svg { stroke-width: 2.1; }
  .m-tabbar a:active { background: var(--m-blue-soft); border-radius: 12px; }
  .m-tabbar a:focus-visible { outline: 2px solid var(--m-blue); outline-offset: -2px; border-radius: 12px; }
  /* Kursleser und Labor-Vollbild haben eigene Leisten */
  body[data-m] .m-tabbar { display: none; }
  body[data-m="lab"] { padding-bottom: 0; }

  /* Mehr-Sheet */
  .m-more { display: grid; }
  .m-more a { display: flex; align-items: center; min-height: 48px; padding: 0 8px; border-radius: 10px;
    color: var(--m-ink); text-decoration: none; font-size: 16px; border-bottom: 1px solid var(--m-surface); }
  .m-more a:active { background: var(--m-blue-soft); }
  .m-more-legal { margin: 0; color: var(--m-ink3); font-size: 14px; }
  .m-more-legal a { display: inline-flex; align-items: center; min-height: 44px; color: var(--m-ink2); }
  .m-more-logout { width: 100%; min-height: 48px; border-radius: 10px; border: 1px solid var(--m-line); background: #fff;
    color: var(--m-ink); font: 600 15px "Ubuntu Sans", system-ui, sans-serif; cursor: pointer; }

  /* iOS zoomt in Felder unter 16 px */
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]), select, textarea { font-size: 16px !important; }

  /* Touch-Ziele ≥ 44 px */
  .site-footer .site-wrap { gap: 0 20px; }
  .site-footer a { display: inline-flex; align-items: center; min-height: 44px; }
  :is(.btn, .btn-secondary) { min-height: 44px; }
  .rad-learn a { min-height: 44px; padding: 0 12px; }
  .rad-more summary { min-height: 44px; }
  .rad-src a { display: inline-flex; align-items: center; min-height: 44px; }
  .simp-h3 a { display: inline-flex; align-items: center; min-height: 44px; }
  .m-copy { min-height: 44px; }
}

/* ---------- Etappe 3: Kursliste mit Filter-Sheet, Start, Lernbereich ---------- */
@media (max-width: 767px) {
  /* Kursliste: Suche + Filter-Knopf, Disziplinen als waagerechte Leiste, Karten als Liste */
  .catalog-tools:has(.m-filter-btn) { display: grid !important; grid-template-columns: minmax(0, 1fr) auto; gap: 10px !important; }
  .catalog-tools:has(.m-filter-btn)[hidden] { display: none !important; }
  .catalog-tools:has(.m-filter-btn) .catalog-search { width: 100%; min-width: 0; height: 46px; border-radius: 12px; }
  .catalog-tools:has(.m-filter-btn) .catalog-count { grid-column: 1 / -1; margin: 0; }
  .m-filter-btn { display: inline-flex; align-items: center; gap: 6px; height: 46px; padding: 0 14px; border-radius: 12px;
    border: 1px solid var(--m-line); background: #fff; color: var(--m-ink); font: 600 14px "Ubuntu Sans", system-ui, sans-serif;
    cursor: pointer; }
  .m-filter-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .m-chips { grid-column: 1 / -1; flex-wrap: nowrap !important; overflow-x: auto; margin: 0 -16px; padding: 2px 16px;
    scrollbar-width: none; }
  .m-chips::-webkit-scrollbar { display: none; }
  .m-chips .filter { flex: none; min-height: 40px; white-space: nowrap; }
  ul.m-list { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  ul.m-list > li > a { display: grid; grid-template-columns: 112px minmax(0, 1fr); grid-template-rows: auto auto;
    column-gap: 12px; align-items: center; align-content: center; padding: 10px; min-height: 96px;
    border: 1px solid var(--m-line); border-radius: 14px; background: #fff; }
  ul.m-list > li > a img.cover { grid-row: 1 / 3; width: 112px; border-radius: 8px; box-shadow: none; transform: none !important; }
  ul.m-list > li > a > span:not(.m-meta) { margin: 0; align-self: end; font-size: 15.5px; font-weight: 600; line-height: 1.3; }
  .m-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-self: start; margin-top: 4px; font-size: 12.5px; color: var(--m-ink3); }
  .m-tag { font: 500 11.5px "JetBrains Mono", ui-monospace, monospace; padding: 1px 7px; border-radius: 6px;
    background: #e6f4ea; color: #14653a; border: 1px solid #cbe8d3; }
  .m-lbl { margin: 4px 0 0; font: 600 12px "JetBrains Mono", ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; color: var(--m-ink3); }
  .m-opts { display: flex; flex-wrap: wrap; gap: 8px; }
  .m-opts button { min-height: 44px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--m-line); background: #fff;
    color: var(--m-ink); font: 500 15px "Ubuntu Sans", system-ui, sans-serif; cursor: pointer; }
  .m-opts button[aria-pressed="true"] { border-color: var(--m-blue); background: var(--m-blue-soft); color: var(--m-blue); font-weight: 600; }
  .m-sheet-go { min-height: 50px; border-radius: 10px; border: 0; background: var(--m-blue); color: #fff;
    font: 600 16px "Ubuntu Sans", system-ui, sans-serif; cursor: pointer; }
  .m-sheet-go[data-count]::after { content: " · " attr(data-count); font-weight: 500; opacity: .85; }

  /* Startseite: Laufband zum Wischen statt Endlos-Animation, volle Knöpfe, Ziele als Leiste */
  .tick { padding-right: 48px; }
  .tick::before, .tick::after { display: none; }
  .tick-track { animation: none !important; width: auto; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
  .tick-track::-webkit-scrollbar { display: none; }
  .tick-dup { display: none; }
  .tick-item { min-height: 44px; scroll-snap-align: start; padding: 0 16px; }
  .tick-close { width: 44px; height: 44px; right: 2px; }
  .hero .cta .btn { flex: 1 1 100%; justify-content: center; min-height: 50px; }
  .goals .tabs { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; margin: 20px -16px 0; padding: 2px 16px;
    scrollbar-width: none; }
  .goals .tabs::-webkit-scrollbar { display: none; }
  .goals .tabs button { flex: none; min-height: 44px; white-space: nowrap; }
  .goals .cards { gap: 10px; margin-top: 16px; }
  .goals .course { grid-template-columns: 104px minmax(0, 1fr); column-gap: 12px; row-gap: 4px; padding: 10px; align-items: center; }
  .goals .course img { grid-row: 1 / span 3; width: 104px; }
  .goals .course :is(.meta, h3, .out) { grid-column: 2; }
  .goals .course .out { display: none; }
  .goals .course .go { display: none; }
  .goals .course-more { grid-template-columns: auto minmax(0, 1fr); }
  .goals .course-more .course-more-n { grid-row: 1 / span 2; }

  /* Lernbereich: „Weiter, wo du warst“ oben, Menü-Leiste mit großen Zielen */
  .m-cont { display: grid; gap: 8px; margin: 4px 0 16px; padding: 18px; border-radius: 18px; text-decoration: none;
    background: linear-gradient(155deg, #1d2d5a, var(--m-navy2)); color: #fff; }
  .m-cont-k { font: 600 11px "JetBrains Mono", ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; color: #8fb0ff; }
  .m-cont b { font: 700 20px/1.2 "Ubuntu Sans", system-ui, sans-serif; }
  .m-cont-c { color: #c3cce0; font-size: 14px; }
  .m-cont-bar { display: block; height: 6px; border-radius: 3px; background: #2b3a63; overflow: hidden; margin-top: 4px; }
  .m-cont-bar i { display: block; height: 100%; background: #7b9bff; border-radius: 3px; }
  .m-cont-row { display: flex; justify-content: space-between; font: 12px "JetBrains Mono", ui-monospace, monospace; color: #aab6d3; }
  .m-cont-go { display: grid; place-items: center; min-height: 50px; margin-top: 6px; border-radius: 10px; background: var(--m-blue);
    color: #fff; font: 600 16px "Ubuntu Sans", system-ui, sans-serif; }
  .dash-side nav a { min-height: 44px; }
  .dash-btn { min-height: 44px; display: inline-flex; align-items: center; }
}

/* ---------- Etappe 4: Labor im Vollbild mit Sondertasten ---------- */
@media (max-width: 767px) {
  .lab-btn, .lab-check, .lab-pick select { min-height: 44px; }
  .lab-term { height: min(62vh, 480px); }
  .m-labfull { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; margin-top: 10px;
    border-radius: 10px; border: 1px solid var(--m-line); background: #fff; color: var(--m-ink);
    font: 600 15px "Ubuntu Sans", system-ui, sans-serif; cursor: pointer; }
  .m-labfull[hidden] { display: none; }

  /* Vollbild: nur Kopf, Aufgabe, Terminal und Tasten – Höhe = sichtbarer Bereich über der Tastatur */
  body[data-m="lab"] { overflow: hidden; }
  body[data-m="lab"] :is(.site-top, .site-footer) { display: none; }
  body[data-m="lab"] .lab-box { position: fixed; z-index: 60; left: 0; right: 0; top: var(--m-vvtop, 0px);
    height: var(--m-vvh, 100dvh); margin: 0; border: 0; border-radius: 0;
    grid-template-rows: auto auto minmax(0, 1fr) auto; padding-top: env(safe-area-inset-top, 0px); }
  body[data-m="lab"] .lab-term { height: auto; min-height: 0; grid-row: 3; padding: 6px 4px 4px 8px; }
  .m-labhead, .m-labtask, .m-keys { display: none; }
  body[data-m="lab"] .m-labhead { display: flex; align-items: center; gap: 6px; grid-row: 1; padding: 4px 8px;
    border-bottom: 1px solid #1d2742; color: #e5e9f5; }
  .m-labhead b { display: block; font: 700 15px "Ubuntu Sans", system-ui, sans-serif; }
  .m-labhead small { display: block; font: 500 11px "JetBrains Mono", ui-monospace, monospace; color: #8fa0c8; }
  body[data-m="lab"] .m-labtask:not([hidden]) { display: grid; gap: 4px; grid-row: 2; margin: 8px 10px 0; padding: 10px 12px;
    border-radius: 12px; background: #131c33; border: 1px solid #263252; color: #e5e9f5; font-size: 14px; }
  .m-labtask-k { font: 600 10.5px "JetBrains Mono", ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; color: #8fb0ff; }
  .m-labtask p { margin: 0; color: #c3cce0; font-size: 13.5px; line-height: 1.45; max-height: 4.4em; overflow-y: auto; }
  .m-labtask-row { display: flex; align-items: center; gap: 10px; }
  .m-labtask-row button { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 0; background: var(--m-blue); color: #fff;
    font: 600 14px "Ubuntu Sans", system-ui, sans-serif; cursor: pointer; }
  .m-labtask-row span { font-size: 13px; color: #aab6d3; }
  body[data-m="lab"] .m-keys { display: flex; grid-row: 4; gap: 6px; overflow-x: auto; padding: 8px 10px calc(8px + var(--m-safe-b));
    background: #1a2238; border-top: 1px solid #2a3554; scrollbar-width: none; }
  .m-keys::-webkit-scrollbar { display: none; }
  .m-keys button { flex: none; min-width: 46px; height: 44px; padding: 0 10px; border-radius: 8px; border: 0; background: #2a3554;
    color: #fff; font: 600 14px "JetBrains Mono", ui-monospace, monospace; cursor: pointer; touch-action: manipulation;
    -webkit-user-select: none; user-select: none; }
  .m-keys button.m-mod { background: #34437a; }
  .m-keys button[aria-pressed="true"] { background: var(--m-blue); outline: 2px solid #93b4ff; }
}
