/* Personal log dashboard: a dark, vibrant, game-like look on ordinary dashboard structure.
   Fills (--c-*) are bright with dark ink on top; text-coloured accents (--t-*) are darker in light mode so they
   keep 4.5:1 on the card. No inline styles anywhere (strict CSP); dynamic values go through custom properties. */

:root {
  color-scheme: dark;
  --page: #0e1020; --surface: #191c33; --surface-2: #23274a; --track: #2a2e52; --line: #3a3f6b;
  --ink: #f4f5ff; --ink-2: #c9cce6; --muted: #a3a8cc; --on-c: #0e1020;
  --c-orange: #ff8a3d; --c-green: #3ddc97; --c-cyan: #3cc8ff; --c-pink: #ff5fa2; --c-violet: #9b7bff; --c-yellow: #ffd23f;
  --t-orange: #ff8a3d; --t-green: #3ddc97; --t-cyan: #3cc8ff; --t-pink: #ff5fa2; --t-violet: #b9a3ff; --t-yellow: #ffd23f;
  --radius: 20px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --page: #f3f4fa; --surface: #ffffff; --surface-2: #eceef8; --track: #dde0f0; --line: #c3c7e0;
    --ink: #14162a; --ink-2: #3a3e5e; --muted: #5a5f82; --on-c: #14162a;
    --t-orange: #b84a08; --t-green: #0a7048; --t-cyan: #0a6590; --t-pink: #b81e68; --t-violet: #5238c4; --t-yellow: #7d5700;
  }
}
.tone-orange { --c: var(--c-orange); --t: var(--t-orange); } .tone-green { --c: var(--c-green); --t: var(--t-green); }
.tone-cyan { --c: var(--c-cyan); --t: var(--t-cyan); } .tone-pink { --c: var(--c-pink); --t: var(--t-pink); }
.tone-violet { --c: var(--c-violet); --t: var(--t-violet); } .tone-yellow { --c: var(--c-yellow); --t: var(--t-yellow); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.45 var(--font); }
h1, h2, h3 { margin: 0; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; letter-spacing: -0.02em; } h2 { font-size: 1.02rem; } h3 { font-size: .95rem; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--t-violet); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--c-violet); outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .num { font-variant-numeric: tabular-nums; }

/* shell */
.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px 96px; }
header.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 20px 0 10px; }
header.top .title { display: flex; flex-direction: column; gap: 2px; }
.btn { border: 2px solid var(--line); background: transparent; padding: 7px 14px; border-radius: 999px; font-weight: 600; min-height: 40px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--c-violet); color: var(--on-c); border-color: var(--c-violet); font-weight: 800; }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; justify-content: space-around; gap: 4px;
  padding: 8px 8px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
nav.tabs a { flex: 1; max-width: 140px; min-height: 44px; display: grid; place-items: center; text-decoration: none; color: var(--muted);
  border-radius: 14px; font-size: .85rem; font-weight: 700; }
nav.tabs a[aria-current="page"] { background: var(--c-violet); color: var(--on-c); }
@media (min-width: 760px) {
  .wrap { padding-bottom: 48px; }
  nav.tabs { position: sticky; top: 0; bottom: auto; justify-content: flex-start; padding: 8px 0 12px; background: var(--page); border: 0; }
  nav.tabs a { flex: none; padding: 0 20px; }
}

/* cards */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card > header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.card > header .sub { color: var(--muted); font-size: .85rem; }
.cols { display: grid; gap: 14px; margin-bottom: 14px; align-items: start; }
.cols > .card { margin-bottom: 0; }
@media (min-width: 900px) { .cols { grid-template-columns: 1fr 1fr; } }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }
.notice { border: 2px dashed var(--line); border-radius: var(--radius); padding: 16px; color: var(--ink-2); margin-bottom: 14px; }
.eyebrow { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--t, var(--t-violet)); }
.chips { display: inline-flex; gap: 4px; background: var(--surface); border-radius: 14px; padding: 3px; }
.chip { border: 0; background: transparent; padding: 0 14px; min-height: 36px; border-radius: 11px; font-weight: 700; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--page); }
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin: 4px 0 14px; }
.pill { display: inline-block; border-radius: 999px; padding: 4px 11px; font-size: .78rem; font-weight: 800; background: var(--surface-2); color: var(--t, var(--ink)); }
.pill.solid { background: var(--c); color: var(--on-c); }

/* rings, pips, meters */
.ring { position: relative; flex: none; }
.ring svg { display: block; }
.ring .track { stroke: var(--track); }
.ring .fg { stroke: var(--c, var(--c-green)); }
.ring .tick { stroke: var(--c-yellow); stroke-width: 3; stroke-linecap: round; }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label b { font-size: 1.8rem; font-weight: 800; } .ring-label span { font-size: .7rem; font-weight: 700; color: var(--muted); letter-spacing: .06em; }
.pips { display: grid; grid-template-columns: repeat(var(--n, 10), minmax(0, 1fr)); gap: 4px; }
.pips i { height: 10px; border-radius: 4px; background: var(--track); }
.pips i.on { background: var(--c, var(--c-violet)); }
.hero { display: flex; gap: 18px; align-items: center; }
.hero .words { display: grid; gap: 8px; min-width: 0; }
.hero .words b { font-size: 1.05rem; }

/* habits: streak cards */
.hcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .hcards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); } }
.hcard { background: var(--surface); border-radius: 18px; padding: 12px; border-top: 4px solid var(--c); display: grid; gap: 10px; align-content: start; }
.hcard .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 800; }
.check { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; border: 2px dashed var(--line); font-weight: 800; font-size: .85rem; flex: none; }
.check.on { background: var(--c); color: var(--on-c); border: 0; } .check.no { border: 2px solid var(--muted); color: var(--muted); }
.streak { display: flex; align-items: center; gap: 6px; }
.streak svg { stroke: var(--c-orange); fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.streak.cold svg { stroke: var(--muted); }
.streak b { font-size: 1.9rem; line-height: 1; font-weight: 800; }
.streak span { color: var(--muted); font-size: .8rem; align-self: flex-end; padding-bottom: 3px; }
.week-dots { display: flex; gap: 5px; }
.week-dots .d { flex: 1; display: grid; justify-items: center; gap: 3px; font-size: .65rem; color: var(--muted); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--track); }
.dot.done { background: var(--c); } .dot.missed { background: transparent; box-shadow: inset 0 0 0 2px var(--muted); }
.dot.unanswered { background: repeating-linear-gradient(135deg, var(--track) 0 2px, var(--surface) 2px 4px); }
.dot.open { box-shadow: inset 0 0 0 2px var(--ink-2); background: transparent; }
.dot.future { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.foot { display: flex; justify-content: space-between; gap: 8px; font-size: .8rem; color: var(--muted); }

/* badges */
.bshape { width: 44px; height: 44px; flex: none; display: grid; place-items: center; font-weight: 800; font-size: .9rem; color: var(--on-c); background: var(--c);
  clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.bshape.round { clip-path: none; border-radius: 50%; }
.bshape.star { clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); padding-top: 3px; }
.bshape.locked { background: var(--track); color: var(--muted); }
.bshelf { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.bcard { display: flex; gap: 12px; align-items: center; background: var(--surface-2); border-radius: 16px; padding: 10px 12px; }
.bcard.locked { opacity: .85; }
.bcard .meta { display: grid; gap: 4px; min-width: 0; flex: 1; }
.bcard .meta b { font-size: .92rem; overflow-wrap: anywhere; }
.bcard .meta .small { color: var(--muted); }
.bcard .pips { --n: 12; }
.bcard .pips i { height: 6px; }

/* habits: 35-day strips */
.hrow { display: grid; gap: 6px; margin-bottom: 14px; }
.hrow .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hrow .meta b { font-weight: 700; } .hrow .meta .r { display: flex; gap: 10px; align-items: center; font-size: .82rem; color: var(--muted); font-weight: 700; }
.hrow .meta .fire { color: var(--t-orange); }
.strip { display: grid; grid-template-columns: repeat(35, minmax(0, 1fr)); gap: 2px; }
.sq { height: 18px; border-radius: 3px; background: var(--track); border: 0; padding: 0; }
.sq.done { background: var(--c); } .sq.missed { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.sq.unanswered { background: repeating-linear-gradient(135deg, var(--track) 0 2px, var(--surface) 2px 4px); }
.sq.open { background: transparent; box-shadow: inset 0 0 0 2px var(--ink); }
.sq.pad { visibility: hidden; }
.axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: .8rem; color: var(--ink-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; background: var(--track); }
.legend .sw.done { background: var(--c-violet); } .legend .sw.missed { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }
.legend .sw.unanswered { background: repeating-linear-gradient(135deg, var(--track) 0 2px, var(--surface) 2px 4px); }
.legend .sw.open { background: transparent; box-shadow: inset 0 0 0 2px var(--ink); }

/* stats */
.bar-row { display: grid; gap: 6px; margin-bottom: 14px; }
.bar-row:last-child { margin-bottom: 0; }
.bar-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.bar-head .lab { color: var(--muted); font-weight: 700; font-size: .85rem; }
.bar-head .val { font-weight: 800; font-size: 1.05rem; } .bar-head .val small { color: var(--muted); font-weight: 600; font-size: .78rem; }
.bar-row.over .pips i.on { background: var(--c-orange); } .bar-row.met .pips i.on { background: var(--c-green); }
.state { font-size: .75rem; font-weight: 800; } .state.met { color: var(--t-green); } .state.over { color: var(--t-orange); } .state.under { color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 760px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { background: var(--surface-2); border-radius: 16px; padding: 10px 12px; display: grid; gap: 3px; }
.tile .l { display: flex; justify-content: space-between; align-items: center; gap: 6px; color: var(--muted); font-weight: 700; font-size: .8rem; }
.tile .v { font-size: 1.3rem; font-weight: 800; color: var(--t); line-height: 1.2; } .tile .v small { color: var(--muted); font-size: .72rem; font-weight: 600; }
.tile .avg { color: var(--muted); font-size: .75rem; }
.delta { font-size: .75rem; font-weight: 800; color: var(--muted); } .delta.good { color: var(--t-green); } .delta.bad { color: var(--t-orange); }
.spark { width: 100%; height: 38px; display: block; }
.spark .line { fill: none; stroke: var(--c); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark .tgt { stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 4 3; }
.spark .dot { fill: var(--c); } .spark .dot.faint { fill: var(--c); opacity: .55; }
.triple { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.triple .stat { background: var(--surface-2); border-radius: 14px; padding: 10px; display: grid; gap: 2px; }
.triple .stat b { font-size: 1.1rem; font-weight: 800; color: var(--t); } .triple .stat span { font-size: .75rem; color: var(--muted); font-weight: 700; }
details.items { margin-top: 6px; } details.items summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.items ul { list-style: none; margin: 0; padding: 0; } .items li { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); font-size: .9rem; }

/* sleep */
.summary3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.summary3 .stat { background: var(--surface); border-radius: 14px; padding: 10px 12px; display: grid; gap: 2px; }
.summary3 .stat span { font-size: .72rem; font-weight: 800; letter-spacing: .06em; color: var(--muted); } .summary3 .stat b { font-size: 1.35rem; font-weight: 800; color: var(--t); }
.sleep-chart { width: 100%; height: auto; display: block; }
.sleep-chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); font-weight: 600; }
.sleep-chart .hours { fill: var(--ink); font-weight: 800; } .sleep-chart .hours.short { fill: var(--t-orange); } .sleep-chart .hours.entry { fill: var(--t-pink); }
.sleep-chart .gridline { stroke: var(--track); stroke-width: 1; }
.sleep-chart .s1 { stop-color: var(--c-violet); } .sleep-chart .s2 { stop-color: var(--c-cyan); }
.sleep-chart .hatch-a { stroke: var(--c-pink); stroke-width: 3; } .sleep-chart .hatch-bg { fill: var(--surface-2); }
.sleep-chart .nobar { fill: var(--track); }
.scroll-x { overflow-x: auto; }
.tabular { margin-top: 8px; } .tabular summary { cursor: pointer; color: var(--muted); font-weight: 700; font-size: .85rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; color: var(--muted); font-weight: 700; font-size: .78rem; padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
td { padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); } td.r, th.r { text-align: right; }

/* study */
.chips3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.chips3 .stat { background: var(--surface); border-radius: 14px; padding: 10px; display: grid; gap: 2px; border-bottom: 4px solid var(--c); }
.chips3 .stat b { font-size: 1.4rem; font-weight: 800; } .chips3 .stat span { font-size: .72rem; font-weight: 700; color: var(--muted); }
.wk { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; height: 210px; }
.wk .col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; height: 100%; }
.wk .p { font-size: .72rem; font-weight: 800; } .wk .p.hit { color: var(--t-green); } .wk .p.miss { color: var(--t-orange); } .wk .p.none { color: var(--muted); }
.avail { width: 100%; border-radius: 8px; background: var(--track); position: relative; overflow: hidden; }
.avail.empty-day { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); }
.avail .studied { position: absolute; left: 0; right: 0; bottom: 0; background: var(--c-pink); }
.avail .goal { position: absolute; left: 0; right: 0; border-top: 2px solid var(--c-yellow); z-index: 1; }
.wk .d { font-size: .72rem; color: var(--muted); font-weight: 700; }
.hm { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.hm .dow { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; }
.hm .day { aspect-ratio: 1; border-radius: 10px; display: grid; place-content: center; text-align: center; background: var(--track); font-size: .7rem; line-height: 1.15; border: 0; padding: 0; color: var(--ink); }
.hm .day b { font-size: .78rem; font-weight: 800; }
.hm .day.s1 { background: #5c2a55; color: #fff; } .hm .day.s2 { background: #a33d7e; color: #fff; } .hm .day.s3 { background: var(--c-pink); color: var(--on-c); }
.hm .day.hit { box-shadow: inset 0 0 0 2px var(--c-green); }
.hm .day.future { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--muted); }
.hm .day.pad { visibility: hidden; }
.hm .day.today { outline: 2px solid var(--ink); outline-offset: 2px; }
.goalbar { height: 12px; border-radius: 999px; background: var(--track); overflow: hidden; }
.goalbar i { display: block; height: 100%; background: var(--c); border-radius: 999px; width: calc(var(--p, 0) * 1%); }

/* tooltip */
#tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: var(--page); padding: 6px 10px;
  border-radius: 8px; font-size: .8rem; max-width: 240px; white-space: pre-line; box-shadow: 0 2px 10px rgba(0, 0, 0, .3); }

/* login */
.login { max-width: 380px; margin: 14vh auto 0; background: var(--surface); border-radius: var(--radius); padding: 22px; }
.login form { display: grid; gap: 10px; margin-top: 14px; }
.login input { padding: 12px 14px; border-radius: 12px; border: 2px solid var(--track); background: var(--page); }
.login input:focus { outline: none; border-color: var(--c-violet); }
.err { color: var(--t-orange); min-height: 1.3em; font-size: .9rem; }

@media (max-width: 420px) { .hero { gap: 12px; } .ring-label b { font-size: 1.5rem; } }
@media (prefers-reduced-motion: no-preference) { .goalbar i, .pips i { transition: background-color .2s, width .3s; } }
@media (forced-colors: active) { .sq, .dot, .pips i, .day { forced-color-adjust: none; } }
