/* 101 — one stylesheet, light and dark. Which one is the device's setting,
   unless this browser has been told otherwise: js/theme.js puts
   data-theme="light" or "dark" on <html> (Settings → Appearance), and no
   attribute means "follow the device". The interface itself stays neutral
   ink-on-paper; colour belongs to the user's activity types, which arrive per
   element as --c. */

:root {
  color-scheme: light dark;   /* native controls and scrollbars follow too */
  --bg: #f5f4f0;
  --surface: #ffffff;
  --sunken: #eceae4;
  --ink: #17181c;
  --muted: #666a72;
  --line: #dedbd3;
  --accent: #640815;        /* the logo's maroon */
  --accent-ink: #ffffff;
  --good: #23784d;
  --bad: #b3261e;
  --apple: #000000;         /* Sign in with Apple: black on a light page, white on a dark one */
  --apple-ink: #ffffff;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 8px 24px rgba(20, 20, 30, .08);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* The dark colours are written out twice: once for "the device is dark and
   this browser hasn't said light", once for "this browser said dark". One
   rule can't sit both inside and outside a media query, so KEEP THE TWO BLOCKS
   THE SAME — scripts/web_theme_check.mjs fails if they drift. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101114;
    --surface: #1a1c21;
    --sunken: #23262c;
    --ink: #f0efea;
    --muted: #9b9fa8;
    --line: #2e3138;
    --accent: #b5364b;      /* the same maroon, lifted to read on a dark page */
    --accent-ink: #ffffff;
    --good: #5fcf96;
    --bad: #ff8a80;
    --apple: #ffffff;
    --apple-ink: #000000;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101114;
  --surface: #1a1c21;
  --sunken: #23262c;
  --ink: #f0efea;
  --muted: #9b9fa8;
  --line: #2e3138;
  --accent: #b5364b;      /* the same maroon, lifted to read on a dark page */
  --accent-ink: #ffffff;
  --good: #5fcf96;
  --bad: #ff8a80;
  --apple: #ffffff;
  --apple-ink: #000000;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .45);
}
:root[data-theme="light"] { color-scheme: light; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font);
}
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: 15px; font-weight: 700; }
a { color: inherit; }
code { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.fineprint { color: var(--muted); font-size: 13px; }
.lede { color: var(--muted); max-width: 62ch; }
.nowrap { white-space: nowrap; }
.noscript { padding: 40px 16px; text-align: center; }

/* ----------------------------------------------------------------- brand */

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 16px; letter-spacing: -.02em; text-decoration: none; line-height: 1; white-space: nowrap;
}
.brand img { border-radius: 8px; display: block; }
.login-logo { border-radius: 28px; display: block; box-shadow: var(--shadow); }

/* --------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { border-color: var(--accent); opacity: .88; }
.btn-ghost { background: transparent; border-style: dashed; color: var(--muted); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-wide { width: 100%; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--bad); }
.btn-danger-ghost:hover { border-color: var(--bad); }
.btn-apple { background: var(--apple); border-color: var(--apple); color: var(--apple-ink); }
.btn-apple::before {
  content: ""; width: 17px; height: 17px; margin-top: -2px; background: currentColor;
  -webkit-mask: var(--apple-mark) center / contain no-repeat; mask: var(--apple-mark) center / contain no-repeat;
  --apple-mark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701'/%3E%3C/svg%3E");
}

.icon-btn {
  width: 30px; height: 30px; flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; cursor: pointer;
}
.icon-btn:hover { background: var(--sunken); color: var(--ink); }
.icon-btn:disabled { opacity: .3; cursor: default; }

.input {
  width: 100%; min-height: 38px; padding: 7px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  font: inherit;
}
.input::placeholder { color: var(--muted); opacity: .75; }
textarea.input { resize: vertical; }
.input-small { min-height: 32px; padding: 4px 8px; font-size: 14px; }
.input-title { font-size: 20px; font-weight: 700; letter-spacing: -.01em; min-height: 46px; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .01em; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 2px 9px 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 2px 8px; border-radius: 6px; background: var(--accent); color: var(--accent-ink);
  font-size: 11.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
}

.segmented { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--sunken); }
.segmented button {
  min-height: 30px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent;
  color: var(--muted); font: inherit; font-weight: 600; cursor: pointer;
}
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
.pill-on { background: var(--c, var(--ink)); border-color: var(--c, var(--ink)); color: #fff; }
.pill-on:not([style]) { color: var(--bg); }

.empty { padding: 28px 16px; border: 1px dashed var(--line); border-radius: var(--radius); text-align: center; color: var(--muted); }
.empty-title { color: var(--ink); font-weight: 700; margin-bottom: 2px; }
.empty .btn { margin-top: 12px; }

.notice { padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.notice-bad { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.notice-good { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 100;
  max-width: min(92vw, 520px); padding: 10px 16px; border-radius: 10px;
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
}
.toast-bad { background: var(--bad); color: #fff; }

/* ------------------------------------------------------------------ login */

.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login-tagline { font-size: 18px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.login-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.login-buttons .btn { min-height: 46px; }

.login-agree { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.login-agree input { width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.login-buttons .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }

/* ------------------------------------------------------------ legal pages */

.legal { max-width: 720px; margin: 0 auto; padding: 32px 20px 64px; line-height: 1.6; }
.legal-head { margin-bottom: 28px; }
.legal .brand { font-size: 18px; }
.legal h1 { margin: 0 0 4px; }
.legal h2 { margin: 28px 0 8px; }
.legal p { margin: 0 0 12px; }
.legal code { padding: 1px 5px; border-radius: 4px; background: var(--sunken); }
.legal-foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ------------------------------------------------------------------ shell */

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  height: 56px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; gap: 2px; }
.nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; text-decoration: none;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current] { background: var(--sunken); color: var(--ink); }
.view { max-width: 1240px; margin: 0 auto; padding: 24px 20px 64px; }

.page { display: flex; flex-direction: column; gap: 16px; }
.page-narrow { max-width: 760px; }
.page-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { margin-top: 12px; font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

.sec-title { display: flex; align-items: center; gap: 9px; font-size: 17px; }
.sec-title i, .dot { width: 11px; height: 11px; border-radius: 50%; background: var(--c); flex: none; }

/* ------------------------------------------------------------------- home */

.progress-wrap { display: flex; flex-direction: column; gap: 6px; }
.progress { height: 14px; border-radius: 999px; background: var(--sunken); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .25s ease; min-width: 0; }
.progress.complete .progress-fill { background: var(--good); }
.progress-label { font-weight: 700; font-variant-numeric: tabular-nums; }

.today-list { display: flex; flex-direction: column; gap: 10px; }
.today-card {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--line); border-left: 5px solid var(--c); border-radius: var(--radius); background: var(--surface); overflow: hidden;
}
.tick {
  width: 60px; flex: none; display: grid; place-items: center;
  border: 0; border-right: 1px solid var(--line); background: transparent; cursor: pointer;
  font: inherit; font-size: 18px; font-weight: 800; color: #fff;
}
.tick::before {
  content: ""; grid-area: 1 / 1; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--muted); background: transparent;
}
.tick[aria-pressed="true"]::before { border-color: var(--good); background: var(--good); }
.tick { position: relative; }
.tick:hover::before { border-color: var(--ink); }

.tick > * { grid-area: 1 / 1; }
.today-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  padding: 14px 16px; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.today-main strong { font-size: 17px; letter-spacing: -.01em; }
.today-main:hover { background: color-mix(in srgb, var(--surface) 94%, var(--ink)); }
.today-card.done .today-main strong { color: var(--muted); }
.today-card.skipped .today-main strong { text-decoration: line-through; opacity: .6; }

/* ---------------------------------------------------------------- library */

.lib-section {
  display: flex; flex-direction: column; gap: 12px; padding: 18px;
  border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: var(--radius); background: var(--surface);
}
.lib-section .card { background: var(--bg); }
.lib-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.offers { display: flex; flex-direction: column; gap: 8px; }
.lib-elements { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.lib-elements .rows { background: var(--bg); }

.picker { display: flex; flex-direction: column; gap: 16px; }
.pick-group { display: flex; flex-direction: column; gap: 8px; }
.pick-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px; background: var(--surface); overflow: hidden; }
.pick {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 9px 12px;
  border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.pick + .pick { border-top: 1px solid var(--line); }
.pick:hover { background: color-mix(in srgb, var(--surface) 94%, var(--ink)); }

/* ---------------------------------------------------------------- profile */

.profile-head { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.profile-photo { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.profile-id { flex: 1 1 280px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; flex: none; }
.avatar-xl { width: 112px; height: 112px; font-size: 38px; }
.avatar-blank { background: var(--accent); color: var(--accent-ink); font-weight: 800; letter-spacing: -.02em; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.stat { display: flex; flex-direction: column; min-width: 104px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.stat strong { font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }

/* --------------------------------------------------------------- calendar */

.cal { display: flex; flex-direction: column; gap: 14px; }
.cal-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cal-bar h1 { margin-right: auto; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav .btn { padding: 0 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 30px; padding: 0 11px 0 9px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.legend-item i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.legend-item.off { color: var(--muted); background: transparent; text-decoration: line-through; }
.legend-item.off i { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

.cal-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.grid {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--line); gap: 1px; overflow: hidden;
}
.dow {
  padding: 8px 0; background: var(--bg); text-align: center;
  font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
}
.grid .cell {
  display: flex; flex-direction: column; gap: 4px; align-items: stretch;
  min-height: 108px; padding: 6px; border: 0; background: var(--surface); color: var(--ink);
  font: inherit; text-align: left; cursor: pointer; min-width: 0;
}
.grid .cell:hover { background: color-mix(in srgb, var(--surface) 92%, var(--ink)); }
.grid .cell-out { background: var(--bg); }
.grid .cell-out .cell-date { color: var(--muted); opacity: .6; }
.grid .cell-on { box-shadow: inset 0 0 0 2px var(--ink); }
.cell-date {
  align-self: flex-start; min-width: 24px; height: 24px; padding: 0 6px;
  display: inline-grid; place-items: center; border-radius: 12px;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.cell-today .cell-date { background: var(--accent); color: var(--accent-ink); }
.cell-chips { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-chip {
  display: block; padding: 2px 6px; border-radius: 5px; border-left: 3px solid var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  font-size: 12px; font-weight: 600; line-height: 1.35; overflow: hidden;
}
.cal-chip-text { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip.skipped { opacity: .55; text-decoration: line-through; }
.cal-more { font-size: 11.5px; color: var(--muted); font-weight: 600; padding-left: 6px; }
.cell-dots { display: none; gap: 3px; flex-wrap: wrap; }
.cell-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

.day {
  position: sticky; top: 76px;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.day-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-list { display: flex; flex-direction: column; gap: 8px; }
.session {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; width: 100%;
  padding: 10px 10px 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 8px;
  background: var(--surface); color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.session:hover { border-color: var(--muted); border-left-color: var(--c); }
.session-time { font-size: 12.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 1px; }
.session-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.session.skipped strong, .row.skipped strong { text-decoration: line-through; opacity: .6; }

/* ------------------------------------------------------------ lists/cards */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 6px; }
.outline { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }

.rows { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.rows li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 14px; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer;
}
.row:hover { background: color-mix(in srgb, var(--surface) 94%, var(--ink)); }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-main .fineprint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-date { display: flex; flex-direction: column; width: 70px; flex: none; font-variant-numeric: tabular-nums; }
.row-count { width: 36px; flex: none; text-align: right; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.status { flex: none; width: 74px; text-align: right; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.status-done { color: var(--good); }

.filters { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.results { display: flex; flex-direction: column; gap: 14px; }
.month { display: flex; flex-direction: column; gap: 8px; }
.month-title { font-size: 13px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.record { display: flex; flex-direction: column; gap: 8px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { padding: 9px 12px; text-align: left; font-size: 12px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; font-variant-numeric: tabular-nums; }
.table tr:last-child td { border-bottom: 0; }
.table .actual { font-weight: 600; }

/* --------------------------------------------------------------- insights */

.bar-actions { display: flex; gap: 8px; }
.week-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; height: 150px; margin-top: 4px; }
.week-bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; height: 100%; }
.week-count { font-size: 11.5px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.week-well { flex: 1; display: flex; align-items: flex-end; justify-content: center; width: 100%; min-height: 0; }
.week-track { display: flex; align-items: flex-end; width: 100%; max-width: 44px; min-height: 3px; border-radius: 6px; background: var(--sunken); overflow: hidden; }
.week-fill { display: block; width: 100%; background: var(--accent); }
.week-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.insight-list { display: flex; flex-direction: column; gap: 10px; }
.insight-card { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.insight-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.insight-now { display: flex; flex-direction: column; align-items: flex-end; flex: none; }
.insight-now strong { font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.trend { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.trend-up { color: var(--good); }
.trend-down { color: var(--bad); }
.spark { width: 100%; max-width: 320px; height: 56px; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.spark-plan { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 4; }
.spark-dot { fill: var(--accent); }

/* --------------------------------------------------------------- settings */

.panel { display: flex; flex-direction: column; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.panel > .segmented { align-self: flex-start; }   /* as wide as its buttons, not the panel */
.type-list { display: flex; flex-direction: column; gap: 8px; }
.type-row { display: flex; align-items: center; gap: 8px; }
.swatch { width: 38px; height: 38px; flex: none; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.feeds { display: flex; flex-direction: column; gap: 10px; }
.feed { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.feed-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.feed-url { display: block; padding: 7px 9px; border-radius: 6px; background: var(--sunken); overflow-x: auto; white-space: nowrap; }
.feed-new { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; padding-top: 12px; border-top: 1px solid var(--line); }
.feed-new .field { width: 100%; }
.form { display: flex; flex-direction: column; gap: 14px; }
.admin-block { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.admin-row { display: flex; align-items: center; gap: 12px; padding: 9px 14px; min-height: 48px; }
.plan-pick { width: auto; flex: none; }
.badge { flex: none; padding: 2px 8px; border-radius: 6px; background: var(--sunken); color: var(--muted); font-size: 12px; font-weight: 700; }
.badge-pending { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.badge-used { background: var(--sunken); color: var(--ink); }

/* ----------------------------------------------------------------- dialog */

.dlg {
  width: min(560px, calc(100vw - 24px)); max-height: min(92vh, 900px); padding: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); box-shadow: var(--shadow);
}
.dlg[open] { display: flex; flex-direction: column; }
.dlg-wide { width: min(880px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(10, 10, 14, .5); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px 20px; flex: none; }
.dlg-body { padding: 4px 20px 20px; overflow-y: auto; flex: 1; min-height: 0; }
.dlg-foot { display: flex; flex-direction: column; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface); flex: none; }
.dlg-foot > .btn { align-self: flex-end; }
.dlg-foot:has(> .btn + .btn) { flex-direction: row; justify-content: flex-end; flex-wrap: wrap; }
.ask-text { color: var(--muted); }
.ask-stack { display: flex; flex-direction: column; gap: 14px; }

/* Encryption setup and unlock (vault.js): the login card, with a form in it. */
.vault-card { max-width: 440px; gap: 14px; }
.vault-title { font-size: 22px; letter-spacing: -.01em; line-height: 1.25; }
.vault-actions { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.recovery-key { display: block; padding: 12px 14px; border-radius: 8px; background: var(--sunken); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; line-height: 1.7; letter-spacing: .04em; word-spacing: .35em; user-select: all; overflow-wrap: anywhere; }

.ed-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ed-foot-right { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.rest-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; border-radius: 8px; background: var(--ink); color: var(--bg); font-variant-numeric: tabular-nums; font-size: 17px;
}
.rest-bar.rest-done { background: var(--accent); color: var(--accent-ink); }

/* ----------------------------------------------------------------- editor */

.editor { display: flex; flex-direction: column; gap: 22px; }
.ed-head { display: flex; flex-direction: column; gap: 12px; }
.ed-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.repeat { display: flex; flex-direction: column; gap: 10px; }
.repeat-detail { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }

.structure { display: flex; flex-direction: column; gap: 12px; }
.structure > .btn { align-self: flex-start; }
.structure-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.structure-head h3 { font-size: 13px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

.block { display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.block > .btn { align-self: flex-start; }
.block-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.block-head .grow { flex: 1 1 140px; }
.block-head .clock, .block-head .rounds { width: 76px; }
.block-head-log { align-items: center; justify-content: space-between; }
.block-tools { display: flex; margin-left: auto; }

.item { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.item > .btn { align-self: flex-start; }
.item-head { display: flex; align-items: center; gap: 6px; }
.item-name { font-weight: 600; flex: 1; min-width: 0; }
.item-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }

.sets { border-collapse: collapse; align-self: flex-start; max-width: 100%; }
.sets th { padding: 0 4px 4px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.sets th small { font-weight: 500; }
.sets td { padding: 2px 4px; }
.sets .set-n { width: 44px; color: var(--muted); font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.sets .input { width: 96px; min-height: 34px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.sets .input.cell-text { width: 180px; }

.fields-editor { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fields-list { display: flex; flex-direction: column; gap: 6px; width: 100%; }
.fields-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 84px 30px; gap: 6px; align-items: center; }

/* ----------------------------------------------------------------- narrow */

@media (max-width: 900px) {
  .cal-wrap { grid-template-columns: minmax(0, 1fr); }
  .day { position: static; }
  .filters { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  /* No backdrop-filter here: it would make .top the containing block for the
     fixed tab bar below and pin the tabs to the header instead of the screen. */
  .top { justify-content: center; height: 48px; background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    justify-content: space-around; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .nav a { padding: 8px 6px; font-size: 13px; }
  .view { padding: 16px 12px 96px; }
  h1 { font-size: 22px; }

  .grid .cell { min-height: 58px; padding: 4px; align-items: center; }
  .cell-date { align-self: center; }
  .cell-chips { display: none; }
  .cell-dots { display: flex; justify-content: center; }
  .dow { font-size: 10.5px; }

  .ed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dlg, .dlg-wide { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
  .dlg-body { padding: 4px 14px 16px; }
  .dlg-foot { padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }
  .block { padding: 10px; }
  .sets .input { width: 76px; }
  .sets .input.cell-text { width: 120px; }
  .status { display: none; }
  .row-date { width: 58px; }
  .fields-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 60px 30px; }
  .toast { bottom: 96px; }
}
