:root {
  --bg: #0e1014; --card: #171a21; --card-2: #1f232c; --line: #2a2f3a;
  --text: #f2f4f7; --muted: #8b93a3; --lime: #c8f560; --coral: #ff7a59;
  --radius: 20px; color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--lime); outline-offset: 2px; }

/* min-height: an iPhone puts a fixed bottom bar at the end of a page shorter than the screen (empty Review tab). */
#app { min-height: 100lvh; max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 96px); }
.stack { display: grid; gap: 12px; }

/* Login */
.login { min-height: 100dvh; display: grid; align-content: center; gap: 32px; padding: 24px; max-width: 420px; margin: 0 auto; }
.brand { text-align: center; }
.brand h1 { font-size: 40px; margin: 12px 0 0; letter-spacing: -1px; }
.brand p { color: var(--muted); margin: 4px 0 0; }
.input { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.input input { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; font-size: 16px; }
.error { color: var(--coral); min-height: 1.4em; margin: 0; text-align: center; }

/* Buttons */
.primary { background: var(--lime); color: #111; border: 0; border-radius: 16px; padding: 16px; font-weight: 700; font-size: 17px; }
.primary:active { transform: scale(.98); }
.ghost { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; color: var(--muted); font-size: 14px; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--card-2); font-size: 22px; line-height: 1; }
.round:disabled { opacity: .3; }

/* Header */
.top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.hello { margin: 0; font-size: 24px; font-weight: 700; text-transform: capitalize; }
.countdown { margin: 2px 0 0; color: var(--lime); font-size: 14px; font-weight: 600; }
.countdown:empty { display: none; }

.daynav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.daynav h2 { margin: 0; font-size: 20px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0; }
.k { color: var(--muted); font-size: 14px; font-weight: 600; padding: 0; }
fieldset.card > legend { float: left; width: 100%; }
fieldset.card > .chips { clear: both; }
.k small { font-weight: 400; opacity: .7; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.metric { display: grid; gap: 8px; align-content: space-between; min-height: 112px; }
.field { display: flex; align-items: baseline; gap: 4px; }
.field input { width: 100%; min-width: 0; background: none; border: 0; padding: 0; font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.field input::placeholder { color: #3a404c; }
.field input:focus { outline: none; }
.metric:focus-within { border-color: var(--lime); }
.field em { font-style: normal; color: var(--muted); }
.stepper { display: flex; align-items: center; justify-content: space-between; }
.stepper output { font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Switches */
.toggles { display: grid; gap: 4px; padding: 6px 16px; }
.toggle { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; font-weight: 600; }
.toggle + .toggle { border-top: 1px solid var(--line); }
.toggle input { appearance: none; width: 52px; height: 32px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); position: relative; transition: background .2s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.toggle input:checked { background: var(--coral); border-color: var(--coral); }
.toggle input:checked::after { transform: translateX(20px); background: #fff; }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 10px 14px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); font-size: 15px; transition: all .15s; }
.chip input:checked + span { background: var(--lime); color: #111; border-color: var(--lime); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--lime); outline-offset: 2px; }

.save { position: sticky; bottom: calc(env(safe-area-inset-bottom) + 84px); box-shadow: 0 8px 24px #0008; }

/* Duo */
.section { font-size: 18px; margin: 8px 0 12px; }
.people { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.person h3 { margin: 0 0 12px; text-transform: capitalize; color: var(--coral); }
.person.me h3 { color: var(--lime); }
.person dl { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.person dt { color: var(--muted); font-size: 12px; }
.person dd { margin: 0; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.day h4 { margin: 0 0 8px; font-size: 15px; }
.line { display: grid; gap: 6px; padding: 8px 0; }
.line + .line { border-top: 1px solid var(--line); }
.line b { text-transform: capitalize; font-size: 14px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--card-2); }
.pill.good { color: var(--lime); }
.pill.bad { color: var(--coral); }
.pill.act { background: #c8f56022; color: var(--lime); }
.muted { color: var(--muted); font-size: 14px; }

/* Review */
.hero { margin-bottom: 12px; text-align: center; padding: 24px 16px; }
.hero h2 { margin: 6px 0; font-size: 30px; letter-spacing: -.5px; }
.hero p { margin: 0; }
.review { display: grid; gap: 14px; }
.review h3 { margin: 0; }
.delta { display: grid; gap: 2px; }
.delta .big { font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.delta .good { color: var(--lime); }
.delta .bad { color: var(--coral); }
.chart { width: 100%; height: auto; display: block; color: var(--coral); }
.me .chart { color: var(--lime); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.person dd small { color: var(--muted); font-weight: 500; font-size: 12px; }

/* Photo & song */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.photo { display: grid; gap: 12px; }
.photo img { width: 100%; max-height: 360px; object-fit: cover; border-radius: 14px; }
.photo-actions { display: flex; gap: 8px; }
.photo-actions .ghost { cursor: pointer; }
.photo-actions label:focus-within { outline: 2px solid var(--lime); outline-offset: 2px; }
.song { display: grid; gap: 8px; }
.song input { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 16px; width: 100%; }
.song-link { color: var(--lime); font-size: 14px; font-weight: 600; text-decoration: none; }
.song-card { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 14px; background: var(--card-2); color: var(--text); text-decoration: none; min-width: 0; }
.song-card img, .song-card .cover { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex: none; display: grid; place-items: center; background: var(--bg); }
.song-card span { display: grid; min-width: 0; }
.song-card b, .song-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-card small { color: var(--muted); font-size: 13px; }
.thumb { width: 100%; max-height: 240px; object-fit: cover; border-radius: 12px; display: block; }

/* Tab bar */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px;
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  background: #0e1014e6; backdrop-filter: blur(12px); border-top: 1px solid var(--line);
}
.tabs button { flex: 1; max-width: 200px; display: grid; justify-items: center; gap: 2px; background: none; border: 0; border-radius: 14px; padding: 8px; color: var(--muted); font-size: 13px; font-weight: 600; }
.tabs button span { font-size: 20px; }
.tabs button[aria-current] { color: var(--text); background: var(--card-2); }

.toast {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 16px); transform: translate(-50%, calc(-100% - 60px));
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600;
  transition: transform .25s; z-index: 10;
}
.toast.show { transform: translate(-50%, 0); }

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