:root {
  color-scheme: light;
  --background: #fcf9f5;
  --surface: #ffffff;
  --surface-low: #f6f3ef;
  --surface-high: #eae8e4;
  --ink: #1c1c1a;
  --muted: #665d52;
  --outline: #ded5c9;
  --primary: #825500;
  --amber: #ffb84c;
  --amber-soft: #ffddb3;
  --green: #416924;
  --green-soft: #dff4cd;
  --lime: #9ed875;
  --coral: #a43d1b;
  --coral-soft: #ffdbd1;
  --danger: #ba1a1a;
  --shadow: 0 14px 34px -18px rgba(83, 55, 15, 0.26);
  --radius: 12px;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--background); scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: "Quicksand", "PingFang SC", "Hiragino Sans GB", sans-serif;
  font-weight: 600;
  letter-spacing: 0;
}

button, input { font: inherit; }
button { letter-spacing: 0; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(255, 184, 76, .55); outline-offset: 3px; }
img { display: block; max-width: 100%; }
h1, h2, p { margin: 0; }
h1, h2, strong, .wordmark { font-family: "Plus Jakarta Sans", "PingFang SC", sans-serif; letter-spacing: 0; }
h1 { font-size: 32px; line-height: 1.22; }
h2 { font-size: 17px; line-height: 1.35; }
.material-symbols-rounded { font-size: 21px; line-height: 1; font-variation-settings: "FILL" 0, "wght" 500; }

.app-bar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: 80px;
  background: rgba(252, 249, 245, .96);
  border-bottom: 1px solid rgba(214, 196, 176, .55);
  box-shadow: 0 16px 34px -28px rgba(84, 48, 0, .55);
  backdrop-filter: blur(16px);
}

.app-bar-inner {
  width: min(1200px, calc(100% - 48px));
  height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.wordmark {
  width: max-content;
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}

.desktop-nav { display: flex; align-items: center; gap: 8px; }
.nav-item {
  min-height: 40px;
  padding: 8px 15px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: color .2s ease, background .2s ease, transform .2s ease;
}
.nav-item:hover { color: var(--primary); background: var(--amber-soft); transform: translateY(-1px); }
.nav-item.active { color: #604000; background: var(--amber); }
.nav-item.active .material-symbols-rounded { font-variation-settings: "FILL" 1, "wght" 500; }

.top-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
.connection-pill, .live-badge {
  min-height: 32px;
  padding: 6px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  white-space: nowrap;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #99938c; box-shadow: 0 0 0 4px rgba(153, 147, 140, .13); }
.status-dot.online { background: #5f9c39; box-shadow: 0 0 0 4px rgba(95, 156, 57, .15); animation: pulse 2s ease-in-out infinite; }
.status-dot.warning { background: var(--amber); box-shadow: 0 0 0 4px rgba(255, 184, 76, .18); }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(95, 156, 57, .05); } }

.icon-button, .avatar-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--primary);
  background: transparent;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.icon-button:hover { background: var(--amber-soft); transform: translateY(-1px); }
.avatar-button { overflow: hidden; border: 2px solid var(--amber); }
.avatar-button:hover { transform: rotate(3deg) scale(1.05); }
.avatar-button img { width: 100%; height: 100%; object-fit: cover; }

.app-shell { width: min(1200px, calc(100% - 48px)); min-height: 100vh; margin: 0 auto; padding: 112px 0 52px; }
.view { display: none; }
.view.active { display: block; }
.surface-panel, .metric-card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.reveal { animation: rise-in .48s both cubic-bezier(.2, .75, .25, 1); }
.delay-1 { animation-delay: .06s; }
.delay-2 { animation-delay: .12s; }
.delay-3 { animation-delay: .18s; }
.delay-4 { animation-delay: .24s; }
@keyframes rise-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.error-banner {
  display: none;
  margin: 0 0 18px;
  padding: 12px 16px;
  align-items: center;
  gap: 10px;
  border: 1px solid #f1b4aa;
  border-radius: 8px;
  color: #7f2417;
  background: #fff0ed;
  font-size: 13px;
}
.error-banner.visible { display: flex; }

.eyebrow { color: var(--primary); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.subtle { color: var(--muted); font-size: 14px; line-height: 1.6; }
.home-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, .9fr); gap: 24px; }
.welcome-panel { min-height: 230px; padding: 28px; display: flex; align-items: center; gap: 26px; overflow: hidden; }
.portrait-wrap { width: 150px; height: 150px; flex: 0 0 auto; overflow: hidden; border: 4px solid var(--amber); border-radius: 50%; background: var(--surface-low); }
.portrait-wrap img { width: 100%; height: 100%; object-fit: cover; }
.welcome-copy h1 { max-width: 530px; margin-top: 7px; color: var(--ink); }
.welcome-copy .subtle { margin-top: 8px; }
.tag-row { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag { width: max-content; min-height: 28px; padding: 4px 10px; display: inline-flex; align-items: center; gap: 5px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.tag .material-symbols-rounded { font-size: 16px; }
.tag.green { color: #315614; background: var(--green-soft); }
.tag.peach { color: #873014; background: var(--coral-soft); }

.story-panel { min-height: 230px; padding: 28px; position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #4f3300; background: var(--amber); border: 1px solid #e39a25; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.story-kicker { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.story-panel p { max-width: 290px; margin-top: 8px; font-size: 17px; line-height: 1.55; }
.story-panel strong { margin-top: 8px; font-size: 42px; line-height: 1; }
.story-panel strong small { margin-left: 5px; font-family: inherit; font-size: 13px; }
.paw-trail { position: absolute; right: 16px; bottom: 3px; color: rgba(79, 51, 0, .24); font-size: 56px; line-height: 1; transform: rotate(-18deg); }

.metric-grid { margin-top: 24px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric-card { min-height: 154px; padding: 20px; display: flex; flex-direction: column; transition: transform .2s ease, box-shadow .2s ease; }
.metric-card:hover { transform: translateY(-3px); box-shadow: 0 18px 38px -20px rgba(83, 55, 15, .34); }
.metric-icon { margin-bottom: 15px; font-size: 27px; }
.amber { color: #e58d00; }
.green-text { color: var(--green); }
.coral { color: var(--coral); }
.brown { color: var(--primary); }
.neutral { color: #756a5d; }
.lime { color: #79ac50; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.metric-card div { margin-top: 7px; display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.metric-card strong { max-width: 100%; font-size: 29px; line-height: 1.15; overflow-wrap: anywhere; }
.metric-card small { color: var(--muted); font-size: 11px; }
.activity-card { grid-column: span 2; min-height: 154px; padding: 22px 26px; display: flex; align-items: center; gap: 20px; color: #315614; background: #e9f7dc; border: 1px solid #b7dc99; border-radius: var(--radius); box-shadow: var(--shadow); }
.activity-icon { width: 68px; height: 68px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--lime); }
.activity-icon .material-symbols-rounded { font-size: 34px; font-variation-settings: "FILL" 1, "wght" 500; }
.activity-card strong { display: block; margin-top: 4px; font-size: 22px; }
.activity-card p { margin-top: 3px; color: #54763c; font-size: 12px; }

.page-heading { margin-bottom: 24px; display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.page-heading .eyebrow { margin-bottom: 7px; }
.page-heading .subtle { margin-top: 8px; }
.live-badge { color: #315614; border-color: #bedba8; background: #f2faec; }
.live-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr); gap: 18px; align-items: stretch; }
.speed-panel { min-height: 420px; padding: 22px; display: flex; flex-direction: column; }
.panel-title { min-height: 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-title > div:first-child { display: flex; align-items: center; gap: 8px; min-width: 0; }
.panel-title > span, .panel-title > strong { color: var(--muted); font-size: 12px; white-space: nowrap; }
.speed-gauge { --gauge: 0deg; width: 230px; height: 230px; margin: 24px auto 20px; position: relative; display: grid; place-items: center; border-radius: 50%; background: conic-gradient(var(--amber) var(--gauge), var(--surface-high) 0); transform: rotate(-90deg); }
.speed-gauge::before { content: ""; position: absolute; inset: 19px; border-radius: 50%; background: var(--surface); }
.gauge-center { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; transform: rotate(90deg); }
.gauge-center strong { font-size: 42px; }
.gauge-center span { color: var(--muted); font-size: 12px; }
.mini-stats { margin-top: auto; display: grid; grid-template-columns: repeat(3, 1fr); border-radius: 9px; background: var(--surface-low); }
.mini-stats div { min-width: 0; padding: 13px 10px; text-align: center; border-right: 1px solid var(--outline); }
.mini-stats div:last-child { border-right: 0; }
.mini-stats span { display: block; color: var(--muted); font-size: 10px; }
.mini-stats strong { display: block; margin-top: 3px; font-size: 13px; overflow-wrap: anywhere; }
.live-side { display: grid; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.goal-panel, .last-run-panel { padding: 22px; }
.goal-panel { display: flex; flex-direction: column; justify-content: center; }
.progress-track, .milestone-track { height: 11px; overflow: hidden; border-radius: 999px; background: var(--surface-high); }
.progress-track { margin-top: 27px; }
.progress-track span, .milestone-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--amber); transition: width .5s ease; }
.goal-panel p, .last-run-panel p { margin-top: 12px; color: var(--muted); font-size: 12px; }
.last-run-panel { display: flex; flex-direction: column; justify-content: center; background: var(--green-soft); border-color: #c4e3ad; }
.last-run-panel div { margin-top: 7px; display: flex; align-items: baseline; gap: 7px; }
.last-run-panel strong { color: var(--green); font-size: 36px; }
.last-run-panel div span { color: var(--green); font-size: 13px; }
.speed-history-panel { margin-top: 18px; padding: 22px; overflow: hidden; }
.speed-chart-meta { display: flex; align-items: baseline; gap: 14px; color: var(--muted); font-size: 11px; }
.speed-chart-meta strong { color: var(--coral); font-size: 11px; }
.speed-chart-meta strong span { font-size: 20px; }
.speed-chart-wrap { height: 240px; margin-top: 18px; position: relative; }
.speed-chart { width: 100%; height: 100%; display: block; overflow: visible; }
.speed-chart-grid { stroke: #e8e0d7; stroke-width: 1; vector-effect: non-scaling-stroke; }
.speed-chart-grid.vertical { stroke-dasharray: 3 6; }
.speed-chart-label { fill: var(--muted); font: 600 10px "Quicksand", "PingFang SC", sans-serif; letter-spacing: 0; }
.speed-chart-area { fill: url(#speedAreaGradient); }
.speed-chart-line { fill: none; stroke: #c5542d; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 2px 2px rgba(164, 61, 27, .08)); vector-effect: non-scaling-stroke; }
.speed-chart-point { fill: var(--coral); opacity: .75; }
.speed-chart-dot { fill: var(--surface); stroke: var(--coral); stroke-width: 3; vector-effect: non-scaling-stroke; }
.speed-chart-hit { fill: transparent; stroke: transparent; pointer-events: all; }
.speed-chart-empty { position: absolute; inset: 0; display: none; place-items: center; color: var(--muted); font-size: 12px; }
.speed-chart-empty.visible { display: grid; }
.timeline-panel { margin-top: 18px; padding: 22px; }
.date-chip { padding: 5px 10px; border-radius: 999px; background: var(--surface-low); }
.timeline-chart { height: 210px; margin-top: 22px; padding: 0 2px 24px; display: grid; grid-template-columns: repeat(24, minmax(5px, 1fr)); align-items: end; gap: 5px; border-bottom: 1px solid var(--outline); }
.hour-column { height: 100%; position: relative; display: flex; align-items: flex-end; outline: none; }
.hour-bar { width: 100%; min-height: 5px; border-radius: 5px 5px 1px 1px; background: #eee8e0; transition: height .35s ease, filter .2s ease; }
.hour-column:hover .hour-bar, .hour-column:focus-visible .hour-bar { filter: brightness(.9); }
.hour-column time { position: absolute; left: 50%; bottom: -22px; color: var(--muted); font-size: 9px; transform: translateX(-50%); white-space: nowrap; }
.hour-tooltip { width: max-content; max-width: 180px; padding: 8px 10px; position: absolute; z-index: 4; left: 50%; bottom: calc(100% + 8px); display: grid; gap: 2px; border-radius: 6px; color: #fff; background: #31302e; box-shadow: 0 8px 20px rgba(49, 48, 46, .18); opacity: 0; pointer-events: none; transform: translate(-50%, 5px); transition: opacity .16s ease, transform .16s ease; }
.hour-tooltip::after { content: ""; width: 7px; height: 7px; position: absolute; left: 50%; bottom: -3px; background: #31302e; transform: translateX(-50%) rotate(45deg); }
.hour-tooltip strong { font-size: 11px; line-height: 1.3; }
.hour-tooltip small { color: #d8d4cf; font-size: 9px; white-space: nowrap; }
.hour-column:hover .hour-tooltip, .hour-column:focus-visible .hour-tooltip { opacity: 1; transform: translate(-50%, 0); }
.hour-column:nth-child(-n+3) .hour-tooltip { left: 0; transform: translate(0, 5px); }
.hour-column:nth-child(-n+3):hover .hour-tooltip, .hour-column:nth-child(-n+3):focus-visible .hour-tooltip { transform: translate(0, 0); }
.hour-column:nth-child(-n+3) .hour-tooltip::after { left: 12px; }
.hour-column:nth-last-child(-n+3) .hour-tooltip { right: 0; left: auto; transform: translate(0, 5px); }
.hour-column:nth-last-child(-n+3):hover .hour-tooltip, .hour-column:nth-last-child(-n+3):focus-visible .hour-tooltip { transform: translate(0, 0); }
.hour-column:nth-last-child(-n+3) .hour-tooltip::after { right: 12px; left: auto; transform: rotate(45deg); }
.hour-bar.level-1 { background: #d9f0c8; }
.hour-bar.level-2 { background: #9ed875; }
.hour-bar.level-3 { background: #ffb84c; }
.hour-bar.level-4 { background: #ff9f80; }
.timeline-legend { margin-top: 28px; display: flex; justify-content: center; flex-wrap: wrap; gap: 18px; color: var(--muted); font-size: 11px; }
.timeline-legend span { display: flex; align-items: center; gap: 6px; }
.timeline-legend i { width: 9px; height: 9px; border-radius: 3px; }
.legend-rest { background: #eee8e0; }.legend-light { background: #d9f0c8; }.legend-active { background: #9ed875; }.legend-sprint { background: #ffb84c; }

.segmented { padding: 3px; display: inline-flex; border: 1px solid var(--outline); border-radius: 999px; background: var(--surface); }
.segmented button { min-width: 66px; padding: 7px 13px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.segmented button.active { color: #5d3d00; background: var(--amber-soft); }
.history-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(290px, .8fr); gap: 18px; align-items: stretch; }
.trend-panel, .records-panel, .calendar-panel { padding: 22px; }
.trend-total { display: flex !important; align-items: baseline !important; gap: 5px !important; }
.trend-total strong { color: var(--primary); font-size: 25px !important; }
.trend-total span { color: var(--muted); font-size: 11px !important; }
.trend-note { margin-top: 8px; color: var(--green); font-size: 11px; }
.bar-chart { height: 260px; margin-top: 18px; display: grid; align-items: end; gap: 7px; border-bottom: 1px solid var(--outline); }
.daily-bar-wrap { height: 100%; min-width: 0; position: relative; display: flex; align-items: flex-end; justify-content: center; }
.daily-bar { width: min(38px, 80%); min-height: 4px; border-radius: 5px 5px 1px 1px; background: var(--amber-soft); transition: height .4s ease, background .2s ease; }
.daily-bar-wrap:hover .daily-bar, .daily-bar.today { background: var(--amber); }
.daily-bar-wrap label { position: absolute; left: 50%; bottom: -24px; color: var(--muted); font-size: 9px; transform: translateX(-50%); white-space: nowrap; }
.daily-bar-wrap output { position: absolute; left: 50%; bottom: calc(var(--bar-height) + 7px); padding: 3px 5px; border-radius: 4px; color: #5f3e00; background: var(--amber-soft); font-size: 9px; transform: translateX(-50%); white-space: nowrap; opacity: 0; pointer-events: none; }
.daily-bar-wrap:hover output, .daily-bar-wrap.featured output { opacity: 1; }
.record-list { margin-top: 14px; display: grid; gap: 10px; }
.record-list > div { min-height: 86px; padding: 15px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 3px 12px; border-radius: 9px; background: var(--surface-low); }
.record-list span { color: var(--muted); font-size: 11px; }
.record-list strong { color: var(--ink); font-size: 18px; text-align: right; }
.record-list small { grid-column: 2; color: var(--muted); font-size: 9px; text-align: right; }
.record-list .record-highlight { grid-template-columns: auto 1fr; color: var(--green); background: var(--green-soft); }
.record-highlight > .material-symbols-rounded { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: #315614; background: var(--lime); }
.record-highlight p { display: flex; flex-direction: column; color: var(--green); font-size: 11px; }
.record-highlight p strong, .record-highlight p small { grid-column: auto; color: var(--green); text-align: left; }
.calendar-panel { margin-top: 18px; }
.calendar-wrap { margin-top: 20px; display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 8px; }
.calendar-weekdays { height: 146px; display: flex; flex-direction: column; justify-content: space-between; color: var(--muted); font-size: 9px; }
.activity-calendar { height: 146px; display: grid; grid-template-rows: repeat(7, 1fr); grid-auto-flow: column; grid-auto-columns: minmax(8px, 1fr); gap: 4px; }
.calendar-cell { min-width: 0; border-radius: 3px; background: var(--surface-high); }
.calendar-cell[data-level="1"] { background: #ffe2b8; }.calendar-cell[data-level="2"] { background: #ffc66d; }.calendar-cell[data-level="3"] { background: #f3a229; }.calendar-cell[data-level="4"] { background: #d77e00; }
.calendar-legend { margin-top: 12px; display: flex; justify-content: flex-end; align-items: center; gap: 5px; color: var(--muted); font-size: 9px; }
.calendar-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--surface-high); }
.calendar-legend i[data-level="1"] { background: #ffe2b8; }.calendar-legend i[data-level="2"] { background: #ffc66d; }.calendar-legend i[data-level="3"] { background: #f3a229; }.calendar-legend i[data-level="4"] { background: #d77e00; }

.device-layout { display: grid; grid-template-columns: minmax(320px, .85fr) minmax(0, 1.45fr); gap: 18px; align-items: stretch; }
.device-panel { padding: 22px; }
.device-hero { min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.device-hero h2 { margin-top: 4px; font-size: 23px; }
.device-illustration { width: 78px; height: 78px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--green); background: var(--green-soft); border: 1px solid #b7dc99; }
.device-illustration .material-symbols-rounded { font-size: 38px; font-variation-settings: "FILL" 1, "wght" 500; }
.online-line { margin-top: 9px; display: flex; align-items: center; gap: 8px; color: var(--green); font-size: 12px; }
.device-facts { margin: 17px 0; display: grid; gap: 8px; }
.device-facts div { min-height: 45px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: 8px; background: var(--surface-low); }
.device-facts dt { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.device-facts dt .material-symbols-rounded { color: var(--primary); font-size: 17px; }
.device-facts dd { margin: 0; font-size: 12px; text-align: right; overflow-wrap: anywhere; }
.primary-button { width: 100%; min-height: 44px; padding: 10px 16px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 8px; color: #503300; background: var(--amber); font-weight: 800; cursor: pointer; transition: filter .2s ease, transform .2s ease; }
.primary-button:hover { filter: brightness(.97); transform: translateY(-1px); }
.achievement-area { display: grid; grid-template-rows: auto 1fr; gap: 18px; }
.achievement-pair { display: grid; grid-template-columns: .82fr 1.18fr; gap: 18px; }
.companion-card, .rhythm-card { min-height: 210px; padding: 20px; border-radius: var(--radius); box-shadow: var(--shadow); }
.companion-card { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #853016; background: var(--coral-soft); border: 1px solid #f4b9a8; text-align: center; }
.companion-card img { position: absolute; left: -22px; bottom: -24px; width: 112px; height: 112px; border-radius: 50%; object-fit: cover; opacity: .25; }
.companion-card span { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.companion-card strong { margin-top: 2px; font-size: 42px; line-height: 1.1; }
.companion-card small { max-width: 140px; margin-top: 4px; font-size: 10px; }
.rhythm-card { display: flex; flex-direction: column; justify-content: center; gap: 14px; background: var(--green-soft); border: 1px solid #c5e4ad; }
.rhythm-card > div { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rhythm-card strong { color: var(--green); font-size: 13px; }
.milestone-panel { padding: 22px; display: flex; flex-direction: column; justify-content: center; }
.milestone-value { margin-top: 8px; display: flex; align-items: baseline; gap: 7px; }
.milestone-value strong { color: var(--primary); font-size: 38px; }
.milestone-value span { color: var(--muted); font-size: 12px; }
.milestone-panel > p { margin-top: 4px; color: var(--muted); font-size: 12px; }
.milestone-track { margin-top: 22px; height: 12px; }
.milestone-scale { margin-top: 8px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 9px; }
.page-footer { margin-top: 16px; display: flex; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 10px; }

.mobile-nav { display: none; }
dialog { width: min(440px, calc(100% - 32px)); padding: 28px; border: 1px solid var(--outline); border-radius: 12px; color: var(--ink); background: var(--surface); box-shadow: 0 28px 80px rgba(65, 43, 12, .24); }
dialog::backdrop { background: rgba(28, 28, 26, .25); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; right: 10px; top: 10px; }
#dialogContent h2 { margin-bottom: 12px; font-size: 22px; }
#dialogContent p { color: var(--muted); font-size: 13px; line-height: 1.7; }
#dialogContent ul { margin: 14px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.8; }
.diagnostic-list { display: grid; gap: 8px; margin-top: 16px; }
.diagnostic-row { padding: 11px 12px; display: flex; justify-content: space-between; gap: 12px; border-radius: 8px; background: var(--surface-low); font-size: 12px; }
.diagnostic-row strong.good { color: var(--green); }
.diagnostic-row strong.warn { color: var(--coral); }
.toast { position: fixed; z-index: 80; left: 50%; bottom: 26px; max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 8px; color: white; background: #31302e; box-shadow: var(--shadow); font-size: 12px; transform: translate(-50%, 24px); opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 920px) {
  .app-bar-inner { width: min(100% - 32px, 760px); grid-template-columns: 1fr auto; }
  .desktop-nav { display: none; }
  .connection-pill { display: none; }
  .app-shell { width: min(100% - 32px, 760px); padding-top: 96px; padding-bottom: 110px; }
  .home-grid, .history-grid, .device-layout { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live-layout { grid-template-columns: minmax(0, 1.1fr) minmax(270px, .9fr); }
  .achievement-pair { grid-template-columns: 1fr 1fr; }
  .mobile-nav { position: fixed; z-index: 50; inset: auto 0 0; height: 78px; padding: 8px max(16px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; gap: 5px; background: rgba(255, 255, 255, .97); border-top: 1px solid var(--outline); box-shadow: 0 -14px 34px -25px rgba(84, 48, 0, .7); backdrop-filter: blur(14px); }
  .mobile-nav button { min-width: 0; min-height: 54px; padding: 6px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; }
  .mobile-nav button.active { color: #5b3b00; background: var(--amber-soft); }
  .mobile-nav button.active .material-symbols-rounded { font-variation-settings: "FILL" 1, "wght" 500; }
  .mobile-nav small { font-size: 10px; }
  .toast { bottom: 94px; }
}

@media (max-width: 680px) {
  h1 { font-size: 27px; }
  .app-bar { height: 68px; }
  .app-shell { padding-top: 86px; }
  .top-actions .icon-button { display: none; }
  .welcome-panel { min-height: 0; padding: 22px; flex-direction: column; text-align: center; }
  .portrait-wrap { width: 112px; height: 112px; }
  .tag-row { justify-content: center; }
  .story-panel { min-height: 210px; }
  .metric-grid { gap: 12px; }
  .metric-card { min-height: 138px; padding: 16px; }
  .metric-card strong { font-size: 24px; }
  .activity-card { min-height: 138px; padding: 18px; }
  .activity-icon { width: 56px; height: 56px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .live-layout { grid-template-columns: 1fr; }
  .speed-panel { min-height: 390px; }
  .live-side { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
  .goal-panel, .last-run-panel { min-height: 170px; }
  .speed-chart-wrap { height: 210px; }
  .timeline-chart { height: 180px; gap: 3px; }
  .timeline-chart time { display: none; }
  .timeline-chart .hour-column:nth-child(6n+1) time { display: block; }
  .bar-chart { overflow-x: auto; grid-auto-columns: minmax(18px, 1fr); }
  .activity-calendar { grid-auto-columns: minmax(7px, 1fr); gap: 3px; }
  .achievement-pair { grid-template-columns: 1fr; }
  .companion-card, .rhythm-card { min-height: 180px; }
  .page-footer { flex-direction: column; }
}

@media (max-width: 440px) {
  .app-bar-inner, .app-shell { width: calc(100% - 24px); }
  .metric-card { min-height: 132px; }
  .metric-icon { margin-bottom: 12px; }
  .activity-card { grid-column: span 2; }
  .activity-card strong { font-size: 18px; }
  .live-side { grid-template-columns: 1fr; }
  .speed-gauge { width: 210px; height: 210px; }
  .mini-stats strong { font-size: 11px; }
  .speed-history-panel { padding: 17px; }
  .speed-chart-meta { align-items: flex-end; flex-direction: column; gap: 2px; }
  .speed-chart-wrap { height: 190px; margin-top: 14px; }
  .trend-panel, .records-panel, .calendar-panel { padding: 17px; }
  .calendar-wrap { overflow-x: auto; }
  .activity-calendar { min-width: 560px; }
  .timeline-legend { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
