:root {
  --ink: #18231f;
  --muted: #6c7772;
  --paper: #eef0eb;
  --card: #fafbf7;
  --line: #d8ddd6;
  --sidebar: #17231f;
  --lime: #b8df4d;
  --blue: #5f9ed1;
  --orange: #dc8848;
  --violet: #8b76c5;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: #edf2ed;
}

.brand {
  height: 48px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 720;
  letter-spacing: -0.025em;
}

.brand-mark {
  position: relative;
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf4e8;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark i {
  content: "";
  width: 2px;
  border-radius: 4px;
  background: #72922d;
}

.brand-mark::before {
  height: 7px;
  transform: translate(7px, 4px);
}

.brand-mark::after {
  height: 14px;
  transform: translate(-7px, -4px);
}

.brand-mark i {
  position: absolute;
  height: 21px;
}

.main-nav {
  display: grid;
  gap: 5px;
  margin-top: 32px;
}

.nav-item {
  width: 100%;
  height: 45px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #aeb9b3;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 590;
  transition: 140ms ease;
}

.nav-item:hover {
  background: rgb(255 255 255 / 6%);
  color: #fff;
}

.nav-item.active {
  background: #2c3934;
  color: #fff;
}

.nav-item.active .nav-icon {
  background: var(--lime);
  color: #233019;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #27342f;
  color: #92a099;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 10px 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgb(255 255 255 / 9%);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 4px rgb(184 223 77 / 10%);
}

.sidebar-foot strong,
.sidebar-foot span {
  display: block;
}

.sidebar-foot strong {
  font-size: 11px;
}

.sidebar-foot div span {
  margin-top: 3px;
  color: #8f9c96;
  font-size: 10px;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  min-height: 76px;
  padding: 14px clamp(20px, 3vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  background: rgb(238 240 235 / 92%);
  backdrop-filter: blur(12px);
}

.topbar p,
.topbar h1 {
  margin: 0;
}

.topbar p {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 720;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar h1 {
  margin-top: 3px;
  font-size: 22px;
  font-weight: 680;
  letter-spacing: -0.035em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.public-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.public-badge .status-dot {
  width: 7px;
  height: 7px;
}

[data-app-mode="local"] [data-public-only] {
  display: none !important;
}

[data-app-mode="public"] .tag-row {
  cursor: default;
}

.button {
  height: 37px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 670;
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

#apply-sleep-chart:disabled {
  cursor: default;
  opacity: 0.42;
}

.button.primary {
  background: var(--ink);
  color: #fff;
}

.button.primary:hover {
  background: #293a33;
}

.button.secondary {
  border-color: #cfd5ce;
  background: #f8f9f5;
  color: #45524c;
}

.button.small {
  height: 32px;
  padding-inline: 11px;
  font-size: 11px;
}

.view {
  width: min(1560px, 100%);
  padding: 24px clamp(20px, 3vw, 42px) 48px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.training-calendar-panel + .metric-grid {
  margin-top: 12px;
}

.training-calendar-panel {
  padding-bottom: 14px;
  overflow: hidden;
}

.training-calendar-head {
  align-items: center;
}

.training-calendar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.training-calendar-actions > span {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.training-calendar-strip {
  margin-top: 14px;
  padding: 2px 1px 8px;
  display: grid;
  grid-auto-columns: minmax(112px, 1fr);
  grid-auto-flow: column;
  gap: 7px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
  scrollbar-color: #c9d0c9 transparent;
  scrollbar-width: thin;
}

.training-calendar-day {
  min-width: 0;
  min-height: 116px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-top: 3px solid #c9cfca;
  border-radius: 7px;
  background: #f5f6f2;
  scroll-snap-align: end;
}

.training-calendar-day.active {
  border-top-color: var(--lime);
  background: #fbfcf8;
}

.training-calendar-day.latest {
  box-shadow: inset 0 0 0 1px rgb(76 105 84 / 22%);
}

.training-calendar-day > header {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: baseline;
  gap: 2px 5px;
}

.training-calendar-day > header span,
.training-calendar-day > header i {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-style: normal;
  text-transform: uppercase;
}

.training-calendar-day > header strong {
  grid-row: 1 / span 2;
  grid-column: 2;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  font-weight: 620;
  letter-spacing: -0.04em;
}

.training-calendar-workouts {
  margin-top: 9px;
  display: grid;
  gap: 4px;
}

.training-calendar-workouts > span {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  color: #41524a;
  font-size: 8px;
  font-weight: 680;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.training-calendar-workouts b {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: #e6edd6;
  color: #587025;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 7px;
}

.training-calendar-workouts small {
  color: var(--muted);
  font-size: 7px;
}

.training-calendar-day > footer {
  margin-top: auto;
  padding-top: 8px;
  color: var(--muted);
  font-size: 7px;
  white-space: nowrap;
}

.training-calendar-rest {
  margin: auto 0;
  display: grid;
  justify-items: center;
  gap: 6px;
  color: #9ca49f;
  font-size: 8px;
}

.training-calendar-rest i {
  width: 22px;
  height: 1px;
  background: #cbd1cc;
}

.metric-card,
.chart-card,
.panel,
.timeline-summary article {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--card);
  box-shadow: 0 1px 2px rgb(33 48 41 / 3%);
}

.metric-card {
  min-height: 126px;
  padding: 18px;
  border-top: 3px solid var(--lime);
}

.metric-card.blue {
  border-top-color: var(--blue);
}

.metric-card.orange {
  border-top-color: var(--orange);
}

.metric-card.violet {
  border-top-color: var(--violet);
}

.eyebrow {
  margin: 0;
  color: #77817c;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
  font-weight: 740;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 17px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(25px, 2.8vw, 36px);
  font-weight: 590;
  letter-spacing: -0.06em;
  line-height: 1;
}

.metric-value span {
  margin-left: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0;
}

.metric-card > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.chart-grid,
.chart-stack {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.chart-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-card {
  min-width: 0;
  padding: 18px 18px 12px;
}

.card-head {
  min-height: 42px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.card-head h2,
.activity-toolbar h2 {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 670;
  letter-spacing: -0.025em;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
}

.chart-card-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
}

.trend-toggle {
  height: 31px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: #78827d;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 720;
}

.trend-toggle:hover {
  color: var(--ink);
}

.trend-toggle.active {
  border-color: #aab6af;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(30 44 37 / 12%);
}

.trend-window-select {
  height: 31px;
  padding: 0 22px 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 720;
}

.chart-range {
  padding: 2px;
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ecefe9;
}

.chart-range button {
  height: 25px;
  min-width: 33px;
  padding: 0 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #78827d;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 720;
}

.chart-range button:hover {
  color: var(--ink);
}

.chart-range button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgb(30 44 37 / 12%);
}

.chart-legend span,
.chart-legend button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend button {
  padding: 2px 3px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: inherit;
  transition:
    opacity 120ms ease,
    background 120ms ease;
}

.chart-legend button:hover {
  background: #ecefe9;
}

.chart-legend button.muted {
  opacity: 0.32;
}

.chart-legend button.muted i {
  background: #8d9691 !important;
}

.chart-legend i {
  width: 16px;
  height: 2px;
  border-radius: 3px;
}

.chart-legend .sleep-overlay-control {
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0f2ed;
}

.sleep-overlay-control select {
  height: 24px;
  padding: 0 19px 0 6px;
  border: 0;
  border-left: 1px solid var(--line);
  background: transparent;
  color: #59645f;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 700;
}

.sleep-rolling-control {
  height: 31px;
  padding-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0f2ed;
}

.sleep-rolling-control > span {
  color: #6d7872;
  font-size: 8px;
  font-weight: 700;
}

.sleep-rolling-control select {
  height: 29px;
  padding: 0 21px 0 7px;
  border: 0;
  border-left: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 720;
}

.sleep-rolling-control select:disabled {
  color: #9aa29e;
  cursor: default;
}

.sleep-custom-range {
  min-height: 31px;
  padding: 3px 5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f0f2ed;
}

.sleep-custom-range label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sleep-custom-range span {
  color: #6d7872;
  font-size: 8px;
  font-weight: 700;
}

.sleep-custom-range input {
  width: 116px;
  height: 23px;
  padding: 0 5px;
  border: 1px solid #d3d9d2;
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 270px;
  margin-top: 12px;
}

.chart-wrap canvas {
  display: block;
}

.sleep-night-nav {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 48px;
  height: 62px;
  border: 1px solid #c6cec7;
  border-radius: 10px;
  background: rgb(250 251 247 / 92%);
  color: #30443b;
  box-shadow: 0 5px 18px rgb(31 45 38 / 14%);
  cursor: pointer;
  font-family: ui-sans-serif, system-ui;
  font-size: 38px;
  font-weight: 420;
  line-height: 1;
  transform: translateY(-50%);
  backdrop-filter: blur(5px);
}

.sleep-night-nav:hover:not(:disabled) {
  border-color: #8e9b93;
  background: #fff;
  transform: translateY(-50%) scale(1.04);
}

.sleep-night-nav.previous {
  left: 8px;
}

.sleep-night-nav.next {
  right: 8px;
}

.sleep-night-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

.chart-hover-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.chart-hover-overlay[hidden],
.chart-hover-dot[hidden] {
  display: none;
}

.chart-hover-guide,
.chart-hover-dot {
  position: absolute;
  display: block;
  pointer-events: none;
}

.chart-hover-guide {
  width: 1px;
  border-left: 1px dashed #89938e;
  transform: translateX(-0.5px);
  opacity: 0.75;
}

.chart-hover-dot {
  width: 9px;
  height: 9px;
  border: 2px solid var(--point-color);
  border-radius: 50%;
  background: #fff;
  box-shadow:
    0 0 0 2px rgb(250 251 247 / 80%),
    0 2px 5px rgb(28 42 35 / 20%);
  transform: translate(-50%, -50%);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 0.75fr);
  gap: 12px;
  margin-top: 12px;
}

.sleep-night-header {
  min-height: 88px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.sleep-night-header h2 {
  margin: 5px 0 0;
  font-size: 20px;
  letter-spacing: -0.035em;
}

.sleep-night-header > div > p:not(.eyebrow) {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.sleep-compact-header {
  min-height: 58px;
  margin-bottom: 10px;
}

.sleep-verdict {
  min-height: 190px;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  border-left: 4px solid #8a9690;
}

.sleep-verdict.good {
  border-left-color: #7da33d;
}

.sleep-verdict.fair {
  border-left-color: #d59a42;
}

.sleep-verdict.poor {
  border-left-color: #cf674c;
}

.sleep-score-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sleep-score-badge {
  width: 108px;
  height: 108px;
  flex: 0 0 auto;
  display: grid;
  place-content: center;
  border: 8px solid #e2e7df;
  border-radius: 50%;
  text-align: center;
}

.sleep-verdict.good .sleep-score-badge {
  border-color: #dbe9bc;
}

.sleep-verdict.fair .sleep-score-badge {
  border-color: #f2dfbb;
}

.sleep-verdict.poor .sleep-score-badge {
  border-color: #f1cec4;
}

.sleep-score-badge strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.07em;
  line-height: 0.9;
}

.sleep-score-badge span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
}

.low-hr-score-badge {
  position: relative;
  width: 92px;
  min-height: 92px;
  padding: 10px 8px;
  display: grid;
  place-content: center;
  border: 2px solid #b8d5c6;
  border-radius: 14px;
  background: #eaf3ee;
  color: #49705f;
  text-align: center;
}

.metric-info-button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 17px;
  height: 17px;
  padding: 0;
  border: 1px solid #91b5a2;
  border-radius: 50%;
  background: transparent;
  color: #49705f;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 11px;
  font-weight: 700;
  line-height: 15px;
}

.metric-info-button:hover,
.metric-info-button:focus-visible {
  background: #d6e8de;
  outline: none;
}

.low-hr-score-badge > span,
.low-hr-score-badge small {
  font-size: 8px;
}

.low-hr-score-badge > span {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.low-hr-score-badge > div {
  margin: 4px 0;
  white-space: nowrap;
}

.low-hr-score-badge strong {
  color: #315f4c;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -0.06em;
}

.low-hr-score-badge i {
  margin-left: 2px;
  color: #638173;
  font-size: 8px;
  font-style: normal;
}

.low-hr-score-badge small {
  color: #638173;
}

.sleep-verdict-copy h2 {
  margin: 5px 0 0;
  font-size: clamp(22px, 3vw, 32px);
  letter-spacing: -0.045em;
}

.sleep-verdict-copy > p:last-of-type {
  max-width: 780px;
  margin: 8px 0 0;
  color: #53605a;
  font-size: 12px;
  line-height: 1.5;
}

.sleep-quick-metrics {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.sleep-quick-metrics span {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f3f5f0;
  color: var(--muted);
  font-size: 9px;
}

.sleep-quick-metrics strong {
  margin-right: 4px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.sleep-quick-metrics .low-hr-metric {
  border-color: #bed6ca;
  background: #eaf3ee;
  color: #49705f;
}

.sleep-quick-metrics .low-hr-metric strong {
  color: #315f4c;
}

.sleep-glance-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.sleep-glance-card {
  min-height: 118px;
  border-top: 3px solid #aab2ae;
}

.sleep-glance-card.support {
  border-top-color: #7ca33d;
}

.sleep-glance-card.headwind {
  border-top-color: #d47651;
}

.sleep-glance-card > span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 8px;
  font-weight: 740;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sleep-glance-card > strong {
  margin-top: 13px;
  display: block;
  font-size: 12px;
}

.sleep-glance-card > p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.sleep-patterns {
  margin-top: 12px;
}

.sleep-pattern-list {
  margin-top: 12px;
}

.sleep-pattern-list article {
  min-height: 58px;
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) 70px;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.sleep-pattern-list article > i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.sleep-pattern-list article > i.positive {
  background: #7ca33d;
}

.sleep-pattern-list article > i.negative {
  background: #d47651;
}

.sleep-pattern-list strong,
.sleep-pattern-list span {
  display: block;
}

.sleep-pattern-list strong {
  font-size: 11px;
}

.sleep-pattern-list span,
.sleep-pattern-list small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.sleep-pattern-list small {
  text-align: right;
}

.sleep-no-pattern {
  padding: 19px 0 4px;
  border-top: 1px solid var(--line);
}

.sleep-no-pattern strong,
.sleep-no-pattern span {
  display: block;
}

.sleep-no-pattern strong {
  font-size: 11px;
}

.sleep-no-pattern span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
}

.sleep-lower-summary {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(210px, 0.65fr) minmax(0, 2fr);
  gap: 20px;
}

.sleep-pattern-compact {
  padding-right: 20px;
  border-right: 1px solid var(--line);
}

.sleep-pattern-compact h2,
.sleep-compact-title h2 {
  margin: 4px 0 0;
  font-size: 15px;
  letter-spacing: -0.025em;
}

.sleep-pattern-empty {
  min-height: 76px;
  margin-top: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 7px;
  background: #f2f4ef;
}

.sleep-pattern-empty > i {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border: 2px solid #929c97;
  border-radius: 50%;
}

.sleep-pattern-empty strong,
.sleep-pattern-empty span {
  display: block;
}

.sleep-pattern-empty strong {
  font-size: 10px;
}

.sleep-pattern-empty span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.4;
}

.sleep-pattern-compact-list {
  margin-top: 10px;
}

.sleep-pattern-compact-list article {
  min-height: 39px;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.sleep-pattern-compact-list article > i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.sleep-pattern-compact-list article > i.positive {
  background: #7ca33d;
}

.sleep-pattern-compact-list article > i.negative {
  background: #d47651;
}

.sleep-pattern-compact-list strong,
.sleep-pattern-compact-list span {
  display: block;
}

.sleep-pattern-compact-list strong {
  font-size: 9px;
}

.sleep-pattern-compact-list span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.sleep-compact-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.sleep-compact-title > span {
  color: var(--muted);
  font-size: 8px;
}

.sleep-night-strip {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(7, minmax(70px, 1fr));
  gap: 7px;
}

.sleep-night-strip button {
  min-width: 0;
  min-height: 82px;
  padding: 9px 8px;
  border: 1px solid var(--line);
  border-top: 3px solid #aab2ae;
  border-radius: 7px;
  background: #f7f8f4;
  cursor: pointer;
  text-align: left;
}

.sleep-night-strip button.good {
  border-top-color: #83a943;
}

.sleep-night-strip button.fair {
  border-top-color: #d69a43;
}

.sleep-night-strip button.poor {
  border-top-color: #d16e51;
}

.sleep-night-strip button:hover {
  background: #fff;
}

.sleep-night-strip button.active {
  border-color: #83918a;
  box-shadow: 0 0 0 2px rgb(84 104 94 / 10%);
}

.sleep-night-strip span,
.sleep-night-strip strong,
.sleep-night-strip i,
.sleep-night-strip small {
  display: block;
}

.sleep-night-strip span {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sleep-night-strip strong {
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 17px;
  font-weight: 610;
}

.sleep-night-strip i,
.sleep-night-strip small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 7px;
  font-style: normal;
}

.sleep-history-compact button {
  grid-template-columns: minmax(120px, 1fr) 60px 80px 100px;
}

.sleep-details {
  margin-top: 12px;
  padding: 0;
  overflow: hidden;
}

.sleep-details > summary {
  padding: 17px 18px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 680;
  list-style-position: inside;
}

.sleep-details[open] > summary {
  border-bottom: 1px solid var(--line);
}

.sleep-details-body {
  padding: 18px;
}

.sleep-selectors {
  display: flex;
  gap: 8px;
}

.sleep-selectors label {
  display: grid;
  gap: 5px;
}

.sleep-selectors label > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 680;
}

.sleep-selectors select {
  height: 36px;
  min-width: 150px;
  padding: 0 28px 0 10px;
  border: 1px solid #cdd4cd;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 10px;
}

.sleep-analysis-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.sleep-insights {
  margin-top: 12px;
}

.sleep-insights > article {
  min-height: 62px;
  padding: 11px 0;
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  border-top: 1px solid var(--line);
}

.sleep-insights > article > i {
  width: 8px;
  height: 8px;
  margin-top: 3px;
  border-radius: 50%;
  background: #9ba49f;
}

.sleep-insights > article.support > i {
  background: #7ca33d;
}

.sleep-insights > article.headwind > i {
  background: #d47651;
}

.sleep-insights strong,
.sleep-insights p {
  margin: 0;
}

.sleep-insights strong {
  font-size: 11px;
}

.sleep-insights p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.sleep-factor-grid {
  margin-top: 13px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sleep-factor {
  min-width: 0;
  min-height: 86px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f4f6f1;
}

.sleep-factor span,
.sleep-factor strong,
.sleep-factor i {
  display: block;
}

.sleep-factor span {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.sleep-factor strong {
  margin-top: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  font-weight: 580;
}

.sleep-factor i {
  margin-top: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sleep-associations-panel {
  margin-top: 12px;
}

.sleep-association-list {
  margin-top: 13px;
}

.sleep-association-list article {
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(100px, 1.6fr) 72px 130px;
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.sleep-association-list article div:first-child strong,
.sleep-association-list article div:first-child span {
  display: block;
}

.sleep-association-list article div:first-child strong {
  font-size: 10px;
}

.sleep-association-list article div:first-child span,
.sleep-association-list article > span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 8px;
}

.sleep-association-list article > strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  text-align: right;
}

.sleep-association-list article > strong.positive {
  color: #638830;
}

.sleep-association-list article > strong.negative {
  color: #c66245;
}

.association-bar {
  height: 5px;
  overflow: hidden;
  border-radius: 5px;
  background: #e2e6df;
}

.association-bar i {
  width: calc(var(--association) * 100%);
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--association-color);
}

.analysis-note {
  margin: 12px 0 0;
  padding-top: 11px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.sleep-history-table {
  margin-top: 13px;
}

.sleep-history-table button {
  width: 100%;
  min-height: 49px;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 70px 80px 90px 90px;
  gap: 12px;
  align-items: center;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.sleep-history-table button:hover {
  background: #f3f5f0;
}

.sleep-history-table span {
  color: var(--muted);
  font-size: 9px;
}

.sleep-history-table strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.panel {
  padding: 18px;
}

.span-2 {
  min-width: 0;
}

.subtle {
  color: var(--muted);
  font-size: 10px;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #4c714d;
  cursor: pointer;
  font-size: 11px;
  font-weight: 680;
}

.text-button:hover {
  text-decoration: underline;
}

.text-button.danger {
  color: #b95348;
}

.activity-list {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}

.activity-list.full {
  max-height: calc(100vh - 205px);
  overflow: auto;
}

.activity-row {
  min-height: 67px;
  display: grid;
  grid-template-columns: 34px minmax(180px, 1fr) 92px 92px 72px;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.activity-row:last-child {
  border-bottom: 0;
}

.activity-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: #e6edd6;
  color: #587025;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
}

.activity-row strong,
.activity-row span {
  display: block;
}

.activity-row strong {
  overflow: hidden;
  font-size: 11px;
  font-weight: 670;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-row span {
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-stack {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.tag-row {
  width: 100%;
  padding: 9px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.tag-row:last-child {
  border-bottom: 0;
}

.tag-row > span:last-child {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.annotation-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 650;
  text-align: left;
}

.annotation-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--tag-color);
}

.timeline-list,
.annotation-table {
  margin-top: 14px;
}

.timeline-row {
  min-height: 63px;
  display: grid;
  grid-template-columns: 8px 120px minmax(0, 1fr) 40px;
  gap: 14px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.timeline-row > i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.timeline-row time {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.timeline-row strong,
.timeline-row p {
  margin: 0;
}

.timeline-row strong {
  font-size: 11px;
}

.timeline-row p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
}

.medical-prompts {
  padding: 18px 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.medical-prompts button {
  min-height: 35px;
  padding: 0 12px;
  border: 1px dashed #bdc7bd;
  border-radius: 7px;
  background: #f4f6f1;
  color: #53615a;
  cursor: pointer;
  font-size: 10px;
  font-weight: 620;
}

.medical-prompts button:hover {
  border-style: solid;
  background: #fff;
}

.activity-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.filters {
  display: flex;
  gap: 8px;
}

.filters input,
.filters select {
  height: 36px;
  border: 1px solid #cdd4cd;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 11px;
  outline: none;
}

.filters input {
  width: 220px;
  padding: 0 11px;
}

.filters select {
  min-width: 150px;
  padding: 0 28px 0 10px;
}

.filters input:focus,
.filters select:focus {
  border-color: #7d947a;
  box-shadow: 0 0 0 3px rgb(125 148 122 / 12%);
}

.list-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.timeline-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.timeline-summary article {
  min-height: 100px;
  padding: 16px;
}

.timeline-summary span,
.timeline-summary strong,
.timeline-summary i {
  display: block;
}

.timeline-summary span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-summary strong {
  margin-top: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 16px;
  font-weight: 580;
}

.timeline-summary i {
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

.annotation-table article {
  min-height: 58px;
  display: grid;
  grid-template-columns: 8px 115px minmax(0, 1fr) 82px 34px 44px;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
}

.annotation-table article > i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.annotation-table time,
.annotation-table .category {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 9px;
}

.annotation-table article div strong,
.annotation-table article div span {
  display: block;
}

.annotation-table article div strong {
  font-size: 11px;
}

.annotation-table article div span {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.annotation-table .category {
  text-transform: capitalize;
}

.empty-state {
  padding: 30px 10px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.empty-state.compact {
  padding-block: 18px;
}

.chart-tooltip {
  position: fixed;
  z-index: 30;
  width: 200px;
  padding: 10px 11px;
  border: 1px solid #cfd5ce;
  border-radius: 7px;
  background: rgb(250 251 247 / 96%);
  box-shadow: 0 10px 30px rgb(31 45 38 / 18%);
  pointer-events: none;
  font-size: 10px;
}

.chart-tooltip b,
.chart-tooltip span,
.chart-tooltip em {
  display: block;
}

.chart-tooltip b {
  margin-bottom: 7px;
  font-size: 10px;
}

.chart-tooltip span {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.chart-tooltip span i {
  width: 8px;
  height: 2px;
}

.chart-tooltip span strong {
  margin-left: auto;
  color: var(--ink);
}

.chart-tooltip span.tooltip-average {
  margin-top: 2px;
  padding-left: 14px;
  font-size: 9px;
  opacity: 0.82;
}

.chart-tooltip span.tooltip-average i {
  width: 10px;
  opacity: 0.75;
}

.chart-tooltip em {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
  color: #b44f45;
  font-style: normal;
  font-weight: 650;
}

dialog {
  width: min(460px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 25px 80px rgb(21 34 28 / 28%);
}

dialog::backdrop {
  background: rgb(14 23 19 / 52%);
  backdrop-filter: blur(2px);
}

#tag-form {
  padding: 21px;
  display: grid;
  gap: 14px;
}

.metric-info-dialog {
  padding: 21px;
}

.metric-info-dialog > p {
  margin: 14px 0 0;
  color: #53605a;
  font-size: 11px;
  line-height: 1.55;
}

.metric-score-scale {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid #bed6ca;
  border-radius: 8px;
  background: #eaf3ee;
}

.metric-score-scale span {
  padding: 11px 8px;
  text-align: center;
}

.metric-score-scale span + span {
  border-left: 1px solid #bed6ca;
}

.metric-score-scale strong,
.metric-score-scale i {
  display: block;
}

.metric-score-scale strong {
  color: #315f4c;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 18px;
}

.metric-score-scale i {
  margin-top: 3px;
  color: #638173;
  font-size: 8px;
  font-style: normal;
}

.metric-info-dialog ul {
  margin: 16px 0 0;
  padding-left: 18px;
  color: #53605a;
  font-size: 10px;
  line-height: 1.6;
}

.metric-info-dialog .metric-info-note {
  padding: 10px;
  border-radius: 7px;
  background: #f1f3ef;
  font-size: 9px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2px;
}

.dialog-head h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.icon-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 6px;
  background: #ecefe9;
  color: #5f6a65;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

#tag-form label {
  display: grid;
  gap: 6px;
}

#tag-form label > span {
  color: #5f6a65;
  font-size: 10px;
  font-weight: 650;
}

#tag-form input,
#tag-form select,
#tag-form textarea {
  width: 100%;
  border: 1px solid #cbd2ca;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

#tag-form input,
#tag-form select {
  height: 39px;
  padding: 0 10px;
}

#tag-form textarea {
  padding: 10px;
  resize: vertical;
}

#tag-form input:focus,
#tag-form select:focus,
#tag-form textarea:focus {
  border-color: #7d947a;
  box-shadow: 0 0 0 3px rgb(125 148 122 / 12%);
}

.dialog-actions {
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-error {
  margin: 0;
  color: #b95348;
  font-size: 10px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 22px;
  bottom: 22px;
  padding: 11px 14px;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 12px 35px rgb(25 38 32 / 24%);
  font-size: 11px;
  font-weight: 650;
}

.fatal-error {
  max-width: 560px;
  padding: 24px;
  border: 1px solid #d7a095;
  border-radius: 9px;
  background: #fff2ee;
}

.fatal-error strong,
.fatal-error span {
  display: block;
}

.fatal-error span {
  margin-top: 7px;
  color: #795b54;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .sidebar {
    padding-inline: 10px;
  }

  .brand {
    justify-content: center;
    padding: 0;
  }

  .brand > span:last-child,
  .nav-item > span:last-child,
  .sidebar-foot div {
    display: none;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .sidebar-foot {
    justify-content: center;
  }

  .metric-grid,
  .timeline-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .sleep-analysis-grid {
    grid-template-columns: 1fr;
  }

  .sleep-glance-grid {
    grid-template-columns: 1fr;
  }

  .sleep-lower-summary {
    grid-template-columns: 1fr;
  }

  .sleep-pattern-compact {
    padding: 0 0 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sleep-night-strip {
    padding-bottom: 4px;
    grid-template-columns: repeat(7, minmax(82px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 20;
    top: auto;
    bottom: 0;
    width: 100%;
    height: 64px;
    padding: 7px 10px;
    flex-direction: row;
    align-items: center;
  }

  .brand,
  .sidebar-foot {
    display: none;
  }

  .main-nav {
    width: 100%;
    margin: 0;
    grid-template-columns: repeat(6, 1fr);
  }

  .nav-item {
    height: 50px;
    flex-direction: column;
    gap: 3px;
    font-size: 8px;
  }

  .nav-item > span:last-child {
    display: block;
  }

  .nav-icon {
    width: 22px;
    height: 22px;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .view {
    padding-bottom: 88px;
  }

  .metric-grid,
  .chart-grid,
  .timeline-summary {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    height: 235px;
  }

  .sleep-night-nav {
    width: 40px;
    height: 52px;
    font-size: 32px;
  }

  .card-head {
    flex-direction: column;
  }

  .training-calendar-actions {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
  }

  .training-calendar-strip {
    grid-auto-columns: 104px;
  }

  .chart-card-actions {
    width: 100%;
    align-items: flex-start;
  }

  .chart-range {
    width: 100%;
  }

  .chart-range button {
    flex: 1;
  }

  .sleep-custom-range {
    width: 100%;
  }

  .sleep-custom-range label {
    flex: 1;
  }

  .sleep-custom-range input {
    width: 100%;
  }

  .activity-row {
    grid-template-columns: 32px minmax(0, 1fr) 72px;
  }

  .activity-row > div:nth-child(4),
  .activity-row > div:nth-child(5) {
    display: none;
  }

  .activity-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    flex-direction: column;
  }

  .filters input,
  .filters select {
    width: 100%;
  }

  .sleep-night-header {
    align-items: stretch;
    flex-direction: column;
  }

  .sleep-verdict {
    min-height: 0;
    grid-template-columns: 158px minmax(0, 1fr);
    gap: 15px;
  }

  .sleep-score-cluster {
    gap: 8px;
  }

  .sleep-score-badge {
    width: 72px;
    height: 72px;
    border-width: 6px;
  }

  .sleep-score-badge strong {
    font-size: 24px;
  }

  .low-hr-score-badge {
    width: 72px;
    min-height: 72px;
    padding: 6px 4px;
  }

  .low-hr-score-badge strong {
    font-size: 18px;
  }

  .sleep-quick-metrics {
    margin-top: 14px;
  }

  .sleep-selectors {
    flex-direction: column;
  }

  .sleep-selectors select {
    width: 100%;
  }

  .sleep-factor-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .sleep-association-list article {
    padding: 10px 0;
    grid-template-columns: minmax(120px, 1fr) 70px;
  }

  .sleep-association-list .association-bar,
  .sleep-association-list article > span {
    display: none;
  }

  .sleep-history-table button {
    grid-template-columns: minmax(145px, 1fr) 45px 60px;
  }

  .sleep-history-table button span:nth-child(4),
  .sleep-history-table button span:nth-child(5) {
    display: none;
  }

  .timeline-row {
    grid-template-columns: 8px 90px minmax(0, 1fr);
  }

  .timeline-row .text-button {
    display: none;
  }

  .annotation-table article {
    grid-template-columns: 8px 86px minmax(0, 1fr) 36px;
  }

  .annotation-table .category,
  .annotation-table .danger {
    display: none;
  }
}
