/* =========================================================
   StudyCorner — arcade-cozy design system
   Pastel gradients + glossy 3D controls. No external assets.
   ========================================================= */

:root {
  /* pastel canvas */
  --sky-50: #e0f2fe;
  --mint-50: #f0fdf4;
  --lilac-50: #faf5ff;
  --peach-50: #fff1f2;
  --cream: #fefce8;

  /* ink */
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --white: #ffffff;

  /* brand */
  --sky-400: #38bdf8;
  --sky-500: #0ea5e9;
  --sky-700: #0284c7;
  --mint-400: #34d399;
  --mint-600: #059669;
  --lilac-400: #a78bfa;
  --lilac-600: #7c3aed;
  --pink-400: #f472b6;
  --pink-600: #db2777;
  --amber-400: #fbbf24;
  --amber-600: #d97706;

  /* surfaces */
  --card-bg: rgba(255, 255, 255, 0.82);
  --card-border: rgba(255, 255, 255, 0.9);
  --card-shadow: 0 18px 40px -22px rgba(15, 23, 42, 0.35), 0 2px 6px rgba(15, 23, 42, 0.05);
  --line: rgba(15, 23, 42, 0.09);

  /* geometry */
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-pill: 999px;

  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system,
    "Helvetica Neue", "Noto Sans Devanagari", "Nirmala UI", sans-serif;
  --ease: cubic-bezier(0.25, 0.9, 0.35, 1);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.5;
  background-color: var(--sky-50);
  background-image:
    radial-gradient(1100px 620px at 8% -8%, #dbeafe 0%, rgba(219, 234, 254, 0) 62%),
    radial-gradient(900px 560px at 96% 2%, #fae8ff 0%, rgba(250, 232, 255, 0) 58%),
    radial-gradient(1000px 700px at 50% 108%, #dcfce7 0%, rgba(220, 252, 231, 0) 62%),
    linear-gradient(160deg, var(--sky-50) 0%, var(--lilac-50) 45%, var(--mint-50) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: var(--sky-700); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--lilac-600); }

.muted { color: var(--ink-3); font-size: 0.9rem; line-height: 1.45; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--white);
  border-radius: var(--r-sm);
  box-shadow: var(--card-shadow);
}
.skip-link:focus { left: 12px; }

/* hidden must always win over layout display rules */
[hidden] { display: none !important; }

.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px clamp(12px, 3vw, 28px) 12px;
}

/* ============================ TOP BAR ============================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.brand-mark {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  border-radius: 18px;
  background: linear-gradient(to bottom, #ffffff, #e0f2fe);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.95),
    inset 0 -3px 6px rgba(2, 132, 199, 0.18),
    0 6px 0 #bae6fd,
    0 12px 22px -8px rgba(2, 132, 199, 0.6);
  display: grid;
  place-items: center;
  padding: 6px;
}
.brand-mark svg { width: 100%; height: 100%; display: block; }

.brand-text h1 {
  font-size: clamp(1.3rem, 3.6vw, 1.7rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  background: linear-gradient(100deg, #075985, #7c3aed 55%, #be185d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-text p {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.sync-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 1px 0 #fff, 0 3px 10px -6px rgba(15, 23, 42, 0.5);
  color: var(--ink-2);
  max-width: 100%;
}
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber-400);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.22);
  flex: 0 0 auto;
}
.sync-chip.is-cloud { color: #065f46; background: rgba(236, 253, 245, 0.95); }
.sync-chip.is-cloud .sync-dot {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  animation: pulseDot 2.2s infinite;
}
.sync-chip.is-offline .sync-dot { background: #f97316; box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.2); }

@keyframes pulseDot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
  50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.05); }
}

/* ============================ 3D BUTTONS ============================ */
.btn {
  --btn-top: #7dd3fc;
  --btn-bottom: #0ea5e9;
  --btn-shadow: #0284c7;
  --btn-ink: #ffffff;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--r-md);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--btn-ink);
  cursor: pointer;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.06) 46%, rgba(0, 0, 0, 0.12)),
    linear-gradient(to bottom, var(--btn-top), var(--btn-bottom));
  box-shadow:
    0 5px 0 var(--btn-shadow),
    0 8px 15px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition: transform 0.08s var(--ease), box-shadow 0.08s var(--ease), filter 0.16s var(--ease);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:hover { filter: brightness(1.05) saturate(1.05); }
.btn:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.45); outline-offset: 3px; }
.btn:active,
.btn.is-pressing {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 var(--btn-shadow),
    0 2px 6px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary { --btn-top: #60c9fb; --btn-bottom: #0ea5e9; --btn-shadow: #0284c7; }
.btn-mint { --btn-top: #6ee7b7; --btn-bottom: #10b981; --btn-shadow: #059669; }
.btn-lilac { --btn-top: #c4b5fd; --btn-bottom: #8b5cf6; --btn-shadow: #7c3aed; }
.btn-pink { --btn-top: #f9a8d4; --btn-bottom: #ec4899; --btn-shadow: #db2777; }

.btn-ghost {
  --btn-top: #ffffff;
  --btn-bottom: #f8fafc;
  --btn-shadow: #cbd5e1;
  --btn-ink: var(--ink-2);
  text-shadow: none;
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.75));
  border: 1px solid rgba(148, 163, 184, 0.35);
}
.btn-ghost:hover { --btn-ink: var(--ink); background-image: linear-gradient(to bottom, #ffffff, #eff6ff); }

.btn-danger {
  --btn-top: #fca5a5;
  --btn-bottom: #ef4444;
  --btn-shadow: #b91c1c;
  --btn-ink: #ffffff;
}

.btn-ground {
  --btn-top: #fef9c3;
  --btn-bottom: #fde68a;
  --btn-shadow: #d6b656;
  --btn-ink: #78350f;
  text-shadow: none;
}

.btn-sm { padding: 8px 13px; font-size: 0.82rem; border-radius: 13px; }
.btn-lg { padding: 15px 30px; font-size: 1.05rem; border-radius: 20px; }
.btn-block { width: 100%; }

.link-btn {
  background: none;
  border: 0;
  padding: 4px 2px;
  color: var(--sky-700);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  border-radius: 8px;
  transition: color 0.15s var(--ease);
}
.link-btn:hover { color: var(--lilac-600); text-decoration: underline; }
.link-btn:focus-visible { outline: 2px solid var(--lilac-400); outline-offset: 2px; }

/* ============================ XP STRIP ============================ */
.xpstrip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(10px);
}

.lvl-badge {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  color: #fff;
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.02) 45%, rgba(0, 0, 0, 0.18)),
    linear-gradient(140deg, #c4b5fd, #8b5cf6 45%, #6366f1);
  box-shadow:
    0 5px 0 #5b21b6,
    0 10px 20px -8px rgba(91, 33, 182, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.22);
}
.lvl-badge-label { font-size: 0.55rem; font-weight: 800; letter-spacing: 0.12em; opacity: 0.9; }
.lvl-badge-num { font-size: 1.5rem; font-weight: 900; line-height: 1; }

.xpstrip-main { flex: 1 1 240px; min-width: 0; }
.xpstrip-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 7px;
}
.xpstrip-top strong { font-size: 1rem; letter-spacing: -0.01em; }
.xp-values { font-size: 0.78rem; color: var(--ink-3); font-weight: 700; }
.xp-values b { color: var(--lilac-600); font-size: 0.9rem; }
.xp-sep { margin: 0 7px; opacity: 0.5; }

.xp-track {
  position: relative;
  height: 16px;
  border-radius: var(--r-pill);
  background: linear-gradient(to bottom, #e2e8f0, #f1f5f9);
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.18), inset 0 -1px 0 #fff;
  overflow: hidden;
}
.xp-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  border-radius: var(--r-pill);
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0) 55%),
    linear-gradient(90deg, #38bdf8, #a78bfa 55%, #f472b6);
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.7);
  transition: width 0.6s var(--ease);
}
.xp-shine {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.28) 0 8px, rgba(255, 255, 255, 0) 8px 20px);
  opacity: 0.5;
  pointer-events: none;
}

.streak-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--r-pill);
  background-image: linear-gradient(to bottom, #fff7ed, #ffedd5);
  border: 1px solid #fed7aa;
  box-shadow: 0 4px 0 #fdba74, 0 8px 16px -10px rgba(217, 119, 6, 0.9), inset 0 1px 0 #fff;
  font-size: 0.8rem;
  font-weight: 700;
  color: #9a3412;
}
.streak-chip b { font-size: 1.05rem; }

/* ============================ TABS ============================ */
.tabs {
  display: flex;
  gap: 6px;
  padding: 7px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 14px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: var(--ink-3);
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
}
.tab:hover { color: var(--ink-2); background: rgba(224, 242, 254, 0.7); }
.tab:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.35); outline-offset: 2px; }
.tab.is-active {
  color: #075985;
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(224, 242, 254, 0.9));
  box-shadow:
    inset 0 1px 0 #fff,
    0 3px 0 #bae6fd,
    0 8px 16px -10px rgba(2, 132, 199, 0.9);
}
.tab-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: linear-gradient(to bottom, #fda4af, #f43f5e);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 900;
  box-shadow: 0 2px 0 #be123c;
}

/* ============================ PANELS & CARDS ============================ */
main { flex: 1 0 auto; display: block; }

.panel { display: none; animation: panelIn 0.35s var(--ease); }
.panel.is-active { display: block; }
@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  box-shadow: var(--card-shadow), inset 0 1px 0 #fff;
  backdrop-filter: blur(12px);
  padding: clamp(16px, 2.4vw, 24px);
}
.card + .card { margin-top: 16px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h2 { font-size: clamp(1.05rem, 2.4vw, 1.22rem); letter-spacing: -0.01em; }
.card-head .muted { margin-top: 3px; }

.status-pill {
  flex: 0 0 auto;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #075985;
  background: linear-gradient(to bottom, #f0f9ff, #e0f2fe);
  border: 1px solid #bae6fd;
  box-shadow: inset 0 1px 0 #fff, 0 2px 6px -4px rgba(2, 132, 199, 0.8);
  white-space: nowrap;
}
.status-pill.is-running { color: #065f46; background: linear-gradient(to bottom, #ecfdf5, #d1fae5); border-color: #a7f3d0; }
.status-pill.is-break { color: #7c2d12; background: linear-gradient(to bottom, #fff7ed, #ffedd5); border-color: #fed7aa; }

/* ============================ FOCUS LAYOUT ============================ */
.focus-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 16px;
  align-items: start;
}
.focus-side { display: grid; gap: 16px; }

/* ============================ TIMER ============================ */
.timer-card { display: flex; flex-direction: column; }

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  padding: 5px;
  border-radius: 16px;
  background: linear-gradient(to bottom, #eef2f7, #f8fafc);
  box-shadow: inset 0 2px 5px rgba(15, 23, 42, 0.1), inset 0 -1px 0 #fff;
  margin-bottom: 14px;
}
.mode-btn {
  border: 0;
  padding: 9px 6px;
  border-radius: 12px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.18s var(--ease);
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.is-active {
  color: #075985;
  background-image: linear-gradient(to bottom, #ffffff, #e0f2fe);
  box-shadow: 0 2px 0 #bae6fd, 0 4px 10px -6px rgba(2, 132, 199, 0.9), inset 0 1px 0 #fff;
}
.mode-btn:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.35); outline-offset: 2px; }

.ring-wrap {
  position: relative;
  width: min(300px, 78vw);
  margin: 4px auto 8px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.ring { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.ring-track {
  fill: none;
  stroke: rgba(148, 163, 184, 0.22);
  stroke-width: 15;
}
.ring-progress {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 15;
  stroke-linecap: round;
  stroke-dasharray: 653.45;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.35s linear;
}

.ring-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
}
.time {
  font-size: clamp(2.6rem, 10vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #0c4a6e;
  text-shadow: 0 1px 0 #fff, 0 8px 20px rgba(2, 132, 199, 0.18);
}
.timer-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.session-dots { display: flex; gap: 5px; margin-top: 6px; height: 8px; }
.session-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.35);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.2);
}
.session-dots i.on {
  background: linear-gradient(to bottom, #fca5a5, #f87171);
  box-shadow: 0 1px 3px rgba(239, 68, 68, 0.6);
}

.timer-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
}

.timer-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 0.82rem;
  color: var(--ink-3);
  font-weight: 700;
}
.timer-meta b { color: var(--ink); font-size: 0.95rem; }

.timer-card.is-running .ring-progress { filter: url(#ringGlow) drop-shadow(0 0 6px rgba(167, 139, 250, 0.55)); }
.timer-card.is-break .time { color: #9a3412; }

/* ============================ AMBIENT ============================ */
.ambient-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.ambient-btn {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 13px 6px 11px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: var(--r-md);
  background-image: linear-gradient(to bottom, #ffffff, #f1f5f9);
  box-shadow: 0 4px 0 #dbe3ec, 0 8px 14px -10px rgba(15, 23, 42, 0.7), inset 0 1px 0 #fff;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--ink-2);
  transition: transform 0.1s var(--ease), box-shadow 0.1s var(--ease), background 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.ambient-btn:hover { background-image: linear-gradient(to bottom, #ffffff, #e0f2fe); }
.ambient-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #dbe3ec, inset 0 1px 0 #fff; }
.ambient-btn:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.35); outline-offset: 2px; }
.ambient-emoji { font-size: 1.5rem; line-height: 1; filter: drop-shadow(0 2px 2px rgba(15, 23, 42, 0.15)); }
.ambient-name { text-align: center; line-height: 1.15; }

.ambient-btn.is-on {
  color: #4c1d95;
  border-color: #c4b5fd;
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 45%, rgba(0, 0, 0, 0.07)),
    linear-gradient(to bottom, #ddd6fe, #a78bfa);
  box-shadow: 0 4px 0 #7c3aed, 0 10px 20px -12px rgba(124, 58, 237, 1), inset 0 1px 0 #fff;
}
.ambient-eq {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}
.ambient-eq i {
  width: 3px;
  height: 4px;
  border-radius: 2px;
  background: currentColor;
  animation: eq 0.9s ease-in-out infinite;
}
.ambient-eq i:nth-child(2) { animation-delay: 0.18s; }
.ambient-eq i:nth-child(3) { animation-delay: 0.36s; }
.ambient-btn.is-on .ambient-eq { opacity: 0.85; }
@keyframes eq {
  0%, 100% { height: 3px; }
  50% { height: 10px; }
}

.ambient-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.ambient-status { font-size: 0.8rem; font-weight: 800; color: var(--ink-3); }
.ambient-status.is-on { color: var(--lilac-600); }

.vol { display: inline-flex; align-items: center; gap: 7px; }
.vol-icon { font-size: 0.85rem; opacity: 0.7; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 108px;
  height: 8px;
  border-radius: var(--r-pill);
  background: linear-gradient(to right, #a78bfa var(--fill, 45%), #e2e8f0 var(--fill, 45%));
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.2);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background-image: radial-gradient(circle at 32% 28%, #ffffff, #c4b5fd 45%, #8b5cf6);
  box-shadow: 0 2px 0 #6d28d9, 0 3px 7px rgba(15, 23, 42, 0.25);
  border: 0;
}
input[type="range"]::-moz-range-thumb {
  width: 19px;
  height: 19px;
  border: 0;
  border-radius: 50%;
  background-image: radial-gradient(circle at 32% 28%, #ffffff, #c4b5fd 45%, #8b5cf6);
  box-shadow: 0 2px 0 #6d28d9;
}
input[type="range"]:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.35); outline-offset: 3px; }

/* ============================ STATS ============================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.stat-tile {
  display: grid;
  gap: 1px;
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow: inset 0 1px 0 #fff, 0 6px 14px -12px rgba(15, 23, 42, 0.9);
  position: relative;
  overflow: hidden;
}
.stat-tile b { font-size: 1.35rem; line-height: 1.1; letter-spacing: -0.02em; }
.stat-tile span:last-child { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.stat-emoji { position: absolute; right: 8px; top: 8px; font-size: 1rem; opacity: 0.55; }
.tile-sky { background-image: linear-gradient(150deg, #eff6ff, #dbeafe); }
.tile-mint { background-image: linear-gradient(150deg, #f0fdf4, #dcfce7); }
.tile-lilac { background-image: linear-gradient(150deg, #faf5ff, #ede9fe); }
.tile-peach { background-image: linear-gradient(150deg, #fff7ed, #ffedd5); }

/* ============================ TASK MANAGER ============================ */
.task-form {
  background: rgba(248, 250, 252, 0.7);
  border: 1px dashed rgba(148, 163, 184, 0.45);
  border-radius: var(--r-md);
  padding: 14px;
  margin-bottom: 16px;
}
.task-form-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
.task-form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.field { display: grid; gap: 5px; min-width: 0; }
.field-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
input[type="text"], input[type="password"], input[type="number"], input[type="time"], select {
  width: 100%;
  padding: 11px 13px;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(to bottom, #f8fafc, #ffffff);
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 13px;
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.07), 0 1px 0 #fff;
  transition: border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: linear-gradient(to bottom, #f8fafc, #ffffff), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0 0, right 13px center;
  padding-right: 34px;
}
input::placeholder { color: #94a3b8; font-weight: 500; }
input:focus, select:focus {
  outline: none;
  border-color: #7dd3fc;
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.05), 0 0 0 4px rgba(56, 189, 248, 0.22);
}

.prio-group {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  border-radius: 14px;
  background: linear-gradient(to bottom, #eef2f7, #f8fafc);
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.09);
}
.prio-btn {
  border: 0;
  padding: 7px 12px;
  border-radius: 10px;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.prio-btn:hover { color: var(--ink-2); }
.prio-btn.is-active {
  background-image: linear-gradient(to bottom, #ffffff, #f1f5f9);
  box-shadow: 0 1px 0 #cbd5e1, 0 3px 8px -5px rgba(15, 23, 42, 0.8), inset 0 1px 0 #fff;
  color: var(--ink);
}
.prio-btn:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.35); outline-offset: 1px; }

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.seg {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 13px;
  background: rgba(241, 245, 249, 0.9);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.1);
}
.seg-btn {
  border: 0;
  padding: 7px 14px;
  border-radius: 10px;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.16s var(--ease);
}
.seg-btn.is-active {
  color: #075985;
  background: #fff;
  box-shadow: 0 1px 0 #cbd5e1, 0 3px 8px -5px rgba(15, 23, 42, 0.8);
}

.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }

.task {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 2px 0 rgba(226, 232, 240, 0.9), 0 8px 18px -16px rgba(15, 23, 42, 1);
  animation: taskIn 0.28s var(--ease);
  position: relative;
  overflow: hidden;
}
@keyframes taskIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.99); }
  to { opacity: 1; transform: none; }
}
.task::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--prio-color, #cbd5e1);
}
.task.is-done { background: rgba(240, 253, 244, 0.92); }
.task.is-done .task-title { text-decoration: line-through; color: var(--ink-3); }

.task-check {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  background: linear-gradient(to bottom, #ffffff, #f1f5f9);
  box-shadow: 0 3px 0 #e2e8f0, inset 0 1px 0 #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  color: transparent;
  transition: all 0.14s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.task-check:hover { border-color: #7dd3fc; }
.task-check:active { transform: translateY(2px); box-shadow: 0 1px 0 #e2e8f0; }
.task.is-done .task-check {
  color: #fff;
  border-color: #059669;
  background-image: linear-gradient(to bottom, #6ee7b7, #10b981);
  box-shadow: 0 3px 0 #047857, 0 4px 10px -6px rgba(5, 150, 105, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.task-check:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.35); outline-offset: 2px; }

.task-body { min-width: 0; }
.task-title {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.task-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 5px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: #f1f5f9;
  color: var(--ink-2);
  border: 1px solid rgba(148, 163, 184, 0.3);
}
.chip-subject { color: #075985; background: #e0f2fe; border-color: #bae6fd; }
.chip-high { color: #991b1b; background: #fee2e2; border-color: #fecaca; }
.chip-med { color: #92400e; background: #fef3c7; border-color: #fde68a; }
.chip-low { color: #166534; background: #dcfce7; border-color: #bbf7d0; }
.chip-xp { color: #5b21b6; background: #ede9fe; border-color: #ddd6fe; }

.task-del {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: linear-gradient(to bottom, #fff, #f8fafc);
  box-shadow: 0 3px 0 #e2e8f0, inset 0 1px 0 #fff;
  cursor: pointer;
  color: #94a3b8;
  font-size: 0.9rem;
  display: grid;
  place-items: center;
  transition: all 0.14s var(--ease);
}
.task-del:hover { color: #e11d48; border-color: #fecdd3; background: linear-gradient(to bottom, #fff, #fff1f2); }
.task-del:active { transform: translateY(2px); box-shadow: 0 1px 0 #e2e8f0; }

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 26px 16px;
  text-align: center;
  color: var(--ink-3);
  font-size: 0.9rem;
  font-weight: 600;
}
.empty-emoji { font-size: 2rem; filter: drop-shadow(0 4px 6px rgba(15, 23, 42, 0.18)); }

/* ============================ PLANNER ============================ */
.plan-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px;
  background: rgba(248, 250, 252, 0.7);
  border: 1px dashed rgba(148, 163, 184, 0.45);
  border-radius: var(--r-md);
  margin-bottom: 16px;
}
.plan-form .field { flex: 0 1 auto; }
.plan-form .field-grow { flex: 1 1 170px; }
.field-day { min-width: 118px; }
.field-colors { flex: 0 1 auto; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; padding: 5px 0; }

/* Rounded dome only. The colour arrives as an INLINE background-color set
   from JavaScript, so nothing here may declare a background that wins:
   no `background:` shorthand, no !important, no gradients painted on top. */
.swatch {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.95);
  cursor: pointer;
  background-image: none;
  box-shadow:
    inset 0 -3px 6px rgba(15, 23, 42, 0.16),
    inset 0 2px 3px rgba(255, 255, 255, 0.55),
    0 3px 0 rgba(15, 23, 42, 0.18),
    0 5px 10px -6px rgba(15, 23, 42, 0.9);
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.is-active {
  transform: translateY(-2px) scale(1.1);
  box-shadow:
    0 0 0 3px #ffffff,
    0 0 0 5px #0f172a,
    0 6px 12px -6px rgba(15, 23, 42, 0.7);
}
.swatch.is-active::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 900;
  color: #0f172a;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.95);
}
.swatch:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.55); outline-offset: 3px; }

.timetable-scroll {
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: thin;
}
.timetable {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 9px;
  min-width: 100%;
}
.day-col {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 130px;
  padding: 8px;
  border-radius: var(--r-md);
  background: rgba(248, 250, 252, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.18);
}
.day-col.is-today {
  background: rgba(224, 242, 254, 0.72);
  border-color: #bae6fd;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.35);
}
.day-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 2px 3px 4px;
  border-bottom: 1px dashed var(--line);
}
.day-head .dot-today {
  width: 7px; height: 7px; border-radius: 50%; background: #0ea5e9;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.18);
}
/* background-color is set inline per slot; keep a dark ink colour here so
   text stays readable on every pastel. */
.slot {
  position: relative;
  padding: 8px 9px 9px;
  border-radius: 12px;
  color: #111827;
  background-image: none;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 2px 0 rgba(15, 23, 42, 0.14), 0 6px 12px -10px rgba(15, 23, 42, 1);
  animation: taskIn 0.25s var(--ease);
}
.slot-time { font-size: 0.66rem; font-weight: 900; letter-spacing: 0.03em; color: #1f2937; opacity: 0.85; font-variant-numeric: tabular-nums; }
.slot-subject { font-size: 0.82rem; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; margin-top: 1px; }
.slot-del {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 19px;
  height: 19px;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  color: #475569;
  font-size: 0.62rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s var(--ease), background 0.15s var(--ease);
  padding: 0;
}
.slot:hover .slot-del, .slot-del:focus-visible { opacity: 1; }
.slot-del:hover { background: #fee2e2; color: #be123c; }

.slot.is-now {
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.95), 0 8px 18px -8px rgba(2, 132, 199, 0.95);
  animation: nowGlow 2.4s ease-in-out infinite;
}
.slot.is-now::after {
  content: "●";
  position: absolute;
  top: 4px;
  left: -2px;
  transform: translateX(-120%);
  color: #ef4444;
  font-size: 0.7rem;
  animation: pulseDot 1.8s infinite;
}
@keyframes nowGlow {
  0%, 100% { box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.9), 0 8px 18px -8px rgba(2, 132, 199, 0.9); }
  50% { box-shadow: 0 0 0 6px rgba(14, 165, 233, 0.25), 0 8px 22px -6px rgba(2, 132, 199, 1); }
}

/* ============================ BADGES / LADDER ============================ */
.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.badge-card {
  display: grid;
  justify-items: center;
  gap: 7px;
  padding: 16px 12px 14px;
  border-radius: var(--r-lg);
  text-align: center;
  background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.95), rgba(241, 245, 249, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 #e2e8f0, 0 12px 24px -20px rgba(15, 23, 42, 1), inset 0 1px 0 #fff;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.badge-card.is-unlocked:hover { transform: translateY(-3px); box-shadow: 0 7px 0 #e2e8f0, 0 18px 28px -20px rgba(15, 23, 42, 1); }

.badge-medal {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.9rem;
  background-image:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 46%),
    linear-gradient(150deg, var(--m1, #bae6fd), var(--m2, #0284c7));
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.85),
    inset 0 -5px 10px rgba(0, 0, 0, 0.18),
    0 5px 0 var(--m3, #075985),
    0 12px 20px -10px rgba(15, 23, 42, 0.85);
  filter: grayscale(0.92) opacity(0.55);
  transition: filter 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.badge-card.is-unlocked .badge-medal { filter: none; }
.badge-card.is-unlocked .badge-medal::after {
  content: "✓";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 900;
  color: #fff;
  background-image: linear-gradient(to bottom, #6ee7b7, #10b981);
  box-shadow: 0 2px 0 #047857, 0 0 0 3px #fff;
}
.badge-name { font-size: 0.9rem; font-weight: 900; line-height: 1.2; }
.badge-desc { font-size: 0.75rem; color: var(--ink-3); font-weight: 600; line-height: 1.3; }
.badge-state {
  margin-top: 2px;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  color: var(--ink-3);
  background: #f1f5f9;
  border: 1px solid rgba(148, 163, 184, 0.3);
}
.badge-card.is-unlocked .badge-state { color: #065f46; background: #dcfce7; border-color: #86efac; }

.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rung {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 14px;
  background: rgba(248, 250, 252, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.16);
  transition: all 0.2s var(--ease);
}
.rung.is-reached { background-image: linear-gradient(to right, #f0f9ff, #faf5ff); border-color: #ddd6fe; }
.rung.is-current {
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0)),
    linear-gradient(to right, #e0f2fe, #ede9fe 60%, #fce7f3);
  border-color: #a78bfa;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.35), 0 8px 18px -14px rgba(124, 58, 237, 1);
}
.rung-num {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.9rem;
  color: var(--ink-3);
  background: linear-gradient(to bottom, #ffffff, #eef2f7);
  box-shadow: 0 2px 0 #dbe3ec, inset 0 1px 0 #fff;
}
.rung.is-reached .rung-num { color: #5b21b6; background-image: linear-gradient(to bottom, #ede9fe, #ddd6fe); box-shadow: 0 2px 0 #c4b5fd, inset 0 1px 0 #fff; }
.rung-name { font-weight: 800; font-size: 0.9rem; }
.rung-xp { font-size: 0.75rem; font-weight: 800; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rung.is-current .rung-xp { color: var(--lilac-600); }

/* ============================ FOOTER ============================ */
.site-footer {
  margin-top: 8px;
  padding: 16px 8px 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.28);
  text-align: center;
}
.credits {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 4px 8px;
  font-size: 0.74rem;
  line-height: 1.7;
  color: var(--ink-3);
  font-weight: 600;
}
.credits strong { color: var(--ink-2); font-weight: 800; }
.credits-sep { opacity: 0.35; }
.credits a { color: #0369a1; font-weight: 700; word-break: break-word; }

/* ============================ MODALS ============================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s var(--ease);
  overflow-y: auto;
}
.modal[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  position: relative;
  width: 90%;
  max-width: 420px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 2rem;
  border-radius: 26px;
  /* glossy 3D shell: pastel core, white sheen, physical bottom lip */
  background-color: #ffffff;
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.82)),
    linear-gradient(150deg, #e0f2fe, #faf5ff 55%, #f0fdf4);
  border: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    0 26px 60px -18px rgba(15, 23, 42, 0.55),
    0 8px 0 -3px rgba(226, 232, 240, 0.85),
    inset 0 2px 0 #ffffff,
    inset 0 -6px 14px rgba(2, 132, 199, 0.1);
  animation: modalIn 0.28s var(--ease);
  overscroll-behavior: contain;
}
.modal-box::before {
  content: "";
  position: absolute;
  inset: 6px 6px auto;
  height: 42%;
  border-radius: 20px 20px 40px 40px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0));
  pointer-events: none;
}
.modal-box > * { position: relative; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.modal-box h2 { font-size: 1.22rem; letter-spacing: -0.01em; margin-bottom: 4px; }
.modal-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(to bottom, #fff, #f1f5f9);
  box-shadow: 0 2px 0 #e2e8f0;
  cursor: pointer;
  color: var(--ink-3);
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}
.modal-x:hover { color: #e11d48; }
.modal-x:active { transform: translateY(2px); box-shadow: none; }

.disclaimer {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: linear-gradient(to bottom, #fffbeb, #fef3c7);
  border: 1px solid #fcd34d;
  box-shadow: inset 0 1px 0 #fff, 0 3px 0 rgba(251, 191, 36, 0.35);
  font-size: 0.78rem;
  line-height: 1.5;
  color: #78350f;
  font-weight: 600;
}
.disclaimer-head {
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: #b45309;
  margin-bottom: 4px;
}
.disclaimer p + p { margin-top: 6px; }
.disclaimer .hi { font-size: 0.8rem; color: #92400e; }

.sync-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.badge-sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  font-size: 0.76rem;
  font-weight: 800;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}
.badge-sync.is-cloud { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }

/* iOS Safari zooms any focused field below 16px — keep them all at 16px. */
input,
select,
textarea {
  font-size: 16px !important;
}

.id-form { display: grid; gap: 12px; }
.id-form-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 2px; }
.form-msg {
  font-size: 0.8rem;
  font-weight: 800;
  padding: 9px 12px;
  border-radius: 12px;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.form-msg.is-ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }

.cloud-panel {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(to bottom, #f0fdf4, #ffffff);
  border: 1px solid #bbf7d0;
  margin-bottom: 12px;
}
.cloud-hello { font-weight: 900; color: #065f46; font-size: 1rem; }
.cloud-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.cloud-actions .btn { flex: 1 1 130px; }

.durations { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.durations .field { position: relative; }
.durations .unit {
  position: absolute;
  right: 10px;
  bottom: 11px;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--ink-3);
  pointer-events: none;
  text-transform: uppercase;
}
.durations input { padding-right: 38px; }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 4px;
  font-size: 0.86rem;
  font-weight: 700;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}
.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 48px;
  height: 27px;
  flex: 0 0 auto;
  border-radius: var(--r-pill);
  background: linear-gradient(to bottom, #e2e8f0, #f1f5f9);
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.2);
  position: relative;
  cursor: pointer;
  transition: background 0.2s var(--ease);
  border: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background-image: radial-gradient(circle at 35% 30%, #ffffff, #f1f5f9);
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.3);
  transition: transform 0.2s var(--ease);
}
.switch:checked { background: linear-gradient(to bottom, #6ee7b7, #10b981); }
.switch:checked::after { transform: translateX(21px); }
.switch:focus-visible { outline: 3px solid rgba(124, 58, 237, 0.4); outline-offset: 2px; }

.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.modal-actions .btn { flex: 1 1 150px; }

/* ============================ CONFIRM MODAL ============================ */
.modal-confirm { text-align: center; }

.confirm-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  border-radius: 19px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  background-image:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 60%),
    linear-gradient(150deg, #fecdd3, #fb7185 55%, #e11d48);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -4px 8px rgba(0, 0, 0, 0.18),
    0 5px 0 #9f1239,
    0 12px 22px -10px rgba(159, 18, 57, 0.9);
}
.confirm-icon.is-safe {
  background-image:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 60%),
    linear-gradient(150deg, #a7f3d0, #34d399 55%, #059669);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    inset 0 -4px 8px rgba(0, 0, 0, 0.18),
    0 5px 0 #047857,
    0 12px 22px -10px rgba(4, 120, 87, 0.9);
}

.modal-confirm h2 { font-size: 1.2rem; }
.modal-confirm .confirm-desc {
  margin: 8px 0 4px;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink-2);
}
.confirm-desc b {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 7px;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  color: #92400e;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.86em;
  letter-spacing: 0.02em;
}

.confirm-field {
  margin: 14px 0 2px;
  text-align: left;
}
.confirm-field input {
  text-align: center;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.confirm-field input.is-match {
  border-color: #34d399;
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.05), 0 0 0 4px rgba(52, 211, 153, 0.22);
}
.confirm-field input.is-mismatch {
  border-color: #fca5a5;
  box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.05), 0 0 0 4px rgba(248, 113, 113, 0.16);
}
.confirm-hint {
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-3);
}
.confirm-hint.is-match { color: var(--mint-600); }

.modal-confirm .modal-actions { margin-top: 18px; }
.modal-confirm .modal-actions .btn { flex: 1 1 0; }
.btn:disabled {
  filter: grayscale(0.45) brightness(0.98);
  box-shadow: 0 2px 0 var(--btn-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  transform: none;
}

/* ============================ VISIT COUNTER ============================ */
.visit-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: var(--r-pill);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #075985;
  background-image: linear-gradient(to bottom, #ffffff, #e0f2fe);
  border: 1px solid #bae6fd;
  box-shadow: 0 2px 0 #bae6fd, inset 0 1px 0 #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.visit-badge[hidden] { display: none !important; }
.visit-badge.is-live { animation: visitPop 0.5s var(--ease); }
@keyframes visitPop {
  0% { transform: scale(0.9); opacity: 0.4; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* ============================ TOASTS & FX ============================ */
#fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 120;
}

.toasts {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 130;
  display: grid;
  gap: 8px;
  width: min(420px, calc(100% - 24px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 15px;
  border-radius: 15px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 rgba(226, 232, 240, 0.9), 0 16px 30px -14px rgba(15, 23, 42, 0.6);
  animation: toastIn 0.3s var(--ease);
}
.toast.is-out { animation: toastOut 0.28s var(--ease) forwards; }
.toast-emoji { font-size: 1.05rem; }
.toast.is-success { background: linear-gradient(to bottom, #f0fdf4, #dcfce7); border-color: #bbf7d0; }
.toast.is-error { background: linear-gradient(to bottom, #fff1f2, #ffe4e6); border-color: #fecdd3; }
.toast.is-xp { background: linear-gradient(to bottom, #faf5ff, #ede9fe); border-color: #ddd6fe; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px) scale(0.97); }
}

/* ============================ RESPONSIVE ============================ */
@media (max-width: 900px) {
  .focus-grid { grid-template-columns: 1fr; }
  .ambient-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
  .app { gap: 12px; padding: 14px 12px 8px; }
  .topbar { gap: 10px; }
  .brand-mark { width: 44px; height: 44px; border-radius: 15px; }
  .top-actions { width: 100%; justify-content: flex-start; gap: 8px; }
  .sync-chip { order: 3; width: 100%; justify-content: center; }
  .top-actions .btn { flex: 1 1 auto; }
  .xpstrip { gap: 10px; padding: 10px 12px; }
  .lvl-badge { width: 48px; height: 48px; border-radius: 16px; }
  .lvl-badge-num { font-size: 1.2rem; }
  .streak-chip { padding: 7px 11px; }
  .streak-chip .streak-label { display: none; }
  .tabs { border-radius: 18px; padding: 6px; }
  .tab { flex: 0 0 auto; padding: 10px 12px; font-size: 0.82rem; }
  .tab span { }
  .task-form-main { grid-template-columns: 1fr; }
  .task-form-foot { flex-direction: column; align-items: stretch; }
  .task-form-foot .btn { width: 100%; }
  .prio-group { display: grid; grid-template-columns: repeat(3, 1fr); }
  .plan-form { flex-direction: column; align-items: stretch; }
  .plan-form .field, .plan-form .field-grow, .plan-form .field-day { flex: 1 1 auto; width: 100%; }
  .plan-form .btn { width: 100%; }
  .timetable { grid-template-columns: repeat(7, minmax(104px, 1fr)); }
  .timer-controls .btn { flex: 1 1 auto; }
  .timer-controls .btn-lg { flex: 1 1 100%; }
  .durations { grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
  .durations input { padding: 9px 30px 9px 9px; font-size: 0.85rem; }
  .durations .unit { right: 7px; bottom: 8px; font-size: 0.6rem; }
  .id-form-actions { grid-template-columns: 1fr; }
  .modal-box { padding: 1.5rem; border-radius: 22px; }
  .confirm-icon { width: 50px; height: 50px; font-size: 1.4rem; margin-bottom: 10px; }
  .credits { font-size: 0.68rem; gap: 2px 6px; }
  .visit-badge { font-size: 0.66rem; padding: 3px 9px; }
  .credits-sep { display: none; }
  .badge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .badge-medal { width: 62px; height: 62px; font-size: 1.6rem; }
  .stat-grid { gap: 8px; }
}

@media (max-width: 380px) {
  .ambient-grid { grid-template-columns: 1fr; }
  .ambient-btn { grid-template-columns: auto 1fr auto; justify-items: start; align-items: center; padding: 10px 12px; }
  .ambient-name { text-align: left; }
  .badge-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
