/* ============================================
   ENERGIE – ME/CFS Pacing App
   Stylesheet v2.0
   ============================================ */

/* ── LOGIN OVERLAY ── */
#login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card);
  border-radius: 24px;
  padding: 40px 32px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
}
.login-icon  { font-size: 48px; margin-bottom: 8px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.login-sub   { color: var(--text2); font-size: 15px; margin: 0 0 28px; }
.login-input {
  width: 100%; box-sizing: border-box;
  padding: 14px 16px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--sep); background: var(--bg);
  color: var(--text); font-size: 17px;
  outline: none; margin-bottom: 12px;
}
.login-input:focus { border-color: var(--primary); }
.login-btn {
  width: 100%; padding: 14px;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 17px; font-weight: 600; cursor: pointer;
}
.login-btn:disabled { opacity: .6; }
.login-err { color: var(--red); font-size: 14px; margin-top: 10px; }

/* ── DESIGN TOKENS ── */
:root {
  --primary:   #6B8FF5;
  --green:     #34C759;
  --orange:    #FF9F0A;
  --red:       #FF3B30;
  --bg:        #F2F2F7;
  --card:      #FFFFFF;
  --text:      #1C1C1E;
  --text2:     #8E8E93;
  --text3:     #AEAEB2;
  --sep:       rgba(60,60,67,.12);
  --radius:    16px;
  --radius-sm: 10px;
  --nav-h:     56px;
  --safe-bot:  env(safe-area-inset-bottom, 0px);
  --safe-top:  env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:   #000000;
    --card: #1C1C1E;
    --text: #FFFFFF;
    --text2:#8E8E93;
    --text3:#636366;
    --sep:  rgba(84,84,88,.65);
  }
}

/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ── ONBOARDING ── */
#onboarding {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: calc(40px + var(--safe-top)) 32px calc(40px + var(--safe-bot));
  background: linear-gradient(160deg, #EEF3FF 0%, #F3EEFF 55%, #FFF8ED 100%);
}
.ob-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  max-width: 340px;
  width: 100%;
}
.ob-logo {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(107,143,245,.35));
}
.ob-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -.5px;
}
.ob-desc {
  font-size: 16px;
  color: var(--text2);
  line-height: 1.6;
}

/* ── APP LAYOUT ── */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
#app.hidden { display: none; }

.screens {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}
.screen.hidden { display: none; }

.screen-scroll {
  padding-bottom: calc(var(--nav-h) + var(--safe-bot) + 24px);
  padding-top: var(--safe-top);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── SCREEN HEADER ── */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 4px;
}
.screen-header h2 {
  font-size: 22px;
  font-weight: 700;
}
.greeting {
  font-size: 20px;
  font-weight: 700;
}
.date-str {
  font-size: 13px;
  color: var(--text2);
  margin-top: 2px;
}

/* ── BOTTOM NAV ── */
.bot-nav {
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--sep);
  height: calc(var(--nav-h) + var(--safe-bot));
  padding-bottom: var(--safe-bot);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--text2);
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn.active { color: var(--primary); }
.nav-ico { font-size: 22px; line-height: 1; }
.nav-lbl { font-size: 10px; font-weight: 500; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* ── BUTTONS ── */
.btn-primary {
  background: var(--primary);
  color: white;
  border-radius: 999px;
  padding: 16px 28px;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  display: block;
  width: 100%;
  transition: opacity .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { opacity: .82; transform: scale(.98); }
.btn-xl { padding: 18px 32px; font-size: 18px; font-weight: 700; }
.btn-full { width: 100%; }

.btn-secondary {
  background: var(--bg);
  color: var(--primary);
  border-radius: 999px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  display: block;
  width: 100%;
  text-align: center;
  transition: opacity .15s;
}
.btn-secondary:active { opacity: .7; }

.btn-danger {
  background: rgba(255,59,48,.12);
  color: var(--red);
  border-radius: 999px;
  padding: 14px 24px;
  font-size: 15px;
  font-weight: 600;
  display: block;
  width: 100%;
  text-align: center;
  transition: opacity .15s;
}
.btn-danger:active { opacity: .7; }

.mt-sm { margin-top: 10px; }

/* ── CHECK-IN BADGE (dashboard header) ── */
.checkin-badge {
  background: rgba(107,143,245,.14);
  color: var(--primary);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  transition: opacity .15s;
}
.checkin-badge:active { opacity: .7; }
.checkin-badge.done {
  background: rgba(52,199,89,.14);
  color: var(--green);
}

/* ── WARNING CARDS ── */
.warn-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
  animation: slideIn .3s ease;
}
.warn-card.hidden { display: none; }
.warn-icon { font-size: 20px; flex-shrink: 0; margin-top: 1px; }

.warn-info   { background: rgba(107,143,245,.13); color: var(--primary); }
.warn-yellow { background: rgba(255,159,10,.13);  color: #CC7A00; }
.warn-red    { background: rgba(255,59,48,.13);   color: var(--red); }

@media (prefers-color-scheme: dark) {
  .warn-yellow { color: var(--orange); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── ENERGY CIRCLE ── */
.circle-card {
  display: flex;
  justify-content: center;
  padding: 8px 16px;
}
.circle-wrap {
  position: relative;
  width: 220px;
  height: 220px;
}
.circle-svg {
  width: 100%;
  height: 100%;
}
.circle-track {
  fill: none;
  stroke: var(--sep);
  stroke-width: 16;
}
.circle-prog {
  fill: none;
  stroke: var(--green);
  stroke-width: 16;
  stroke-linecap: round;
  transition: stroke-dashoffset .6s cubic-bezier(.4,0,.2,1),
              stroke .4s ease;
}
.circle-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.circle-pts {
  font-size: 48px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -2px;
}
.circle-lbl {
  font-size: 14px;
  color: var(--text2);
}
.circle-used {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

/* ── QUICK ACTIONS ── */
.qg { margin-bottom: 14px; }
.qg-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
}
.qb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.qb {
  background: var(--bg);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
  display: flex;
  align-items: center;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.qb:active { background: var(--sep); transform: scale(.96); }
.qb-row-wide { margin-top: 4px; }
.qb-wide { flex: 1; justify-content: center; }

/* ── SEC TITLE ── */
.sec-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
}

/* ── TODAY ACTIVITY LIST ── */
.act-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--sep);
}
.act-item:last-child { border-bottom: none; padding-bottom: 0; }
.act-item:first-child { padding-top: 0; }
.act-ico { font-size: 22px; flex-shrink: 0; }
.act-info { flex: 1; min-width: 0; }
.act-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.act-meta { font-size: 12px; color: var(--text2); margin-top: 1px; }
.act-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.act-pts {
  font-size: 14px;
  font-weight: 600;
  color: var(--red);
}
.act-pts.neg { color: var(--green); }
.del-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,59,48,.12);
  color: var(--red);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.del-btn:active { background: rgba(255,59,48,.25); }

.empty {
  font-size: 14px;
  color: var(--text2);
  text-align: center;
  padding: 16px 0;
  line-height: 1.6;
}

/* ── ACTIVITIES SCREEN: Check-in Buttons ── */
.ci-btns { display: flex; gap: 8px; }
.ci-btn {
  background: var(--bg);
  color: var(--text2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s, color .15s;
  min-height: 36px;
}
.ci-btn:active { opacity: .7; }
.ci-btn.done {
  background: rgba(52,199,89,.14);
  color: var(--green);
}

/* ── CATEGORY ACCORDION ── */
.cat-card {
  background: var(--card);
  border-radius: var(--radius);
  margin: 0 16px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.cat-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.cat-hdr:active { opacity: .7; }
.cat-hdr-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
}
.cat-icon-big { font-size: 24px; }
.cat-factor {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  background: var(--bg);
  border-radius: 6px;
  padding: 2px 7px;
}
.cat-factor.neg { color: var(--green); background: rgba(52,199,89,.12); }
.cat-chevron {
  font-size: 18px;
  color: var(--text3);
  transition: transform .25s ease;
  line-height: 1;
}
.cat-chevron.open { transform: rotate(90deg); }

.cat-body { border-top: 1px solid var(--sep); }
.cat-body.hidden { display: none; }

.act-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--sep);
}
.act-row:last-child { border-bottom: none; }
.act-row-name {
  font-size: 14px;
  color: var(--text);
  flex-shrink: 0;
  min-width: 80px;
}
.dur-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.dur-btn {
  background: rgba(120,120,128,.14);
  color: var(--primary);
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 600;
  min-height: 36px;
  display: flex;
  align-items: center;
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.dur-btn:active { background: var(--primary); color: white; transform: scale(.93); }

/* ── STEPPER (Spazieren) ── */
.act-row-stepper { flex-wrap: wrap; gap: 8px; }
.stepper-input {
  display: flex;
  align-items: center;
  gap: 4px;
}
.stepper-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  min-width: 56px;
  text-align: center;
}
.stepper-val small {
  font-size: 11px;
  font-weight: 400;
  color: var(--text2);
}
.step-adj {
  background: rgba(120,120,128,.18);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 600;
  min-height: 36px;
  transition: background .12s;
}
.step-adj:active { background: rgba(120,120,128,.35); }
/* ✓-Button: gleiche Schriftgröße wie stepper-val */
.step-log {
  background: var(--primary);
  color: white;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: 700;
  height: 36px;
  line-height: 36px;
  margin-left: 6px;
  transition: opacity .12s;
}
.step-log:active { opacity: .7; }
/* Dark Mode: Buttons besser sichtbar */
@media (prefers-color-scheme: dark) {
  .step-adj {
    background: rgba(255,255,255,.18);
    color: #fff;
  }
  .step-adj:active { background: rgba(255,255,255,.30); }
  .dur-btn {
    background: rgba(255,255,255,.14);
  }
}
.qc-hint {
  font-size: 12px;
  color: var(--text2);
  margin: 0 0 8px;
}

/* ── HISTORY SCREEN ── */
.baseline-banner {
  background: var(--card);
  border-radius: var(--radius);
  margin: 0 16px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.bl-label { font-size: 13px; color: var(--text2); }
.bl-value { font-size: 22px; font-weight: 800; color: var(--orange); }

/* ── 7-DAY CHART ── */
.chart-wrap {
  background: var(--card);
  border-radius: var(--radius);
  margin: 0 16px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.chart-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
}
.chart-area {
  position: relative;
  height: 140px;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  position: relative;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 4px;
}
.chart-bar-fill {
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 3px;
  transition: height .4s ease;
}
.chart-bar-fill.bar-green  { background: var(--green); }
.chart-bar-fill.bar-orange { background: var(--orange); }
.chart-bar-fill.bar-red    { background: var(--red); }
.chart-bar-fill.bar-empty  { background: var(--sep); }

.chart-day-labels {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.chart-day-labels span {
  flex: 1;
  text-align: center;
  font-size: 11px;
  color: var(--text2);
}

.baseline-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--orange);
  pointer-events: none;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}
.leg-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text2);
}
.leg-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  flex-shrink: 0;
}
.leg-dot.green  { background: var(--green); }
.leg-dot.orange { background: var(--orange); }
.leg-dot.red    { background: var(--red); }

/* ── BASELINE PROGRESS ── */
.bl-progress-wrap {
  background: var(--card);
  border-radius: var(--radius);
  margin: 0 16px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.bl-progress-bar {
  background: var(--sep);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 12px 0 6px;
}
.bl-progress-fill {
  background: var(--primary);
  height: 100%;
  border-radius: 999px;
  transition: width .5s ease;
}
.bl-progress-text {
  font-size: 12px;
  color: var(--text2);
  text-align: center;
}

/* ── SETTINGS ── */
.setting-lbl {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 8px;
}
.setting-inp {
  width: 100%;
  background: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 16px;
  color: var(--text);
  outline: none;
  -webkit-appearance: none;
}
.setting-inp:focus { outline: 2px solid var(--primary); }

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.step-btn {
  width: 52px;
  height: 48px;
  font-size: 22px;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.step-btn:active { background: var(--sep); }
.step-val {
  flex: 1;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

.mt-sm { margin-top: 12px; }

.sev-row { display: flex; gap: 8px; }
.sev-btn {
  flex: 1;
  background: var(--bg);
  color: var(--text2);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: background .15s, color .15s;
  min-height: 44px;
}
.sev-btn.active {
  background: var(--primary);
  color: white;
}
.sev-hint {
  font-size: 11px;
  color: var(--text2);
  margin-top: 8px;
  text-align: center;
}

/* ── MODALS (Bottom Sheet) ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.modal.hidden { display: none; }

.modal-bd {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
  animation: fadeBd .25s ease;
}
@keyframes fadeBd {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-sheet {
  position: relative;
  z-index: 1;
  background: var(--card);
  border-radius: 24px 24px 0 0;
  padding: 12px 24px calc(28px + var(--safe-bot));
  max-height: 90dvh;
  overflow-y: auto;
  animation: slideUp .3s cubic-bezier(.32,.72,0,1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--sep);
  border-radius: 999px;
  margin: 0 auto 16px;
}
.modal-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
}

/* ── CHECK-IN QUESTIONS ── */
.ci-q { margin-bottom: 20px; }
.ci-q-text {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}

.emoji-row {
  display: flex;
  gap: 4px;
}
.em-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  transition: background .15s, transform .1s;
  -webkit-tap-highlight-color: transparent;
  min-height: 72px;
  justify-content: center;
}
.em-btn:active { transform: scale(.92); }
.em-btn.selected {
  background: var(--primary);
}
.em-btn span:first-child { font-size: 26px; line-height: 1; }
.em-btn span:last-child {
  font-size: 10px;
  color: var(--text2);
  text-align: center;
  line-height: 1.2;
}
.em-btn.selected span:last-child { color: rgba(255,255,255,.85); }

.cmp-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cmp-btn {
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  min-height: 52px;
  display: flex;
  align-items: center;
  transition: background .15s;
  -webkit-tap-highlight-color: transparent;
}
.cmp-btn:active { opacity: .7; }
.cmp-btn.selected {
  background: var(--primary);
  color: white;
}

/* ── TOAST ── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + var(--safe-bot) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: rgba(28,28,30,.9);
  color: white;
  border-radius: 999px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 900;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.hidden { display: none; }
