/* ── RESET & TOKENS ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg:       #0d0d10;
  --s1:       #17171c;
  --s2:       #202027;
  --s3:       #2a2a33;
  --border:   #2e2e3a;
  --text:     #eaeaed;
  --sub:      #9898a8;
  --muted:    #5a5a6e;
  --accent:   #7c6af7;
  --a2:       #a990ff;
  --green:    #3dd68c;
  --amber:    #f5a623;
  --red:      #f06060;
  --r:        14px;
  --rsm:      9px;
  --rchip:    20px;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
}

/* ── LAYOUT ─────────────────────────────────────────────── */
header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 10;
}
.h-title { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--sub); }
.h-date  { font-size: 12px; color: var(--muted); }
.gear-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  cursor: pointer;
  color: var(--sub);
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.gear-btn:hover { border-color: var(--accent); color: var(--accent); }
.gear-btn svg { display: block; }
.gear-btn.syncing #sync-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse {
  0% { opacity: 0.8; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.4); }
}

main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

nav {
  flex-shrink: 0;
  display: flex;
  background: var(--s1);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 9px 4px 7px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
  transition: color .15s;
  position: relative;
  text-transform: uppercase;
}
.tab svg { width: 19px; height: 19px; }
.tab.on  { color: var(--a2); }
.tab.on::before {
  content: '';
  position: absolute;
  top: 0; left: 18%; right: 18%;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 3px 3px;
}
.tab-dot {
  position: absolute;
  top: 7px; right: calc(50% - 15px);
  width: 7px; height: 7px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid var(--s1);
}

/* ── PANEL ──────────────────────────────────────────────── */
.panel { display: none; padding: 18px 18px 24px; }
.panel.on { display: block; }

/* ── CARD ───────────────────────────────────────────────── */
.card {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 15px 16px;
  margin-bottom: 12px;
}
.card-tight { padding: 12px 14px; }

/* ── LABELS ─────────────────────────────────────────────── */
.lbl {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ── PROGRESS ───────────────────────────────────────────── */
.prog-wrap { }
.prog-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.prog-status { font-size: 14px; font-weight: 700; }
.prog-count  { font-size: 12px; color: var(--muted); }
.prog-track  { height: 5px; background: var(--s3); border-radius: 3px; overflow: hidden; }
.prog-fill   { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent) 0%, var(--a2) 100%); transition: width .5s cubic-bezier(.4,0,.2,1); }

/* ── TASK ITEMS ─────────────────────────────────────────── */
.task-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--rsm);
  padding: 11px 13px;
  margin-bottom: 7px;
  transition: opacity .2s;
}
.task-row.done    { opacity: .45; }
.task-row.skipped { opacity: .35; }
.task-body { flex: 1; min-width: 0; }
.task-name { font-size: 13px; font-weight: 500; line-height: 1.4; }
.task-row.done .task-name { text-decoration: line-through; }
.task-hint { font-size: 11px; margin-top: 3px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { font-size: 10px; color: var(--muted); background: var(--s1); border: 1px solid var(--border); border-radius: 4px; padding: 1px 7px; }
.task-acts { display: flex; gap: 5px; flex-shrink: 0; align-items: flex-start; margin-top: 1px; }
.act-btn {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--s1);
  color: var(--sub);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  transition: all .12s;
  white-space: nowrap;
  line-height: 1.2;
}
.act-btn:hover { border-color: var(--accent); color: var(--text); }
.act-btn.g  { color: var(--green); border-color: #1d5e3d; }
.act-btn.y  { color: var(--amber); }
.act-btn.r  { color: var(--red);   }

/* ── BAG ITEM ───────────────────────────────────────────── */
.bag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--rsm);
  padding: 9px 12px;
  margin-bottom: 6px;
}
.bag-body { flex: 1; min-width: 0; }
.bag-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bag-acts { display: flex; gap: 5px; flex-shrink: 0; align-items: center; }

/* ── CARE PROMPT ────────────────────────────────────────── */
.care-row {
  background: rgba(245,166,35,.08);
  border: 1px solid rgba(245,166,35,.25);
  border-radius: var(--rsm);
  padding: 10px 13px;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.care-body { flex: 1; min-width: 0; }
.care-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--amber); display: block; margin-bottom: 2px; }
.care-name  { font-size: 13px; }

/* ── BAG METER ──────────────────────────────────────────── */
.meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--rsm);
  padding: 9px 13px;
  margin-bottom: 14px;
}
.meter-count { font-size: 13px; font-weight: 700; }
.meter-sub   { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── FILTER CHIPS ───────────────────────────────────────── */
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--rchip);
  color: var(--sub);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  cursor: pointer;
  transition: all .12s;
}
.chip.on { background: rgba(124,106,247,.18); border-color: var(--accent); color: var(--a2); }

/* ── INPUTS ─────────────────────────────────────────────── */
input, textarea {
  width: 100%;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--rsm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 72px; }

.row { display: flex; gap: 8px; margin-bottom: 12px; }
.row input { flex: 1; margin-bottom: 0; }

/* ── BUTTONS ────────────────────────────────────────────── */
.btn {
  background: var(--accent);
  border: none;
  border-radius: var(--rsm);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 16px;
  transition: opacity .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:hover   { opacity: .85; }
.btn.ghost   { background: var(--s2); border: 1px solid var(--border); color: var(--text); font-weight: 600; }
.btn.danger  { background: var(--red); }
.btn.sm      { font-size: 11px; font-weight: 700; padding: 6px 11px; }
.btn.w100    { width: 100%; }
.btn.mt8     { margin-top: 8px; }

/* ── EMPTY STATE ────────────────────────────────────────── */
.empty { text-align: center; padding: 44px 20px; }
.empty-icon { font-size: 38px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ── REVIEW ─────────────────────────────────────────────── */
.rv-header {
  background: linear-gradient(160deg, rgba(124,106,247,.22) 0%, rgba(124,106,247,.04) 100%);
  border-bottom: 1px solid var(--border);
  padding: 26px 20px;
  text-align: center;
}
.rv-icon  { font-size: 44px; margin-bottom: 10px; }
.rv-title { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.rv-sub   { font-size: 13px; color: var(--sub); }
.rv-body  { padding: 18px 18px 20px; }

.outcome-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 14px 0 16px; }
.out-btn {
  background: var(--s2);
  border: 2px solid var(--border);
  border-radius: var(--rsm);
  color: var(--sub);
  cursor: pointer;
  padding: 14px 8px 12px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  transition: all .15s;
}
.out-btn .oi { font-size: 22px; display: block; margin-bottom: 5px; }
.out-btn:hover      { border-color: var(--accent); color: var(--text); }
.out-btn.win-on     { background: rgba(61,214,140,.12); border-color: var(--green); color: var(--green); }
.out-btn.partial-on { background: rgba(245,166,35,.12); border-color: var(--amber); color: var(--amber); }
.out-btn.loss-on    { background: rgba(240,96,96,.12);  border-color: var(--red);   color: var(--red);   }

.sel-list { margin-bottom: 12px; }
.sel-row { font-size: 13px; padding: 4px 0; display: flex; align-items: center; gap: 8px; }
.sel-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ── SCORE ──────────────────────────────────────────────── */
.score-hero {
  background: linear-gradient(145deg, rgba(124,106,247,.28) 0%, rgba(124,106,247,.05) 100%);
  border: 1px solid rgba(124,106,247,.3);
  border-radius: var(--r);
  padding: 28px 20px 22px;
  text-align: center;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
}
.score-hero::after {
  content: '';
  position: absolute;
  top: -40px; left: 50%; transform: translateX(-50%);
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(124,106,247,.18) 0%, transparent 70%);
  pointer-events: none;
}
.score-num {
  font-size: 72px;
  font-weight: 900;
  letter-spacing: -3px;
  line-height: 1;
  background: linear-gradient(135deg, #fff 20%, var(--a2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  position: relative;
  z-index: 1;
}
.score-lbl { font-size: 12px; color: var(--sub); margin-top: 5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }

.streak-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.streak-box {
  flex: 1;
  background: var(--s2);
  border: 1px solid var(--border);
  border-radius: var(--rsm);
  padding: 12px 14px;
}
.streak-val { font-size: 26px; font-weight: 900; }
.streak-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }

.breakdown .br-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.breakdown .br-row:last-child { border-bottom: none; }
.br-val { font-weight: 700; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7,1fr);
  gap: 5px;
  margin-top: 10px;
}
.wday {
  border-radius: 6px;
  aspect-ratio: 1;
  background: var(--s2);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.wday .wd { font-size: 9px; color: var(--muted); font-weight: 600; }
.wday .ws { font-size: 11px; font-weight: 800; color: var(--text); }
.wday.win     { background: rgba(61,214,140,.15);  border-color: rgba(61,214,140,.35); }
.wday.partial { background: rgba(245,166,35,.15);  border-color: rgba(245,166,35,.35); }
.wday.loss    { background: rgba(240,96,96,.1);    border-color: rgba(240,96,96,.25); }

/* ── TIMER ──────────────────────────────────────────────── */
.timer-face {
  font-size: 38px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  text-align: center;
  color: var(--a2);
  padding: 14px 0 10px;
}
.timer-label { text-align: center; font-size: 12px; color: var(--muted); margin-bottom: 10px; }

/* ── COMFORT ────────────────────────────────────────────── */
.comfort-item {
  border-left: 3px solid var(--accent);
  background: var(--s2);
  border-radius: 0 var(--rsm) var(--rsm) 0;
  padding: 9px 13px;
  margin-bottom: 7px;
}
.comfort-title { font-size: 13px; font-weight: 600; }
.comfort-date  { font-size: 10px; color: var(--muted); margin-top: 3px; }

/* ── UTILITY CLASSES ────────────────────────────────────────── */
.hidden { display: none; }

/* ── 6-TAB NAV ───────────────────────────────────────────── */
.tab { font-size: 9px; }

/* ── LISTS ───────────────────────────────────────────────── */
.list-type-tabs { display:flex; gap:6px; margin-bottom:16px; }
.ltype-btn { flex:1; background:var(--s2); border:1px solid var(--border); border-radius:var(--rsm); color:var(--sub); font-size:11px; font-weight:600; padding:8px 4px; cursor:pointer; text-align:center; transition:all .15s; }
.ltype-btn.on { background:rgba(124,106,247,.18); border-color:var(--accent); color:var(--a2); }

.list-card { background:var(--s1); border:1px solid var(--border); border-radius:var(--r); margin-bottom:10px; overflow:hidden; }
.list-card-header { display:flex; align-items:center; gap:10px; padding:12px 14px; cursor:pointer; }
.list-card-header:hover { background:var(--s2); }
.list-card-title { flex:1; font-size:14px; font-weight:700; }
.list-card-meta { font-size:11px; color:var(--muted); }
.list-card-chevron { color:var(--muted); font-size:14px; transition:transform .2s; }
.list-card-chevron.open { transform:rotate(90deg); }
.list-card-body { border-top:1px solid var(--border); }

.chk-row { display:flex; align-items:center; gap:10px; padding:10px 14px; border-bottom:1px solid var(--border); }
.chk-row:last-child { border-bottom:none; }
.chk-row.checked .chk-label { text-decoration:line-through; color:var(--muted); }
.chk-box { width:20px; height:20px; border-radius:5px; border:2px solid var(--border); background:var(--s2); cursor:pointer; flex-shrink:0; display:flex; align-items:center; justify-content:center; transition:all .15s; }
.chk-box.checked { background:var(--accent); border-color:var(--accent); }
.chk-box svg { display:none; }
.chk-box.checked svg { display:block; }
.chk-label { flex:1; font-size:13px; }
.chk-del { background:none; border:none; color:var(--muted); cursor:pointer; font-size:18px; padding:0 4px; line-height:1; flex-shrink:0; }
.chk-del:hover { color:var(--red); }

.list-add-row { display:flex; gap:8px; padding:10px 12px; border-top:1px solid var(--border); }
.list-add-row input { flex:1; background:var(--s2); border:1px solid var(--border); border-radius:var(--rsm); color:var(--text); font-size:13px; font-family:inherit; padding:7px 10px; outline:none; }
.list-add-row input:focus { border-color:var(--accent); }
.list-add-row button { background:var(--accent); border:none; border-radius:var(--rsm); color:#fff; font-size:12px; font-weight:700; padding:7px 12px; cursor:pointer; }

.day-badge { display:inline-flex; align-items:center; justify-content:center; width:24px; height:24px; border-radius:50%; font-size:10px; font-weight:800; background:var(--s3); color:var(--sub); flex-shrink:0; }
.day-badge.today-day { background:var(--accent); color:#fff; }

.reset-btn { background:none; border:1px solid var(--border); border-radius:6px; color:var(--muted); font-size:10px; padding:3px 8px; cursor:pointer; }
.reset-btn:hover { border-color:var(--amber); color:var(--amber); }

/* ── WISHLIST ─────────────────────────────────────────────── */
.wish-card { background:var(--s1); border:1px solid var(--border); border-radius:var(--r); padding:14px 16px; margin-bottom:10px; position:relative; overflow:hidden; }
.wish-card::before { content:''; position:absolute; top:0; left:0; bottom:0; width:3px; background:var(--border); }
.wish-card.locked::before { background:var(--red); }
.wish-card.unlocked::before { background:var(--green); }
.wish-title { font-size:14px; font-weight:700; margin-bottom:4px; }
.wish-streak-target { font-size:11px; color:var(--muted); margin-bottom:8px; }
.wish-progress-wrap { margin-bottom:8px; }
.wish-prog-bar { height:5px; background:var(--s3); border-radius:3px; overflow:hidden; margin-top:4px; }
.wish-prog-fill { height:100%; border-radius:3px; transition:width .4s ease; }
.wish-prog-fill.locked   { background:linear-gradient(90deg,var(--red),#ff9999); }
.wish-prog-fill.unlocked { background:linear-gradient(90deg,var(--green),#7fffcc); }
.wish-meta { display:flex; align-items:center; justify-content:space-between; font-size:11px; color:var(--muted); }
.wish-unlock-badge { display:inline-block; background:rgba(61,214,140,.2); color:var(--green); border:1px solid rgba(61,214,140,.4); border-radius:5px; font-size:11px; font-weight:700; padding:2px 8px; }
.wish-locked-badge { display:inline-block; background:rgba(240,96,96,.15); color:var(--red); border:1px solid rgba(240,96,96,.3); border-radius:5px; font-size:11px; font-weight:700; padding:2px 8px; }
.wish-actions { display:flex; gap:6px; margin-top:10px; }

/* ── MISC ───────────────────────────────────────────────── */
hr.div { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.text-sm   { font-size: 13px; }
.text-xs   { font-size: 11px; }
.text-muted{ color: var(--muted); }
.skip-link { background:none; border:none; color:var(--muted); font-size:12px; cursor:pointer; text-decoration:underline; display:block; text-align:center; margin-top:12px; padding:0; }
.skip-link:hover { color: var(--red); }
.badge-warn { background: rgba(240,96,96,.15); color: var(--red); border: 1px solid rgba(240,96,96,.3); border-radius: 5px; font-size:10px; font-weight:700; padding: 2px 7px; }

/* ── TOAST ──────────────────────────────────────────────── */
#toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-90px);
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  transition: transform .28s cubic-bezier(.34,1.56,.64,1);
  white-space: nowrap;
  pointer-events: none;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
#toast.up    { transform: translateX(-50%) translateY(0); }
#toast.green { color: var(--green); border-color: rgba(61,214,140,.4); }
#toast.amber { color: var(--amber); border-color: rgba(245,166,35,.4); }
#toast.red   { color: var(--red);   border-color: rgba(240,96,96,.4);  }

/* scrollbar */
::-webkit-scrollbar       { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--s3); border-radius: 2px; }

/* ── SETTINGS MODAL ──────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--s1);
  border: 1px solid var(--border);
  border-radius: var(--r);
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all .15s;
}
.modal-close:hover { background: var(--s2); color: var(--text); }
.modal-body { padding: 20px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-info { flex: 1; }
.setting-label { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.setting-desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--s3);
  border-radius: 13px;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.toggle.on .toggle-knob { transform: translateX(22px); }
.api-url-input {
  width: 100%;
  margin-top: 8px;
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 12px;
}
.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  margin-top: 6px;
}
.status-badge.connected { background: rgba(61,214,140,.2); color: var(--green); border: 1px solid rgba(61,214,140,.3); }
.status-badge.disconnected { background: rgba(240,96,96,.2); color: var(--red); border: 1px solid rgba(240,96,96,.3); }
.status-badge.local { background: rgba(124,106,247,.2); color: var(--a2); border: 1px solid rgba(124,106,247,.3); }