/* Weeks: iOS-nahes Aussehen, hell und dunkel. */

:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #000000;
  --secondary: rgba(60, 60, 67, 0.6);
  --tertiary: rgba(60, 60, 67, 0.3);
  --separator: rgba(60, 60, 67, 0.18);
  --switch-off: rgba(120, 120, 128, 0.16);
  --dot-off: rgba(120, 120, 128, 0.2);
  --bar-bg: rgba(120, 120, 128, 0.16);
  --chrome: rgba(249, 249, 249, 0.82);
  --accent: #E38C21;
  --danger: #FF3B30;
  --shadow: 0 3px 10px rgba(0, 0, 0, 0.07);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --text: #FFFFFF;
    --secondary: rgba(235, 235, 245, 0.6);
    --tertiary: rgba(235, 235, 245, 0.3);
    --separator: rgba(84, 84, 88, 0.55);
    --switch-off: rgba(120, 120, 128, 0.32);
    --dot-off: rgba(120, 120, 128, 0.35);
    --bar-bg: rgba(120, 120, 128, 0.3);
    --chrome: rgba(22, 22, 24, 0.82);
    --danger: #FF453A;
    --shadow: none;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  overscroll-behavior-y: none;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
button:disabled { opacity: 0.35; cursor: default; }
h1, h2, h3, p { margin: 0; }

.secondary { color: var(--secondary); }
.small, small { font-size: 13px; }
.center { text-align: center; }
.strong { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.title1 { font-size: 28px; font-weight: 700; }
.title2 { font-size: 22px; font-weight: 700; }
.headline { font-size: 17px; font-weight: 600; }

/* Gerüst */

.screen {
  position: relative;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

.content {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px max(16px, env(safe-area-inset-left)) 24px max(16px, env(safe-area-inset-right));
}

.stack { display: flex; flex-direction: column; gap: 16px; }

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 8px;
  background: var(--chrome);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--separator);
}

.nav.large {
  display: block;
  position: relative;
  background: transparent;
  border: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: calc(env(safe-area-inset-top) + 18px) 20px 6px;
  max-width: 640px;
  margin: 0 auto;
}

.nav.large h1 { font-size: 34px; font-weight: 700; letter-spacing: 0.01em; }

.nav-title { font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; }
.nav-left { justify-self: start; }
.nav-right { justify-self: end; display: flex; gap: 4px; }

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--accent);
  min-height: 36px;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.icon { width: 36px; justify-content: center; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.nav-btn.icon svg { width: 18px; height: 18px; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: space-around;
  padding: 6px 8px calc(env(safe-area-inset-bottom) + 4px);
  background: var(--chrome);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 500;
  color: var(--secondary);
  padding: 4px 0;
}
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--accent); }

/* Listen und Karten */

.card {
  background: var(--card);
  border-radius: 14px;
  display: block;
  width: 100%;
}
.card.pad { padding: 16px; }
.center-col { display: flex; flex-direction: column; align-items: center; gap: 8px; }

.group { margin-top: 22px; }
.group:first-of-type { margin-top: 8px; }
.group-header {
  font-size: 13px;
  font-weight: 400;
  text-transform: uppercase;
  color: var(--secondary);
  padding: 0 16px 6px;
}
.group-header.split { display: flex; align-items: baseline; justify-content: space-between; text-transform: none; }
.group-header.split h2 { font-size: 13px; font-weight: 400; text-transform: uppercase; }
.group-footer { font-size: 13px; color: var(--secondary); padding: 6px 16px 0; }

.link { color: var(--accent); font-size: 15px; }

.list .row + .row { border-top: 0.5px solid var(--separator); }

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  width: 100%;
  padding: 8px 16px;
  cursor: pointer;
}
.row-icon { width: 28px; text-align: center; font-size: 20px; flex: none; }
.row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-text small { color: var(--secondary); font-size: 13px; }
.row.action { color: var(--accent); justify-content: center; }
.row.action.danger { color: var(--danger); }

.tip-row { text-align: left; }
.tip-row strong { font-size: 15px; font-weight: 600; }
.chev { color: var(--tertiary); width: 16px; height: 16px; flex: none; }
.chev svg { width: 16px; height: 16px; }

.info { color: var(--secondary); width: 30px; height: 30px; display: grid; place-items: center; flex: none; }
.info svg { width: 22px; height: 22px; }

.field {
  font: inherit;
  color: var(--accent);
  background: var(--switch-off);
  border: 0;
  border-radius: 8px;
  padding: 6px 10px;
  min-height: 34px;
}

.stepper { display: inline-flex; background: var(--switch-off); border-radius: 9px; overflow: hidden; }
.stepper button { width: 46px; height: 32px; font-size: 20px; text-align: center; color: var(--text); }
.stepper button + button { border-left: 0.5px solid var(--separator); }

/* Schalter wie bei iOS */

.switch {
  -webkit-appearance: none;
  appearance: none;
  flex: none;
  width: 51px;
  height: 31px;
  margin: 0;
  border-radius: 16px;
  background: var(--switch-off);
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}
.switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16);
  transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.4, 1.2);
}
.switch:checked { background: var(--tint, #34C759); }
.switch:checked::before { transform: translateX(20px); }

/* Tageszusammenfassung */

.summary { display: flex; justify-content: space-around; padding: 10px 8px; }
.sum { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 22px; filter: grayscale(1); opacity: 0.35; transition: all 0.2s; }
.sum i { width: 6px; height: 6px; border-radius: 50%; background: transparent; }
.sum.on { filter: none; opacity: 1; }
.sum.on i { background: var(--tint); }

/* Hinweise */

.hint {
  font-size: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.share { font-weight: 700; }
.tip { text-align: center; padding: 16px; border-radius: 14px; background: color-mix(in srgb, #6B66D9 13%, transparent); }

.btn {
  align-self: center;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 24px;
  text-align: center;
}

/* Figuren */

.hero { height: 240px; border-radius: 20px; overflow: hidden; }

.char-frame {
  position: relative;
  height: 230px;
  border-radius: 14px;
  overflow: hidden;
  background: color-mix(in srgb, var(--tint) 12%, transparent);
}
.char-frame.small { height: 150px; border-radius: 12px; }
.char-frame.big { height: 300px; border-radius: 24px; }

.char { width: 100%; height: 100%; }
.char > img, .char > canvas { display: block; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-select: none; }
.breathe > img, .breathe > canvas { transform-origin: 50% 100%; animation: breathe 4.4s ease-in-out infinite; }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

.char-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; text-align: left; box-shadow: var(--shadow); border-radius: 20px; }
.char-card h3 { font-size: 20px; font-weight: 700; }
.char-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.crit { font-size: 15px; font-weight: 500; }
.badge { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 10px; background: color-mix(in srgb, #4DB3D9 20%, transparent); color: var(--text); }

.bar { width: 100%; height: 6px; border-radius: 3px; background: var(--bar-bg); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; background: var(--tint); }

.aura-bg {
  position: absolute;
  inset: 0 0 auto 0;
  height: 600px;
  pointer-events: none;
  background: radial-gradient(600px circle at 50% 0, rgba(77, 179, 217, var(--glow)), transparent 70%);
}

.stages { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stage { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.stage .char-frame { width: 100%; }
.stage strong { font-size: 15px; }
.stage.locked .char { filter: blur(8px); transform: scale(1.1); }
.lock {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 50px; height: 50px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; background: rgba(0, 0, 0, 0.35);
}
.lock svg { width: 24px; height: 24px; }

/* Verlauf */

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; background: var(--tint); }

.week { display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); border-radius: 16px; }
.week-head { display: flex; align-items: baseline; gap: 8px; }
.week-head strong { font-size: 17px; }
.medal { margin-left: auto; }
.cells { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; border-radius: 10px; }
.cell small { color: var(--secondary); font-size: 11px; }
.cell strong { font-size: 15px; }
.cell.today { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.cell:disabled { opacity: 0.4; }
.dots { display: grid; grid-template-columns: repeat(3, 6px); gap: 2px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--tint); }

/* Sheets */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0);
  transition: background 0.25s;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.open { background: rgba(0, 0, 0, 0.35); }

.sheet {
  width: 100%;
  max-width: 640px;
  max-height: 72vh;
  display: flex; flex-direction: column;
  background: var(--bg);
  border-radius: 14px 14px 0 0;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet.large { max-height: calc(100vh - env(safe-area-inset-top) - 20px); height: calc(100vh - env(safe-area-inset-top) - 20px); }
.sheet-backdrop.open .sheet { transform: translateY(0); }

.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--tertiary); margin: 6px auto 0; }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 16px 10px; }
.sheet-head h2 { font-size: 17px; font-weight: 600; text-align: center; }
.sheet-head .link { justify-self: end; font-size: 17px; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 16px; }

.rule-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.rule-card h3 { font-size: 17px; font-weight: 600; }
.idea {
  display: flex; gap: 8px;
  font-size: 15px;
  padding: 10px;
  border-radius: 10px;
  background: color-mix(in srgb, #40A85C 12%, transparent);
}

.celebrate { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; padding-top: 12px; }
.celebrate .char-frame { width: 100%; animation: pop 0.6s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
.party { font-size: 60px; animation: pop 0.6s cubic-bezier(0.3, 1.5, 0.5, 1) both; }

@keyframes pop {
  from { transform: scale(0.4); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Blätterregen */

.leaf-rain { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.leaf {
  position: absolute;
  color: rgba(115, 140, 71, 0.85);
  animation: fall 2.3s ease-in both;
}
.leaf svg { width: 100%; height: 100%; display: block; }

@keyframes fall {
  from { transform: translate(0, 0) rotate(var(--r0)); }
  to { transform: translate(var(--dx), calc(100vh + 120px)) rotate(var(--r1)); }
}

.leaf-pill {
  position: absolute;
  left: 50%; top: 40%;
  transform: translate(-50%, -50%);
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 24px;
  background: var(--chrome);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  white-space: nowrap;
  animation: pill 2.8s ease both;
}

@keyframes pill {
  0% { transform: translate(-50%, -50%) scale(0.6); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
  22%, 85% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .breathe > img, .breathe > canvas, .leaf, .party, .celebrate .char-frame { animation: none; }
}
