:root {
  --bg: #15100c;
  --bg2: #1e1712;
  --card: #241b14;
  --card2: #2d2218;
  --line: #3c2e21;
  --cream: #f2e4cf;
  --dim: #b5a18a;
  --faint: #80705d;
  --amber: #e8a33d;
  --amber2: #c97f2a;
  --red: #d96b4f;
  --green: #9cb96a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(232,163,61,0.08), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(217,107,79,0.06), transparent 60%),
    var(--bg);
  color: var(--cream);
  font-family: 'Karla', sans-serif;
}

.rst-root { min-height: 100vh; padding: 0 16px 64px; }

/* dev-mode side banners (mounted only when the login bypass is active) */
.rst-devbanner {
  position: fixed; top: 0; bottom: 0; width: 40px; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(
    -45deg, var(--amber) 0 14px, var(--amber2) 14px 28px);
  color: #1b130a; font-family: 'Fraunces', serif; font-weight: 900;
  font-size: 18px; letter-spacing: 0.35em; text-transform: uppercase;
  writing-mode: vertical-rl; pointer-events: none; user-select: none;
  box-shadow: 0 0 24px rgba(0,0,0,0.45);
}
.rst-devbanner.left  { left: 0; }
.rst-devbanner.right { right: 0; transform: rotate(180deg); }
/* hide once the viewport is too narrow to fit them beside the 880px content */
@media (max-width: 1000px) { .rst-devbanner { display: none; } }
.rst-shell { max-width: 880px; margin: 0 auto; }

.rst-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 28px 4px 18px; border-bottom: 1px dashed var(--line);
  flex-wrap: wrap; gap: 8px;
}
.rst-logo { font-family: 'Fraunces', serif; font-weight: 900; font-size: 34px; letter-spacing: -0.02em; line-height: 1; }
.rst-logo em { font-style: italic; color: var(--amber); }
.rst-user { color: var(--dim); font-size: 14px; }
.rst-user b { color: var(--cream); }
.rst-user button {
  margin-left: 10px; background: none; border: 1px solid var(--line); color: var(--dim);
  border-radius: 999px; padding: 3px 12px; font-family: 'Karla', sans-serif; font-size: 12px; cursor: pointer;
}
.rst-user button:hover { color: var(--cream); border-color: var(--faint); }

.rst-tabs { display: flex; gap: 6px; margin: 20px 0 24px; flex-wrap: wrap; }
.rst-tab {
  background: var(--card); border: 1px solid var(--line); color: var(--dim);
  padding: 9px 18px; border-radius: 999px; cursor: pointer;
  font-family: 'Karla', sans-serif; font-size: 14px; font-weight: 500; transition: all .15s;
  position: relative;
}
.rst-tab:hover { color: var(--cream); }
.rst-tab.on { background: var(--amber); border-color: var(--amber); color: #1b130a; font-weight: 700; }
.rst-tab .badge {
  position: absolute; top: -6px; right: -4px; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 6px;
}

.rst-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin-bottom: 18px; }
.rst-h { font-family: 'Fraunces', serif; font-weight: 600; font-size: 21px; margin: 0 0 14px; }
.rst-h small { font-family: 'Karla', sans-serif; font-size: 13px; color: var(--faint); font-weight: 400; margin-left: 8px; }

/* gauge */
.rst-big { font-family: 'Fraunces', serif; font-weight: 900; font-size: 56px; line-height: 1; }
.rst-big span { font-size: 20px; color: var(--faint); font-weight: 400; }
.rst-sub { color: var(--dim); font-size: 14px; margin-top: 6px; }
.rst-bar { height: 14px; background: var(--bg2); border-radius: 999px; overflow: hidden; margin-top: 14px; border: 1px solid var(--line); }
.rst-bar > div { height: 100%; border-radius: 999px; transition: width .4s ease; }

/* drink grid */
.rst-cat { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; margin: 16px 0 8px; }
.rst-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.rst-drink {
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; cursor: pointer; text-align: left; color: var(--cream);
  font-family: 'Karla', sans-serif; transition: all .12s; display: flex; flex-direction: column; gap: 2px;
}
.rst-drink:hover { border-color: var(--amber2); transform: translateY(-1px); }
.rst-drink:active { transform: scale(.97); }
.rst-drink .nm { font-size: 13px; font-weight: 500; }
.rst-drink .mg { font-size: 12px; color: var(--amber); font-weight: 700; }

.rst-serving { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.rst-serving .lbl { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: 0.12em; margin-right: 4px; }
.rst-serving .x { color: var(--dim); font-weight: 700; }
.rst-step {
  width: 30px; height: 30px; flex: 0 0 auto; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card2); color: var(--cream); cursor: pointer; font-size: 18px; line-height: 1;
  font-family: 'Karla', sans-serif; transition: all .12s;
}
.rst-step:hover { border-color: var(--amber2); }
.rst-step:active { transform: scale(.94); }
.rst-sv-input {
  width: 60px; text-align: center; background: var(--bg2); border: 1px solid var(--line);
  color: var(--cream); border-radius: 8px; padding: 6px 8px;
  font-family: 'Karla', sans-serif; font-size: 14px; outline: none;
}
.rst-sv-input:focus { border-color: var(--amber2); }

.rst-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.rst-input {
  background: var(--bg2); border: 1px solid var(--line); color: var(--cream);
  border-radius: 10px; padding: 10px 14px; font-family: 'Karla', sans-serif; font-size: 14px;
  outline: none; flex: 1; min-width: 120px;
}
.rst-input:focus { border-color: var(--amber2); }
.rst-btn {
  background: var(--amber); color: #1b130a; border: none; border-radius: 10px;
  padding: 10px 20px; font-family: 'Karla', sans-serif; font-weight: 700; font-size: 14px;
  cursor: pointer; transition: all .12s;
}
.rst-btn:hover { background: #f3b14e; }
.rst-btn:disabled { opacity: .4; cursor: default; }
.rst-btn.ghost { background: none; border: 1px solid var(--line); color: var(--dim); }
.rst-btn.ghost:hover { color: var(--cream); border-color: var(--faint); }
.rst-btn.danger { background: none; border: 1px solid var(--line); color: var(--red); }
.rst-btn.danger:hover { border-color: var(--red); background: rgba(217, 107, 79, 0.1); }
a.rst-btn { display: inline-flex; align-items: center; text-decoration: none; }
.rst-consent { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--dim); text-align: left; }
.rst-consent input { margin-top: 2px; accent-color: var(--amber); }
.rst-consent a { color: var(--amber); }
.rst-btn.sm { padding: 6px 12px; font-size: 13px; }

/* log list */
.rst-log { list-style: none; margin: 0; padding: 0; }
.rst-log li { display: flex; justify-content: space-between; align-items: center; padding: 9px 4px; border-bottom: 1px dashed var(--line); font-size: 14px; }
.rst-log li:last-child { border-bottom: none; }
.rst-log .t { color: var(--faint); font-size: 12px; margin-right: 10px; }
.rst-log .mg { color: var(--amber); font-weight: 700; }
.rst-log .del { background: none; border: none; color: var(--faint); cursor: pointer; font-size: 14px; padding: 2px 6px; }
.rst-log .del:hover { color: var(--red); }

/* stat pills */
.rst-pills { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.rst-pill { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.rst-pill .lbl { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.rst-pill .val { font-family: 'Fraunces', serif; font-weight: 900; font-size: 26px; margin-top: 4px; }
/* lifetime aggregate cards hold longer values (dates, big totals) — shrink to fit */
.rst-pills.lifetime .val { font-size: 20px; white-space: nowrap; }
.rst-pill .cmp { font-size: 12px; margin-top: 4px; }
.cmp-up { color: var(--red); } .cmp-down { color: var(--green); } .cmp-na { color: var(--faint); }

.rst-seg { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.rst-seg button {
  background: var(--card2); border: 1px solid var(--line); color: var(--dim);
  padding: 6px 14px; border-radius: 8px; font-family: 'Karla', sans-serif; font-size: 13px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, transform .05s;
}
.rst-seg button.on { background: var(--amber); color: #1b130a; border-color: var(--amber); font-weight: 700; }
.rst-seg button:not(.on):hover { color: var(--cream); border-color: var(--faint); background: var(--card); }
.rst-seg button:not(:disabled):active { transform: translateY(1px); }
.rst-seg button:disabled { cursor: default; opacity: 0.7; }
#lbRefresh:hover { color: var(--amber); border-color: var(--amber2); }
.rst-seg button .spin { display: inline-block; animation: rst-spin 0.7s linear infinite; }
@keyframes rst-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.rst-seg-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.caf-controls { align-items: center; }
.caf-unit { color: var(--dim); font-size: 14px; }
/* higher specificity than the base .rst-hint shorthand below, so its top margin wins */
.rst-hint.caf-hint { margin-top: 10px; }

.chart-box { position: relative; width: 100%; height: 280px; }
/* lets the Day-view chart scroll horizontally when it's wider than the card */
.chart-scroll { overflow-x: auto; overflow-y: hidden; }
/* taper-chart tooltip — lives on <body> so the canvas edge can't clip it */
.rst-charttip {
  position: fixed; z-index: 60; display: none; pointer-events: none; white-space: nowrap;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; font-size: 12px; color: var(--amber);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}
.rst-charttip .t { color: var(--cream); margin-right: 7px; }

/* history calendar */
.rst-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rst-cal-title { font-family: 'Fraunces', serif; font-weight: 600; font-size: 18px; }
.rst-cal-nav {
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 18px; line-height: 1;
  background: var(--card2); border: 1px solid var(--line); color: var(--cream);
}
.rst-cal-nav:hover { border-color: var(--faint); }
.rst-cal-stats { color: var(--dim); font-size: 13px; margin-bottom: 12px; }
.rst-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.rst-cal-dow { text-align: center; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; padding-bottom: 2px; }
.rst-cal-cell {
  position: relative; min-height: 52px; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--cream); cursor: pointer; font-family: 'Karla', sans-serif;
}
.rst-cal-cell.empty { background: none; border: none; cursor: default; }
.rst-cal-cell .d { font-size: 13px; font-weight: 600; }
.rst-cal-cell .m { font-size: 10px; color: var(--amber); font-weight: 700; }
.rst-cal-cell.has { border-color: var(--amber2); }
.rst-cal-cell.over, .rst-cal-cell.over.has { border-color: var(--red); }
.rst-cal-cell.over .m { color: var(--red); }
.rst-cal-cell.today { box-shadow: 0 0 0 1px var(--amber) inset; }
.rst-cal-cell.sel { background: var(--amber); border-color: var(--amber); color: #1b130a; }
.rst-cal-cell.sel .m { color: #1b130a; }
.rst-cal-cell.future { opacity: 0.35; cursor: default; }
.rst-cal-cell.edit::after { content: ""; position: absolute; top: 5px; right: 5px; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.rst-cal-cell.sel.edit::after { background: #1b130a; }
.rst-cal-day { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.rst-cal-day .rst-loading { padding: 24px 0; }
.rst-cal-dayhead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.rst-cal-dayhead b { font-family: 'Fraunces', serif; font-size: 16px; }
.rst-cal-dayhead span { color: var(--dim); font-size: 13px; }
.rst-cal-add { margin-top: 12px; }
.rst-cal-add select { flex: 1 1 150px; }
.rst-cal-add #calName { flex: 1 1 120px; }

/* leaderboard + friends */
.rst-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.rst-table th { text-align: left; color: var(--faint); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.rst-table td { padding: 10px 6px; border-bottom: 1px dashed var(--line); }
.rst-table tr.me td { color: var(--amber); font-weight: 700; }
.rst-table .rank { font-family: 'Fraunces', serif; font-weight: 900; width: 40px; }
.rst-note { color: var(--faint); font-size: 12px; margin-top: 10px; line-height: 1.5; }
.rst-empty { color: var(--faint); font-size: 14px; }

/* leaderboard — daily winners strip */
.rst-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.rst-strip-day { flex: 1 1 0; min-width: 62px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px;
  cursor: pointer; color: var(--cream); font-family: 'Karla', sans-serif; transition: all .12s; }
.rst-strip-day:hover { border-color: var(--amber2); transform: translateY(-1px); }
.rst-strip-day.on { border-color: var(--amber); background: var(--card); }
.rst-strip-day .dow { font-size: 11px; color: var(--faint); }
.rst-strip-day .medal { font-size: 17px; line-height: 1.1; }
.rst-strip-day .who { font-size: 12px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rst-strip-day .who.me { color: var(--amber); }
.rst-strip-day .mg { font-size: 11px; color: var(--amber); }

/* leaderboard — refresh button (stands out from the granularity segments) */
.rst-seg button.rst-refresh { background: var(--amber); color: #1b130a; border-color: var(--amber); font-weight: 700; }
.rst-seg button.rst-refresh:not(:disabled):hover { background: var(--amber2); border-color: var(--amber2); color: #1b130a; }
.rst-seg button.rst-refresh:disabled { opacity: 1; }

/* leaderboard — period navigator */
.rst-pnav { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 6px 0 14px; }
.rst-pnav button { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px; border: 1px solid var(--line);
  background: var(--card2); color: var(--cream); cursor: pointer; font-size: 20px; line-height: 1; }
.rst-pnav button:not(:disabled):hover { border-color: var(--amber2); }
.rst-pnav button:disabled { opacity: .35; cursor: default; }
.rst-pnav-lbl { font-family: 'Fraunces', serif; font-weight: 600; font-size: 16px; color: var(--cream); text-align: center; min-width: 180px; }

/* leaderboard — winner banner */
.rst-winner { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 15px; border: 1px solid var(--line); }
.rst-winner b { color: var(--cream); }
.rst-winner.final { background: rgba(232,163,61,0.12); border-color: var(--amber2); color: var(--cream); }
.rst-winner.live { background: var(--card2); color: var(--dim); }
.rst-winner.none { background: var(--card2); color: var(--faint); }

/* leaderboard — rolling side-info (one ranked table per window) */
.rst-roll-block { margin-bottom: 16px; }
.rst-roll-block:last-of-type { margin-bottom: 4px; }

/* auth */
.rst-auth { max-width: 420px; margin: 9vh auto 0; text-align: center; }
.rst-auth .rst-logo { font-size: 48px; margin-bottom: 8px; }
.rst-auth p { color: var(--dim); font-size: 15px; line-height: 1.6; }
.rst-auth form { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; text-align: left; }
.rst-auth .switch { margin-top: 16px; font-size: 14px; color: var(--dim); }
.rst-auth .switch a { color: var(--amber); cursor: pointer; text-decoration: underline; }
.rst-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }
.rst-ok { color: var(--green); font-size: 13px; margin-top: 10px; }
.rst-hint { font-size: 12px; color: var(--faint); margin: -4px 2px 0; min-height: 15px; }
.rst-hint.good { color: var(--green); }
.rst-hint.bad { color: var(--red); }
/* hints that sit under a form field's input/controls need breathing room, unlike the
   tight auth hint the negative top margin above was meant for */
.rst-field .rst-hint { margin-top: 10px; }

/* ── taper planner ── */
/* home-card line summarising today's taper ceiling */
.rst-taperline { margin-top: 14px; font-size: 14px; color: var(--dim); display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.rst-taperline.ok { color: var(--green); }
.rst-taperline.over { color: var(--red); }
.rst-taperline.done { color: var(--amber); }

/* setup form fields */
.rst-field { margin-top: 18px; }
.rst-field-lbl { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; }
.rst-seg.taper-goal { align-items: center; }
.rst-pace-read { text-transform: none; letter-spacing: 0; color: var(--cream); font-size: 14px; margin-left: 8px; font-family: 'Karla', sans-serif; }

/* the unified Pace slider */
.rst-range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--red), var(--amber), var(--green)); outline: none; margin: 6px 0; }
.rst-range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--cream); border: 2px solid var(--amber2); cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.rst-range::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--cream);
  border: 2px solid var(--amber2); cursor: pointer; }
.rst-range-ends { display: flex; justify-content: space-between; color: var(--faint); font-size: 11px; margin-bottom: 4px; }

/* streak card */
.rst-streaks { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rst-streak { background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.rst-streak .lbl { color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.rst-streak .val { font-family: 'Fraunces', serif; font-weight: 900; font-size: 30px; margin: 4px 0; color: var(--amber); }
.rst-streak .sub { color: var(--dim); font-size: 12px; }
@media (max-width: 460px) { .rst-streaks { grid-template-columns: 1fr; } }

/* legal / privacy page */
.rst-legal { max-width: 640px; margin: 5vh auto; line-height: 1.65; }
.rst-legal .rst-logo { font-size: 40px; margin: 18px 0 6px; }
.rst-legal h1 { font-family: 'Fraunces', serif; font-size: 30px; margin: 6px 0 4px; }
.rst-legal h2 { font-family: 'Fraunces', serif; font-size: 19px; margin: 26px 0 6px; color: var(--cream); }
.rst-legal p, .rst-legal li { color: var(--dim); font-size: 15px; }
.rst-legal b { color: var(--cream); }
.rst-legal ul { padding-left: 20px; }
.rst-legal li { margin: 6px 0; }
.rst-back { color: var(--amber); text-decoration: none; font-size: 14px; }

/* persistent app footer (legal links, always available) */
.rst-foot { text-align: center; margin: 28px 0 12px; font-family: 'Karla', sans-serif; font-size: 12px; color: var(--faint); }
.rst-foot a { color: var(--faint); text-decoration: none; }
.rst-foot a:hover { color: var(--cream); }
.rst-back:hover { text-decoration: underline; }
.rst-muted { color: var(--faint); font-size: 13px; }

.rst-verify { margin-top: 28px; }
.rst-verify-icon { font-size: 44px; margin-bottom: 6px; }
.rst-verify h2 { font-family: 'Fraunces', serif; font-size: 24px; margin: 0 0 10px; color: var(--cream); }
.rst-verify .rst-btn { margin-top: 22px; }

.rst-loading { text-align: center; color: var(--faint); padding: 80px 0; font-size: 15px; }

/* toast */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--card2); border: 1px solid var(--amber2); color: var(--cream);
  padding: 10px 20px; border-radius: 999px; font-size: 14px; opacity: 0;
  transition: all .25s; pointer-events: none; z-index: 50;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
