/* ==========================================================================
   Elise — Activity Tracker
   Light theme only, mobile first. The layout switches from a bottom tab bar
   to a fixed sidebar at 900px.
   ========================================================================== */

:root {
  --bg:          #f5f7fa;
  --surface:     #ffffff;
  --surface-2:   #fafbfd;
  --ink:         #16202e;
  --ink-2:       #4d5a6b;
  --ink-3:       #8593a4;
  --line:        #e4e9f0;
  --line-strong: #cdd6e2;

  --accent:      #3766c8;
  --accent-ink:  #2b52a3;
  --accent-soft: #ebf1fd;

  --exercise:    #dd8b3c;
  --rest:        #6b83c4;
  --mental:      #3f9d8f;
  --task:        #7a6fd4;

  --good:        #2f8f68;
  --warn:        #c98a1e;
  --crash:       #cf4d5f;
  --crash-soft:  #fdf0f2;

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;

  --shadow-sm: 0 1px 2px rgba(21, 33, 51, .06), 0 1px 1px rgba(21, 33, 51, .04);
  --shadow:    0 2px 10px rgba(21, 33, 51, .07), 0 1px 3px rgba(21, 33, 51, .05);
  --shadow-lg: 0 18px 44px rgba(21, 33, 51, .16);

  --tabbar-h: 62px;
  --sidebar-w: 236px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

/* Crash mode tints the whole app so the state is impossible to miss. */
body.crash { background: var(--crash-soft); }
body.crash { --accent: #b8465a; --accent-ink: #9c3a4c; --accent-soft: #fdeaee; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.011em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Sign in
   -------------------------------------------------------------------------- */
.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, #e8eefb 0%, rgba(232,238,251,0) 62%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 26px 26px;
  text-align: center;
}
.login-mark {
  width: 54px; height: 54px;
  margin: 0 auto 16px;
  display: grid; place-items: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(150deg, #4a78d8, #2f56ad);
  box-shadow: 0 6px 16px rgba(47, 86, 173, .3);
}
.login h1 { font-size: 22px; }
.login-sub { color: var(--ink-3); font-size: 14px; margin-top: 6px; margin-bottom: 22px; }
.login .field { text-align: left; }
.login-error {
  color: var(--crash);
  background: var(--crash-soft);
  border: 1px solid #f4ccd3;
  border-radius: var(--radius-sm);
  font-size: 14px;
  padding: 9px 12px;
  margin-bottom: 14px;
}

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */
.app { min-height: 100dvh; display: flex; }

.sidebar { display: none; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(245, 247, 250, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
body.crash .topbar { background: rgba(253, 240, 242, .9); }
.topbar-title { font-size: 21px; }
.topbar-sub { font-size: 13px; color: var(--ink-3); margin-top: 2px; }
.topbar-right { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.content {
  padding: 16px 16px 32px;
  outline: none;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

/* Bottom tab bar (mobile) */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 22px; height: 22px; }
.tab.is-active { color: var(--accent); }
.tab-dot {
  position: absolute;
  margin: -18px 0 0 20px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--crash);
}

/* --------------------------------------------------------------------------
   Cards & sections
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: 14px;
}
.card-pad-0 { padding: 0; overflow: hidden; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  /* Wraps rather than squeezing the title into two words per line when a
     segmented control sits beside it on a phone. */
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty {
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
  padding: 26px 16px;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 15px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  /* The export controls are anchors wearing .btn, so kill the link underline. */
  text-decoration: none;
  transition: background .13s ease, border-color .13s ease, transform .06s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: rgba(21,33,51,.05); }
.btn-danger { color: var(--crash); border-color: #f0c8cf; background: #fef7f8; }
.btn-danger:hover { background: #fdecef; }
.btn-sm { min-height: 32px; padding: 4px 11px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { min-height: 36px; width: 36px; padding: 0; border-radius: 9px; }

.seg {
  display: inline-flex;
  background: #eceff5;
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  /* An inline-flex track sizes to its content and would otherwise push past
     the card on a narrow phone. */
  max-width: 100%;
  flex-wrap: wrap;
}
.seg button {
  border: 0; background: none; cursor: pointer;
  padding: 6px 13px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  white-space: nowrap;
}
@media (max-width: 400px) {
  .seg button { padding: 6px 9px; font-size: 13px; }
}
.seg button.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* --------------------------------------------------------------------------
   Current activity hero
   -------------------------------------------------------------------------- */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  color: #fff;
  background: linear-gradient(140deg, #46608f, #2c3f63);
  box-shadow: 0 10px 26px rgba(28, 45, 76, .22);
}
.hero.is-exercise { background: linear-gradient(140deg, #e0954a, #c26a2c); }
.hero.is-rest     { background: linear-gradient(140deg, #7183c8, #4a5c9e); }
.hero.is-idle     { background: linear-gradient(140deg, #94a2b6, #6b7b91); }
.hero-label { font-size: 12px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; opacity: .8; }
.hero-name { font-size: 24px; font-weight: 700; margin-top: 4px; letter-spacing: -.02em; }
.hero-timer {
  font-family: var(--mono);
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
  line-height: 1.05;
}
.hero-since { font-size: 13.5px; opacity: .82; margin-top: 4px; }
.hero-tag {
  position: absolute; top: 18px; right: 18px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: rgba(255,255,255,.2); padding: 4px 10px; border-radius: 999px;
}

/* --------------------------------------------------------------------------
   Activity buttons
   -------------------------------------------------------------------------- */
.act-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.act {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-height: 74px;
  padding: 12px 14px;
  text-align: left;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .13s ease, background .13s ease, transform .07s ease;
  -webkit-tap-highlight-color: transparent;
}
.act:active { transform: scale(.975); }
/* Keeps a wrapped name clear of the colour dot pinned to the top-right. */
.act-name { font-size: 15px; font-weight: 650; line-height: 1.25; padding-right: 16px; }
.act-meta { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.act-swatch {
  position: absolute; top: 12px; right: 12px;
  width: 10px; height: 10px; border-radius: 50%;
}
.act.is-on {
  border-color: currentColor;
  background: color-mix(in srgb, currentColor 9%, #fff);
  box-shadow: inset 0 0 0 1px currentColor;
}
.act.is-on .act-name { color: currentColor; }
.act.is-on .act-meta { color: color-mix(in srgb, currentColor 72%, var(--ink-2)); }
.act-add {
  align-items: center;
  justify-content: center;
  border-style: dashed;
  color: var(--ink-3);
  font-weight: 600;
  font-size: 14px;
}

/* Mental toggles */
.chip-wrap { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-size: 14.5px; font-weight: 600;
  cursor: pointer;
  transition: all .13s ease;
  -webkit-tap-highlight-color: transparent;
}
.chip:active { transform: scale(.97); }
.chip-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); }
.chip.is-on { color: #fff; border-color: currentColor; }
.chip.is-on .chip-dot { background: rgba(255,255,255,.9); }
.chip.is-on .chip-time { opacity: .85; font-weight: 500; }
.chip-time { font-size: 12.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Today's task taps, each with a remove control. */
.logged-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 5px 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.logged-x {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-3);
  cursor: pointer; padding: 0;
  -webkit-tap-highlight-color: transparent;
}
.logged-x:hover { background: #fdecef; color: var(--crash); }

/* Tasks */
.task-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.task-btn {
  display: flex; align-items: center; gap: 11px;
  min-height: 60px; padding: 10px 13px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: var(--surface);
  cursor: pointer; text-align: left;
  transition: border-color .13s ease, transform .07s ease;
  -webkit-tap-highlight-color: transparent;
}
.task-btn:active { transform: scale(.975); }
.task-count {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.task-name { display: block; font-size: 14.5px; font-weight: 650; line-height: 1.2; }
.task-sched { display: block; font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.task-btn.is-due { border-color: var(--warn); background: #fffaf0; }

/* --------------------------------------------------------------------------
   Crash
   -------------------------------------------------------------------------- */
.crash-banner {
  margin: 0 16px 0;
  margin-top: 12px;
  padding: 13px 15px;
  border-radius: var(--radius);
  background: #fdeaee;
  border: 1px solid #f3c4cd;
  color: #8f2c3d;
  font-size: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.crash-msg {
  padding: 18px;
  border-radius: var(--radius);
  background: #fdeaee;
  border: 1px solid #f3c4cd;
  color: #8f2c3d;
  margin-bottom: 14px;
}
.crash-msg h3 { font-size: 16px; margin-bottom: 6px; }
.btn-crash {
  border-color: #e9b8c0; color: var(--crash); background: #fff;
  font-weight: 700;
}
.btn-crash:hover { background: #fdf3f5; }

/* --------------------------------------------------------------------------
   Lists & timeline
   -------------------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }

.tl-item { display: flex; gap: 12px; padding: 12px 16px; align-items: flex-start; }
.tl-time {
  flex-shrink: 0;
  width: 74px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  padding-top: 1px;
}
.tl-bar { flex-shrink: 0; width: 4px; border-radius: 2px; align-self: stretch; min-height: 22px; }
.tl-body { flex: 1; min-width: 0; }
/* These two stack; without display:block the name and its detail line run
   together into one unreadable string. */
.tl-name { display: block; font-size: 14.5px; font-weight: 620; }
.tl-sub { display: block; font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.tl-actions { display: flex; gap: 4px; flex-shrink: 0; }
.tl-gap { background: #fffaf0; }
.tl-gap .tl-name { color: var(--warn); }

.badge {
  display: inline-block;
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px;
  background: #eef1f6; color: var(--ink-2);
}
.badge-exercise { background: #fdf0e2; color: #a4610f; }
.badge-rest { background: #eceffb; color: #45589c; }
.badge-mental { background: #e6f4f1; color: #2c7367; }
.badge-live { background: #e6f4ec; color: var(--good); }

/* Totals bars */
.tot { display: flex; align-items: center; gap: 11px; padding: 8px 0; }
.tot-name { width: 40%; font-size: 14px; }
.tot-track { flex: 1; height: 9px; border-radius: 5px; background: #eef1f6; overflow: hidden; }
/* Inline elements ignore height, so the fill has to be blockified or the bar
   renders as an empty track. */
.tot-fill { display: block; height: 100%; border-radius: 5px; min-width: 2px; }
.tot-val { width: 66px; text-align: right; font-size: 13.5px; font-variant-numeric: tabular-nums;
  color: var(--ink-2); }

/* Goal progress */
.goal { padding: 14px 0; border-bottom: 1px solid var(--line); }
.goal:last-child { border-bottom: 0; padding-bottom: 0; }
.goal:first-child { padding-top: 0; }
.goal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin-bottom: 9px; }
.goal-label { font-size: 15px; font-weight: 620; }
.goal-num { font-size: 13.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.goal-track { height: 12px; border-radius: 6px; background: #eef1f6; overflow: hidden; }
.goal-fill { height: 100%; border-radius: 6px; transition: width .35s ease; }
.goal-pct { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px;
  margin-bottom: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 11.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-3); }
.stat-value { font-size: 22px; font-weight: 680; margin-top: 3px;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-sub { font-size: 12.5px; color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 13px; font-weight: 620; color: var(--ink-2);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  /* 16px keeps iOS Safari from zooming the page on focus. */
  font-size: 16px;
  transition: border-color .13s ease, box-shadow .13s ease;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
/* minmax(0, 1fr) rather than 1fr: a bare 1fr floors at the item's min-content
   width, and a date/time input's min-content (text + picker icon) is wide
   enough that two of them burst out of the card on a phone. Below 400px they
   stack instead, since two shrunken pickers get unusable. */
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 12px;
}
@media (min-width: 400px) {
  .field-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.field-row > .field { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; }
.field-hint { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }

.check { display: flex; align-items: center; gap: 10px; padding: 9px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex-shrink: 0; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch {
  width: 32px; height: 32px; border-radius: 9px; border: 2px solid transparent;
  cursor: pointer; padding: 0;
}
.swatch.is-on { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }

/* 1-10 rating scale.
   Two rows of five on a phone: ten square cells in one row overflow a 390px
   screen, and squeezing them to fit leaves tap targets too small for someone
   answering these while exhausted. */
.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.scale button {
  height: 46px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  border-radius: 9px;
  font-size: 15px; font-weight: 650;
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
@media (min-width: 560px) {
  .scale { grid-template-columns: repeat(10, 1fr); gap: 5px; }
  .scale button { height: 42px; font-size: 14px; }
}
.scale button.is-on { background: var(--accent); border-color: var(--accent); color: #fff; }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px;
  color: var(--ink-3); margin-top: 6px; }
.yesterday {
  font-size: 13px; color: var(--accent-ink); background: var(--accent-soft);
  border-radius: 8px; padding: 7px 11px; margin-bottom: 12px;
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(16, 24, 38, .42);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
  animation: fade .16s ease;
  overscroll-behavior: contain;
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: .6; } }
.modal {
  width: 100%;
  max-width: 520px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  animation: rise .2s cubic-bezier(.2,.7,.3,1);
  -webkit-overflow-scrolling: touch;
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; margin-bottom: 16px; }
.modal-title { font-size: 18px; }
.modal-sub { font-size: 13.5px; color: var(--ink-3); margin-top: 3px; }
.modal-actions { display: flex; gap: 9px; margin-top: 20px; }
.modal-actions .btn { flex: 1; min-height: 46px; }

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast-root {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 12px);
  z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  width: max-content; max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: #1d2837; color: #fff;
  padding: 10px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-lg);
  animation: rise .18s ease;
}
.toast.is-warn { background: #9a6410; }
.toast.is-bad  { background: #a83a4b; }
/* The root ignores pointer events so toasts never block a tap; a toast that
   offers Undo has to opt back in. */
.toast.has-action { pointer-events: auto; padding-right: 6px; }
.toast-action {
  border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .18);
  color: #fff; font-size: 13.5px; font-weight: 700;
  padding: 6px 14px; border-radius: 999px;
  min-height: 32px;
  -webkit-tap-highlight-color: transparent;
}
.toast-action:hover { background: rgba(255, 255, 255, .3); }

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */
.chart-wrap { position: relative; width: 100%; overflow-x: auto;
  -webkit-overflow-scrolling: touch; }
.chart-wrap svg { display: block; }

.chart-tip {
  position: absolute;
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
  background: #1d2837;
  color: #fff;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: var(--shadow-lg);
  min-width: 128px;
  max-width: 220px;
}
.tip-head { font-weight: 700; margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 7px; }
.tip-key { width: 9px; height: 9px; border-radius: 2px; flex-shrink: 0; }
.tip-label { flex: 1; opacity: .82; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.tip-value { font-variant-numeric: tabular-nums; font-weight: 600; }

/* Table view — the accessible fallback for every chart. */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table thead th {
  position: sticky; top: 0; background: var(--surface);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-3); font-weight: 700;
}
.table-scroll { max-height: 420px; overflow: auto; margin: 0 -16px -16px;
  padding: 0 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  color: var(--ink-2); }
.legend-key { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

/* --------------------------------------------------------------------------
   Desktop
   -------------------------------------------------------------------------- */
@media (min-width: 900px) {
  .tabbar { display: none; }
  .main { padding-bottom: 0; margin-left: var(--sidebar-w); }

  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 40;
  }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
  .brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(150deg, #4a78d8, #2f56ad);
  }
  .brand-text { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }

  .side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .side-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px;
    border: 0; background: none; cursor: pointer;
    border-radius: 10px;
    font-size: 14.5px; font-weight: 600;
    color: var(--ink-2);
    text-align: left;
    width: 100%;
  }
  .side-link svg { width: 19px; height: 19px; flex-shrink: 0; }
  .side-link:hover { background: #f1f4f9; color: var(--ink); }
  .side-link.is-active { background: var(--accent-soft); color: var(--accent-ink); }
  .side-badge {
    margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--crash);
  }
  .sidebar-foot { padding-top: 10px; border-top: 1px solid var(--line); }

  .topbar { padding: 20px 28px 14px; }
  .topbar-title { font-size: 25px; }
  .content { padding: 20px 28px 48px; }
  .crash-banner { margin-left: 28px; margin-right: 28px; }

  .act-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .task-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  .modal-backdrop { align-items: center; padding: 24px; }
  .modal { border-radius: var(--radius-lg); max-height: 86dvh; padding: 24px; }
  .toast-root { bottom: 24px; }

  .hero { display: flex; align-items: center; justify-content: space-between; }
  .hero-timer { font-size: 46px; margin-top: 0; }
}

@media (min-width: 1180px) {
  .act-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
