html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

:root { --tabbar-h: 58px; --topbar-h: 50px; }
/* Sicherer Bereich unten nur als installierte PWA (standalone) – im Browser-Tab
   kümmert sich die Browser-Leiste darum, und ohne viewport-fit=cover legt iOS den
   Inhalt automatisch in den sicheren Bereich. */
:root { --safe-bottom: 0px; }
/* Als installierte PWA die Tab-Leiste etwas vom unteren Rand abheben
   (sicherer Bereich + kleiner Abstand). Hebt Icons an und hält .views konsistent. */
@media (display-mode: standalone) {
  :root { --safe-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }
}

/* Durchgehende obere Leiste (auf jedem Tab) */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--safe-top));
  padding-top: var(--safe-top);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg2); border-bottom: 1px solid var(--bg3); z-index: 50;
}
.topbar-title { font-size: 1.1rem; font-weight: 800; letter-spacing: -0.01em; }

/* Bereich zwischen oberer Leiste und Tab-Leiste */
.views {
  position: fixed;
  left: 0; right: 0;
  top: calc(var(--topbar-h) + var(--safe-top));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
}
.view {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.view.active { display: block; }

/* Eingebettete Aktivitäten */
.act-frame { width: 100%; height: 100%; border: none; display: block; }

/* Pull-to-Refresh-Indikator (Shell) */
#ptr-indicator {
  position: fixed; top: calc(var(--topbar-h) + var(--safe-top)); left: 0; right: 0;
  z-index: 49; background: var(--accent); color: #fff;
  font-size: 0.8rem; font-weight: 600; text-align: center; padding: 8px 16px;
  transform: translateY(-130%); transition: transform 0.18s ease; pointer-events: none;
}
#ptr-indicator.ptr-visible { transform: translateY(0); }
#ptr-indicator.ptr-ready { background: #ea6c10; }

/* Home */
.home-wrap, .settings-wrap { padding: 16px 20px 28px; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.block-title { font-size: 0.95rem; font-weight: 700; color: var(--text2); margin-bottom: 10px; }

.streak-card {
  background: linear-gradient(135deg, #f97316, #fb923c);
  color: #fff; border-radius: var(--radius); padding: 14px 16px; text-align: center;
}
.streak-cap-top { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; }
.streak-duo { display: flex; align-items: stretch; justify-content: center; gap: 14px; margin-top: 6px; }
.streak-item { flex: 1 1 0; min-width: 0; }
.streak-divider { width: 1px; background: rgba(255, 255, 255, 0.35); }
.streak-big { font-size: 2.6rem; font-weight: 900; line-height: 1; display: flex; align-items: center; justify-content: center; gap: 6px; }
.streak-big .flame { font-size: 1.8rem; }
.streak-cap { margin-top: 4px; font-size: 0.78rem; font-weight: 600; opacity: 0.95; }
.streak-sub { margin-top: 6px; font-size: 0.78rem; opacity: 0.85; }

.today-list { display: flex; flex-direction: column; gap: 8px; }
.today-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg2); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.95rem;
  cursor: pointer; border: none; width: 100%; color: var(--text); font-family: inherit; text-align: left;
}
.today-row:active { transform: scale(0.99); }
.today-left { display: flex; align-items: center; gap: 10px; }
.today-left img { width: 24px; height: 24px; }
.today-row .done { color: var(--green); font-weight: 700; }
.today-row .open { color: var(--text3); }

.act-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.act-tile {
  background: var(--bg2); border: 1px solid var(--bg3); border-radius: var(--radius);
  padding: 16px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  cursor: pointer; font-family: inherit; color: var(--text); min-width: 0;
}
.act-tile:active { transform: scale(0.98); }
.act-tile img { width: 40px; height: 40px; }
.act-name { font-weight: 700; font-size: 0.92rem; text-align: center; }
.act-val { font-size: 0.72rem; color: var(--text3); white-space: nowrap; }

.home-acct, .set-version { text-align: center; font-size: 0.8rem; color: var(--text3); }
.home-acct .link-btn, #set-account .link-btn {
  background: none; border: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0;
}

/* Einstellungen */
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bg2); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
  font-size: 0.95rem;
}
.set-row small { color: var(--text3); font-size: 0.75rem; }
.set-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); }
.set-links a { color: var(--accent); text-decoration: none; }
#set-account { display: flex; flex-direction: column; gap: 10px; }
.set-btn {
  align-self: flex-start; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); padding: 11px 16px; font-weight: 700; font-size: 0.95rem; cursor: pointer; font-family: inherit;
}
.set-btn.danger { background: var(--red); }
.set-btn.ghost { background: var(--bg3); color: var(--text); }

/* Tab-Leiste */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; background: var(--bg2);
  border-top: 1px solid var(--bg3); z-index: 50;
}
.tab {
  flex: 1; min-width: 0; background: none; border: none; cursor: pointer; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text3); padding: 6px 2px;
}
.tab-lbl { max-width: 100%; }
.tab-ico { font-size: 1.3rem; line-height: 1; opacity: 0.5; filter: grayscale(1); }
.tab-ico-img { width: 22px; height: 22px; opacity: 0.55; filter: grayscale(1); }
.tab-lbl { font-size: 0.65rem; font-weight: 600; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tab.active { color: var(--accent); }
.tab.active .tab-ico { opacity: 1; filter: none; }
.tab.active .tab-ico-img { opacity: 1; filter: none; }

/* ── Aktivitäten-Reihenfolge (Einstellungen) ───────────────── */
.activity-order { display: flex; flex-direction: column; gap: 8px; }
.act-order-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg2); border: 1px solid var(--bg3);
  border-radius: var(--radius); padding: 10px 12px;
}
.act-order-row.shown { border-color: var(--accent); }
.act-order-row img { width: 26px; height: 26px; flex: 0 0 auto; }
.act-order-pos {
  flex: 0 0 auto; width: 20px; text-align: center;
  font-weight: 800; color: var(--text3); font-variant-numeric: tabular-nums;
}
.act-order-name { font-weight: 700; flex: 1 1 auto; min-width: 0; }
.act-order-badge {
  flex: 0 0 auto; font-size: 0.62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px; padding: 2px 7px;
}
.act-order-btns { flex: 0 0 auto; display: flex; gap: 6px; }
.ord-btn {
  width: 34px; height: 34px; border: 1px solid var(--bg3); background: var(--bg);
  color: var(--text); border-radius: 8px; font-size: 0.9rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.ord-btn:active { border-color: var(--accent); color: var(--accent); }
.ord-btn:disabled { opacity: 0.3; cursor: default; }
.act-order-sep {
  text-align: center; font-size: 0.68rem; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.05em; margin: 4px 0 2px;
}
