/* Schulpult — Handy zuerst. Vorlage: das Familien-Pult (Minecraft/Dashboard).
   Schrift und Farben: Wilhelmswerk-Markenkit (_workspace/brand). Der Dunkelmodus
   nimmt die Terminal-Töne des Kits. Form: Inventar-Slots, Hotbar, Bögen. */

@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('./fonts/IBMPlexSans-var-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2192, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'IBM Plex Sans';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('./fonts/IBMPlexSans-var-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+20AD-20C0;
}
@font-face {
  font-family: 'IBM Plex Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('./fonts/IBMPlexMono-400-latin.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --ground: #eef3f7;
  --surface: #ffffff;
  --sunken: #e5ecf1;
  --ink: #141a20;
  --ink-soft: #46545f;
  --ink-faint: #66727d;
  --line: #e3e8ec;
  --line-strong: #c9d3dc;
  --brand: #2b3a4a;
  --brand-on: #ffffff;
  --navy: #00235d;
  --teal: #00bea0;
  --teal-ink: #007a67;
  --warn: #c07a00;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --slot: #d9e2ea;
  --slot-dark: rgba(20, 26, 32, .28);
  --slot-light: rgba(255, 255, 255, .9);
  --shade: rgba(15, 26, 36, .45);
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --tabs-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0f1a24;
    --surface: #16222e;
    --sunken: #0b141c;
    --ink: #e6eef5;
    --ink-soft: #9fb6c9;
    --ink-faint: #7d8fa0;
    --line: #24323f;
    --line-strong: #34465a;
    --brand: #e6eef5;
    --brand-on: #0f1a24;
    --teal-ink: #2fd6bb;
    --warn: #f0b429;
    --danger: #ff7a6b;
    --danger-soft: #3a1f1d;
    --slot: #22303d;
    --slot-dark: rgba(0, 0, 0, .55);
    --slot-light: rgba(255, 255, 255, .12);
    --shade: rgba(0, 0, 0, .6);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.4 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
body.is-busy { cursor: progress; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
#view:focus { outline: none; }

/* ------------------------------------------------------------- Gerüst -- */
.app { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 10px;
  background: var(--ground);
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.top-mark { image-rendering: pixelated; flex: none; }
.top-title { font-weight: 600; font-size: 17px; }
.top-status { margin-left: auto; display: flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.top-open { padding: 1px 6px; background: var(--sunken); color: var(--teal-ink); font-weight: 600; }
.view { flex: 1; padding: 12px 12px calc(var(--tabs-h) + var(--safe-b) + 24px); }
body.has-hotbar .view { padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 132px); }
.mock-note { margin-top: 6px; font-size: 13px; color: var(--ink-faint); text-align: center; }
.search { position: relative; margin-top: 10px; }
.search .field { padding-right: 48px; -webkit-appearance: none; appearance: none; }
.search .field::-webkit-search-cancel-button { display: none; } /* eigener Knopf, nicht zwei */
.search-clear { position: absolute; top: 0; right: 0; width: 44px; height: 44px; border: 0; background: none; color: var(--ink-faint); font-size: 24px; line-height: 1; }
.noscript { padding: 24px; text-align: center; }
.dot { width: 8px; height: 8px; flex: none; background: var(--ink-faint); }
.dot.ok { background: var(--teal); }
.dot.down { background: var(--danger); }

/* Reiter unten, in Daumenreichweite */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 640px; margin: 0 auto; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line-strong);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--ink-faint); font-size: 12px; font-weight: 500; position: relative; }
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 3px; background: var(--teal); }
.px { width: 24px; height: 24px; display: block; fill: currentColor; shape-rendering: crispEdges; }
.px.sm { width: 18px; height: 18px; }

/* ------------------------------------------------------------ Bausteine -- */
.group { margin: 0 0 20px; }
.group > h2 { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin: 0 4px 8px; letter-spacing: .01em; }
.hint { font-size: 14px; color: var(--ink-faint); margin: 8px 4px 0; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.list > * + * { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; }
.row-text { flex: 1; min-width: 0; }
.row-title { display: block; font-weight: 500; overflow-wrap: anywhere; }
.row-sub { display: block; font-size: 14px; color: var(--ink-faint); }
.row-value { font-variant-numeric: tabular-nums; color: var(--ink-soft); text-align: right; }
.row-btn { width: 100%; border: 0; background: none; text-align: left; }
.row.stack { flex-direction: column; align-items: stretch; gap: 10px; padding: 12px 14px; }
.row > .btn { flex: none; padding: 8px 12px; }
.row-who { display: flex; align-items: center; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px; border-radius: 4px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 500;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-on); font-weight: 600; }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); font-weight: 600; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--teal-ink); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; }
.btn-grid.two { grid-template-columns: 1fr 1fr; }
.btn-grid.three { grid-template-columns: repeat(3, 1fr); }
.btn-grid.four { grid-template-columns: repeat(4, 1fr); }
.btn-grid .btn { padding: 8px 6px; }
.btn.is-on { border-color: var(--teal); box-shadow: inset 0 0 0 2px var(--teal); font-weight: 600; }
.btn .btn-sub { display: block; font-size: 12px; font-weight: 400; color: var(--ink-faint); }
.btn.tall { flex-direction: column; gap: 0; min-height: 56px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { min-height: 36px; padding: 4px 12px; border-radius: 4px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink-soft); font-size: 14px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-on); }
.chip[disabled] { opacity: .45; cursor: default; }

.switch { position: relative; flex: none; width: 52px; height: 32px; padding: 0; border: 0; background: var(--slot); box-shadow: inset 2px 2px 0 var(--slot-dark), inset -2px -2px 0 var(--slot-light); }
.switch::after { content: ""; position: absolute; top: 5px; left: 5px; width: 22px; height: 22px; background: var(--ink-faint); transition: transform .12s ease-out, background .12s; }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--teal); }
.switch.is-busy::after { background: var(--warn); }

.field { width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px; } /* unter 16 px zoomt iOS beim Antippen */
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; min-width: 0; }

/* -------------------------------------------------------------- Spieler -- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 10px; }
.players { list-style: none; margin: 0; padding: 0; }
.player { display: grid; grid-template-columns: auto 1fr; align-items: stretch; }
.slot {
  --s: 40px;
  position: relative; flex: none; width: calc(var(--s) + 12px); height: calc(var(--s) + 12px); margin: 8px 0 8px 10px; padding: 0; border: 0;
  background: var(--slot); box-shadow: inset 2px 2px 0 var(--slot-dark), inset -2px -2px 0 var(--slot-light);
}
.slot .face {
  position: absolute; inset: 6px; width: var(--s); height: var(--s);
  display: grid; place-items: center; background: var(--brand); color: var(--brand-on); font-weight: 600; font-size: 17px;
}
.player:not(.is-online) .face { filter: grayscale(1); opacity: .55; }
.slot .online { position: absolute; right: -3px; top: -3px; width: 12px; height: 12px; background: var(--teal); border: 2px solid var(--surface); }
.slot[aria-pressed="true"] { outline: 3px solid var(--teal); outline-offset: 0; }
.slot[aria-pressed="true"]::before { content: ""; position: absolute; z-index: 2; inset: 0; background: rgba(0, 190, 160, .35); }
.slot .tick { position: absolute; z-index: 3; inset: 0; display: none; place-items: center; color: #fff; }
.slot[aria-pressed="true"] .tick { display: grid; }
.slot.small { --s: 28px; margin: 0; }
.slot.small .face { font-size: 12px; }

.player-main { display: block; min-width: 0; padding: 10px 14px 10px 12px; border: 0; background: none; text-align: left; }
.player-line { display: flex; align-items: baseline; gap: 8px; }
.player-name { flex: 1 1 auto; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.player-sub { font-size: 13px; color: var(--ink-faint); }
.player-note { display: block; margin-top: 1px; font-size: 15px; color: var(--ink-soft); overflow-wrap: anywhere; }
.tag { flex: none; font-size: 12px; font-weight: 500; padding: 1px 6px; color: var(--ink-soft); background: var(--sunken); }
.tag.ok { color: var(--teal-ink); }
.tag.warn { color: var(--brand-on); background: var(--warn); font-weight: 600; }
.tag.alert { color: var(--danger); background: var(--danger-soft); font-weight: 600; }
.tag.teacher { color: #fff; background: var(--navy); font-weight: 600; }
.dest .tag { margin-left: auto; }

.empty { padding: 28px 16px; text-align: center; color: var(--ink-soft); }
.empty p + p { margin-top: 6px; }
.banner { margin: 0 0 12px; padding: 10px 14px; border-radius: 6px; background: var(--danger-soft); color: var(--danger); font-weight: 500; }

/* Hotbar: erscheint, sobald jemand gewählt ist */
.hotbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); z-index: 25;
  max-width: 640px; margin: 0 auto; padding: 8px 10px 10px;
  background: var(--brand); color: var(--brand-on);
  display: grid; gap: 8px;
}
.hotbar-head { display: flex; align-items: center; justify-content: space-between; font-size: 14px; font-weight: 600; }
.hotbar-head button { border: 0; background: none; color: inherit; font-size: 14px; font-weight: 500; min-height: 32px; padding: 0 4px; text-decoration: underline; text-underline-offset: 3px; }
.hotbar-slots { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.hot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; padding: 4px 2px; border: 0;
  background: rgba(127, 140, 153, .28); color: inherit; font-size: 12px; font-weight: 500;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, .35), inset -2px -2px 0 rgba(255, 255, 255, .22);
}
.hot:active { background: var(--teal); color: #06231e; }

/* --------------------------------------------------------------- Bögen -- */
.shade { position: fixed; inset: 0; z-index: 40; background: var(--shade); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--ground); border-radius: 10px 10px 0 0; padding: 0 14px calc(18px + var(--safe-b));
  animation: rise .16s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 14px 0 12px; background: var(--ground); }
.sheet-head h2 { flex: 1; min-width: 0; font-size: 19px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.sheet-head .sub { display: block; font-size: 14px; font-weight: 400; color: var(--ink-faint); }
.sheet-close { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: var(--sunken); color: var(--ink-soft); border-radius: 4px; }
.sheet .slot { margin: 0; }
.sheet h3 { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin: 18px 2px 8px; }
.sheet h3:first-of-type { margin-top: 4px; }
.sheet .note { font-size: 14px; color: var(--ink-faint); margin: 8px 2px 0; }
.sheet .facts { font-size: 15px; color: var(--ink-soft); margin: 0 2px 8px; font-variant-numeric: tabular-nums; }
.password {
  margin: 4px 0 14px; padding: 18px 12px; text-align: center; overflow-wrap: anywhere;
  font: 400 24px/1.3 var(--mono); letter-spacing: .02em; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; user-select: all;
}
@media (min-width: 720px) {
  .shade { align-items: center; }
  .sheet { border-radius: 10px; max-width: 520px; }
}

.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabs-h) + var(--safe-b) + 12px); z-index: 60;
  max-width: 616px; margin: 0 auto; padding: 12px 16px; border-radius: 4px;
  background: var(--brand); color: var(--brand-on); font-weight: 500;
  transform: translateY(16px); opacity: 0; pointer-events: none; transition: transform .16s ease-out, opacity .16s;
}
.toast.show { transform: none; opacity: 1; }
.toast.error { background: var(--danger); color: #fff; }
.toast small { display: block; font-weight: 400; opacity: .85; margin-top: 2px; }
body.has-hotbar .toast { bottom: calc(var(--tabs-h) + var(--safe-b) + 124px); }
body:has(.shade) .toast { top: calc(env(safe-area-inset-top, 0px) + 12px); bottom: auto; } /* nie über dem Bogen, etwa dem neuen Passwort */

/* -------------------------------------------------------- Zugang, Server -- */
.status-word { display: block; font-size: 26px; font-weight: 600; line-height: 1.15; }
.status-word.ok { color: var(--teal-ink); }
.status-word.down { color: var(--danger); }

/* ---------------------------------------------------------------- Karte -- */
.mapbox { margin: 0 0 16px; }
.map iframe { display: block; width: 100%; height: 62dvh; border: 1px solid var(--line); border-radius: 6px; background: var(--sunken); }
.map .btn { margin-top: 6px; }

/* ---------------------------------------------------------------- Login -- */
.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px 16px; }
.login { width: 100%; max-width: 340px; }
.login-mark { display: block; image-rendering: pixelated; box-shadow: 0 0 0 4px var(--surface), 0 0 0 5px var(--line-strong); }
.login h1 { font-size: 24px; font-weight: 600; margin: 24px 0 2px; }
.login-sub { color: var(--ink-faint); margin: 0 0 20px; }
.login-form label { display: block; font-size: 14px; font-weight: 500; color: var(--ink-soft); margin: 14px 0 6px; }
.login-form input[type="text"], .login-form input[type="password"] { width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 4px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px; }
.login-form .btn { margin-top: 22px; min-height: 48px; }
.login-error { padding: 10px 12px; border-radius: 4px; background: var(--danger-soft); color: var(--danger); font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
