/* Kosmos. Order and ornament. A mosaic look: tile colours, grout-dark outlines,
   hard shadows, one job per screen. Day is cool white marble. Night is a star vault. */

@font-face { font-family: "Fredoka"; font-weight: 500; font-display: swap; src: url("../fonts/fredoka-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 600; font-display: swap; src: url("../fonts/fredoka-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Fredoka"; font-weight: 700; font-display: swap; src: url("../fonts/fredoka-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 400; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("../fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2"); }

:root {
  --bg: #F0F1FA;
  --card: #FFFFFF;
  --text: #161E57;
  --muted: #555C8F;
  --edge: #161E57;
  --shade: #161E57;
  --soft: #E1E3F5;
  --bed: #DCDEEE;
  --gold: #F5B82E;
  --pop: #F0567A;
  --go: #2CCFB8;
  --sky: #8DB6FF;
  --on: #161E57;
  --display: "Fredoka", "Trebuchet MS", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 20px;
  --lift: 4px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1440;
    --card: #1A2363;
    --text: #F2F1FF;
    --muted: #AEB4E6;
    --edge: #6072DE;
    --shade: #050823;
    --soft: #26307A;
    --bed: #0A0F33;
    --gold: #FFCB47;
    --pop: #FF7C9C;
    --go: #46DBC6;
    --sky: #9CC0FF;
    --on: #161E57;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* ---- frame ---- */

.shell {
  max-width: 34rem;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
}
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.purse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 2px solid var(--edge);
  border-radius: 99px;
  background: var(--gold);
  color: var(--on);
  box-shadow: 3px 3px 0 var(--shade);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.purse .tile-ic { color: var(--card); }
.purse.bump { animation: bump 0.45s ease; }
.band {
  height: 10px;
  margin: 0 max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px));
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 10px, transparent 10px 13px, var(--go) 13px 23px, transparent 23px 26px, var(--pop) 26px 36px, transparent 36px 39px, var(--sky) 39px 49px, transparent 49px 52px);
}
@keyframes bump { 40% { transform: scale(1.18) rotate(-3deg); } }

.page {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.page.solo { padding-top: calc(20px + env(safe-area-inset-top, 0px)); padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px)); }

.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 8px max(10px, env(safe-area-inset-right, 0px)) calc(8px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
  background: var(--card);
  border-top: 2px solid var(--edge);
}
.tabs-in { display: flex; width: 100%; max-width: 34rem; gap: 4px; }
.tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
}
.tab.on { background: var(--text); color: var(--card); }

/* ---- type ---- */

.h1 { font-family: var(--display); font-weight: 700; font-size: 2rem; line-height: 1.05; letter-spacing: -0.01em; text-wrap: balance; }
.h2 { font-family: var(--display); font-weight: 600; font-size: 1.3rem; line-height: 1.15; }
.eyebrow { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.back { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; padding: 6px 10px 6px 2px; font-weight: 700; text-decoration: none; color: var(--muted); }

/* ---- surfaces ---- */

.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: var(--r);
  box-shadow: var(--lift) var(--lift) 0 var(--shade);
}
.card.flat { box-shadow: none; }
.card.tint-gold { background: var(--gold); color: var(--on); }
.card.tint-go { background: var(--go); color: var(--on); }
.card.tint-sky { background: var(--sky); color: var(--on); }
.card.tint-gold .muted, .card.tint-go .muted, .card.tint-sky .muted, .card.tint-gold .eyebrow, .card.tint-go .eyebrow, .card.tint-sky .eyebrow { color: var(--on); opacity: 0.75; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }

/* ---- controls ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 10px 20px;
  border: 2px solid var(--edge);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
  box-shadow: 3px 3px 0 var(--shade);
  font-family: var(--display);
  font-weight: 600;
  font-size: 1.08rem;
  text-decoration: none;
  text-align: center;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.btn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--shade); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.go { background: var(--go); color: var(--on); }
.btn.gold { background: var(--gold); color: var(--on); }
.btn.pop { background: var(--pop); color: var(--on); }
.btn.huge { min-height: 68px; font-size: 1.3rem; font-weight: 700; border-radius: 20px; }
.btn.wide { width: 100%; }
.btn.small { min-height: 40px; padding: 6px 14px; font-size: 0.95rem; border-radius: 12px; box-shadow: 2px 2px 0 var(--shade); }
.btn.danger { color: var(--pop); }
.btn.plain, .btn.small.plain { border-color: transparent; box-shadow: none; background: transparent; color: var(--muted); min-height: 44px; }
.btn.plain.danger { color: var(--pop); }

.field {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 2px solid var(--edge);
  border-radius: 16px;
  background: var(--card);
  color: var(--text);
}
.field::placeholder { color: var(--muted); opacity: 0.85; }
textarea.field { min-height: 9rem; resize: vertical; line-height: 1.4; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 6px 14px;
  border: 2px solid var(--edge);
  border-radius: 99px;
  background: var(--card);
  color: var(--text);
  font-weight: 700;
  font-size: 0.92rem;
}
.chip.on { background: var(--text); color: var(--card); }
.chip.static { min-height: 0; padding: 2px 10px; font-size: 0.8rem; border-width: 2px; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .knob {
  flex: none;
  width: 56px; height: 32px;
  border: 2px solid var(--edge);
  border-radius: 99px;
  background: var(--soft);
  position: relative;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s ease;
}
.switch input:checked + .knob { background: var(--go); }
.switch input:checked + .knob::after { transform: translateX(24px); background: var(--on); }
.switch input:focus-visible + .knob { outline: 3px solid var(--sky); outline-offset: 2px; }

/* ---- progress ---- */

.meter { height: 14px; border: 2px solid var(--edge); border-radius: 99px; background: var(--card); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--go); border-right: 2px solid var(--edge); transition: width 0.4s ease; }
.meter > i[style*="width: 0%"] { border-right: 0; }

/* ---- tasks ---- */

.tasks { display: flex; flex-direction: column; gap: 10px; }
.task {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: 16px;
}
.task.big { padding: 12px 14px 12px 10px; }
.tick {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border: 2px solid var(--edge);
  border-radius: 50%;
  background: var(--card);
  color: transparent;
  transition: transform 0.08s ease;
}
.task.big .tick { width: 54px; height: 54px; }
.tick:active { transform: scale(0.9); background: var(--go); color: var(--on); }
.task-title {
  flex: 1;
  min-width: 0;
  padding: 6px 0;
  border: 0;
  background: none;
  text-align: left;
  overflow-wrap: anywhere;
}
.task.big .task-title { font-size: 1.1rem; }
.worth {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.worth .tile-ic { color: var(--gold); }
.task.done { opacity: 0.6; }
.task.done .tick { background: var(--go); color: var(--on); }
.task.done .task-title { text-decoration: line-through; }
.add { display: flex; flex-direction: column; gap: 10px; }

/* ---- sprint ---- */

.sprint { align-items: stretch; text-align: center; }
.ring { position: relative; width: min(64vw, 260px); aspect-ratio: 1; margin: 4px auto; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { stroke: var(--soft); }
.ring .left { stroke: var(--go); transition: stroke-dashoffset 0.3s linear; }
.ring .clock {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.6rem, 15vw, 4rem);
  font-variant-numeric: tabular-nums;
}
.sprint .tasks { text-align: left; }
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border: 2px solid var(--edge);
  border-radius: 14px;
  background: var(--go);
  color: var(--on);
  font-weight: 700;
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.banner.gold { background: var(--gold); }
.bignum { font-family: var(--display); font-weight: 700; font-size: 4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.bignum .tile-ic { color: var(--gold); }

/* ---- mosaic ---- */

.mosaic { display: block; width: 100%; aspect-ratio: 1; border: 2px solid var(--edge); border-radius: 16px; background: var(--bed); }
.mosaic.small { width: 116px; flex: none; border-radius: 12px; }
.mosaic.mid { width: min(62vw, 250px); margin: 0 auto; }
.mosaic.mini { width: 72px; flex: none; border-radius: 10px; }

/* ---- photos ---- */

.thumbs { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.thumb { flex: none; position: relative; width: 104px; height: 104px; border: 2px solid var(--edge); border-radius: 14px; overflow: hidden; padding: 0; background: var(--soft); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb span { position: absolute; left: 4px; bottom: 4px; padding: 0 6px; border-radius: 6px; background: var(--card); font-size: 0.7rem; font-weight: 700; }
.shot { width: 100%; max-height: 46vh; object-fit: contain; border: 2px solid var(--edge); border-radius: var(--r); background: var(--soft); }
.pick { position: relative; }
.pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.pick:focus-within { outline: 3px solid var(--sky); outline-offset: 2px; }
.checkrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 2px solid var(--edge); border-radius: 14px; background: var(--card); }
.checkrow input { width: 22px; height: 22px; accent-color: var(--go); flex: none; }

/* ---- celebration card ---- */

.pops { position: fixed; left: 0; right: 0; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); z-index: 50; display: flex; justify-content: center; padding: 0 16px; pointer-events: none; }
.pops.solo { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
.popcard {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 30rem;
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--edge);
  border-radius: 18px;
  background: var(--gold);
  color: var(--on);
  box-shadow: var(--lift) var(--lift) 0 var(--shade);
  animation: rise 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.popcard.bonus { background: var(--pop); }
.popcard.note { background: var(--card); color: var(--text); }
.popcard .amount { font-family: var(--display); font-weight: 700; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.popcard .lines { flex: 1; min-width: 0; font-size: 0.88rem; line-height: 1.3; }
.popcard .lines b { display: block; font-size: 1rem; }
.popcard .undo { border: 0; background: none; padding: 8px 4px; font-weight: 700; text-decoration: underline; color: inherit; }
@keyframes rise { from { transform: translateY(24px) scale(0.92); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
