/* Dexter Tracker: app-only styles on top of vendor/pixel-ui.css */
:root {
  --heat-0: var(--px-bg-3); --heat-1: color-mix(in srgb, var(--px-accent) 35%, var(--px-bg-3)); --heat-2: color-mix(in srgb, var(--px-accent) 65%, var(--px-bg-3)); --heat-3: var(--px-accent); --heat-4: var(--px-good);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
html { overscroll-behavior-y: none; -webkit-text-size-adjust: 100%; }
body.px { min-height: 100dvh; overflow-x: hidden; padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
h1, h2, h3 { margin: 0; }
button, input, select { font-family: inherit; }
.small { font-size: 14px; }
.px-hide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- top bar ---- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--px-3) var(--px-5); padding: var(--px-3) var(--px-4); border-bottom: var(--px-border); background: var(--px-bg-2); }
.top__title { font-size: 16px; }
.top__tabs .px-tab { min-height: 44px; padding-inline: var(--px-5); display: inline-flex; align-items: center; }
.top__right { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--px-2); align-items: center; }
.px-btn--sm { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
main { padding: var(--px-4); max-width: 1500px; margin: 0 auto; outline: none; }
.px-panel { padding: var(--px-4); }
.px-panel > .px-title { margin-bottom: var(--px-3); }
.live { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--px-4) + var(--safe-b)); z-index: var(--px-z-toast); pointer-events: none; text-align: center; width: max-content; max-width: calc(100vw - 32px); }
.live .px-toast { white-space: normal; }
.px-toast--danger { background: var(--px-danger); }

/* ---- tracker grid ---- */
.tracker { display: grid; gap: var(--px-4); grid-template-columns: minmax(0, 1fr); grid-template-areas: "ban" "hero" "cal" "day" "prog" "items" "heat"; }
.col { display: contents; }
.banner { display: flex; flex-wrap: wrap; align-items: center; gap: var(--px-3); }
@media (min-width: 720px) {
  .tracker { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "ban ban" "cal day" "hero prog" "heat items"; }
}
@media (min-width: 1180px) {
  .tracker { grid-template-columns: 300px minmax(0, 1fr) 380px; grid-template-areas: "ban ban ban"; align-items: start; }
  .col { display: flex; flex-direction: column; gap: var(--px-4); min-width: 0; }
  .banner { grid-column: 1 / -1; }
}

/* ---- hero ---- */
.hero { display: grid; grid-template-columns: auto 1fr; gap: var(--px-4); align-items: start; padding: var(--px-3); }
.hero__stage { border: var(--px-border-thin); background: var(--px-bg-3); line-height: 0; }
.stage { image-rendering: pixelated; image-rendering: crisp-edges; max-width: 100%; }
.hero__info { display: flex; flex-direction: column; gap: var(--px-2); min-width: 0; }
.bubble { font-size: 14px; line-height: 1.4; min-height: 2.8em; border-left: 4px solid var(--px-warm); padding-left: var(--px-2); margin: var(--px-1) 0; }
.chips { display: flex; flex-wrap: wrap; gap: var(--px-1); }
.chips .px-tag { display: inline-flex; align-items: center; gap: 4px; }
@media (min-width: 1180px) { .hero { grid-template-columns: 1fr; justify-items: stretch; } .hero__stage { justify-self: center; } }
.stat { margin: var(--px-2) 0; }
.stat__top { display: flex; justify-content: space-between; gap: var(--px-2); align-items: baseline; margin-bottom: 2px; }
.stat__top b { font-size: 13px; font-weight: 500; }

/* ---- calendar ---- */
.cal__head { display: flex; align-items: center; gap: var(--px-2); margin-bottom: var(--px-3); }
.cal__title { flex: 1; text-align: center; font-size: 16px; }
.px-icon-btn { min-width: 44px; min-height: 44px; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal__wd { font: 500 11px/1 var(--px-font-mono); text-transform: uppercase; color: var(--px-ink-2); text-align: center; padding: 4px 0; }
.cal__blank { min-height: 44px; }
.cal__day { appearance: none; cursor: pointer; text-align: left; min-height: 56px; padding: 4px; border: 2px solid var(--px-line); background: var(--heat-0); color: var(--px-ink); display: flex; flex-direction: column; justify-content: space-between; gap: 2px; position: relative; font: 500 13px/1 var(--px-font-mono); }
.cal__day[data-lvl="1"] { background: var(--heat-1); } .cal__day[data-lvl="2"] { background: var(--heat-2); } .cal__day[data-lvl="3"] { background: var(--heat-3); color: var(--px-on-accent); } .cal__day[data-lvl="4"] { background: var(--heat-4); color: var(--px-on-accent); }
.cal__day:hover { border-color: var(--px-ink); }
.cal__day[aria-pressed="true"] { border-color: var(--px-ink); box-shadow: 3px 3px 0 var(--px-ink-3); transform: translate(-1px, -1px); }
.cal__day.is-today .cal__n::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 4px; background: var(--px-warm); vertical-align: middle; border: 1px solid var(--px-bg); }
.cal__day.is-future:not([aria-pressed="true"]) { color: var(--px-ink-2); border-style: dashed; }
.cal__day:focus-visible { outline: var(--px-focus); outline-offset: 2px; z-index: 1; }
.dots { display: flex; flex-wrap: wrap; gap: 2px; min-height: 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border: 1px solid var(--c, var(--px-ink-2)); background: var(--px-bg); box-sizing: border-box; }
.dot--full { background: var(--c); border-color: var(--px-on-accent); }
.dot--half { box-shadow: inset 0 -4px 0 var(--c); }
.cal__legend { display: flex; flex-wrap: wrap; gap: var(--px-1) var(--px-3); margin-top: var(--px-3); align-items: center; font: 400 12px/1.4 var(--px-font-mono); color: var(--px-ink-2); }
.lg { display: inline-flex; align-items: center; gap: 4px; }
.lg--hint .dot { margin-left: 4px; }

/* ---- day checklist ---- */
.day__head { display: flex; align-items: center; gap: var(--px-2); margin-bottom: var(--px-3); }
.day__title { flex: 1; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.day__title .px-title { font-size: 16px; }
.day__list { margin-top: var(--px-3); display: grid; gap: var(--px-3); }
.grp { border-left: 4px solid var(--c); padding-left: var(--px-2); }
.grp__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 2px; }
.grp__name { color: var(--px-ink); }
.grp__n { font-size: 12px; color: var(--px-ink-2); }
.row { position: relative; display: flex; align-items: center; gap: var(--px-3); min-height: 44px; padding: 0 var(--px-2); border-bottom: 1px solid var(--px-line); cursor: pointer; }
.row:hover { background: var(--px-bg-3); }
.row__cb { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.row__box { flex: none; width: 22px; height: 22px; border: 2px solid var(--px-ink); background: var(--px-bg-3); position: relative; }
.row__cb:checked + .row__box { background: var(--c, var(--px-good)); }
.row__cb:checked + .row__box::after { content: ""; position: absolute; left: 3px; top: 7px; width: 2px; height: 2px; background: var(--px-bg); box-shadow: 2px 2px 0 var(--px-bg), 4px 0 0 var(--px-bg), 6px -2px 0 var(--px-bg), 8px -4px 0 var(--px-bg), 4px 2px 0 var(--px-bg), 6px 0 0 var(--px-bg); }
.grp .row__cb:checked + .row__box { background: var(--c); }
.row__cb:focus-visible + .row__box { outline: var(--px-focus); outline-offset: 3px; }
.row:has(.row__cb:focus-visible) { background: var(--px-bg-3); }
.row__name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 16px; }
.row.is-on .row__name { color: var(--px-ink-2); text-decoration: line-through; text-decoration-thickness: 2px; }
.sample { font: 500 11px/1 var(--px-font-mono); color: var(--px-warm); text-transform: uppercase; font-style: normal; margin-left: 4px; text-decoration: none; display: inline-block; }
.row__tag { font-size: 11px; padding: 0 6px; }
.row__streak { display: inline-flex; align-items: center; gap: 2px; font: 500 12px/1 var(--px-font-mono); color: var(--px-warm); }
.row__key { flex: none; min-width: 22px; padding: 0 4px; font-size: 11px; color: var(--px-ink-2); }
@media (pointer: coarse) { .row__key, .hint { display: none; } }
@media (pointer: fine) and (min-width: 720px) { .row { min-height: 38px; } }
.day__foot { display: flex; flex-wrap: wrap; gap: var(--px-2); align-items: center; margin-top: var(--px-4); }
.hint { font: 400 12px/1.4 var(--px-font-mono); color: var(--px-ink-2); margin-left: auto; }

/* ---- progress ---- */
.goal { margin: var(--px-2) 0; display: flex; gap: var(--px-2); align-items: center; flex-wrap: wrap; }
.wk { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin: var(--px-3) 0; }
.wk__day { appearance: none; cursor: pointer; border: 2px solid var(--px-line); background: var(--heat-0); color: var(--px-ink); min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font: 500 11px/1 var(--px-font-mono); padding: 2px; }
.wk__day b { font-weight: 700; font-size: 13px; }
.wk__day[data-lvl="1"] { background: var(--heat-1); } .wk__day[data-lvl="2"] { background: var(--heat-2); } .wk__day[data-lvl="3"] { background: var(--heat-3); color: var(--px-on-accent); } .wk__day[data-lvl="4"] { background: var(--heat-4); color: var(--px-on-accent); }
.wk__day.is-sel { border-color: var(--px-ink); }
.wk__day:hover { border-color: var(--px-ink); }

/* ---- heat map ---- */
.hm-grid { display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; margin-bottom: var(--px-3); }
.hm { display: inline-block; aspect-ratio: 1; min-width: 10px; background: var(--heat-0); border: 1px solid var(--px-line); }
.hm[data-lvl="x"] { background: transparent; border-style: dashed; }
.hm[data-lvl="1"] { background: var(--heat-1); } .hm[data-lvl="2"] { background: var(--heat-2); } .hm[data-lvl="3"] { background: var(--heat-3); } .hm[data-lvl="4"] { background: var(--heat-4); }
.hm--today { outline: 2px solid var(--px-warm); outline-offset: 0; }
.hm--key { width: 12px; height: 12px; vertical-align: middle; margin: 0 1px; }

/* ---- per item ---- */
.it-list { list-style: none; margin: var(--px-3) 0 0; padding: 0; display: grid; gap: var(--px-2); }
.it { display: grid; grid-template-columns: minmax(80px, 1.1fr) minmax(60px, 1fr) 42px 40px; gap: var(--px-2); align-items: center; font-size: 14px; border-left: 4px solid var(--c); padding-left: var(--px-2); }
.it__name { overflow-wrap: anywhere; }
.it__bar > i { background: var(--c); }
.it__pct { font-size: 12px; font-weight: 500; text-align: right; }
.it__st { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--px-warm); }

/* ---- character screen ---- */
.charscreen { display: grid; gap: var(--px-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .charscreen { grid-template-columns: minmax(340px, 480px) minmax(0, 1fr); align-items: start; } .cs-stage { position: sticky; top: calc(var(--px-nav-h, 0px) + var(--px-4)); } }
.cs-canvas { display: flex; justify-content: center; background: var(--px-bg-3); border: var(--px-border-thin); line-height: 0; }
.seg-wrap { margin-top: var(--px-3); overflow-x: auto; }
.px-seg > button { min-height: 44px; }
.cs-actions, .cs-save { margin-top: var(--px-3); }
.cs-controls { display: grid; gap: var(--px-3); }
.cs-controls > .px-title { margin-bottom: 0; }
.fs { border: 0; padding: 0; margin: 0; min-width: 0; }
.fs legend { padding: 0; margin-bottom: var(--px-1); }
.sw-row, .chip-row { display: flex; flex-wrap: wrap; gap: var(--px-1); align-items: center; }
.sw { appearance: none; width: 44px; height: 44px; border: 2px solid var(--px-line); background: transparent; padding: 0; cursor: pointer; position: relative; }
.sw::before { content: ""; position: absolute; inset: 6px; background: var(--c); border: 2px solid var(--px-bg); }
.sw:hover { border-color: var(--px-ink); }
.sw[aria-pressed="true"] { border-color: var(--px-ink); box-shadow: 3px 3px 0 var(--px-ink-3); }
.sw[aria-pressed="true"]::after { content: ""; position: absolute; right: 2px; top: 2px; width: 6px; height: 6px; background: var(--px-warm); border: 1px solid var(--px-bg); }
.sw-input { width: 44px; height: 44px; border: 2px solid var(--px-line); background: var(--px-bg-3); padding: 2px; cursor: pointer; }
.chip-row .px-tag { min-height: 44px; display: inline-flex; align-items: center; padding: 0 var(--px-3); font-size: 12px; text-transform: uppercase; }

/* ---- dialogs ---- */
.dlg { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.px-dialog__foot { justify-content: space-between; }
.ed { display: grid; gap: var(--px-4); margin-top: var(--px-3); }
.ed__grp { border-left: 4px solid var(--c); padding-left: var(--px-3); display: grid; gap: var(--px-2); }
.ed__ghead, .ed__item { display: flex; flex-wrap: wrap; gap: var(--px-2); align-items: center; }
.ed__ghead .px-input { flex: 1; min-width: 160px; font-weight: 700; }
.ed__name { flex: 2 1 200px; min-width: 0; }
.ed__sel { flex: 1 1 110px; width: auto; min-width: 0; }
.ed__num { flex: 0 0 72px; width: 72px; }
.ed__item { padding: var(--px-2); background: var(--px-bg-3); border: var(--px-border-thin); }
.px-input { min-height: 44px; font-size: 16px; }
select.px-input { appearance: auto; }
.px-btn--danger { background: transparent; color: var(--px-danger); border-color: var(--px-danger); }
.px-btn--danger:hover { background: var(--px-danger); color: var(--px-on-accent); }
.px-btn--ghost { box-shadow: none; }
.px-btn[disabled] { opacity: .5; cursor: not-allowed; }
.px-field { gap: var(--px-2); }

@media (max-width: 520px) {
  main { padding: var(--px-2); }
  .tracker { gap: var(--px-3); }
  .px-panel { padding: var(--px-2); }
  .cal { gap: 2px; }
  .top { padding: var(--px-2) var(--px-3); }
  .top__right { margin-left: 0; width: 100%; }
  .cal__day { min-height: 52px; padding: 3px; }
  .hero { gap: var(--px-3); }
  .it { grid-template-columns: minmax(70px, 1fr) minmax(50px, 1fr) 40px 36px; }
}
@media (max-height: 460px) and (orientation: landscape) { .cal__day { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } .cal__day[aria-pressed="true"] { transform: none; } }
