/* Routine Star Chart — rainbow-sparkle theme (production PWA) */
:root {
  --pink: #f472b6;
  --purple: #a855f7;
  --violet: #8b5cf6;
  --sky: #38bdf8;
  --gold: #ffd54a;
  --ink: #3b2d4f;
  --card: #ffffff;
  --danger: #ff3b30;
  --radius: 22px;
  --shadow: 0 6px 24px rgba(139, 92, 246, 0.16);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI Rounded", "Baloo 2",
    "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(244, 114, 182, 0.20) 0 6px, transparent 7px),
    radial-gradient(circle at 84% 10%, rgba(56, 189, 248, 0.22) 0 5px, transparent 6px),
    radial-gradient(circle at 70% 82%, rgba(255, 213, 74, 0.25) 0 6px, transparent 7px),
    radial-gradient(circle at 28% 88%, rgba(168, 85, 247, 0.16) 0 5px, transparent 6px),
    linear-gradient(160deg, #fff6fb 0%, #f3efff 55%, #e8f7ff 100%);
  min-height: 100vh;
}
.hidden { display: none !important; }
#app { max-width: 560px; margin: 0 auto; padding: 12px 14px 40px; }

/* ---------- header / tabs ---------- */
header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0 14px;
}
#tabs { display: flex; gap: 10px; flex: 1; }
.tab {
  display: flex; align-items: center; gap: 9px;
  border: 3px solid transparent; background: rgba(255,255,255,0.75);
  border-radius: 999px; padding: 6px 16px 6px 7px;
  font: inherit; font-size: 1.15rem; font-weight: 800; color: var(--ink);
  cursor: pointer; box-shadow: var(--shadow);
}
.tab.active {
  border-color: var(--purple);
  background: linear-gradient(120deg, #fdf4ff, #eff6ff);
}
.avatar-wrap {
  position: relative; display: inline-flex; flex: none;
  width: 40px; height: 40px;
}
.avatar-wrap img, .avatar-fallback {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
}
.avatar-fallback {
  align-items: center; justify-content: center;
  color: #fff; font-weight: 900; font-size: 1.15rem;
}
.avatar-wrap.large { width: 56px; height: 56px; }
.avatar-wrap.large img, .avatar-wrap.large .avatar-fallback {
  width: 56px; height: 56px; font-size: 1.5rem;
}

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 800; cursor: pointer; border: none;
  border-radius: 999px; padding: 12px 22px; color: #fff;
  background: linear-gradient(120deg, var(--pink), var(--purple));
  box-shadow: var(--shadow);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-settings { margin-left: auto; background: linear-gradient(120deg, var(--sky), var(--violet)); }
.btn-back { background: linear-gradient(120deg, var(--violet), var(--sky)); padding: 9px 18px; }
.btn-small { padding: 9px 18px; font-size: 0.95rem; background: linear-gradient(120deg, var(--violet), var(--pink)); }
.btn-quiet { background: #e9e4f5; color: var(--ink); box-shadow: none; }
.btn-next { background: linear-gradient(120deg, #4ade80, var(--sky)); font-size: 1.15rem; }
.btn-done {
  display: block; width: 100%; margin-top: 14px;
  font-size: 1.7rem; padding: 20px 10px; letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(120deg, #f59e0b, #ef4444 55%, var(--pink));
  border: 4px solid #fff;
  box-shadow: 0 10px 30px rgba(239, 68, 68, 0.35);
}
.btn-done:disabled, .btn-done.is-expired {
  background: linear-gradient(120deg, #cbd5e1, #94a3b8);
  border-color: #e2e8f0;
  box-shadow: none;
  color: #f8fafc;
  cursor: not-allowed;
  opacity: 1;
  transform: none;
}

/* ---------- cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.status-card { text-align: center; margin-top: 60px; }
.status-card h1 { margin: 8px 0 4px; font-size: 1.8rem; }

/* ---------- star jar ---------- */
.jar-card { text-align: center; }
.jar-head {
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.jar-count { font-size: 1.5rem; font-weight: 900; }
.jar-count .jar-of { color: var(--violet); }
.jar {
  margin: 12px auto 6px; max-width: 340px; min-height: 92px;
  border: 4px solid rgba(139, 92, 246, 0.35);
  border-top-width: 10px; border-radius: 14px 14px 34px 34px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(243, 239, 255, 0.9));
  padding: 10px; display: flex; flex-wrap: wrap; gap: 4px;
  align-content: flex-end; justify-content: center;
}
.jar .star-slot { width: 28px; height: 28px; }
.jar .star-slot.pop { animation: starPop 0.45s ease; }
@keyframes starPop {
  0% { transform: scale(0) rotate(-40deg); }
  70% { transform: scale(1.35) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}
.progress-track {
  height: 16px; border-radius: 999px; overflow: hidden;
  background: #eee7fb; margin-top: 10px;
}
.progress-fill {
  height: 100%; border-radius: 999px; transition: width 0.6s ease;
  background: linear-gradient(90deg, #f87171, #fb923c, #facc15, #4ade80, #38bdf8, #a78bfa);
}

/* ---------- routine sections ---------- */
.routine-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.routine-title { font-size: 1.4rem; font-weight: 900; margin: 0; }
.routine-total { color: var(--violet); font-weight: 800; }
.routine-head .btn { margin-left: auto; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 6px; border-radius: 14px;
}
.task-row + .task-row { border-top: 2px dashed #f1eafd; }
.task-icon, .task-tile {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  object-fit: cover;
}
.task-tile {
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 900; font-size: 1.4rem;
}
.task-name { font-size: 1.08rem; font-weight: 700; flex: 1; }
.task-mins { font-weight: 900; color: var(--violet); white-space: nowrap; }
.task-row.startable { cursor: pointer; }
.task-row.startable:active { transform: scale(0.99); background: #fdf4ff; }
.task-start {
  flex: none; font-size: 0.82rem; font-weight: 900; color: #fff;
  background: linear-gradient(120deg, var(--pink), var(--purple));
  border-radius: 999px; padding: 5px 11px; box-shadow: var(--shadow);
}
.task-row.current { background: #fdf4ff; outline: 3px solid var(--pink); }
.live-chip {
  font-weight: 900; color: #fff; background: var(--danger);
  border-radius: 999px; padding: 4px 12px; font-size: 0.95rem;
}

/* ---------- timer ---------- */
.timer-topbar {
  display: flex; align-items: center; gap: 12px; padding: 6px 0 12px;
}
.timer-child { font-size: 1.15rem; font-weight: 900; }
.btn-close-step {
  margin-left: auto; width: 46px; height: 46px; padding: 0;
  border-radius: 50%; font-size: 1.55rem; line-height: 1;
  background: #e9e4f5; color: var(--ink); box-shadow: none;
}
.timer-card { text-align: center; }
.timer-task-icon { display: flex; justify-content: center; }
.timer-task-icon .task-icon, .timer-task-icon .task-tile {
  width: 110px; height: 110px; border-radius: 26px; font-size: 3rem;
}
.timer-task-name { font-size: 1.55rem; margin: 10px 0 2px; }
.timer-progress {
  display: flex; gap: 7px; justify-content: center; margin: 8px 0 4px;
}
.timer-progress .dot {
  width: 13px; height: 13px; border-radius: 50%; background: #e7ddfa;
}
.timer-progress .dot.done { background: var(--gold); }
.timer-progress .dot.now { background: var(--pink); transform: scale(1.25); }
.timer-task-list {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px; margin: 12px 0 4px;
}
.jump-task {
  border: 2px solid #eee7fb; background: #fff; border-radius: 16px;
  padding: 7px; display: flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 800; color: var(--ink); cursor: pointer;
  text-align: left; box-shadow: none;
}
.jump-task .task-icon, .jump-task .task-tile {
  width: 38px; height: 38px; border-radius: 12px; font-size: 1rem;
}
.jump-task span { flex: 1; font-size: 0.86rem; line-height: 1.08; }
.jump-task small { color: var(--violet); font-weight: 900; white-space: nowrap; }
.jump-task.current { border-color: var(--pink); background: #fdf4ff; }
.jump-task:disabled { opacity: 0.78; cursor: default; }
.ring-wrap { position: relative; width: 240px; height: 240px; margin: 6px auto; }
.ring { width: 240px; height: 240px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 15; }
.ring-track { stroke: #f0e9fb; }
.ring-prog {
  stroke: url(#ringGrad); stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear;
}
.ring-prog.final-minute { stroke: var(--danger); }
.ring-center {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
}
.ring-readout { font-size: 3rem; font-weight: 900; }
.ring-readout.final-minute { color: var(--danger); }
.timer-ready { margin-top: 12px; }
.timer-expired { margin-top: 10px; }
.expired-title { font-size: 1.4rem; font-weight: 900; color: var(--danger); margin: 4px 0 10px; }
.timer-actions {
  display: flex; gap: 10px; justify-content: center; margin-top: 14px;
}

/* ---------- overlay celebration ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(59, 45, 79, 0.45);
  display: flex; align-items: center; justify-content: center;
}
.overlay-inner { text-align: center; padding: 20px; }
.overlay-star { display: flex; justify-content: center; }
.overlay-star svg {
  animation: bigStar 1.7s ease forwards;
  filter: drop-shadow(0 0 26px rgba(255, 213, 74, 0.85));
}
@keyframes bigStar {
  0% { transform: scale(0.2) rotate(-50deg); opacity: 0; }
  35% { transform: scale(1.15) rotate(14deg); opacity: 1; }
  55% { transform: scale(1) rotate(0deg); }
  80% { transform: scale(1.05) rotate(6deg); opacity: 1; }
  100% { transform: scale(0.55) rotate(0deg) translateY(30px); opacity: 0; }
}
.overlay-caption {
  color: #fff; font-size: 1.5rem; font-weight: 900; margin-top: 10px;
  text-shadow: 0 2px 10px rgba(0,0,0,0.35);
}
.big-star-spin svg { animation: starPop 0.8s ease; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-weight: 700;
  padding: 11px 20px; border-radius: 999px; z-index: 50;
  box-shadow: var(--shadow); max-width: 88vw; text-align: center;
}

/* ---------- settings ---------- */
.settings-section h3 { margin: 4px 0 10px; font-size: 1.15rem; }
.stepper { display: inline-flex; align-items: center; gap: 14px; }
.stepper button {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  font: inherit; font-size: 1.5rem; font-weight: 900; color: #fff;
  background: linear-gradient(120deg, var(--violet), var(--sky)); cursor: pointer;
}
.stepper .stepper-value { font-size: 1.5rem; font-weight: 900; min-width: 3ch; text-align: center; }
.field-row {
  display: flex; align-items: center; gap: 10px; margin: 10px 0;
  flex-wrap: wrap;
}
.field-row label { font-weight: 800; min-width: 130px; }
.field-row input[type="time"], .field-row input[type="text"],
.field-row input[type="number"] {
  font: inherit; font-weight: 700; color: var(--ink);
  border: 2px solid #e3d9fb; border-radius: 12px; padding: 8px 10px;
  background: #fbf9ff;
}
.field-row input[type="number"] { width: 80px; }
.switch { position: relative; width: 56px; height: 32px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px; background: #ddd3f5;
  transition: background 0.2s;
}
.switch .track::after {
  content: ""; position: absolute; top: 4px; left: 4px;
  width: 24px; height: 24px; border-radius: 50%; background: #fff;
  transition: left 0.2s;
}
.switch input:checked + .track { background: var(--violet); }
.switch input:checked + .track::after { left: 28px; }
.task-edit-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 0; border-top: 2px dashed #f1eafd;
}
.task-edit-row .task-icon, .task-edit-row .task-tile { width: 44px; height: 44px; border-radius: 12px; }
.task-edit-row input.name-input { flex: 1; min-width: 130px; }
.task-edit-row input.icon-input { flex: 1; min-width: 130px; font-size: 0.85rem; }
.mini-btn {
  font: inherit; font-weight: 800; border: none; cursor: pointer;
  border-radius: 10px; padding: 7px 11px; background: #efe9fd; color: var(--ink);
}
.mini-btn.danger { background: #ffe1de; color: #b91c1c; }
.add-task-btn { margin-top: 8px; }
