/* Layout: Kopfzeile als Raster (links Status, Mitte Marke mit Menü, rechts Knöpfe), main scrollt
   selbst, untere Leiste am Handy. Kein Rechnen mit Fensterhöhen: body ist 100dvh, main füllt den Rest. */
@layer bausteine {
  header.kopf {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: .6rem;
    padding: calc(.45rem + var(--d-oben) + var(--sicher-oben)) calc(1rem + var(--sicher-rechts)) .45rem calc(1rem + var(--sicher-links));
    background: var(--flaeche);
    border-bottom: 1px solid var(--rand);
    position: relative;
    z-index: var(--z-kopf);
  }
  .kopf-links { justify-self: start; min-width: 0; display: flex; align-items: center; gap: .3rem; }
  .kopf-mitte { justify-self: center; position: relative; }
  .kopf-rechts { justify-self: end; display: flex; align-items: center; gap: .2rem; min-width: 0; }
  .marke { font-weight: 700; font-size: 1.05rem; color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .7rem; border-radius: var(--rundung-pille); background: transparent; border: 0; }
  button.marke:hover, .marke[aria-expanded=true] { background: var(--ton-2); }
  .marke .pfeil { opacity: .5; font-size: .75rem; }
  .marke kbd { margin-left: .2rem; }
  .wer-bin-ich { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .6rem; border-radius: var(--rundung-pille); max-width: 12rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .wer-bin-ich:hover { background: var(--ton-2); }
  .admin-marke { font-size: var(--winzig); opacity: .6; border: 1px solid currentColor; padding: .1rem .5rem; border-radius: var(--rundung-pille); }
  /* Unterzeile: Gast-Frist, Admin-Reiter */
  .unterzeile { display: flex; gap: .5rem 1rem; align-items: center; flex-wrap: wrap; padding: .35rem 1rem; background: var(--flaeche); border-bottom: 1px solid var(--rand); font-size: var(--klein); }
  .unterzeile a { color: inherit; }
  .frist-zeile { background: var(--akzent-hell); }
  .frist-zeile a { text-decoration: underline; }
  .admin-reiter { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .admin-reiter a { white-space: nowrap; opacity: .7; padding: .15rem .4rem; border-radius: var(--rundung-klein); }
  .admin-reiter a:hover, .admin-reiter a.aktiv { opacity: 1; background: var(--ton-2); }
  /* Untere Leiste: nur am Handy */
  .leiste-unten { display: none; }
  .schreib-schweber { display: none; }
  body:has(.davor) header.kopf { display: none; }
}

@layer handy {
  @media (max-width: 48rem) {
    /* minmax(0, 1fr): sonst darf die linke Spalte so breit werden wie der Status-Knopf und schiebt sich unter die Marke */
    header.kopf { gap: .3rem; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); padding-left: calc(.6rem + var(--sicher-links)); padding-right: calc(.6rem + var(--sicher-rechts)); }
    /* justify-self: start ließe den Inhalt über die Zelle hinausragen; stretch begrenzt ihn auf die Zelle */
    .kopf-links { justify-self: stretch; overflow: hidden; }
    .kopf-rechts { justify-self: stretch; justify-content: flex-end; overflow: hidden; }
    .kopf-links > * { min-width: 0; }
    .status-knopf { max-width: 100%; min-width: 0; overflow: hidden; }
    .marke kbd, .marke .pfeil { display: none; }
    .wer-bin-ich { max-width: 7rem; padding: .3rem .4rem; }
    .fenster-knopf { display: none; }
    main { padding: .6rem; }
    body { padding-bottom: calc(var(--leiste-hoehe) + var(--sicher-unten)); }
    .leiste-unten { position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-leiste); display: flex; justify-content: space-around; padding: .4rem 0 calc(.35rem + var(--sicher-unten)); background: color-mix(in srgb, var(--flaeche) 85%, transparent); border-top: 1px solid var(--rand); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
    .leiste-unten a { display: flex; flex-direction: column; align-items: center; gap: .1rem; font-size: .68rem; color: inherit; text-decoration: none; opacity: .55; min-width: 4rem; padding: .1rem 0; }
    .leiste-unten a.aktiv { opacity: 1; color: var(--d-akzent); }
    .leiste-unten .hinweis-zahl { margin-left: .2rem; }
    .schreib-schweber { position: fixed; right: 1.1rem; bottom: calc(var(--leiste-hoehe) + 1rem + var(--sicher-unten)); width: 3.4rem; height: 3.4rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--d-akzent); color: var(--akzent-text); box-shadow: var(--schatten); z-index: var(--z-leiste); }
    .nur-handy { display: inline-flex; }
    .nur-rechner { display: none; }
  }
}
