:root {
  --bg: #EEF4FA;
  --surface: #FFFFFF;
  --ink: #22303B;
  --muted: #7E8A92;
  --muted-soft: #8C97A0;
  --muted-softer: #9DA8B0;
  --hairline: #DDE6EE;
  --track: #E4ECF3;
  --track-warm: #E0E8F0;
  --flame: #2C8FE0;
  --flame-dark: #1E6FB8;
  --flame-text: #1E6FB8;
  --amber: #F4A52A;
  --warm-pill-bg: #E5F1FB;
  --warm-pill-border: #C9E2F6;
  --teal: #1FB6A6;
  --teal-dark: #178B80;
  --teal-track: #DCEEEA;
  --teal-border: #CDE7E2;
  --blue: #3FA9F5;
  --green: #34C77B;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Nunito', sans-serif;
}
.app { min-height: 100vh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; }

/* ---------- shared type ---------- */
.display { font-family: 'Baloo 2', sans-serif; font-weight: 800; }

/* ---------- pressable buttons ---------- */
button { font-family: 'Nunito', sans-serif; cursor: pointer; }
.btn-flame {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--flame); color: #fff; border: none; border-radius: 18px;
  font-family: 'Baloo 2', sans-serif; font-weight: 800;
  box-shadow: 0 5px 0 var(--flame-dark); transition: transform .06s, box-shadow .06s;
}
.btn-flame:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--flame-dark); }
.btn-neutral {
  background: #fff; color: var(--ink); border: 1px solid var(--hairline); border-radius: 16px;
  font-family: 'Baloo 2', sans-serif; font-weight: 700;
  box-shadow: 0 4px 0 var(--hairline); transition: transform .06s, box-shadow .06s;
}
.btn-neutral:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--hairline); }
.btn-teal {
  background: var(--teal); color: #fff; border: none; border-radius: 16px;
  font-family: 'Baloo 2', sans-serif; font-weight: 800;
  box-shadow: 0 5px 0 var(--teal-dark); transition: transform .06s, box-shadow .06s;
}
.btn-teal:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--teal-dark); }
.btn-teal-neutral {
  background: #fff; color: var(--ink); border: 1px solid var(--teal-border); border-radius: 16px;
  font-family: 'Baloo 2', sans-serif; font-weight: 700;
  box-shadow: 0 4px 0 var(--teal-border); transition: transform .06s, box-shadow .06s;
}
.btn-teal-neutral:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--teal-border); }
.btn-ghost {
  background: none; border: none; color: var(--muted-softer);
  font-weight: 800; font-size: 14px; padding: 15px 14px;
}

/* ---------- app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(238, 244, 250, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
  padding: 0 28px; height: 66px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 9px; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 23px; letter-spacing: -0.5px; }
.logo .flame-emoji { font-size: 26px; }
.appbar-right { display: flex; align-items: center; gap: 12px; }
.streak-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--warm-pill-bg); border: 1px solid var(--warm-pill-border);
  border-radius: 999px; padding: 7px 15px 7px 12px;
}
.streak-pill .num { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 18px; color: var(--flame-text); }
.streak-pill .lbl { font-size: 12px; font-weight: 800; color: #7CA3C4; letter-spacing: 0.3px; }
.level-pill {
  display: flex; align-items: center; gap: 9px;
  background: #fff; border: 1px solid var(--hairline); border-radius: 999px; padding: 7px 15px;
}
.level-pill .lvl { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 15px; }
.xp-track { width: 74px; height: 8px; border-radius: 999px; background: var(--hairline); overflow: hidden; }
.xp-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--amber), var(--flame)); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 14px; border: 1px solid var(--hairline);
  background: #fff; font-size: 18px; box-shadow: 0 2px 0 var(--hairline);
  transition: transform .06s, box-shadow .06s;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 0 0 var(--hairline); }
.flicker { display: inline-block; animation: flick 2.8s ease-in-out infinite; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 26px; padding: 28px;
  box-shadow: 0 2px 0 var(--hairline), 0 10px 30px rgba(43, 38, 32, 0.04);
}

/* ---------- home ---------- */
.home {
  width: 100%; max-width: 1060px; margin: 0 auto; padding: 30px 28px 56px;
  display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; align-items: start;
}
.col { display: flex; flex-direction: column; gap: 22px; }
.h1 { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 26px; letter-spacing: -0.5px; }
.subtext { color: var(--muted); font-weight: 600; margin-top: 4px; margin-bottom: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.chip {
  display: flex; align-items: center; gap: 9px; padding: 10px 15px; border-radius: 999px;
  border: 2px solid var(--hairline); background: #fff; color: var(--muted);
  font-weight: 800; font-size: 14.5px; transition: transform .08s;
}
.chip:active { transform: scale(0.96); }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.switch-topic { margin-top: 20px; width: 100%; border-top: 1px solid var(--hairline); padding-top: 16px; }
.switch-topic-label { font-weight: 800; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; text-align: center; }
.switch-topic .chips { justify-content: center; margin-bottom: 0; }
.start-btn { width: 100%; padding: 18px; font-size: 21px; }
.start-btn .arrow { font-size: 22px; }
.adjust-line {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  margin-top: 14px; background: none; border: none; font-weight: 700; font-size: 13.5px; color: var(--muted-soft);
}
.adjust-line:active { opacity: 0.7; }
.adjust-line .adjust { color: var(--flame-text); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; }

.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 20px; }
.manage-btn {
  border: 1px solid var(--hairline); background: var(--bg); border-radius: 11px; padding: 7px 14px;
  font-weight: 800; font-size: 13px; color: #5E6B74;
}
.manage-btn:active { transform: translateY(1px); }
.chips-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.chips-label { font-weight: 800; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.empty-hint { color: var(--muted); font-weight: 700; font-size: 14px; }

/* streak hero */
.hero {
  background: linear-gradient(160deg, #F0F7FE, #E2EFFB); border: 1px solid var(--warm-pill-border);
  border-radius: 26px; padding: 30px 24px; text-align: center;
  box-shadow: 0 2px 0 #C9E2F6, 0 10px 30px rgba(44, 143, 224, 0.08);
}
.snowball {
  width: 88px; height: 88px; border-radius: 50%; margin: 0 auto;
  background: radial-gradient(circle at 34% 28%, #ffffff 0%, #EAF3FC 55%, #C9DEF2 100%);
  box-shadow: 0 8px 16px rgba(44, 143, 224, 0.22),
              inset -7px -9px 16px rgba(120, 160, 200, 0.22),
              inset 7px 9px 14px rgba(255, 255, 255, 0.9);
}
.hero-num { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 66px; line-height: 1; color: var(--flame-text); margin-top: 6px; }
.hero-lbl { font-weight: 800; color: #7CA3C4; letter-spacing: 1px; font-size: 13px; text-transform: uppercase; margin-top: 2px; }
.hero-best {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 16px;
  background: rgba(255, 255, 255, 0.65); border: 1px solid #C9E2F6; border-radius: 999px;
  padding: 6px 14px; font-weight: 800; font-size: 13px; color: #5A82A6;
}

/* daily goal */
.goal { display: flex; align-items: center; gap: 22px; padding: 26px; }
.ring-wrap { position: relative; flex: none; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.goal-pct { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 22px; }
.goal-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 18px; }
.goal-sub { color: var(--muted); font-weight: 700; font-size: 14px; margin-top: 3px; }
.goal-msg { color: var(--green); font-weight: 800; font-size: 13px; margin-top: 8px; }
.goal { position: relative; }
.goal-gear { position: absolute; top: 12px; right: 14px; background: none; border: none; padding: 4px; font-size: 17px; line-height: 1; cursor: pointer; opacity: 0.55; transition: opacity .12s, transform .06s; }
.goal-gear:hover { opacity: 1; }
.goal-gear:active { transform: scale(0.9); }

/* stats row */
.stats-row { display: flex; gap: 14px; }
.stat-card { flex: 1; background: #fff; border: 1px solid var(--hairline); border-radius: 22px; padding: 20px; box-shadow: 0 2px 0 var(--hairline); }
.stat-emoji { font-size: 22px; }
.stat-val { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 24px; margin-top: 6px; }
.stat-lbl { color: var(--muted); font-weight: 800; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* achievements */
.achv-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 18px; margin-bottom: 16px; }
.achv-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.achv { text-align: center; padding: 14px 6px; border-radius: 16px; }
.achv-icon { font-size: 28px; }
.achv-name { font-weight: 800; font-size: 12px; margin-top: 6px; line-height: 1.2; }

/* ---------- inline timer card (on the dashboard) ---------- */
.timer-card-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 4px 0 2px; }
.timer-card .controls { margin-top: 2px; }
.timer-emoji { font-size: 38px; line-height: 1; }

/* ---------- focus / break (shared timer bits) ---------- */
.timer-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; }
.focus-bg { background: radial-gradient(circle at 50% 30%, #F0F7FE, #EEF4FA 70%); }
.break-bg { background: radial-gradient(circle at 50% 30%, #E8F7F4, #EEF4FA 70%); }
.topic-pill { display: inline-flex; align-items: center; gap: 9px; border-radius: 999px; padding: 9px 18px; margin-bottom: 8px; border: 1px solid; }
.topic-pill .name { font-weight: 800; font-size: 15px; }
.phase-label-sm { font-weight: 800; letter-spacing: 2px; text-transform: uppercase; font-size: 13px; margin-bottom: 18px; }
.ring-area { position: relative; }
.ring-readout { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-clock { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 64px; line-height: 1; letter-spacing: -1px; }
.ring-status { color: var(--muted); font-weight: 800; font-size: 13px; margin-top: 6px; }
.motiv { color: var(--muted); font-weight: 700; font-size: 15px; margin-top: 22px; max-width: 360px; text-align: center; }
.controls { display: flex; align-items: center; gap: 14px; margin-top: 26px; }
.break-emoji { font-size: 54px; margin-bottom: 6px; }
.break-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 32px; letter-spacing: -0.5px; }
.break-msg { color: #6B8C86; font-weight: 700; font-size: 15px; margin: 6px 0 24px; max-width: 360px; text-align: center; }
.break-clock { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 58px; letter-spacing: -1px; }

/* ---------- modals ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(43, 38, 32, 0.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 24px; animation: overlayIn .18s ease;
}
.modal { background: #fff; border-radius: 26px; padding: 30px; width: 440px; max-width: 100%; box-shadow: 0 24px 60px rgba(43, 38, 32, 0.3); }
.modal.wide { width: 480px; max-height: 84vh; overflow: auto; }
.date-range { display: flex; gap: 12px; margin-bottom: 18px; }
.date-field { display: flex; flex-direction: column; gap: 6px; flex: 1; font-weight: 800; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.date-field input { font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 15px; color: var(--ink); background: var(--bg); border: 1px solid var(--hairline); border-radius: 12px; padding: 10px 12px; }
.stats-summary { display: flex; gap: 12px; margin-bottom: 18px; }
.stats-summary .stat-card { flex: 1; }
.chart-block { margin-bottom: 8px; position: relative; }
.line-chart { width: 100%; height: 180px; display: block; }
.chart-marker { position: absolute; width: 11px; height: 11px; border-radius: 50%; background: #3FA9F5; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(63,169,245,0.35); transform: translate(-50%, -50%); pointer-events: none; z-index: 4; }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--ink); color: #fff; font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 12px; padding: 6px 9px; border-radius: 9px; white-space: nowrap; box-shadow: 0 4px 14px rgba(34,48,59,0.22); }
.chart-axis { display: flex; justify-content: space-between; font-weight: 700; font-size: 12px; color: var(--muted); margin: 4px 2px 18px; }
.srows { display: flex; flex-direction: column; gap: 12px; }
.srow { display: flex; align-items: center; gap: 10px; }
.srow-name { font-weight: 800; font-size: 15px; color: var(--ink); }
.srow-time { margin-left: auto; font-weight: 800; font-size: 14px; color: var(--muted); }
/* Settings modal: cap height and scroll the rows so the title + Done stay pinned. */
#settings-card { display: flex; flex-direction: column; max-height: 88vh; }
#settings-card .modal-head, #settings-card .modal-done { flex: none; }
#settings-card .setting-rows { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.modal-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 24px; }
.close-btn { width: 36px; height: 36px; border-radius: 11px; border: 1px solid var(--hairline); background: var(--bg); font-size: 16px; }
.setting-rows { display: flex; flex-direction: column; gap: 14px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--bg); border: 1px solid var(--hairline); border-radius: 16px; }
.setting-label { font-weight: 800; font-size: 15px; }
.setting-hint { color: var(--muted); font-weight: 700; font-size: 12.5px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.step-btn { width: 38px; height: 38px; border-radius: 11px; border: 1px solid var(--hairline); background: #fff; font-size: 20px; font-weight: 800; color: #5E6B74; box-shadow: 0 3px 0 var(--hairline); transition: transform .06s, box-shadow .06s; }
.step-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--hairline); }
.step-field { display: flex; align-items: baseline; gap: 5px; min-width: 96px; justify-content: center; white-space: nowrap; }
.step-input { width: 56px; text-align: right; border: 1px solid var(--hairline); background: #fff; border-radius: 8px; padding: 6px 8px; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 19px; color: var(--ink); outline: none; -moz-appearance: textfield; }
.step-input:focus { border-color: var(--flame); }
.step-unit { font-weight: 700; font-size: 13px; color: var(--muted); }
.toggle { width: 52px; height: 30px; flex: none; border-radius: 999px; border: 1px solid var(--hairline); background: #E4ECF3; position: relative; padding: 0; transition: background .15s, border-color .15s; }
.toggle .knob { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(43, 38, 32, 0.25); transition: left .15s; }
.toggle.on { background: var(--flame); border-color: var(--flame); }
.toggle.on .knob { left: 27px; }
.modal-done { width: 100%; margin-top: 22px; padding: 15px; font-size: 18px; }

.topic-rows { display: flex; flex-direction: column; gap: 12px; }
.topic-row { padding: 14px 16px; background: var(--bg); border: 1px solid var(--hairline); border-radius: 16px; }
.topic-row-top { display: flex; align-items: center; gap: 12px; }
.topic-dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.topic-name-input { flex: 1; min-width: 0; border: none; border-bottom: 1.5px solid var(--hairline); background: none; padding: 2px 0; font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 15px; color: var(--ink); outline: none; transition: border-color .12s ease, background-color .12s ease; }
.topic-name-input:hover { border-bottom-color: var(--muted); }
.topic-name-input:focus { border-bottom-color: var(--blue); background: rgba(63,169,245,0.08); }
.topic-edit-icon { flex: none; font-size: 12px; line-height: 1; opacity: .35; transition: opacity .12s ease; cursor: text; }
.topic-row-top:hover .topic-edit-icon, .topic-name-input:focus + .topic-edit-icon { opacity: .8; }
.topic-time { font-weight: 800; font-size: 13px; color: var(--muted); }
.archive-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--hairline); background: #fff; font-size: 14px; }
.swatches { display: flex; gap: 8px; margin-top: 12px; padding-left: 28px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; padding: 0; cursor: pointer; }
.add-block { margin-top: 18px; padding: 16px; border: 2px dashed #D2DEE8; border-radius: 16px; }
.add-label { font-weight: 800; font-size: 14px; color: #5E6B74; margin-bottom: 10px; }
.add-row { display: flex; gap: 10px; }
.add-input { flex: 1; border: 1px solid var(--hairline); background: #fff; border-radius: 12px; padding: 11px 14px; font-family: 'Nunito', sans-serif; font-weight: 700; font-size: 14px; color: var(--ink); outline: none; }
.add-btn { background: var(--flame); color: #fff; border: none; border-radius: 12px; padding: 0 22px; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 15px; box-shadow: 0 4px 0 var(--flame-dark); transition: transform .06s, box-shadow .06s; }
.add-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--flame-dark); }
.add-swatches { display: flex; gap: 9px; margin-top: 12px; }
.add-swatches .swatch { width: 26px; height: 26px; }

/* ---------- celebration ---------- */
.celebration { position: fixed; inset: 0; z-index: 50; background: rgba(43, 38, 32, 0.55); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; animation: overlayIn .2s ease; overflow: hidden; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti span { position: absolute; top: 0; border-radius: 2px; }
.celeb-card { position: relative; background: #fff; border-radius: 30px; padding: 42px 40px; width: 380px; max-width: 90vw; text-align: center; box-shadow: 0 24px 60px rgba(43, 38, 32, 0.3); animation: pop .4s cubic-bezier(.2, .9, .3, 1.2); }
.celeb-icon { font-size: 78px; line-height: 1; }
.celeb-title { font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 30px; margin-top: 10px; letter-spacing: -0.5px; }
.celeb-desc { color: var(--muted); font-weight: 700; font-size: 15px; margin-top: 6px; }
.celeb-xp { display: inline-flex; align-items: center; gap: 8px; margin-top: 20px; background: var(--warm-pill-bg); border: 1px solid var(--warm-pill-border); border-radius: 999px; padding: 9px 18px; font-family: 'Baloo 2', sans-serif; font-weight: 800; font-size: 18px; color: var(--flame-text); }
.celeb-cta { width: 100%; margin-top: 24px; padding: 16px; font-size: 18px; }

/* ---------- animations ---------- */
@keyframes flick { 0%, 100% { transform: scale(1) rotate(-2deg); } 50% { transform: scale(1.08) rotate(2deg); } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
@keyframes confFall { 0% { transform: translateY(-20px) rotate(0deg); opacity: 1; } 100% { transform: translateY(420px) rotate(540deg); opacity: 0; } }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .flicker { animation: none !important; }
  .confetti { display: none !important; }
}

@media (max-width: 860px) {
  .home { grid-template-columns: 1fr; }
}

/* ---------- auth control ---------- */
.auth-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 999px;
  background: #2C8FE0; color: #fff; font-weight: 800;
  text-decoration: none; font-size: 14px;
}
.auth-user { display: inline-flex; align-items: center; gap: 8px; }
.auth-avatar {
  width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
}
.auth-avatar--blank { background: #cfe6fb; color: #1c4f7c; font-weight: 800; }
.auth-name { font-weight: 700; color: #22303B; font-size: 14px; }
.auth-signout {
  border: none; background: transparent; color: #6b8197;
  font-weight: 700; cursor: pointer; font-size: 13px;
}
.auth-signout:hover { color: #2C8FE0; }
.guest-banner {
  display: flex; align-items: center; gap: 12px;
  background: #eaf4fd; border: 1px solid #cfe6fb; border-radius: 16px;
  padding: 10px 16px; margin-bottom: 16px; color: #1c4f7c; font-weight: 700;
}

#afk-card .step-input, #rm-count { border: 1px solid var(--hairline); border-radius: 10px; padding: 8px; font-weight: 800; font-size: 15px; }
#afk-card .switch-topic { border-top: 1px solid var(--hairline); padding-top: 16px; }
