/* Design tokens */
:root {
  --bg: #f7f7f8;
  /* neutral light surface for cards and buttons */
  --surface: #ffffff;
  --text: #222222;
  --muted: #6b6b6b;
  --accent: #6366f1;
  --radius: 10px;
  --on-accent: #ffffff;

  /* Typography sizes (semantic) */
  --fs-base: 17px; /* mobile-first reading size */
  --fs-md: 16px;
  --fs-sm: 14px;
  --fs-xs: 12px;

  /* Shared sizing tokens for touch targets and icons */
  --hit-target-sm: 36px;
  --hit-target-md: 40px;
  --icon-size-sm: 18px;
  --icon-size-md: 20px;
  --icon-size-lg: 32px;

  /* Semantic surface tokens (single source of truth for components) */
  --surface-bg: var(--surface);
  --surface-on-muted: var(--muted); /* non-active / secondary text on surface */

  /* Generic border tokens (use for cards, dividers, nav) */
  --border-color: rgba(0, 0, 0, 0.08);
  --border: 1px solid var(--border-color);

  /* Shadow and overlay tokens */
  --shadow-sm: 0 8px 18px rgba(17, 24, 39, 0.08);
  --shadow-md: 0 10px 24px rgba(38, 42, 52, 0.35);
  --overlay-backdrop: rgba(0, 0, 0, 0.28);

  /* Bottom nav layer treatment */
  --nav-bg: color-mix(in srgb, var(--surface) 85%, var(--accent) 15%);
  --nav-border-top: rgba(0, 0, 0, 0.12);
  --nav-shadow-up: 0 -8px 20px rgba(17, 24, 39, 0.15);
}

/* Explicit theme override using data-theme on html */
html[data-theme='dark'] {
  --bg: #0b0b0c;
  /* neutral dark surface for cards and buttons */
  --surface: #1c1c1e;
  --text: #e6e6e6;
  --muted: #9a9a9a;
  --on-accent: #ffffff;

  /* semantic overrides for dark */
  --surface-bg: var(--surface);
  --surface-on: rgba(255, 255, 255, 0.88);
  --surface-on-muted: rgba(255, 255, 255, 0.78);

  /* generic border color for dark */
  --border-color: hsla(0, 0%, 100%, 0.06);
  --border: 1px solid var(--border-color);

  /* Shadow and overlay tokens for dark */
  --shadow-sm: 0 10px 24px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 12px 26px rgba(0, 0, 0, 0.42);
  --overlay-backdrop: rgba(0, 0, 0, 0.42);

  /* Bottom nav layer treatment for dark */
  --nav-bg: color-mix(in srgb, var(--surface) 90%, var(--accent) 10%);
  --nav-border-top: hsla(0, 0%, 100%, 0.12);
  --nav-shadow-up: 0 -8px 20px rgba(38, 42, 52, 0.44);
}

/* Base layout */
html,
body {
  min-height: 100%;
  margin: 0;
  box-sizing: border-box;
  font-family: -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  /* set base font size from tokens so spacing scales with typography */
  font-size: var(--fs-base);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: none;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}
#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 12px; /* reduce horizontal padding to fit small screens */
  box-sizing: border-box;
  overflow: visible;
  /* ensure content does not sit under the nav (nav height 56px on small screens) */
  padding-bottom: calc(56px + 8px + env(safe-area-inset-bottom));
  max-width: 450px; /* clamp width for phone-sized content */
  margin: 0 auto; /* center on wider screens */
  width: 100%;
}

/* Screen content */
.screen {
  /* allow screen to fill the app width so header and lists use full width */
  max-width: none;
  width: 100%;
  margin: 0;
  position: relative; /* needed so the add button can be positioned relative to the screen */
}

.screen-about {
  width: calc(100% + 24px);
  margin: -12px;
}

.about-marketing-root {
  width: 100%;
}

.about-site-header,
.about-site-footer {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-left: 32px;
  padding-right: 32px;
  border-bottom: 1px solid var(--border-color);
}

.about-site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  color: var(--accent);
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  text-decoration: none;
}

.about-site-header .brand img {
  display: block;
  width: 50px;
  height: 50px;
  object-fit: contain;
}

.about-site-footer {
  min-height: 0;
  padding-top: 24px;
  padding-bottom: 28px;
  border-top: 1px solid var(--border-color);
  border-bottom: 0;
}

.about-site-footer p {
  margin: 0;
  font-size: 0.88rem;
}

.about-site-footer p span {
  color: #68727a;
}

@media (max-width: 760px) {
  .about-site-header,
  .about-site-footer {
    padding-left: 20px;
    padding-right: 20px;
  }

  .about-site-header {
    min-height: 70px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
}

.screen-header {
  display: flex;
  justify-content: space-between; /* title left, button right */
  align-items: flex-end; /* align on bottom edge */
  gap: 0px;
  margin: 0 0 8px 0;
  height: 36px;
}

.screen-header h1 {
  width: 100%;
  font-size: 24px;
  font-weight: 700;
  margin: 0;
}

.screen-header .header-controls {
  display: inline-flex;
  align-items: flex-end;
  gap: 8px;
}

.screen-header .header-menu-wrap {
  position: relative;
  display: inline-flex;
}

.screen-header .header-button-secondary {
  width: var(--hit-target-sm);
  min-width: var(--hit-target-sm);
  height: var(--hit-target-sm);
  border: none;
  background: transparent;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.screen-header .header-button-secondary:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.screen-header .header-button-secondary[aria-expanded='true'] {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.screen-header .header-button-secondary[aria-expanded='true']:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

html[data-theme='dark'] .screen-header .header-button-secondary:hover {
  background: color-mix(in srgb, var(--accent) 24%, var(--surface) 76%);
}

html[data-theme='dark']
  .screen-header
  .header-button-secondary[aria-expanded='true'],
html[data-theme='dark']
  .screen-header
  .header-button-secondary[aria-expanded='true']:hover {
  background: color-mix(in srgb, var(--accent) 30%, var(--surface) 70%);
}

.screen-header .header-button-secondary svg.feather {
  width: var(--icon-size-lg);
  height: var(--icon-size-lg);
  stroke: currentColor;
  stroke-width: 1.5;
}

.screen-header .header-menu {
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  min-width: 172px;
  padding: 8px;
  border-radius: 0;
  border: none;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg) 90%);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 80;
}

html[data-theme='dark'] .screen-header .header-menu {
  background: color-mix(in srgb, var(--accent) 24%, var(--surface) 76%);
  box-shadow: var(--shadow-md);
}

.screen-header .menu-option {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 0;
  font-size: var(--fs-sm);
  cursor: pointer;
}

.screen-header .menu-option:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.screen-header .menu-option.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

/* Position add button inside the header and make it round and match header height */
.screen-header .header-button-primary {
  flex: 0 0 var(--hit-target-md);
  width: var(--hit-target-md);
  min-width: var(--hit-target-md);
  height: var(--hit-target-md);
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%; /* make it round */
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 60;
  align-self: flex-end;
}
.screen-header .header-button-primary svg.feather {
  width: var(--icon-size-sm);
  height: var(--icon-size-sm);
  display: block;
  stroke: currentColor;
  stroke-width: 1.8;
}

/* Bottom navigation - opaque stationaty bar across bottom */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0; /* stick to bottom edge */
  height: 56px;
  display: flex;
  gap: 0;
  justify-content: space-around; /* evenly space icons */
  align-items: center;
  padding: 6px calc(10px + env(safe-area-inset-left)) 6px
    calc(10px + env(safe-area-inset-right));
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-border-top);
  box-shadow: var(--nav-shadow-up);
  z-index: 30;
  /* ensure it covers safe area on devices with home indicator */
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
}

.bottom-nav .nav-button {
  /* make each nav item vertical: icon (if present) above a small label */
  background: transparent;
  border: none;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--surface-on-muted);
  font-weight: 600;
  font-size: var(--fs-sm);
  min-width: 46px;
}

.bottom-nav .nav-button svg.feather {
  width: var(--icon-size-md);
  height: var(--icon-size-md);
  flex-shrink: 0;
}

.bottom-nav .nav-button .nav-label {
  white-space: nowrap;
}

.bottom-nav .nav-button.active {
  color: var(--accent);
}

/* reduce visual chrome when focused */
.bottom-nav .nav-button:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent);
  outline-offset: 2px;
}

.bottom-nav .nav-save-button {
  position: static;
  justify-content: center;
  display: none;
  pointer-events: none;
}

.bottom-nav.tracking-active .nav-button[data-screen='lists'] {
  display: none;
}

.bottom-nav.tracking-active .nav-button[data-screen='history'] {
  display: none;
}

.bottom-nav.tracking-active .nav-button[data-screen='about'] {
  display: none;
}

.bottom-nav.tracking-active .nav-button[data-screen='track'] {
  display: none;
}

.bottom-nav.tracking-active .nav-save-button {
  display: flex;
  pointer-events: auto;
}

/* Lists screen styles */
.lists-container {
  display: flex;
  flex-direction: column;
  gap: 0; /* rows will have their own separators */
  margin-top: 12px;

  /* card surface */
  background: var(--surface-bg);
  border: var(--border);
  border-radius: 12px;
  /* remove inner padding so row dividers reach container edges */
  padding: 0;
  width: 100%;
  position: relative; /* allow positioned children (the add button) to align to the card edge */
}

.list-item {
  border-bottom: var(--border);
}
.list-item:last-child {
  border-bottom: none;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* give rows their own horizontal padding; no radius so dividers are straight */
  padding: 12px 12px 12px 16px;
  border-radius: 0;
  background: transparent;
  border: none;
  gap: 12px;
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}

.list-row:hover {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.list-row.selected {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.list-title.editable,
.breadcrumb-current.editable,
.detail-item-label.editable {
  cursor: text;
  border-bottom: 1px dashed color-mix(in srgb, var(--accent) 45%, transparent);
}

.list-title-input,
.detail-breadcrumb-input,
.detail-item-input {
  width: 100%;
  max-width: 100%;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: calc(var(--radius) - 3px);
  background: var(--surface-bg);
  color: var(--text);
  font-size: inherit;
  line-height: 1.2;
  padding: 2px 6px;
}

.list-title-input,
.detail-breadcrumb-input {
  font-weight: inherit;
}

.list-title-input:focus,
.detail-breadcrumb-input:focus,
.detail-item-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* round the outer corners by applying radius to first/last rows so card keeps rounded corners */
.list-item:first-child .list-row {
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.list-item:last-child .list-row {
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.list-item.expanded:last-child .list-row {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.list-drawer {
  display: flex;
  gap: 8px;
  padding: 4px 12px 10px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.history-session-drawer {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.history-session-inline-row {
  display: block;
  width: 100%;
}

.history-session-inline-row .track-progress {
  margin-top: 0;
}

.history-session-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding-top: 4px;
}

.history-session-actions-row .drawer-action {
  flex: 0 0 auto;
  justify-content: space-between;
}

.list-item:last-child .list-drawer {
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.drawer-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  padding: 6px 8px;
  font-size: var(--fs-sm);
  border-radius: var(--radius);
  cursor: pointer;
}

.drawer-action svg.feather {
  width: var(--icon-size-sm);
  height: var(--icon-size-sm);
  flex: 0 0 auto;
  stroke: currentColor;
  stroke-width: 2;
}

.drawer-action:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.drawer-action.primary {
  background: var(--accent);
  color: var(--on-accent);
  border-color: var(--accent);
}

.drawer-action.primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, black);
}

.drawer-action:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Built-in badge: small filled pill using accent tint for visibility */
.badge,
.track-grid-count {
  padding: 3px 8px;
  font-size: var(--fs-xs);
  /* slightly rounded but not fully pill-shaped */
  border-radius: calc(var(--radius) - 2px);
  line-height: 1;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
}

/* Ensure rows remain flat in dark mode as well */
html[data-theme='dark'] .lists-container {
  background: var(--surface-bg);
  border: var(--border);
}
html[data-theme='dark'] .badge,
html[data-theme='dark'] .track-grid-count {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}
html[data-theme='dark'] .list-item {
  border-bottom: var(--border);
}

html[data-theme='dark'] .list-drawer {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface-bg));
}

.list-meta {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.item-count-text {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1;
}

.list-row-count {
  align-self: center;
}

.row-delete,
.detail-item-delete {
  border: none;
  background: transparent;
  color: var(--accent);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.row-delete {
  line-height: 1;
}

.row-delete svg.feather,
.detail-item-grip svg.feather,
.detail-item-delete svg.feather {
  width: var(--icon-size-sm);
  height: var(--icon-size-sm);
  stroke: currentColor;
  stroke-width: 2;
}

.row-delete:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.screen-header .detail-breadcrumb {
  width: auto;
  min-width: 0;
  flex: 1 1 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.screen-header .detail-breadcrumb .badge {
  margin-left: 4px;
}

.list-breadcrumb-link {
  color: var(--accent);
  text-decoration: none;
}

.list-breadcrumb-link:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: var(--muted);
}

.breadcrumb-current {
  color: var(--text);
}

.track-breadcrumb-root {
  cursor: default;
  user-select: none;
}

.detail-breadcrumb-input {
  min-width: 0;
}

.list-detail-card {
  overflow: hidden;
}

.list-detail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0 0;
  color: var(--muted);
  font-size: var(--fs-xs);
  text-align: left;
}

.list-detail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 12px 16px;
  border-bottom: var(--border);
  font-size: var(--fs-md);
  font-weight: 500;
}

.list-detail-item:last-child {
  border-bottom: none;
}

.list-detail-item.selected {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.list-detail-item.detail-drop-target {
  position: relative;
}

.list-detail-item.detail-drop-target::before {
  content: '';
  position: absolute;
  left: 10px;
  right: 10px;
  height: 2px;
  background: color-mix(in srgb, var(--accent) 75%, transparent);
  border-radius: 1px;
}

.list-detail-item.detail-drop-target[data-drop-position='before']::before {
  top: 0;
  transform: translateY(-1px);
}

.list-detail-item.detail-drop-target[data-drop-position='after']::before {
  bottom: 0;
  transform: translateY(1px);
}

.detail-item-chosen {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.detail-item-ghost {
  opacity: 0.35;
}

.detail-item-drag {
  opacity: 0.9;
}

.detail-item-main {
  min-width: 0;
  flex: 1;
}

.detail-item-grip {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: none;
  background: transparent;
  padding: 0;
  cursor: grab;
  touch-action: none;
  -webkit-user-drag: none;
}

.detail-item-grip:active {
  cursor: grabbing;
}

.detail-item-label {
  display: inline-block;
}

.detail-item-delete {
  flex: 0 0 auto;
}

.list-detail-empty {
  padding: 14px;
  color: var(--muted);
  font-size: var(--fs-md);
}

.list-detail-empty-copy {
  margin-bottom: 10px;
}

.list-detail-empty-input {
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: calc(var(--radius) - 3px);
  background: var(--surface-bg);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.3;
  padding: 8px 10px;
}

.list-detail-empty-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Track screen states */
.track-picker-card {
  padding: 12px;
}

.track-picker-wrap {
  position: relative;
  z-index: 20;
}

.track-picker-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.track-picker-toggle {
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border-color));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--text);
  padding: 7px 10px;
  display: block;
  text-align: left;
  cursor: pointer;
}

.track-picker-toggle:hover {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.track-picker-selected-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.track-picker-selected-right svg.feather {
  width: var(--icon-size-sm);
  height: var(--icon-size-sm);
  stroke: var(--accent);
  stroke-width: 2.2;
}

.track-picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin-top: 0;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--surface-bg);
  box-shadow: var(--shadow-sm);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow: auto;
  z-index: 40;
}

html[data-theme='dark'] .track-picker-menu {
  box-shadow: var(--shadow-md);
}

.track-picker-option {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  border-radius: calc(var(--radius) - 3px);
  padding: 7px 10px;
  display: block;
  cursor: pointer;
}

.track-picker-option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.track-picker-option-name {
  font-size: var(--fs-md);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-picker-option-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.track-picker-option:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.track-picker-option.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.track-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.track-start-button {
  flex: 0 0 auto;
}

.track-empty {
  padding: 14px;
  color: var(--muted);
  font-size: var(--fs-md);
}

.track-active-body {
  margin-top: 12px;
  min-height: 180px;
  padding: 10px;
}

.track-progress {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.track-progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.track-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--muted) 24%, transparent);
}

.track-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.18s ease;
}

.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
}

.track-grid-button {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border-color);
  border-radius: calc(var(--radius) - 2px);
  background: var(--surface-bg);
  color: var(--text);
  padding: 5px 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
  cursor: pointer;
}

.track-grid-button:hover {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-bg));
}

.track-grid-button:active {
  transform: translateY(1px);
}

.track-grid-button[data-count='0'] {
  color: var(--muted);
  background: color-mix(in srgb, var(--surface-bg) 92%, transparent);
  border-color: color-mix(in srgb, var(--border-color) 82%, transparent);
}

.track-grid-button:not([data-count='0']) {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-bg));
  border-color: color-mix(in srgb, var(--accent) 20%, var(--border-color));
}

.track-grid-button:not([data-count='0']) .track-grid-label {
  font-weight: 700;
}

.track-grid-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.track-grid-count {
  align-self: center;
  min-width: 24px;
  min-height: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 6px;
  font-weight: 700;
}

.track-grid-count.track-grid-count-zero {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border-color);
}

.track-summary-line {
  white-space: nowrap;
}

.history-chart-card {
  margin-top: 8px;
}

.history-chart-wrap {
  position: relative;
  min-height: 180px;
  height: clamp(180px, 28vh, 320px);
  padding: 8px 10px 6px;
}

.history-chart-canvas {
  width: 100%;
  height: 100%;
}

.history-chart-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.history-chart-fallback[hidden] {
  display: none !important;
}

.history-full-list {
  margin-top: 10px;
}

.history-full-list-summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  padding: 6px 2px;
}

.history-full-list-card {
  margin-top: 6px;
}

.history-detail-note {
  margin-top: 8px;
}

.session-exit-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 120;
}

.session-exit-dialog {
  width: min(360px, 100%);
  background: var(--surface-bg);
  border: var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-exit-title {
  font-size: var(--fs-md);
  font-weight: 700;
}

.session-exit-copy {
  font-size: var(--fs-sm);
  color: var(--muted);
}

.session-exit-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
