/* Mein Wochenplan – Gestaltung
   Farben und Formen lehnen sich an den gedruckten Plan an:
   runde Karten, Pastelltoene, grosse Flaechen zum Antippen. */

:root {
  color-scheme: light;
  --bg:        #f2f6fc;
  --card:      #ffffff;
  --ink:       #1f2937;
  --ink-soft:  #6b7a90;
  --line:      #e3e9f3;
  --blue:      #5b8def;
  --blue-dark: #3f6fd8;
  --green:     #4bb86f;
  --amber:     #f0a63c;
  --pink:      #ef7fa6;
  --violet:    #9b7fe0;
  --red:       #e4685f;
  --shadow:    0 6px 18px rgba(30, 55, 100, .08);
  --shadow-lg: 0 14px 40px rgba(30, 55, 100, .16);
  --radius:    18px;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0; padding: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 17px; line-height: 1.45;
  overscroll-behavior-y: contain;
}
body { padding-bottom: calc(24px + var(--safe-bottom)); }

h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }
button { font-family: inherit; }
.muted { color: var(--ink-soft); font-size: 15px; }
[hidden] { display: none !important; }

.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.center-view {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
}

/* --------------------------------------------------------------- Buttons */
.btn {
  border: 0; border-radius: 14px; padding: 14px 18px; font-size: 17px; font-weight: 700;
  cursor: pointer; transition: transform .08s ease, filter .15s ease; color: #fff; background: var(--blue);
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }
.btn-primary { background: var(--blue-dark); }
.btn-soft { background: #eaf0fb; color: var(--blue-dark); }
.btn-finish { background: var(--green); font-size: 20px; padding: 18px; }
.btn-ghost { background: transparent; color: var(--ink-soft); font-weight: 600; }
.btn-small { padding: 9px 14px; font-size: 15px; border-radius: 11px; }
.btn-danger { background: #fbeceb; color: var(--red); }

.icon-btn {
  width: 42px; height: 42px; flex: none; border: 0; border-radius: 12px; background: #fff;
  font-size: 20px; line-height: 1; cursor: pointer; box-shadow: var(--shadow); color: var(--ink);
}

/* ------------------------------------------------------------- Anmeldung */
.login-card {
  width: 100%; max-width: 400px; background: var(--card); border-radius: 24px;
  padding: 30px 26px; box-shadow: var(--shadow-lg); text-align: center;
}
.login-buddy { font-size: 60px; line-height: 1; margin-bottom: 8px; }
.login-card h1, .login-card h2 { font-size: 25px; margin-bottom: 6px; }
.login-card form { margin-top: 20px; text-align: left; }
label { display: block; font-size: 14px; font-weight: 700; color: var(--ink-soft); margin: 14px 0 5px; }
input, select, textarea {
  width: 100%; padding: 12px 14px; font-size: 16px; border: 1px solid var(--line);
  border-radius: 12px; background: #fbfcfe; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
.login-card .btn { margin-top: 22px; }
#pinInput { text-align: center; font-size: 30px; letter-spacing: 10px; padding: 14px; }
.form-error {
  margin-top: 14px; background: #fdeeed; color: #a3342c; border-radius: 10px;
  padding: 10px 12px; font-size: 15px; white-space: pre-line; text-align: left;
}

/* ----------------------------------------------------------------- Kopf */
.app-header {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 16px 12px;
  background: linear-gradient(180deg, #e6eeff 0%, var(--bg) 100%);
}
.header-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-buddy { font-size: 38px; line-height: 1; }
.app-header h1 { font-size: 21px; }
.header-sub { font-size: 14px; color: var(--ink-soft); }
.parent-header { justify-content: space-between; }
.parent-header h1 { font-size: 19px; }

/* ------------------------------------------------------------ Zielleiste */
.goal-bar {
  display: block; width: calc(100% - 32px); text-align: left; border: 0; font: inherit; color: inherit;
  margin: 4px 16px 0; background: var(--card); border-radius: var(--radius);
  padding: 13px 16px 16px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .08s ease;
}
.goal-bar:active { transform: scale(.985); }
.goal-bar.no-goal { background: linear-gradient(135deg, #fff5da, #ffe9b8); }
.goal-cta { display: block; margin-top: 9px; font-size: 13.5px; font-weight: 700; color: var(--blue-dark); }
.goal-bar.no-goal .goal-cta { color: #8a6415; }
.goal-top { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.goal-icon { font-size: 22px; }
.goal-text { flex: 1; font-weight: 600; }
.goal-points { color: var(--ink-soft); font-size: 14px; white-space: nowrap; }
.progress {
  position: relative; height: 16px; margin-top: 11px; background: #edf1f8;
  border-radius: 10px; overflow: visible;
}
.progress-fill {
  height: 100%; width: 0; border-radius: 10px; transition: width .5s cubic-bezier(.3,.8,.3,1);
  background: linear-gradient(90deg, #7fb2ff, var(--blue-dark));
}
.progress-buddy {
  position: absolute; top: -12px; left: 0; font-size: 26px; transform: translateX(-50%);
  transition: left .5s cubic-bezier(.3,.8,.3,1);
}

/* ------------------------------------------------------------ Kennzahlen */
.stat-row { display: flex; gap: 10px; padding: 14px 16px 4px; }
.stat {
  flex: 1; background: var(--card); border-radius: 14px; padding: 10px 6px;
  text-align: center; box-shadow: var(--shadow);
}
.stat-value { display: block; font-size: 22px; font-weight: 800; color: var(--blue-dark); }
.stat-label { display: block; font-size: 12px; color: var(--ink-soft); }

/* ----------------------------------------------------------------- Tabs */
.tabs { display: flex; gap: 6px; padding: 14px 16px 0; }
.tabs-scroll { overflow-x: auto; scrollbar-width: none; }
.tabs-scroll::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; white-space: nowrap; border: 0; background: transparent; padding: 10px 12px;
  font-size: 15px; font-weight: 700; color: var(--ink-soft); border-radius: 12px; cursor: pointer;
}
.tab.is-active { background: var(--card); color: var(--blue-dark); box-shadow: var(--shadow); }
.tab-panels { padding: 14px 16px 0; }
.panel { display: none; }
.panel.is-active { display: block; animation: fade .2s ease-out; }

.section-title { font-size: 15px; color: var(--ink-soft); margin: 22px 0 10px; font-weight: 700; }

/* --------------------------------------------------------- Tagesauswahl */
.day-switch { display: flex; gap: 8px; align-items: center; justify-content: center; margin-bottom: 12px; }
.pill {
  border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 11px;
  padding: 7px 14px; font-size: 16px; font-weight: 700; color: var(--ink-soft); cursor: pointer;
}
.pill-today { color: var(--blue-dark); }

/* -------------------------------------------------------------- Aufgaben */
.task-list { display: flex; flex-direction: column; gap: 11px; }
.task {
  display: flex; align-items: center; gap: 13px; background: var(--card); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow); border-left: 6px solid var(--blue);
  transition: opacity .2s ease;
}
.task-icon { font-size: 30px; line-height: 1; flex: none; width: 38px; text-align: center; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 700; font-size: 17px; }
.task-sub { font-size: 14px; color: var(--ink-soft); }
.task-meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.task-action { flex: none; }
.task.kind-check  { border-left-color: var(--amber); }
.task.kind-info   { border-left-color: #cbd5e5; background: #f7f9fd; box-shadow: none; }
.task.is-optional { border-left-style: dashed; }
.task.is-done     { opacity: .62; border-left-color: var(--green); }
.task.is-running  { border-left-color: var(--green); box-shadow: 0 0 0 3px rgba(75,184,111,.22), var(--shadow); }
.task.is-paused   { border-left-color: var(--amber); box-shadow: 0 0 0 3px rgba(240,166,60,.22), var(--shadow); }
.task.is-done .task-title { text-decoration: line-through; }

.check-box {
  width: 38px; height: 38px; border-radius: 11px; border: 2px solid var(--line);
  background: #fff; font-size: 20px; line-height: 1; cursor: pointer; color: var(--green);
}
.check-box.is-checked { background: var(--green); border-color: var(--green); color: #fff; }

.badge-pill {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: #eef3fc; color: var(--blue-dark); margin-left: 6px;
}
.rating-dot { font-size: 13px; }

.motto {
  margin: 18px 0 6px; text-align: center; font-weight: 700; color: var(--blue-dark);
  background: #e8efff; border-radius: 14px; padding: 12px;
}
.reminder {
  margin: 10px 0 0; text-align: center; font-size: 14px; color: var(--ink-soft);
  background: #fdeef4; border-radius: 14px; padding: 11px 14px;
}

/* ----------------------------------------------------------- Belohnungen */
.wallet {
  background: linear-gradient(135deg, #ffd873, #ffb648); border-radius: 20px; padding: 20px;
  text-align: center; box-shadow: var(--shadow); color: #5a3c05;
}
.wallet-star { font-size: 28px; }
.wallet-value { display: block; font-size: 42px; font-weight: 800; line-height: 1.1; }
.wallet-label { font-size: 14px; font-weight: 600; }
.wallet-hint { margin-top: 10px; font-size: 14px; font-weight: 700; background: rgba(255,255,255,.55);
               border-radius: 10px; padding: 8px 10px; }
.wallet-hint:empty { display: none; }

.reward-progress { height: 7px; margin-top: 7px; background: #edf1f8; border-radius: 5px; overflow: hidden; }
.reward-progress i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #ffd873, var(--amber)); }
.reward.is-affordable { border: 2px solid var(--green); }
.reward.is-affordable .reward-cost { color: var(--green); font-weight: 700; }

.reward-list, .purchase-list { display: flex; flex-direction: column; gap: 10px; }
.reward {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border-radius: var(--radius); padding: 13px 15px; box-shadow: var(--shadow);
}
.reward-icon { font-size: 28px; }
.reward-body { flex: 1; min-width: 0; }
.reward-title { font-weight: 700; }
.reward-cost { font-size: 14px; color: var(--ink-soft); }
.reward.is-goal { outline: 2px solid var(--blue); }
.reward .goal-flag { font-size: 12px; color: var(--blue-dark); font-weight: 700; }
.purchase { display: flex; gap: 10px; align-items: center; background: #f7f9fd; border-radius: 14px; padding: 10px 13px; font-size: 15px; }
.purchase .done-flag { margin-left: auto; font-size: 13px; color: var(--green); font-weight: 700; }

/* -------------------------------------------------------------- Abzeichen */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 11px; }
.badge {
  background: var(--card); border-radius: 16px; padding: 15px 11px; text-align: center; box-shadow: var(--shadow);
}
.badge.locked { opacity: .42; filter: grayscale(1); }
.badge-icon { font-size: 34px; }
.badge-title { font-weight: 700; font-size: 15px; margin-top: 4px; }
.badge-text { font-size: 12px; color: var(--ink-soft); }

/* ------------------------------------------------------------------ Timer */
.timer-view {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center;
  padding: calc(14px + var(--safe-top)) 18px calc(20px + var(--safe-bottom));
  background: radial-gradient(120% 60% at 50% 0%, #e8f1ff 0%, var(--bg) 60%);
}
.timer-head { display: flex; align-items: center; gap: 12px; width: 100%; max-width: 460px; }
.timer-title { flex: 1; font-size: 19px; font-weight: 800; text-align: center; }
.timer-points { font-size: 15px; font-weight: 700; color: var(--amber); }

.ring-wrap { position: relative; width: min(84vw, 320px); margin: auto auto 6px; }
.ring { width: 100%; height: auto; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #e2eaf7; stroke-width: 16; }
.ring-fill {
  fill: none; stroke: var(--green); stroke-width: 16; stroke-linecap: round;
  stroke-dasharray: 603.2; stroke-dashoffset: 0; transition: stroke-dashoffset .45s linear, stroke .3s ease;
}
.ring-wrap.is-paused .ring-fill { stroke: var(--amber); }
.ring-wrap.is-over   .ring-fill { stroke: var(--red); }
.ring-center {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none;
}
.ring-time { font-size: 13vw; max-font-size: 58px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
@media (min-width: 420px) { .ring-time { font-size: 54px; } }
.ring-state { font-size: 15px; color: var(--ink-soft); font-weight: 700; }
.timer-buddy {
  position: absolute; bottom: -6px; right: -4px; font-size: 44px;
  animation: bob 2.6s ease-in-out infinite;
}
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* Konzentrations-Sterne: fuer jede erreichte Etappe leuchtet einer auf. */
.focus-stars {
  display: flex; gap: 7px; justify-content: center; margin-top: 12px; min-height: 26px;
}
.focus-stars span { font-size: 22px; opacity: .22; filter: grayscale(1); transition: all .3s ease; }
.focus-stars span.on { opacity: 1; filter: none; animation: starPop .5s cubic-bezier(.2,1.4,.4,1); }
@keyframes starPop { 0% { transform: scale(.3) rotate(-30deg); } 100% { transform: scale(1) rotate(0); } }

/* Lob waehrend des Timers */
.praise {
  display: flex; align-items: center; gap: 10px; margin: 12px auto 0; max-width: 460px;
  background: linear-gradient(135deg, #e6f7ec, #d6f1e2); color: #17643a;
  border-radius: 16px; padding: 12px 16px; font-weight: 700; font-size: 15.5px;
  box-shadow: var(--shadow); animation: praiseIn .45s cubic-bezier(.2,1.2,.4,1);
}
.praise.is-goal { background: linear-gradient(135deg, #fff3d6, #ffe6ae); color: #7a5310; }
.praise-icon { font-size: 26px; flex: none; }
@keyframes praiseIn {
  from { transform: translateY(10px) scale(.94); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.timer-buddy.cheer { animation: cheer .7s ease-in-out 2; }
@keyframes cheer {
  0%,100% { transform: translateY(0) rotate(0); }
  25%     { transform: translateY(-14px) rotate(-12deg) scale(1.15); }
  75%     { transform: translateY(-14px) rotate(12deg) scale(1.15); }
}

.timer-info { text-align: center; color: var(--ink-soft); font-size: 15px; margin: 6px 0 auto; padding-bottom: 14px; min-height: 22px; }
.timer-actions { display: flex; gap: 10px; width: 100%; max-width: 460px; }
.timer-actions .btn { flex: 1; }
.timer-view .btn-finish { max-width: 460px; margin-top: 12px; }
.timer-hint { font-size: 14px; color: var(--ink-soft); text-align: center; margin-top: 10px; min-height: 20px; }

/* ----------------------------------------------------------------- Eltern */
.parent-view { padding-bottom: 30px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 15px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.card h3 { font-size: 16px; margin-bottom: 8px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span:last-child { font-weight: 700; white-space: nowrap; }

.jrow { display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.jrow:last-child { border-bottom: 0; }
.jrow .j-icon { font-size: 22px; }
.jrow .j-body { flex: 1; min-width: 0; }
.jrow .j-title { font-weight: 700; font-size: 15px; }
.jrow .j-meta { font-size: 13px; color: var(--ink-soft); }
.jrow .j-right { text-align: right; font-size: 13px; white-space: nowrap; }

.chart { width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--ink-soft); margin-top: 8px; }
.chart-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.empty { color: var(--ink-soft); font-size: 15px; text-align: center; padding: 22px 8px; }

.range-row { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.range-row .pill.is-active { color: #fff; background: var(--blue-dark); }

.edit-row { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.edit-row:last-child { border-bottom: 0; }
.edit-row .er-body { flex: 1; min-width: 0; }
.edit-row .er-title { font-weight: 700; font-size: 15px; }
.edit-row .er-meta { font-size: 13px; color: var(--ink-soft); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid .full { grid-column: 1 / -1; }
.field-grid label { margin-top: 4px; }

/* Symbol-Auswahl */
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px;
  max-height: 178px; overflow-y: auto; padding: 8px; background: #f7f9fd;
  border: 1px solid var(--line); border-radius: 12px; margin-top: 4px;
  -webkit-overflow-scrolling: touch;
}
.icon-grid button {
  font-size: 23px; line-height: 1; padding: 8px 0; border: 2px solid transparent;
  border-radius: 10px; background: #fff; cursor: pointer;
}
.icon-grid button.sel { border-color: var(--blue); background: #eaf0fb; }
.icon-current {
  display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 14px; color: var(--ink-soft);
}
.icon-current b { font-size: 26px; }

/* ---------------------------------------------------------------- Dialoge */
.modal-root { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 22px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 35, 60, .45); backdrop-filter: blur(2px); }
.modal {
  position: relative; width: 100%; max-width: 400px; background: var(--card);
  border-radius: 24px; padding: 26px 22px; text-align: center; box-shadow: var(--shadow-lg);
  animation: pop .22s cubic-bezier(.2,1.2,.4,1);
}
@keyframes pop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-icon { font-size: 52px; line-height: 1; }
.modal h2 { font-size: 21px; margin: 8px 0 6px; }
.modal p { color: var(--ink-soft); font-size: 16px; }
.modal-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
.modal-actions .btn { width: 100%; }
.modal .modal-form { text-align: left; margin-top: 8px; }

/* ----------------------------------------------------------------- Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 12px 20px; border-radius: 30px; font-weight: 700;
  z-index: 70; box-shadow: var(--shadow-lg); font-size: 16px; max-width: 90vw; text-align: center;
}

/* -------------------------------------------------------------- Konfetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 65; overflow: hidden; }
.confetti i {
  position: absolute; width: 10px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  from { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
  to   { transform: translateY(105vh) rotate(720deg); opacity: .9; }
}

.points-pop {
  position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%);
  font-size: 46px; font-weight: 800; color: var(--amber); z-index: 66; pointer-events: none;
  text-shadow: 0 3px 10px rgba(0,0,0,.18); animation: popUp 1.5s ease-out forwards;
}
@keyframes popUp {
  0%   { transform: translate(-50%, -30%) scale(.5); opacity: 0; }
  25%  { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  70%  { transform: translate(-50%, -60%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -110%) scale(.9); opacity: 0; }
}

.offline-bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 80; background: var(--amber); color: #3b2500;
  text-align: center; font-size: 14px; font-weight: 700; padding: calc(5px + var(--safe-top)) 8px 5px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
