/* ============================================================================
   VATER IN FORM – FORTSCHRITTS-COCKPIT V2
   styles.css
   ----------------------------------------------------------------------------
   Farbwelt: TRAINING (Training Bronze #B95A22 / Bronze Light #D9824C).
   Verbindliche Quelle: docs/BRAND_PALETTE_VATER_IN_FORM.md, Abschnitte 3 und 6.
   Die Nutrition-Farbwelt gehoert ausdruecklich NICHT in dieses Produkt –
   sie bleibt dem Ernaehrungs-Cockpit vorbehalten.

   Standard ist der HELLE Premium-Modus – die hellen Werte stehen deshalb
   direkt in :root. Der Dunkelmodus ist ein Override unter
   html[data-theme="dark"]. Faellt JavaScript oder der Speicher aus, bleibt
   damit verlaesslich Hell aktiv.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS – HELL (Standard)
   ------------------------------------------------------------------------ */

:root {
  /* Flaechen */
  --vif-bg-page:      #F7F5F1;  /* Warmes Weiss */
  --vif-bg-card:      #FFFFFF;  /* Reinweiss */
  --vif-bg-sand:      #E9E2D7;  /* Sand */
  --vif-bg-raised:    #FFFFFF;
  --vif-bg-inverse:   #2B2E34;  /* Anthrazit */
  --vif-bg-black:     #141518;  /* Tiefschwarz */
  --vif-bg-subtle:    #F1EDE6;  /* abgeleitet: zarte Hover-/Sekundaerflaeche */

  /* Text */
  --vif-text-primary:   #2B2E34;
  --vif-text-body:      #54585F;
  --vif-text-secondary: #6B6F77;
  --vif-text-tertiary:  #6B6F77;  /* im Hellmodus bewusst nicht heller – Kontrast */
  --vif-text-on-dark:   #E8E5E0;
  --vif-text-on-dark-soft: rgba(232, 229, 224, .80);
  --vif-text-on-accent: #FFFFFF;  /* 4,62:1 auf Training Bronze */

  /* Rahmen */
  --vif-border-hair:   rgba(43, 46, 52, .08);
  --vif-border-soft:   rgba(43, 46, 52, .13);
  --vif-border-strong: rgba(43, 46, 52, .30);
  --vif-border-warm:   #DED4C4;

  /* Training-Akzent */
  --vif-accent:        #B95A22;
  --vif-accent-hover:  #9E4A1B;  /* dunklere Mischstufe, kein neuer Markenton */
  /* Training Bronze als kleiner TEXT erreicht auf Warmweiss nur 4,24:1.
     Fuer Textrollen wird deshalb dieselbe Abdunklung verwendet wie beim Hover:
     #9E4A1B ergibt 5,59:1 auf Warmweiss und 4,73:1 auf Sand.
     Flaechen, Rahmen und Linien behalten das kraeftige Training Bronze. */
  --vif-accent-text:   #9E4A1B;
  --vif-accent-tint:   rgba(185, 90, 34, .09);
  --vif-accent-border: rgba(185, 90, 34, .32);

  /* Funktional – bewusst entsaettigt, damit nichts nach Fitness-App wirkt */
  --vif-ok:        #1B7A50;
  --vif-ok-tint:   rgba(27, 122, 80, .10);
  --vif-danger:      #B4342A;
  --vif-danger-tint: rgba(180, 52, 42, .10);

  /* Schatten auf Tiefschwarz-Basis */
  --vif-shadow-sm: 0 1px 2px rgba(20, 21, 24, .05);
  --vif-shadow-md: 0 6px 20px rgba(20, 21, 24, .08);
  --vif-shadow-lg: 0 16px 40px rgba(20, 21, 24, .14);

  /* Diagramme */
  --vif-chart-1:      #B95A22;
  --vif-chart-2:      #2B2E34;
  --vif-chart-grid:   rgba(43, 46, 52, .12);
  --vif-chart-axis:   #6B6F77;

  /* Masse */
  --vif-radius-sm: 8px;
  --vif-radius:    12px;
  --vif-radius-lg: 16px;
  --vif-radius-pill: 999px;

  --vif-space-1: 4px;
  --vif-space-2: 8px;
  --vif-space-3: 12px;
  --vif-space-4: 16px;
  --vif-space-5: 24px;
  --vif-space-6: 32px;
  --vif-space-7: 48px;

  --vif-sidenav-width: 244px;
  --vif-content-max: 940px;

  /* Typografie */
  --vif-font: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --fs-xs:   0.75rem;
  --fs-sm:   0.875rem;
  --fs-base: 1rem;
  --fs-md:   1.0625rem;
  --fs-lg:   1.25rem;
  --fs-xl:   1.5rem;
  --fs-2xl:  1.875rem;
  --fs-3xl:  2.25rem;

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2. TOKENS – DUNKEL (Override)
   ------------------------------------------------------------------------ */

html[data-theme="dark"] {
  --vif-bg-page:      #141518;
  --vif-bg-card:      #2B2E34;
  --vif-bg-sand:      #33363D;
  --vif-bg-raised:    #2B2E34;
  --vif-bg-inverse:   #E9E2D7;
  --vif-bg-black:     #0F1013;
  --vif-bg-subtle:    #33363D;

  --vif-text-primary:   #E8E5E0;
  --vif-text-body:      rgba(232, 229, 224, .82);
  --vif-text-secondary: #9AA0A8;
  --vif-text-tertiary:  #9AA0A8;
  --vif-text-on-dark:   #E8E5E0;
  --vif-text-on-dark-soft: rgba(232, 229, 224, .80);
  --vif-text-on-accent: #141518;  /* 7:1 auf Bronze Light */

  --vif-border-hair:   rgba(232, 229, 224, .08);
  --vif-border-soft:   rgba(232, 229, 224, .14);
  --vif-border-strong: rgba(232, 229, 224, .34);
  --vif-border-warm:   rgba(222, 212, 196, .22);

  /* Auf dunklen Flaechen gilt Training Bronze LIGHT (Palette Abschnitt 3). */
  --vif-accent:        #D9824C;
  --vif-accent-hover:  #E59A6B;
  /* Auf getoenten Flaechen im Dunkelmodus reicht Bronze Light als Text nicht
     (3,82:1). Dieselbe Aufhellung wie beim Hover erreicht 4,83:1. */
  --vif-accent-text:   #E59A6B;
  --vif-accent-tint:   rgba(217, 130, 76, .14);
  --vif-accent-border: rgba(217, 130, 76, .38);

  --vif-ok:        #5FCFA0;
  --vif-ok-tint:   rgba(95, 207, 160, .14);
  --vif-danger:      #E8827A;
  --vif-danger-tint: rgba(232, 130, 122, .14);

  --vif-shadow-sm: 0 1px 2px rgba(0, 0, 0, .30);
  --vif-shadow-md: 0 6px 20px rgba(0, 0, 0, .38);
  --vif-shadow-lg: 0 16px 40px rgba(0, 0, 0, .50);

  --vif-chart-1:    #D9824C;
  --vif-chart-2:    #E8E5E0;
  --vif-chart-grid: rgba(232, 229, 224, .14);
  --vif-chart-axis: #9AA0A8;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   3. GRUNDLAGEN
   ------------------------------------------------------------------------ */

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

/* Ohne diese Zeile greift das hidden-Attribut bei Elementen mit eigener
   display-Regel (Buttons, Badges) nicht. */
[hidden] { display: none !important; }

html {
  font-family: var(--vif-font);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--vif-bg-page);
  color: var(--vif-text-body);
  font-size: var(--fs-base);
  line-height: 1.55;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  color: var(--vif-text-primary);
  line-height: 1.2;
  margin: 0 0 var(--vif-space-3);
  letter-spacing: -0.018em;
}
h1 { font-size: var(--fs-2xl); font-weight: 800; }
h2 { font-size: var(--fs-xl);  font-weight: 800; }
h3 { font-size: var(--fs-md);  font-weight: 700; letter-spacing: -0.01em; }
h4 { font-size: var(--fs-base); font-weight: 700; }

p { margin: 0 0 var(--vif-space-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--vif-accent-text); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--vif-accent-hover); }

img, svg { max-width: 100%; }

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

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

.skip-link {
  position: absolute; left: var(--vif-space-3); top: -60px;
  background: var(--vif-accent); color: var(--vif-text-on-accent);
  padding: 10px 16px; border-radius: var(--vif-radius-sm);
  font-weight: 700; z-index: 200; transition: top .15s ease;
}
.skip-link:focus { top: var(--vif-space-3); }

/* Lange Übungsnamen und Notizen dürfen nie das Layout sprengen. */
p, li, td, th, h1, h2, h3, h4, .card, .journal-detail { overflow-wrap: anywhere; }

/* --------------------------------------------------------------------------
   4. GRUNDGERÜST
   ------------------------------------------------------------------------ */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: var(--vif-space-3);
  /* Senkrechter Innenabstand bewusst schmaler als die uebrigen 12 px: So
     bleibt die Kopfzeile trotz des groesseren Logos fast genauso hoch wie
     vorher (rund 70 statt 65 px). */
  padding: var(--vif-space-2) var(--vif-space-4);
  padding-top: calc(var(--vif-space-2) + env(safe-area-inset-top, 0px));
  background: var(--vif-bg-raised);
  border-bottom: 1px solid var(--vif-border-soft);
}

.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex: 0 0 auto;
  background: transparent; border: 1px solid var(--vif-border-soft);
  border-radius: var(--vif-radius-sm); color: var(--vif-text-primary);
  cursor: pointer;
}
.nav-toggle:hover { background: var(--vif-bg-subtle); }

.brand { display: flex; align-items: center; gap: var(--vif-space-3); min-width: 0; }
/* Die Logodateien haben einen eingebrannten Hintergrund. Statt die geschuetzten
   Dateien zu veraendern, wird der Hintergrund per Mischmodus neutralisiert. */
.brand-logo {
  /* WARUM DIESE ZAHLEN?
     Die Logodatei ist 640 x 640 Pixel gross, das sichtbare Logo darin aber nur
     rund 61,5 % davon – ringsum liegen etwa 19 % durchsichtiger Leerrand. Bei
     "height: 54px" waren deshalb nur ca. 33 px Logo zu sehen; es wirkte viel
     kleiner als der eingestellte Wert. Das war die eigentliche Ursache.

     Statt die Kopfzeile hoeher zu machen, wird der Leerrand hier optisch
     weggeschnitten: Das Bild wird auf 88 px vergroessert und mit einem
     negativen Aussenabstand wieder auf 54 px Platzbedarf zurueckgeholt.
       88 px Bild x 0,615 sichtbarer Anteil = 54 px sichtbares Logo
       88 px - 2 x 17 px                    = 54 px Platzbedarf
     Ergebnis: Das sichtbare Logo waechst von ca. 33 auf 54 px (+64 %), waehrend
     der Platzbedarf in der Kopfzeile exakt derselbe bleibt wie vorher – die
     Zeile bleibt also unveraendert 71 px hoch.

     Das Seitenverhaeltnis bleibt 1:1, nichts wird verzerrt. Der ueberstehende
     Bereich ist vollstaendig durchsichtig und ueberdeckt deshalb nichts.

     Soll das Logo spaeter noch groesser werden, aendert man nur diese beiden
     Zahlen im Verhaeltnis 88 : 17 - dann waechst allerdings auch die Kopfzeile,
     weil der Platzbedarf steigt. */
  height: 88px; width: 88px;
  margin: -17px;
  display: block; flex: 0 0 auto;
  object-fit: contain;
  mix-blend-mode: multiply;
}
html[data-theme="dark"] .brand-logo { mix-blend-mode: screen; }
.brand-text { min-width: 0; }
.brand-title {
  font-size: var(--fs-base); font-weight: 800; color: var(--vif-text-primary);
  margin: 0; line-height: 1.2; letter-spacing: -0.01em;
}
.brand-sub {
  font-size: var(--fs-xs); color: var(--vif-text-secondary);
  margin: 0; line-height: 1.3;
}

.app-body { flex: 1 1 auto; display: block; }

/* Seitennavigation */
.sidenav {
  position: fixed; inset: 0 auto 0 0; z-index: 90;
  width: min(280px, 84vw);
  background: var(--vif-bg-raised);
  border-right: 1px solid var(--vif-border-soft);
  padding: var(--vif-space-4);
  padding-top: calc(var(--vif-space-4) + env(safe-area-inset-top, 0px));
  transform: translateX(-100%);
  visibility: hidden;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: var(--vif-space-2);
}
/* Die Animation gilt nur in der mobilen Ansicht. Sonst wuerde beim Wechsel
   ueber den Breakpoint die feste Desktop-Navigation sichtbar weggeschoben. */
@media (max-width: 1023.98px) {
  .sidenav { transition: transform .22s ease, visibility .22s ease; }
}
.sidenav.is-open { transform: translateX(0); visibility: visible; }

.nav-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(20, 21, 24, .48);
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
.nav-overlay.is-open { opacity: 1; pointer-events: auto; }

.nav-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--vif-space-3);
}
.nav-link {
  display: flex; align-items: center; gap: var(--vif-space-3);
  min-height: 46px; padding: 0 var(--vif-space-3);
  border-radius: var(--vif-radius-sm);
  color: var(--vif-text-body); text-decoration: none;
  font-size: var(--fs-sm); font-weight: 600;
  background: transparent; border: none; width: 100%;
  cursor: pointer; text-align: left; font-family: inherit;
}
.nav-link:hover { background: var(--vif-bg-subtle); color: var(--vif-text-primary); }
.nav-link[aria-current="page"] {
  background: var(--vif-accent-tint);
  color: var(--vif-accent-text);
  font-weight: 800;
}
.nav-link .ico { flex: 0 0 auto; }
.nav-badge {
  margin-left: auto; font-size: var(--fs-xs); font-weight: 800;
  background: var(--vif-accent); color: var(--vif-text-on-accent);
  border-radius: var(--vif-radius-pill); padding: 1px 8px;
}

.content {
  min-width: 0;
  padding: var(--vif-space-5) var(--vif-space-4) var(--vif-space-7);
  max-width: var(--vif-content-max);
  margin: 0 auto;
}

.app-footer {
  border-top: 1px solid var(--vif-border-hair);
  padding: var(--vif-space-5) var(--vif-space-4);
  padding-bottom: calc(var(--vif-space-5) + env(safe-area-inset-bottom, 0px));
  font-size: var(--fs-sm);
  color: var(--vif-text-secondary);
}
.app-footer .inner { max-width: var(--vif-content-max); margin: 0 auto; }

/* Rechtliches und Social sind zwei getrennte Gruppen. Auf schmalen Displays
   stehen sie untereinander, ab 600 px nebeneinander. */
.footer-cols {
  display: flex; flex-wrap: wrap;
  gap: var(--vif-space-5);
  margin-bottom: var(--vif-space-4);
}
.footer-group { min-width: 0; }
.footer-group-social { margin-left: auto; }
.footer-heading {
  display: block;
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--vif-text-tertiary);
  margin-bottom: var(--vif-space-2);
}

/* Vier Rechtslinks – auf schmalen Displays umbrechend, mit ausreichender
   Tippflaeche und ohne dass die Zeile gedraengt wirkt. */
.footer-links {
  display: flex; flex-wrap: wrap;
  gap: var(--vif-space-1) var(--vif-space-4);
}
.footer-links a {
  display: inline-flex; align-items: center;
  min-height: 32px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.footer-links a:hover,
.footer-links a:focus-visible { border-bottom-color: currentColor; }

/* Social-Buttons in der Vater-in-Form-Farbwelt – bewusst KEINE Instagram-
   oder TikTok-Markenfarben, damit die Fusszeile ruhig bleibt. */
.social-row { display: flex; flex-wrap: wrap; gap: var(--vif-space-2); }
.social-chip {
  display: inline-flex; align-items: center; gap: var(--vif-space-2);
  min-height: 44px; padding: 0 var(--vif-space-4);
  border: 1px solid var(--vif-border-soft);
  border-radius: var(--vif-radius-pill);
  background: var(--vif-bg-card);
  color: var(--vif-text-primary);
  font-size: var(--fs-sm); font-weight: 600;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease;
}
.social-chip .ico { color: var(--vif-accent-text); }
.social-chip:hover {
  background: var(--vif-bg-subtle);
  border-color: var(--vif-border-strong);
}
.social-chip:focus-visible {
  outline: 3px solid var(--vif-accent);
  outline-offset: 2px;
}

.footer-meta { font-size: var(--fs-xs); color: var(--vif-text-secondary); }

/* Unter 600 px stehen die Gruppen untereinander und der automatische
   Links-Abstand der Social-Gruppe wuerde sie sonst nach rechts schieben. */
@media (max-width: 599.98px) {
  .footer-cols { gap: var(--vif-space-4); }
  .footer-group-social { margin-left: 0; }
  .footer-group { flex: 1 1 100%; }
}

/* --------------------------------------------------------------------------
   5. ABSCHNITTSKOPF (Eyebrow-Hierarchie wie im Trainingsguide)
   ------------------------------------------------------------------------ */

.section-head { margin-bottom: var(--vif-space-5); }
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--vif-space-2);
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .16em;
  text-transform: uppercase; color: var(--vif-accent-text);
  margin-bottom: var(--vif-space-2);
}
.rule {
  width: 48px; height: 3px; background: var(--vif-accent);
  border-radius: 2px; margin: var(--vif-space-3) 0 0;
}
.section-intro {
  color: var(--vif-text-body); max-width: 62ch; margin-top: var(--vif-space-3);
}

/* --------------------------------------------------------------------------
   6. KARTEN
   ------------------------------------------------------------------------ */

.card {
  background: var(--vif-bg-card);
  border: 1px solid var(--vif-border-soft);
  border-radius: var(--vif-radius);
  padding: var(--vif-space-4);
  box-shadow: var(--vif-shadow-sm);
}
.card + .card { margin-top: var(--vif-space-4); }
.card > h3 { margin-bottom: var(--vif-space-2); }
.card-sub { font-size: var(--fs-sm); color: var(--vif-text-secondary); margin: 0; }

/* Fokuskarte – genau eine pro Ansicht. */
.card-focus {
  background: var(--vif-bg-card);
  border: 1px solid var(--vif-accent-border);
  border-left: 4px solid var(--vif-accent);
  border-radius: var(--vif-radius-lg);
  padding: var(--vif-space-5);
  box-shadow: var(--vif-shadow-md);
}
.card-focus h2 { font-size: var(--fs-lg); margin-bottom: var(--vif-space-1); }

/* Persoenliche Begruessung auf der Uebersicht. Bewusst als Absatz und nicht
   als Ueberschrift: Die Ueberschriftenreihenfolge der Seite bleibt dadurch
   unveraendert. Sie steht genau einmal pro Ansicht ganz oben. */
.greeting {
  font-size: var(--fs-md);
  line-height: 1.35;
  color: var(--vif-text-primary);
  margin: 0 0 var(--vif-space-4);
}
.greeting strong { font-weight: 800; }
.greeting .greeting-sub {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--vif-text-body);
  margin-top: 2px;
}

/* Ruhige Sekundaerkarte fuer Zahlen. */
.card-quiet {
  background: var(--vif-bg-sand);
  border: 1px solid var(--vif-border-warm);
  border-radius: var(--vif-radius);
  padding: var(--vif-space-4);
  box-shadow: none;
}
.card-dark {
  background: var(--vif-bg-inverse);
  color: var(--vif-text-on-dark);
  border: none; border-radius: var(--vif-radius);
  padding: var(--vif-space-4);
}
.card-dark h3, .card-dark h2 { color: var(--vif-text-on-dark); }
.card-dark .card-sub { color: var(--vif-text-on-dark-soft); }

.stat-grid {
  display: grid; gap: var(--vif-space-3);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat {
  background: var(--vif-bg-card);
  border: 1px solid var(--vif-border-soft);
  border-radius: var(--vif-radius);
  padding: var(--vif-space-3) var(--vif-space-4);
}
.stat-label {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--vif-text-secondary);
  margin: 0 0 2px;
}
.stat-value {
  font-size: var(--fs-xl); font-weight: 800; color: var(--vif-text-primary);
  line-height: 1.1; margin: 0;
}
.stat-hint { font-size: var(--fs-xs); color: var(--vif-text-secondary); margin: 2px 0 0; }

.grid-2 { display: grid; gap: var(--vif-space-4); grid-template-columns: 1fr; }

/* --------------------------------------------------------------------------
   7. BUTTONS
   ------------------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--vif-space-2);
  min-height: 44px; padding: 0 var(--vif-space-4);
  border-radius: var(--vif-radius-sm);
  border: 1px solid var(--vif-border-strong);
  background: var(--vif-bg-card); color: var(--vif-text-primary);
  font-family: inherit; font-size: var(--fs-sm); font-weight: 700;
  cursor: pointer; text-decoration: none;
  transition: background .14s ease, border-color .14s ease;
}
.btn:hover { background: var(--vif-bg-subtle); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--vif-accent); border-color: var(--vif-accent);
  color: var(--vif-text-on-accent);
}
.btn-primary:hover { background: var(--vif-accent-hover); border-color: var(--vif-accent-hover); }

.btn-lg { min-height: 52px; font-size: var(--fs-base); padding: 0 var(--vif-space-5); }

.btn-ghost {
  border-color: transparent; background: transparent;
  color: var(--vif-text-body); font-weight: 600;
}
.btn-ghost:hover { background: var(--vif-bg-subtle); color: var(--vif-text-primary); }

.btn-danger {
  border-color: var(--vif-danger); color: var(--vif-danger);
  background: var(--vif-bg-card);
}
.btn-danger:hover { background: var(--vif-danger-tint); }

.btn-row {
  display: flex; flex-wrap: wrap; gap: var(--vif-space-3);
  margin-top: var(--vif-space-4);
}
.btn-block { width: 100%; }

/* --------------------------------------------------------------------------
   8. FORMULARE
   ------------------------------------------------------------------------ */

fieldset { border: none; margin: 0; padding: 0; }
legend { padding: 0; font-weight: 800; color: var(--vif-text-primary); }

.form-group { margin-bottom: var(--vif-space-4); }
.form-group > label {
  display: block; font-weight: 700; font-size: var(--fs-sm);
  color: var(--vif-text-primary); margin-bottom: 5px;
}
.hint { font-size: var(--fs-sm); color: var(--vif-text-secondary); margin: 4px 0 6px; }

input[type="number"], input[type="text"], input[type="date"], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px;               /* verhindert das Zoomen auf iOS */
  color: var(--vif-text-primary);
  background: var(--vif-bg-card);
  border: 1px solid var(--vif-border-strong);
  border-radius: var(--vif-radius-sm);
}
textarea { min-height: 92px; resize: vertical; line-height: 1.5; }
input:disabled, select:disabled, textarea:disabled {
  background: var(--vif-bg-subtle); color: var(--vif-text-secondary); cursor: not-allowed;
}
input[aria-invalid="true"], select[aria-invalid="true"] {
  border-color: var(--vif-danger);
  background: var(--vif-danger-tint);
}

.field-error {
  display: block; font-size: var(--fs-sm); font-weight: 600;
  color: var(--vif-danger); margin-top: 4px;
}

.check-row { display: flex; flex-direction: column; gap: var(--vif-space-2); }
.check-item {
  display: flex; align-items: center; gap: var(--vif-space-3);
  min-height: 44px; padding: var(--vif-space-2) var(--vif-space-3);
  border: 1px solid var(--vif-border-soft);
  border-radius: var(--vif-radius-sm);
  background: var(--vif-bg-card);
  cursor: pointer;
}
.check-item:hover { background: var(--vif-bg-subtle); }
.check-item input { width: 22px; height: 22px; flex: 0 0 auto; accent-color: var(--vif-accent); margin: 0; }
.check-item label { flex: 1; cursor: pointer; font-size: var(--fs-sm); margin: 0; }
.check-item .sub { display: block; font-size: var(--fs-xs); color: var(--vif-text-secondary); font-weight: 400; }

/* 132 px, damit auch "Donnerstag" in eine Zeile passt und nicht mitten im
   Wort umbricht. */
.day-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: var(--vif-space-2); }
.day-grid .check-item label { white-space: nowrap; }

.segmented {
  display: inline-flex; border: 1px solid var(--vif-border-strong);
  border-radius: var(--vif-radius-pill); overflow: hidden; background: var(--vif-bg-card);
}
.segmented label {
  padding: 9px 18px; font-size: var(--fs-sm); font-weight: 700;
  cursor: pointer; color: var(--vif-text-body); min-height: 42px;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented input { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented input:checked + label { background: var(--vif-accent); color: var(--vif-text-on-accent); }
.segmented input:focus-visible + label { outline: 3px solid var(--vif-accent); outline-offset: -3px; }

/* --------------------------------------------------------------------------
   9. HINWEISE
   ------------------------------------------------------------------------ */

.callout {
  border: 1px solid var(--vif-border-soft);
  border-left: 3px solid var(--vif-border-strong);
  border-radius: var(--vif-radius-sm);
  padding: var(--vif-space-3) var(--vif-space-4);
  background: var(--vif-bg-card);
  font-size: var(--fs-sm);
  margin-bottom: var(--vif-space-4);
}
/* Hinweisboxen tragen eine echte Ueberschrift (h3), damit die Reihenfolge
   h2 -> h3 nicht springt. Optisch bleiben sie bewusst klein. */
.callout .callout-title,
.callout h3, .callout h4 {
  margin-bottom: 4px;
  font-size: var(--fs-sm);
  font-weight: 800;
  letter-spacing: 0;
  display: flex; align-items: flex-start; gap: 6px;
}
.callout-accent {
  border-color: var(--vif-accent-border);
  border-left-color: var(--vif-accent);
  background: var(--vif-accent-tint);
}
.callout-danger {
  border-color: var(--vif-danger);
  border-left-color: var(--vif-danger);
  background: var(--vif-danger-tint);
}
.callout-quiet { background: var(--vif-bg-sand); border-color: var(--vif-border-warm); border-left-color: var(--vif-border-warm); }

/* Auf getoenten Flaechen (Sand, Akzent-Tint) reicht der normale Sekundaerton
   nicht mehr fuer 4,5:1. Innerhalb dieser Container wird er deshalb eine Stufe
   kraeftiger gesetzt – ueber Tokens, damit kein einziger Hex-Wert im
   Komponenten-CSS landet. */
.card-quiet,
.callout-quiet,
.callout-accent,
.target-box,
.value-chain .vc.is-final,
.timer-card.is-done {
  --vif-text-secondary: var(--vif-text-body);
  --vif-text-tertiary: var(--vif-text-body);
}
html[data-theme="dark"] .card-quiet,
html[data-theme="dark"] .callout-quiet,
html[data-theme="dark"] .callout-accent,
html[data-theme="dark"] .target-box,
html[data-theme="dark"] .value-chain .vc.is-final,
html[data-theme="dark"] .timer-card.is-done {
  --vif-text-secondary: var(--vif-text-primary);
  --vif-text-tertiary: var(--vif-text-primary);
}

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-xs); font-weight: 700;
  padding: 3px 10px; border-radius: var(--vif-radius-pill);
  background: var(--vif-bg-subtle); color: var(--vif-text-body);
  border: 1px solid var(--vif-border-soft);
}
.badge-ok { background: var(--vif-ok-tint); color: var(--vif-ok); border-color: transparent; }
.badge-accent { background: var(--vif-accent-tint); color: var(--vif-accent-text); border-color: transparent; }

.empty-state {
  text-align: center;
  padding: var(--vif-space-6) var(--vif-space-4);
  border: 1px dashed var(--vif-border-strong);
  border-radius: var(--vif-radius);
  background: var(--vif-bg-card);
  color: var(--vif-text-body);
}
.empty-state .ico { color: var(--vif-text-secondary); margin-bottom: var(--vif-space-2); }
.empty-state h3 { margin-bottom: 4px; }
.empty-state p { margin-bottom: var(--vif-space-4); font-size: var(--fs-sm); }

/* --------------------------------------------------------------------------
   10. FORTSCHRITTSBALKEN
   ------------------------------------------------------------------------ */

.progress {
  height: 8px; border-radius: var(--vif-radius-pill);
  background: var(--vif-bg-subtle); overflow: hidden;
  border: 1px solid var(--vif-border-hair);
}
.progress > span { display: block; height: 100%; background: var(--vif-accent); }
.progress-label {
  display: flex; justify-content: space-between; gap: var(--vif-space-3);
  font-size: var(--fs-xs); color: var(--vif-text-secondary); margin-top: 5px;
}

/* --------------------------------------------------------------------------
   11. ÜBUNGSKARTEN
   ------------------------------------------------------------------------ */

.exercise-list { display: grid; gap: var(--vif-space-4); grid-template-columns: 1fr; }

.exercise-card {
  background: var(--vif-bg-card);
  border: 1px solid var(--vif-border-soft);
  border-radius: var(--vif-radius);
  padding: var(--vif-space-4);
  box-shadow: var(--vif-shadow-sm);
}
.exercise-card.is-skipped { background: var(--vif-bg-subtle); }
.exercise-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--vif-space-3); margin-bottom: var(--vif-space-3);
}
.exercise-title { margin: 0; font-size: var(--fs-md); font-weight: 800; }
.exercise-variant { font-size: var(--fs-sm); color: var(--vif-text-secondary); margin: 2px 0 0; }
.exercise-area {
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; color: var(--vif-accent-text);
}

/* Der heutige Zielwert ist die wichtigste Zahl der Trainingsansicht. */
.target-box {
  background: var(--vif-bg-sand);
  border: 1px solid var(--vif-border-warm);
  border-radius: var(--vif-radius-sm);
  padding: var(--vif-space-3);
  margin-bottom: var(--vif-space-3);
  display: flex; align-items: baseline; gap: var(--vif-space-3); flex-wrap: wrap;
}
.target-label {
  font-size: var(--fs-xs); font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--vif-text-secondary);
}
.target-value { font-size: var(--fs-xl); font-weight: 800; color: var(--vif-text-primary); }
.target-note { font-size: var(--fs-sm); color: var(--vif-text-body); width: 100%; margin: 0; }

/* Kette Test → Arbeitswert → Zielwert */
.value-chain {
  display: flex; flex-wrap: wrap; gap: var(--vif-space-2); align-items: stretch;
  margin: var(--vif-space-3) 0;
}
.value-chain .vc {
  flex: 1 1 118px; min-width: 0;
  background: var(--vif-bg-card); border: 1px solid var(--vif-border-soft);
  border-radius: var(--vif-radius-sm); padding: var(--vif-space-2) var(--vif-space-3);
}
.value-chain .vc.is-final { border-color: var(--vif-accent-border); background: var(--vif-accent-tint); }
.value-chain .vc-label {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--vif-text-secondary); margin: 0;
}
.value-chain .vc-value {
  font-size: var(--fs-lg); font-weight: 800; color: var(--vif-text-primary); margin: 0; line-height: 1.2;
}

.set-grid { display: grid; gap: var(--vif-space-3); grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.set-field label {
  display: block; font-size: var(--fs-xs); font-weight: 700;
  color: var(--vif-text-secondary); margin-bottom: 3px;
  white-space: normal;      /* "Satz 1 links" darf umbrechen, nie abschneiden */
}

.cue {
  font-size: var(--fs-sm); color: var(--vif-text-body);
  border-left: 2px solid var(--vif-border-warm);
  padding-left: var(--vif-space-3); margin: var(--vif-space-3) 0 0;
}
.requirement {
  font-size: var(--fs-sm); color: var(--vif-accent-text); font-weight: 600;
  margin-top: var(--vif-space-2);
}

/* --------------------------------------------------------------------------
   12. TABELLEN
   ------------------------------------------------------------------------ */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td {
  text-align: left; padding: 10px var(--vif-space-3);
  border-bottom: 1px solid var(--vif-border-hair);
  vertical-align: top;
  white-space: normal;
}
th { font-weight: 800; color: var(--vif-text-primary); font-size: var(--fs-xs);
     text-transform: uppercase; letter-spacing: .06em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* Auf schmalen Displays werden Tabellen zu Karten. */
.table-cards tbody tr {
  display: block; border: 1px solid var(--vif-border-soft);
  border-radius: var(--vif-radius-sm); padding: var(--vif-space-3);
  margin-bottom: var(--vif-space-3); background: var(--vif-bg-card);
}
.table-cards thead { display: none; }
.table-cards td {
  display: flex; justify-content: space-between; gap: var(--vif-space-3);
  border: none; padding: 3px 0; text-align: right;
}
.table-cards td::before {
  content: attr(data-label);
  font-weight: 700; color: var(--vif-text-secondary);
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em;
  text-align: left; flex: 0 0 auto;
}

/* --------------------------------------------------------------------------
   13. TAGEBUCH
   ------------------------------------------------------------------------ */

.journal-item {
  border: 1px solid var(--vif-border-soft); border-radius: var(--vif-radius);
  background: var(--vif-bg-card); margin-bottom: var(--vif-space-3);
  overflow: hidden;
}
.journal-head {
  display: flex; align-items: center; gap: var(--vif-space-3);
  padding: var(--vif-space-3) var(--vif-space-4); flex-wrap: wrap;
}
.journal-title { font-weight: 800; color: var(--vif-text-primary); font-size: var(--fs-sm); }
.journal-meta { font-size: var(--fs-xs); color: var(--vif-text-secondary); }
.journal-actions { margin-left: auto; display: flex; gap: var(--vif-space-2); }
.journal-detail {
  padding: 0 var(--vif-space-4) var(--vif-space-4);
  border-top: 1px solid var(--vif-border-hair);
  white-space: normal;
}

/* --------------------------------------------------------------------------
   14. TIMER
   ------------------------------------------------------------------------ */

.timer-grid { display: grid; gap: var(--vif-space-3); grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.timer-card {
  border: 1px solid var(--vif-border-soft); border-radius: var(--vif-radius);
  padding: var(--vif-space-4); background: var(--vif-bg-card); text-align: center;
}
.timer-display {
  font-size: var(--fs-2xl); font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--vif-text-primary); line-height: 1.1; margin: var(--vif-space-2) 0;
}
.timer-card.is-done { border-color: var(--vif-accent); background: var(--vif-accent-tint); }
.timer-card.is-done .timer-display { color: var(--vif-accent-text); }
.timer-actions { display: flex; gap: var(--vif-space-2); justify-content: center; }

/* --------------------------------------------------------------------------
   15. TOASTS
   ------------------------------------------------------------------------ */

.toast-container {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--vif-space-4) + env(safe-area-inset-bottom, 0px));
  z-index: 300; display: flex; flex-direction: column; gap: var(--vif-space-2);
  width: min(460px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--vif-bg-inverse); color: var(--vif-text-on-dark);
  border-radius: var(--vif-radius); padding: var(--vif-space-3) var(--vif-space-4);
  box-shadow: var(--vif-shadow-lg); font-size: var(--fs-sm); font-weight: 600;
  display: flex; align-items: flex-start; gap: var(--vif-space-3);
}
html[data-theme="dark"] .toast { background: var(--vif-bg-card); border: 1px solid var(--vif-border-soft); }
.toast .ico { flex: 0 0 auto; margin-top: 1px; }
.toast-ok .ico { color: var(--vif-ok); }
.toast-error { background: var(--vif-danger); color: #fff; }
.toast-error .ico { color: #fff; }

/* --------------------------------------------------------------------------
   16. DIAGRAMME
   ------------------------------------------------------------------------ */

.chart-box { width: 100%; overflow: hidden; }
.chart-box canvas { width: 100%; height: auto; display: block; }

/* --------------------------------------------------------------------------
   17. ZYKLUSVERLAUF
   ------------------------------------------------------------------------ */

.cycle-item {
  border: 1px solid var(--vif-border-soft); border-radius: var(--vif-radius);
  padding: var(--vif-space-4); background: var(--vif-bg-card);
  margin-bottom: var(--vif-space-3);
}
.cycle-item.is-active { border-color: var(--vif-accent-border); border-left: 4px solid var(--vif-accent); }
.cycle-head { display: flex; align-items: center; gap: var(--vif-space-3); flex-wrap: wrap; margin-bottom: var(--vif-space-2); }

/* --------------------------------------------------------------------------
   18. ICONS
   ------------------------------------------------------------------------ */

.ico {
  display: inline-block; width: 20px; height: 20px;
  stroke: currentColor; fill: none;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  vertical-align: -4px; flex: 0 0 auto;
}
.ico-sm { width: 16px; height: 16px; vertical-align: -3px; }
.ico-lg { width: 28px; height: 28px; vertical-align: -6px; }

/* --------------------------------------------------------------------------
   19. BREITERE BILDSCHIRME
   ------------------------------------------------------------------------ */

@media (min-width: 560px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .check-row.cols-2 { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (min-width: 768px) {
  .content { padding: var(--vif-space-6) var(--vif-space-5) var(--vif-space-7); }
  h1 { font-size: var(--fs-3xl); }
  .exercise-list { grid-template-columns: 1fr; }
  /* Ab hier lohnt sich der Kartenmodus fuer Tabellen nicht mehr. */
  .table-cards tbody tr { display: table-row; border: none; padding: 0; margin: 0; background: none; }
  .table-cards thead { display: table-header-group; }
  .table-cards td {
    display: table-cell; text-align: left; padding: 10px var(--vif-space-3);
    border-bottom: 1px solid var(--vif-border-hair);
  }
  .table-cards td::before { content: none; }
  .table-cards td.num { text-align: right; }
}

@media (min-width: 1024px) {
  /* Die Seitennavigation ist fest sichtbar und darf weder Kopf noch Fuss
     ueberdecken – der Inhalt wird eingerueckt, nicht ueberlagert. */
  .nav-toggle { display: none; }
  .sidenav {
    transform: none; visibility: visible;
    width: var(--vif-sidenav-width);
    top: 0; bottom: 0;
    padding-top: var(--vif-space-4);
  }
  .nav-overlay { display: none; }
  .topbar,
  .content,
  .app-footer { padding-left: calc(var(--vif-sidenav-width) + var(--vif-space-5)); }
  /* Kopfzeile, Inhalt und Fusszeile stehen auf derselben linken Kante –
     sonst wirkt der Inhalt gegenueber der Marke verschoben. */
  .content {
    max-width: calc(var(--vif-content-max) + var(--vif-sidenav-width) + var(--vif-space-5));
    margin: 0;
  }
  .app-footer .inner { max-width: var(--vif-content-max); margin: 0; }
  .nav-head .nav-close { display: none; }
  .exercise-list { grid-template-columns: 1fr 1fr; }
  .exercise-list.single-col { grid-template-columns: 1fr; }
}

@media (min-width: 1440px) {
  .content { padding-right: var(--vif-space-6); }
}

/* --------------------------------------------------------------------------
   20. BEWEGUNG UND DRUCK
   ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  :root {
    --vif-bg-page: #fff; --vif-bg-card: #fff; --vif-bg-sand: #fff;
    --vif-text-primary: #000; --vif-text-body: #222; --vif-text-secondary: #444;
  }
  html, body { background: #fff !important; color: #000 !important; }
  .topbar, .sidenav, .nav-overlay, .app-footer,
  .btn, .btn-row, .timer-grid, .toast-container, .skip-link { display: none !important; }
  .content { padding: 0 !important; max-width: none !important; }
  .card, .card-focus, .card-quiet, .exercise-card, .journal-item, .cycle-item {
    border: 1px solid #bbb !important; box-shadow: none !important;
    page-break-inside: avoid; background: #fff !important;
  }
  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; }
}
