/* VM Javis – gemeinsames Dark-Mode-Fundament für alle Seiten.
   Jeder Bereich (Fitness/Finanzen) überschreibt --accent für seinen
   eigenen Akzent-Look, der Rest (Flächen, Text, Abstände) bleibt gleich,
   damit sich die App trotzdem wie ein Stück anfühlt. */

:root {
  --bg: #0b0b0d;
  --surface: #19191d;
  --surface-2: #232328;
  --border: #2c2c32;
  --text: #f2f2f4;
  --text-muted: #98989f;
  --text-faint: #6b6b72;
  --danger: #ff5c5c;
  --success: #34d399;
  --radius: 16px;
  --radius-sm: 10px;

  /* Standard-Akzent (Hub/Login): schwarz/weiß wie das App-Icon */
  --accent: #f2f2f4;
  --accent-text: #0b0b0d;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 640px;
  margin: 0 auto;
  /* unten Platz für die feste Tab-Leiste + Home-Indikator (viewport-fit=cover) */
  padding: max(28px, env(safe-area-inset-top, 0px)) 16px calc(92px + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
}

/* Tippen ohne Zoom-Verzögerung und ohne graues Aufblitzen (iOS). */
a, button, summary, label, .tile, .tab, .day-btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; }

a.back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 12px;
  padding: 10px 0;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
}
a.back:hover { color: var(--text); }

a.logout {
  float: right;
  padding: 10px 0 10px 12px;
  font-size: 0.8rem;
  color: var(--text-faint);
  text-decoration: none;
}
a.logout:hover { color: var(--text); }

/* Feste Tab-Leiste unten (Daumenzone), gebaut von nav.js */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: center;
  background: rgba(11, 11, 13, 0.92);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar-inner { display: flex; width: 100%; max-width: 640px; }
.tab {
  flex: 1; min-height: 58px; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--text-faint); font-size: 0.66rem; letter-spacing: 0.01em;
}
.tab .tab-icon { font-size: 1.3rem; line-height: 1; filter: grayscale(1) opacity(0.55); }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] .tab-icon { filter: none; }
.tab-add .tab-icon {
  width: 46px; height: 46px; margin: -12px 0; position: relative; top: -14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: #34d399; color: #06281c; font-size: 1.7rem; font-weight: 700; filter: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
}
.tab-add { color: var(--text-muted); }

h1 { font-size: 1.5rem; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin: 30px 0 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.8rem; }
p.sub, p.hint { color: var(--text-muted); font-size: 0.9rem; margin-top: 0; line-height: 1.4; }

/* Kachel-Navigation: Hub-Seiten (index/fitness/finanzen) bestehen nur
   daraus, keine Sonderfälle nötig pro Ebene. */
.tiles { display: grid; gap: 12px; margin-top: 8px; }
.tile {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.tile:hover { border-color: var(--accent); background: var(--surface-2); }
.tile:active { transform: scale(0.99); }
.tile .icon {
  font-size: 1.6rem; line-height: 1; width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border-radius: 12px; flex-shrink: 0;
}
.tile .title { font-weight: 600; font-size: 1.05rem; }
.tile .desc { color: var(--text-muted); font-size: 0.85rem; margin-top: 2px; }
.tile .chevron { margin-left: auto; color: var(--text-faint); font-size: 1.2rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

label { display: block; margin-top: 12px; font-size: 0.85rem; color: var(--text-muted); }

input[type=text], input[type=number], input[type=date], input[type=password], select, input[type=file] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 4px;
  width: 100%;
  max-width: 260px;
  min-height: 44px;
  font-size: 1rem; /* 16px: kleiner zoomt iOS beim Antippen automatisch ins Feld */
}
input::placeholder { color: var(--text-faint); }
input[type=file] { padding: 8px; }

button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  min-height: 44px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 14px;
}
button:hover { opacity: 0.88; }
button:active { opacity: 0.75; }
button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
button.delete {
  background: transparent;
  color: var(--text-faint);
  border: none;
  padding: 4px 10px;
  min-width: 44px;
  font-weight: 400;
  margin-top: 0;
  font-size: 0.9rem;
}
button.delete:hover { color: var(--danger); opacity: 1; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
th { color: var(--text-faint); font-weight: 600; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }

#status, .status-text { margin-top: 10px; font-size: 0.85rem; color: var(--text-muted); }

details { margin-top: 14px; font-size: 0.9rem; color: var(--text-muted); }
details summary { cursor: pointer; }
details input { max-width: 140px; }

progress {
  width: 100%; height: 8px; -webkit-appearance: none; appearance: none;
  border-radius: 999px; overflow: hidden; border: none; background: var(--surface-2);
}
progress::-webkit-progress-bar { background: var(--surface-2); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--bar-color, var(--accent)); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--bar-color, var(--accent)); border-radius: 999px; }

/* ---- Tab-Leiste: ＋ ist ein Button (öffnet das Hinzufügen-Fenster), kein Link ---- */
button.tab {
  background: none; border: none; border-radius: 0; margin: 0; padding: 6px 2px;
  font: inherit; font-size: 0.66rem; font-weight: 400; cursor: pointer; min-height: 58px;
}
button.tab.tab-add { color: var(--text-muted); }

/* ---- Bottom Sheet: Mahlzeit hinzufügen ---- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, 0.6);
  opacity: 0; transition: opacity .2s ease;
}
body.sheet-open .sheet-backdrop { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  max-width: 640px; margin: 0 auto; max-height: 88vh; max-height: 88dvh;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-bottom: none;
  border-radius: 20px 20px 0 0;
  transform: translateY(100%); transition: transform .25s ease;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
body.sheet-open .sheet { transform: translateY(0); }
.sheet[hidden], .sheet-backdrop[hidden], .toast[hidden] { display: none; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 8px auto 2px; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 12px; }
.sheet-title { flex: 1; text-align: center; font-weight: 600; font-size: 1rem; }
.sheet-btn {
  background: none; color: var(--text-muted); margin: 0; padding: 0 10px; min-width: 64px;
  font-weight: 500; font-size: 0.95rem; border-radius: 10px;
}
.sheet-btn[hidden] { display: block; visibility: hidden; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.sheet-body section { display: flex; flex-direction: column; gap: 10px; }
.sheet-body section[hidden] { display: none; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 96px; margin: 0; padding: 12px; border-radius: 16px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 600;
}
.choice span { font-size: 1.8rem; line-height: 1; }
.choice:active { border-color: #34d399; }
.sheet .field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.sheet .field-row label { flex: 1 1 100px; margin-top: 4px; }
.sheet .field-row input { max-width: none; }
.sheet .pick-row { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet .pick-row button, .sheet-actions button { margin-top: 0; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet button { align-self: flex-start; }
.sheet .choice, .sheet .sheet-btn { align-self: auto; }
.hint-small { font-size: 0.78rem; color: var(--text-faint); }
.meal-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.meal-item .info { flex: 1; }
.meal-item .name { font-weight: 600; font-size: 0.92rem; }
.meal-item .sub { color: var(--text-muted); font-size: 0.78rem; }
.meal-item button { margin-top: 0; padding: 7px 14px; }
.check-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.check-row input { width: auto; min-height: 0; margin: 0; max-width: none; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 120;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  background: #34d399; color: #06281c; font-weight: 600; font-size: 0.9rem;
  padding: 10px 18px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* Hinweis mit Aktions-Knopf (Rückgängig) */
.toast { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.toast button {
  margin: 0; min-height: 32px; padding: 4px 12px; font-size: 0.85rem; font-weight: 700;
  background: rgba(6, 40, 28, 0.14); color: #06281c; border-radius: 999px;
}

/* Ladegerüste (Skeletons): Platzhalter in der Form des echten Inhalts statt "Lade…" */
@keyframes skel-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel {
  border-radius: 8px; color: transparent !important; pointer-events: none; user-select: none;
  background: linear-gradient(90deg, var(--surface-2) 25%, #2c2c33 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: skel-shimmer 1.4s linear infinite;
}
.skel-card { height: 76px; border-radius: var(--radius); }

/* Sanfte Seitenübergänge zwischen den Seiten (Browser ohne Unterstützung ignorieren das einfach).
   Die Tab-Leiste bleibt beim Wechsel stehen, nur der Inhalt blendet über. */
@view-transition { navigation: auto; }
.tabbar { view-transition-name: tabbar; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.16s; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
  .skel { animation: none; }
  .sheet, .sheet-backdrop { transition: none; }
}
