/* ============================================================
   fitness tracker — style.css
   Mobile-first, dunkles UI, Grün-Akzent. Bewusst System-Fonts:
   im Gym zählt Ladezeit, kein Font-CDN.
   ============================================================ */

:root {
  --bg:      #0B0E12;
  --surface: #141922;
  --raised:  #1B222E;
  --hover:   #242E3C;
  --line:    #263140;

  --text:  #ECF1F8;
  --muted: #8D99AB;
  --faint: #5B6678;

  --accent:      #3DDC84;
  --accent-dim:  #2FA866;
  --accent-soft: rgba(61, 220, 132, .12);
  --danger:      #F0606B;
  --warn:        #E6A256;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 20px -6px rgba(0,0,0,.45);

  --tabbar-h: 62px;
  --timerbar-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 16px; /* nie unter 16px auf Mobile → verhindert iOS-Zoom bei Inputs */
  -webkit-font-smoothing: antialiased;
  color-scheme: dark;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea {
  font: inherit; color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent-dim); }
input::placeholder, textarea::placeholder { color: var(--faint); }

/* ============ Layout ============ */
#view {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + var(--timerbar-h) + 32px);
}

.pagehead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 6px 0 18px;
}
.pagehead h1 { font-size: 26px; letter-spacing: -.02em; }
.greet { color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.backlink { color: var(--muted); font-size: 13px; display: inline-block; margin-bottom: 4px; }

.section-label {
  color: var(--muted); font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; margin: 22px 0 10px; font-weight: 600;
}
.group-label {
  color: var(--faint); font-size: 12px; text-transform: uppercase;
  letter-spacing: .08em; margin: 16px 0 6px; font-weight: 600;
}

/* ============ Karten & Zeilen ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  width: 100%;
  text-align: left;
}
.card-title { font-weight: 650; font-size: 16px; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.grow { flex: 1; min-width: 0; }
.dim { color: var(--muted); }

.row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 8px;
  color: var(--text);
  width: 100%;
  text-align: left;
}
.row:active { background: var(--hover); }
.row-title { font-weight: 600; font-size: 15px; }
.row-sub { color: var(--muted); font-size: 12.5px; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--faint); font-size: 20px; }
.maxw { color: var(--accent); font-weight: 700; font-size: 14px; white-space: nowrap; }

.empty { color: var(--muted); text-align: center; padding: 28px 12px; }
.empty.small { padding: 14px; font-size: 13px; }
.hint {
  background: var(--accent-soft); border: 1px solid transparent;
  border-radius: var(--radius); padding: 12px 14px;
  color: var(--muted); font-size: 13.5px; margin-bottom: 12px;
}
.hint a { font-weight: 600; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 16px; font-weight: 600; font-size: 15px;
  min-height: 44px; /* Touch-Target */
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06281A; }
.btn.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn.big { width: 100%; margin: 10px 0; }
.btn.mini { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.danger, .btn.danger-outline { color: var(--danger); }
.btn.danger-outline { border-color: rgba(240,96,107,.4); background: transparent; }

.iconbtn {
  min-width: 40px; min-height: 40px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 16px;
  background: var(--raised); border: 1px solid var(--line);
}
.iconbtn:disabled { opacity: .3; }
.minilink { font-size: 13px; color: var(--accent); padding: 4px 8px; white-space: nowrap; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--uc, var(--accent)); color: #0B0E12;
  font-weight: 800; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}

/* ============ Login ============ */
.login { padding-top: 8dvh; text-align: center; }
.login-logo { font-size: 54px; }
.login-title { font-size: 30px; margin: 8px 0 2px; }
.login-sub { color: var(--muted); margin-bottom: 26px; }
.login-users { display: flex; flex-direction: column; gap: 10px; }
.login-user {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  color: var(--text); font-size: 17px; font-weight: 600;
}
.login-user.sel { border-color: var(--accent); background: var(--accent-soft); }
.login-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--uc); color: #0B0E12;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
}
.badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  padding: 4px 8px; border-radius: 999px;
}
.login-form { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; }
.login-form-user { color: var(--muted); font-size: 13.5px; }
.login-err { color: var(--danger); font-size: 14px; min-height: 18px; }

/* ============ Home ============ */
.day-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.day-card { margin-bottom: 0; min-height: 84px; }
.day-card:active { background: var(--hover); }
.day-card.free { border-style: dashed; }
.day-card.free .card-title { color: var(--muted); }

.active-session {
  display: flex; align-items: center; gap: 14px;
  border-color: var(--accent-dim); background: var(--accent-soft);
}
.pulse {
  width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite; flex-shrink: 0;
}
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }

/* ============ Live-Session ============ */
.excard { padding: 14px 14px 12px; }
.excard.done { border-color: var(--accent-dim); }
.excard-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.setcount {
  background: var(--raised); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 11px;
  font-weight: 700; font-size: 13px; color: var(--muted); white-space: nowrap;
}
.excard.done .setcount { color: var(--accent); border-color: var(--accent-dim); }

.lastline {
  font-size: 13.5px; color: var(--muted);
  background: var(--raised); border-radius: var(--radius-sm);
  padding: 8px 11px; margin-bottom: 10px;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline;
}
.lastline b { color: var(--text); }
.lastline.none { color: var(--faint); }
.lastlabel { font-size: 12px; }
.lastall { color: var(--faint); font-size: 12px; }

.setlist { margin-bottom: 10px; display: flex; flex-direction: column; gap: 5px; }
.setrow { display: flex; align-items: center; gap: 10px; padding: 3px 2px; }
.setnr {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.setval { flex: 1; font-size: 15px; color: var(--muted); }
.setval b { color: var(--text); }
.rpe { color: var(--warn); font-size: 12.5px; }
.del-set { min-width: 34px; min-height: 34px; font-size: 13px; border: none; background: transparent; color: var(--faint); }

.setentry { display: flex; gap: 8px; align-items: stretch; }
.stepper {
  flex: 1; display: flex; align-items: stretch;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: var(--radius-sm); overflow: hidden;
}
.step {
  width: 42px; font-size: 20px; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.step:active { background: var(--hover); color: var(--accent); }
.stepval { flex: 1; position: relative; min-width: 0; }
.stepval input {
  border: none; background: transparent; border-radius: 0;
  text-align: center; font-weight: 700; font-size: 17px;
  padding: 10px 2px 20px; height: 100%;
}
.steplabel {
  position: absolute; bottom: 4px; left: 0; right: 0;
  text-align: center; font-size: 10px; color: var(--faint);
  text-transform: uppercase; letter-spacing: .06em; pointer-events: none;
}
.logbtn { width: 58px; font-size: 20px; flex-shrink: 0; }

.field { margin-top: 16px; }
.field label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }

/* ============ Pläne ============ */
.planex { display: flex; align-items: center; gap: 10px; }
.planex-btns { display: flex; gap: 6px; flex-shrink: 0; }
.planex .card-sub { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.ziel { width: 74px; padding: 7px 8px; font-size: 13.5px; text-align: center; }
.ziel.zr { width: 110px; }

/* ============ History ============ */
.seg {
  display: flex; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 4px; gap: 4px; margin-bottom: 14px;
}
.seg-btn {
  flex: 1; padding: 9px 6px; border-radius: 7px;
  color: var(--muted); font-weight: 600; font-size: 14px;
}
.seg-btn.active { background: var(--raised); color: var(--text); }

.chart-card { padding: 12px 8px 8px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--faint); font-size: 11px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart .area { fill: var(--accent); opacity: .08; }
.chart .dot { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.chart .dotlabel { fill: var(--muted); font-size: 10.5px; }
.chart-label { text-align: center; color: var(--faint); font-size: 12px; padding: 4px 0 6px; }

.hxrow-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.hxsets { display: flex; flex-wrap: wrap; gap: 6px; }
.settag {
  background: var(--raised); border: 1px solid var(--line);
  border-radius: 8px; padding: 4px 9px; font-size: 13.5px; font-weight: 600;
}
.settag i { color: var(--warn); font-style: normal; font-size: 11.5px; }

.searchbar { margin-bottom: 6px; }

/* ============ Einkaufsliste ============ */
.shopadd { display: flex; gap: 8px; margin-bottom: 6px; }
.shopadd #shopText { flex: 1.6; min-width: 0; }
.shopadd #shopLaden { flex: 1; min-width: 0; }
.shopadd .btn { width: 52px; font-size: 20px; flex-shrink: 0; }

.shoprow { padding: 10px 12px; }
.shoprow.done .row-title { text-decoration: line-through; color: var(--faint); }
.check {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--raised);
  color: #06281A; font-weight: 800; font-size: 16px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.check.on { background: var(--accent); border-color: var(--accent); }
.shoptext { cursor: pointer; }
.shopdel { min-width: 34px; min-height: 34px; border: none; background: transparent; color: var(--faint); }
.whodot {
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0;
  background: var(--uc, var(--accent)); color: #0B0E12;
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.doneline { display: flex; align-items: center; justify-content: space-between; margin-top: 26px; }

/* ============ Profil ============ */
.switchrow {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 10px; font-size: 14.5px; color: var(--muted);
}
.switchrow input { width: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
.restlist { margin-top: 12px; border-top: 1px solid var(--line); }
.restrow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 0; font-size: 14px; border-bottom: 1px solid var(--line);
}
.restrow:last-child { border-bottom: 0; }
.restrow span { color: var(--muted); }
.restrow b { color: var(--text); font-variant-numeric: tabular-nums; }
.restrow.muted span, .restrow.muted b { color: var(--faint); }
.pwform { display: flex; gap: 8px; margin-top: 10px; }
.version { text-align: center; color: var(--faint); font-size: 12px; margin-top: 18px; }

/* ============ Modal / Sheet ============ */
#modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.6); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 560px; max-height: 82dvh;
  display: flex; flex-direction: column;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  animation: sheetup .22s ease;
}
@keyframes sheetup { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; gap: 8px; margin-bottom: 10px; }
.sheet-body { overflow-y: auto; flex: 1; }

/* ============ Timer-Leiste ============ */
#timerbar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  z-index: 40;
  background: var(--raised);
  border-top: 1px solid var(--line);
  overflow: hidden;
}
.timer-progress {
  position: absolute; inset: 0;
  background: var(--accent-soft);
  transform-origin: left;
  transition: transform .25s linear;
}
.timer-inner {
  position: relative;
  max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 16px; min-height: var(--timerbar-h);
}
.timer-inner.presets { justify-content: flex-start; flex-wrap: wrap; }
.timer-label { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.timer-clock {
  font-variant-numeric: tabular-nums;
  font-weight: 800; font-size: 26px; letter-spacing: .02em;
}
.timer-clock.soon { color: var(--warn); }
.timer-clock.over { color: var(--accent); animation: blink .5s step-end infinite alternate; }
@keyframes blink { 50% { opacity: .4; } }
.timer-btns { display: flex; gap: 6px; }

/* ============ Tab-Bar ============ */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs {
  max-width: 560px; margin: 0 auto;
  display: flex; height: var(--tabbar-h);
}
.tab {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  color: var(--faint); font-size: 11px; font-weight: 600;
}
.tab .ico { font-size: 21px; }
.tab.active { color: var(--accent); }

/* ============ Toast ============ */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--timerbar-h) + 24px);
  transform: translate(-50%, 16px); z-index: 60;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 20px;
  font-size: 14.5px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: all .25s ease;
  box-shadow: var(--shadow);
  max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { color: var(--danger); border-color: rgba(240,96,107,.4); }

/* ============ Desktop-Feinschliff ============ */
@media (min-width: 700px) {
  #view { padding-top: 28px; }
  .day-grid { grid-template-columns: 1fr 1fr 1fr; }
  #modal { align-items: center; }
  .sheet { border-radius: 20px; max-height: 70vh; }
}
