:root {
  --bg: #14100f;
  --bg-soft: #1b1614;
  --card: #201a18;
  --card-hi: #271f1c;
  --line: #322926;
  --line-soft: #2a2320;
  --text: #f2ebe7;
  --muted: #9c8d85;
  --dim: #6f625b;

  --accent: #e0714a;
  --accent-soft: #f0a882;
  --good: #7fc99a;

  --r1: #d9a441;
  --r2: #e08a4a;
  --r3: #e0714a;
  --r4: #d8543f;
  --r5: #c6392f;

  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

/* Must beat the ID-level display rules below. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(900px 500px at 15% -10%, rgba(224, 113, 74, .10), transparent 70%),
    radial-gradient(700px 400px at 100% 0%, rgba(217, 164, 65, .06), transparent 60%);
  background-attachment: fixed;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.015em; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 1.5; }
.center { text-align: center; }

/* ----------------------------- screens ----------------------------- */

.screen[hidden] { display: none; }

#auth, #setup {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px;
  box-shadow: var(--shadow);
}
.card.narrow { width: 100%; max-width: 400px; }

.logo {
  font-size: 26px;
  text-align: center;
  background: linear-gradient(100deg, var(--accent-soft), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 8px 0 24px;
}
.setup-msg {
  margin: 18px 0 14px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(224, 113, 74, .1);
  border: 1px solid rgba(224, 113, 74, .3);
  font-size: 14px;
  line-height: 1.55;
}

/* ------------------------------ forms ------------------------------ */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 22px;
}
.tab {
  flex: 1;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab.is-active { background: var(--card-hi); color: var(--text); }

.field { display: block; margin-bottom: 15px; }
.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 7px;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224, 113, 74, .16);
}

.error {
  margin: 4px 0 14px;
  color: #f09a86;
  font-size: 13.5px;
  line-height: 1.5;
}
.error[hidden] { display: none; }

/* ----------------------------- buttons ----------------------------- */

.btn {
  border: 1px solid var(--line);
  background: var(--card-hi);
  border-radius: 11px;
  padding: 11px 18px;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #2e2522; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: #e88157; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.block { width: 100%; margin-top: 6px; }
.btn.small { padding: 8px 14px; font-size: 13.5px; border-radius: 9px; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--muted);
  font-size: 17px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--dim); }

/* ------------------------------- app ------------------------------- */

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 18px 64px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}
.topbar h1 { font-size: 26px; }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 4px;
}

/* standing debt — the thing that refuses to go away */
.debt-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 11px;
  margin: -20px -18px 20px;
  padding: 13px 18px;
  background: linear-gradient(90deg, rgba(198, 57, 47, .95), rgba(198, 57, 47, .8));
  color: #fff;
  font-size: 14.5px;
  font-weight: 550;
  box-shadow: 0 6px 22px rgba(198, 57, 47, .28);
}
.debt-banner[hidden] { display: none; }
.debt-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
  animation: pulse 1.9s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}

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

.progress-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 22px;
}
.ring {
  --pct: 0;
  position: relative;
  width: 62px; height: 62px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid; place-items: center;
  background:
    conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--line-soft) 0);
}
.ring::after {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--card);
}
.ring span {
  position: relative;
  z-index: 1;
  font-size: 14px;
  font-weight: 650;
}
.progress-copy { min-width: 0; flex: 1; }
#progressLine { font-size: 14.5px; color: var(--muted); margin-bottom: 10px; }

.heatmap { display: flex; gap: 4px; }
.heat {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--line-soft);
}
.heat.l1 { background: rgba(127, 201, 154, .3); }
.heat.l2 { background: rgba(127, 201, 154, .55); }
.heat.l3 { background: var(--good); }

/* ----------------------------- prompt ------------------------------ */

.prompt {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
  background: rgba(224, 113, 74, .09);
  border: 1px solid rgba(224, 113, 74, .26);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 22px;
}
.prompt[hidden] { display: none; }
.prompt strong { font-size: 14.5px; }
.prompt .btn { flex-shrink: 0; }

/* ------------------------------ tiers ------------------------------ */

.tier { margin-bottom: 26px; }
.tier[hidden] { display: none; }
.tier-head {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 11px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.tier-note {
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  font-size: 12.5px;
  color: #574b45;
}

.items { display: flex; flex-direction: column; gap: 10px; }

/* ------------------------------ item ------------------------------- */

.item {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  transition: border-color .2s, background .2s;
}
.item.r1 { border-left-color: var(--r1); }
.item.r2 { border-left-color: var(--r2); background: linear-gradient(90deg, rgba(224, 138, 74, .07), transparent 55%); }
.item.r3 { border-left-color: var(--r3); background: linear-gradient(90deg, rgba(224, 113, 74, .11), transparent 60%); }
.item.r4 { border-left-color: var(--r4); background: linear-gradient(90deg, rgba(216, 84, 63, .15), transparent 65%); }
.item.r5 {
  border-left-color: var(--r5);
  background: linear-gradient(90deg, rgba(198, 57, 47, .2), transparent 70%);
  border-color: rgba(198, 57, 47, .4);
}
.item.done { border-left-color: var(--good); opacity: .72; }
.item.skipped { opacity: .55; }

.item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
}
.item-label { font-size: 16px; font-weight: 600; }
.item-when {
  font-size: 12.5px;
  color: var(--dim);
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.item-line { font-size: 14px; color: var(--muted); line-height: 1.5; }
.item.r3 .item-line, .item.r4 .item-line { color: #f0b9a4; }
.item.r5 .item-line { color: #f5c4b6; font-weight: 550; }
.item.done .item-line { color: var(--good); }

.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.badge {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .03em;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.streak { color: var(--accent-soft); border-color: rgba(240, 168, 130, .3); }
.badge.rung { color: #f0b9a4; border-color: rgba(224, 113, 74, .33); }

.item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 13px;
  flex-wrap: wrap;
}

/* skip confirmation — deliberately more work than just doing the thing */

.item.skip-mode {
  border-left-color: var(--r3);
  background: linear-gradient(90deg, rgba(224, 113, 74, .09), transparent 60%);
}
.item.skip-mode.tier1 {
  border-left-color: var(--r5);
  background: linear-gradient(90deg, rgba(198, 57, 47, .13), transparent 65%);
}

.skip-q { font-size: 15.5px; font-weight: 600; margin-bottom: 5px; }
.skip-stakes {
  font-size: 13.5px;
  line-height: 1.5;
  color: #f0b9a4;
  margin-bottom: 12px;
}
.skip-reason {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14.5px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.skip-reason:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(224, 113, 74, .16);
}
.skip-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.skip-actions .btn { flex: 1 1 auto; }

.btn.danger {
  background: transparent;
  border-color: rgba(198, 57, 47, .45);
  color: #f09a86;
}
.btn.danger:hover:not(:disabled) {
  background: rgba(198, 57, 47, .14);
  border-color: rgba(198, 57, 47, .7);
}

/* counter */
.counter {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 3px;
}
.counter button {
  width: 38px; height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  border-radius: 8px;
  cursor: pointer;
  transition: background .14s, color .14s;
}
.counter button:hover { background: var(--card-hi); color: var(--text); }
.counter .val {
  min-width: 66px;
  text-align: center;
  font-size: 14.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.counter .val small { color: var(--dim); font-weight: 500; }

.bar {
  height: 4px;
  border-radius: 2px;
  background: var(--line-soft);
  overflow: hidden;
  margin-top: 11px;
}
.bar > i {
  display: block;
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width .35s cubic-bezier(.2, .8, .3, 1);
}
.item.done .bar > i { background: var(--good); }

/* ------------------------------ sheet ------------------------------ */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 6, 5, .72);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.sheet[hidden] { display: none; }
.sheet-inner {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  padding: 26px 22px 34px;
  animation: rise .28s cubic-bezier(.2, .9, .3, 1);
}
@keyframes rise { from { transform: translateY(28px); opacity: .4; } }
.sheet-close {
  position: absolute;
  top: 16px; right: 18px;
  width: 32px; height: 32px;
  border: 0;
  border-radius: 9px;
  background: var(--card);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.sheet h2 { font-size: 21px; margin-bottom: 6px; }
.sheet h3 {
  font-size: 12.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 24px 0 11px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.score-row .name { flex: 1; font-size: 14.5px; min-width: 0; }
.score-row .track {
  width: 96px;
  height: 6px;
  border-radius: 3px;
  background: var(--line-soft);
  overflow: hidden;
  flex-shrink: 0;
}
.score-row .track > i { display: block; height: 100%; border-radius: 3px; }
.score-row .num {
  width: 46px;
  text-align: right;
  font-size: 13.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.verdict {
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  margin: 10px 0 4px;
}
.big-pct { font-size: 40px; font-weight: 700; letter-spacing: -.03em; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.toggle-row p { font-size: 14.5px; }
.switch {
  position: relative;
  width: 46px; height: 27px;
  flex-shrink: 0;
  border: 0;
  border-radius: 20px;
  background: var(--line);
  cursor: pointer;
  transition: background .2s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: transform .2s cubic-bezier(.2, .9, .3, 1);
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(19px); }

.foot { margin-top: 34px; text-align: center; }

/* ------------------------------ toast ------------------------------ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--card-hi);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 36px);
  animation: rise .2s ease-out;
}
.toast[hidden] { display: none; }
.toast.bad { border-color: rgba(224, 113, 74, .5); color: #f0b9a4; }

@media (max-width: 420px) {
  .app { padding: 16px 14px 56px; }
  .debt-banner { margin: -16px -14px 18px; }
  .topbar h1 { font-size: 22px; }
  .counter .val { min-width: 56px; }
}

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