/* lubadash — Formsprache.
 *
 * Farben aus dem bestehenden Dashboard (app/static/css/styles.css im alten
 * lubadash): dunkler Grund #1b1b1d, Karten #2e2e30, Text #e6edf3, Grün als
 * Akzent. Das bleibt, damit die App nach derselben App aussieht.
 *
 * Handy zuerst, und zwar ernst gemeint: die Eingabe passiert am Telefon,
 * einhändig, oft im Stehen. Darum sind Tippflächen mindestens 44px, das
 * Habit-Raster scrollt waagerecht statt zu schrumpfen, und die Navigation
 * sitzt unten am Daumen. Ab 900px wird daraus eine Seitenleiste.
 */

:root {
  --grund: #1b1b1d;
  --karte: #242427;
  --karte-hoch: #2e2e30;
  --rand: #3a3a3c;
  --text: #e6edf3;
  --text-leise: #9198a1;
  --gruen: #3fb950;
  --gruen-dunkel: #1d4425;
  --rot: #f85149;
  --gelb: #eab308;
  --blau: #74adc1;
  --radius: 10px;
  --tippflaeche: 44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 16px;            /* unter 16px zoomt iOS beim Fokus in ein Feld */
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

/* ------------------------------------------------------------- Gerüst */

.app {
  display: grid;
  min-height: 100%;
  /* Reihenfolge über Bereiche, nicht über die Reihenfolge im HTML: dort
     steht die Navigation vor dem Inhalt (sinnvoll fürs Durchtabben), am
     Handy gehört sie aber unten an den Daumen. */
  grid-template-rows: auto 1fr auto;
  grid-template-areas: "kopf" "main" "nav";
  min-width: 0;
}
header.kopf { grid-area: kopf; }
nav.tabs    { grid-area: nav; }
main        { grid-area: main; }

header.kopf {
  display: flex; align-items: center; gap: .7em;
  padding: .7em 1em;
  border-bottom: 1px solid var(--rand);
  background: var(--grund);
  position: sticky; top: 0; z-index: 20;
}
header.kopf img { height: 26px; width: auto; }
header.kopf .titel { font-weight: 700; letter-spacing: .01em; }
header.kopf .rechts { margin-left: auto; display: flex; gap: .5em; align-items: center; }

/* min-width:0 und overflow-x:hidden: ohne beides drückt das Habit-Raster
   das ganze Grid breiter als den Bildschirm, und die Navigation ragt rechts
   aus dem Bild. Scrollen soll nur das Raster selbst, nicht die Seite. */
main { padding: 1em; max-width: 1400px; width: 100%; margin: 0 auto;
       min-width: 0; overflow-x: hidden; }

/* Navigation: am Handy unten (Daumen), ab 900px links als Spalte. */
nav.tabs {
  display: flex; border-top: 1px solid var(--rand);
  background: var(--karte); position: sticky; bottom: 0; z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs button {
  flex: 1; min-height: 56px; border: 0; background: none; color: var(--text-leise);
  font-size: .72rem; font-weight: 600; letter-spacing: .03em;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; padding: 6px 2px;
}
nav.tabs button .zeichen { font-size: 1.25rem; line-height: 1; }
nav.tabs button[aria-selected="true"] { color: var(--gruen); }
nav.tabs button[aria-selected="true"] .zeichen { transform: translateY(-1px); }

@media (min-width: 900px) {
  .app { grid-template-columns: 210px 1fr; grid-template-rows: auto 1fr;
         grid-template-areas: "kopf kopf" "nav main"; }
  header.kopf { grid-area: kopf; }
  nav.tabs { grid-area: nav; flex-direction: column; border-top: 0;
             border-right: 1px solid var(--rand); position: sticky; top: 60px;
             height: calc(100vh - 60px); align-items: stretch; padding-top: .6em; }
  nav.tabs button { flex: none; flex-direction: row; justify-content: flex-start;
                    gap: .7em; padding: 0 1.1em; min-height: 46px; font-size: .9rem; }
  nav.tabs button[aria-selected="true"] { background: var(--karte-hoch); }
  main { grid-area: main; padding: 1.4em; }
}

/* ------------------------------------------------------------- Bausteine */

h1 { font-size: 1.25rem; margin: 0 0 .8em; }
h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .09em;
     color: var(--text-leise); margin: 1.6em 0 .7em; font-weight: 700; }
h2:first-child { margin-top: 0; }

.karte {
  background: var(--karte); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 1em; margin-bottom: 1em;
}

.knopf {
  min-height: var(--tippflaeche); padding: 0 1.1em;
  background: var(--gruen); color: #07210c; border: 0; border-radius: 8px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
}
.knopf.leise { background: var(--karte-hoch); color: var(--text); border: 1px solid var(--rand); }
.knopf.gefahr { background: transparent; color: var(--rot); border: 1px solid var(--rot); }
.knopf:active { transform: translateY(1px); }

input, select, textarea {
  background: var(--grund); color: var(--text); border: 1px solid var(--rand);
  border-radius: 8px; padding: .6em .7em; font-size: 1rem; min-height: var(--tippflaeche);
  width: 100%; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--gruen); outline-offset: 1px; border-color: transparent;
}
label { display: block; font-size: .8rem; color: var(--text-leise);
        margin-bottom: .25em; font-weight: 600; }
.feld { margin-bottom: .8em; }
.reihe { display: flex; gap: .6em; align-items: flex-end; flex-wrap: wrap; }
.reihe > * { flex: 1 1 0; min-width: 0; }
.reihe > .schmal { flex: 0 0 auto; }

/* ------------------------------------------------------- Habit-Raster */

/* Waagerecht scrollbar statt gestaucht: bei 11 Habits × 30 Tagen wäre jede
   Zelle sonst 6px breit und nicht mehr treffbar. */
.raster-huelle { overflow-x: auto; -webkit-overflow-scrolling: touch;
                 margin: 0 -1em; padding: 0 1em; max-width: 100vw; }
table.raster { border-collapse: separate; border-spacing: 3px; }
table.raster th.tag {
  font-size: .64rem; font-weight: 600; color: var(--text-leise);
  height: 22px; padding: 0 0 4px; white-space: nowrap; text-align: center;
}
table.raster th.tag.monatsanfang { color: var(--text); font-weight: 700; }
table.raster th.name {
  text-align: left; font-size: .85rem; font-weight: 600; white-space: nowrap;
  padding-right: .8em; position: sticky; left: 0; background: var(--grund);
  z-index: 2; max-width: 9em; overflow: hidden; text-overflow: ellipsis;
}
table.raster td.zelle { padding: 0; }
table.raster td.zelle button {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--rand);
  background: var(--karte); cursor: pointer; padding: 0; display: block;
}
table.raster td.zelle button[data-an="1"] { background: var(--gruen); border-color: var(--gruen); }
table.raster td.zelle button[data-heute="1"] { outline: 2px solid var(--blau); outline-offset: 1px; }
table.raster td.zelle button:focus-visible { outline: 2px solid var(--text); }

/* Streifen für "heute" in der Tagesliste */
.heute-liste { display: grid; gap: .5em; }
.heute-zeile {
  display: flex; align-items: center; gap: .8em;
  background: var(--karte); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: .55em .8em; min-height: 56px;
}
.heute-zeile .name { flex: 1; font-weight: 600; }
.heute-zeile .streak { font-size: .78rem; color: var(--text-leise); }
.haken {
  width: 42px; height: 42px; flex: none; border-radius: 11px;
  border: 2px solid var(--rand); background: transparent; cursor: pointer;
  font-size: 1.2rem; color: transparent; display: grid; place-items: center;
}
.haken[data-an="1"] { background: var(--gruen); border-color: var(--gruen); color: #07210c; }

/* ------------------------------------------------------------ Training */

.satz-zeile {
  display: grid; grid-template-columns: 2.2em 1fr 1fr auto; gap: .5em;
  align-items: center; padding: .3em 0;
}
.satz-zeile .nr { color: var(--text-leise); font-variant-numeric: tabular-nums; font-size: .85rem; }
.satz-zeile input { min-height: 40px; text-align: center; }

.uebung-karte { background: var(--karte); border: 1px solid var(--rand);
                border-radius: var(--radius); padding: .8em; margin-bottom: .8em; }
.uebung-karte .kopfzeile { display: flex; align-items: baseline; gap: .6em; margin-bottom: .5em; }
.uebung-karte .kopfzeile .name { font-weight: 700; }
.uebung-karte .kopfzeile .zuletzt { font-size: .75rem; color: var(--text-leise); margin-left: auto; }

/* --------------------------------------------------------------- Rest */

.kennzahlen { display: grid; gap: .7em; min-width: 0;
              grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); }
.kennzahl { background: var(--karte); border: 1px solid var(--rand);
            border-radius: var(--radius); padding: .8em; }
.kennzahl .wert { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kennzahl .bez { font-size: .75rem; color: var(--text-leise); text-transform: uppercase;
                 letter-spacing: .05em; }

.plot { width: 100%; min-height: 300px; }
.leise { color: var(--text-leise); font-size: .88rem; }
.fehler { border-left: 4px solid var(--rot); background: #2a1a1a;
          padding: .7em .9em; border-radius: 8px; margin-bottom: 1em; }
.hinweis { border-left: 4px solid var(--gelb); background: #2a2616;
           padding: .7em .9em; border-radius: 8px; margin-bottom: 1em; font-size: .9rem; }

/* --------------------------------------------------------- Anmeldung */

.login-mitte {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5em;
}
.login-karte {
  width: 100%; max-width: 360px; background: var(--karte);
  border: 1px solid var(--rand); border-radius: 14px; padding: 1.6em;
}
.login-karte img { height: 34px; margin-bottom: 1.2em; }
.login-karte .knopf { width: 100%; margin-top: .4em; }
