/* ---------------------------------------------------------
   Stride Lab — treadmill console design system
--------------------------------------------------------- */

:root {
  --bg: #e7e4dd;
  --bg-grain: #ddd9d0;
  --panel: #f5f3ef;
  --panel-border: #cac6bc;
  --screen: #14171a;
  --screen-edge: #0a0c0e;
  --ink: #20241f;
  --ink-soft: #55584f;
  --amber: #ffb020;
  --amber-dim: #7a5518;
  --cyan: #4fd3c4;
  --cyan-dim: #1f5750;
  --safety: #e03a2f;
  --safety-dark: #b12a21;
  --line: #cac6bc;

  --font-display: "Oswald", "Arial Narrow", sans-serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 1px 1px, rgba(0,0,0,0.035) 1px, transparent 0) 0 0/14px 14px,
    linear-gradient(180deg, var(--bg) 0%, var(--bg-grain) 100%);
  min-height: 100vh;
  padding: clamp(16px, 4vw, 40px);
}

.chassis {
  max-width: 980px;
  margin: 0 auto;
}

/* ---------- Header ---------- */

.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  margin-bottom: 14px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 8px 20px -16px rgba(0,0,0,0.4);
}

.header__id { display: flex; align-items: center; gap: 14px; }

.header__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--safety);
  box-shadow: 0 0 0 3px rgba(224,58,47,0.15), 0 0 10px rgba(224,58,47,0.6);
  flex: none;
}

.header__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(24px, 4vw, 32px);
  letter-spacing: 0.06em;
  margin: 0;
  color: var(--ink);
}

.header__sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

/* ---------- Buttons & pills ---------- */

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 7px;
  padding: 10px 16px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--safety);
  color: #fff8f0;
  box-shadow: 0 2px 0 var(--safety-dark), 0 6px 14px -6px rgba(224,58,47,0.55);
  width: 100%;
  margin-top: 4px;
}
.btn--primary:hover { background: #e94a3e; }

.btn--ghost {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--ink-soft);
}
.btn--ghost:hover { border-color: var(--ink-soft); color: var(--ink); }

.icon-btn {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--ink-soft);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { border-color: var(--ink-soft); color: var(--ink); }
.icon-btn--danger:hover { border-color: var(--safety); color: var(--safety); }

.pill-group, .unit-toggle {
  display: inline-flex;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
  background: var(--bg);
}

.pill {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.02em;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.pill--sm { padding: 6px 12px; font-size: 12px; }

.pill[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

/* ---------- Layout panels ---------- */

.panels {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 22px 24px 24px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset, 0 10px 24px -20px rgba(0,0,0,0.5);
}

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
  color: var(--ink);
}

.panel__title--summary {
  cursor: pointer;
  list-style: none;
}
.panel__title--summary::-webkit-details-marker { display: none; }
.panel__title--summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.15s ease;
  color: var(--safety);
}
details[open] .panel__title--summary::before { transform: rotate(90deg); }

.panel__meta { margin: 0; font-size: 12.5px; color: var(--ink-soft); font-family: var(--font-mono); }

.hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* ---------- Fields ---------- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.field label, .field__label-static {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

.field--inline { margin-top: 10px; }
.field--grow { flex: 1; min-width: 180px; }

.field__input-wrap {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 2px 10px;
  gap: 6px;
}
.field__input-wrap:focus-within {
  border-color: var(--ink);
}

.field__input-wrap--split input { width: 3.5em; text-align: right; }
.field__input-wrap--split .field__unit:not(:last-child) { margin-right: 4px; }

.field__input-wrap input {
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
  padding: 9px 0;
  width: 100%;
  min-width: 0;
}

.field__unit {
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--font-body);
  white-space: nowrap;
}

.screen {
  background: var(--screen);
  border: 1px solid var(--screen-edge);
  border-radius: 8px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.03);
}

/* ---------- Segments ---------- */

.segment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.segment {
  border: 1px solid var(--panel-border);
  background: var(--bg);
  border-radius: 8px;
  padding: 14px 16px 16px;
}

.segment__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.segment__index {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12.5px;
  color: #fff;
  background: var(--ink);
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

.segment__head-actions { display: flex; gap: 6px; }

.segment__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.field--tight label { margin-bottom: 5px; }

.pill-group--tight { width: 100%; }
.pill-group--tight .pill { flex: 1; text-align: center; }

.segment__curls {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--panel-border);
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.checkbox { padding-top: 9px; }

.curl-details:not([hidden]) {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.hint--tight {
  margin: 6px 0 0;
  font-size: 11.5px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.checkbox input {
  width: 17px;
  height: 17px;
  accent-color: var(--cyan-dim);
  cursor: pointer;
}

/* ---------- Library ---------- */

.save-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.btn--save {
  width: auto;
  margin-top: 0;
  white-space: nowrap;
  padding: 11px 20px;
}

.library-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.library-empty {
  font-size: 13px;
  color: var(--ink-soft);
  padding: 10px 2px;
}

.library-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 12px 14px;
}

.library-item__name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.library-item__meta {
  margin: 3px 0 0;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ink-soft);
}

.library-item__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.btn--sm {
  padding: 7px 14px;
  font-size: 12.5px;
}

/* ---------- Results ---------- */

.readout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.screen--readout {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.readout-label {
  font-family: var(--font-body);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9a9d94;
}

.readout-value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: clamp(34px, 6vw, 44px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.screen--amber .readout-value { color: var(--amber); text-shadow: 0 0 18px rgba(255,176,32,0.35); }
.screen--cyan .readout-value { color: var(--cyan); text-shadow: 0 0 18px rgba(79,211,196,0.35); }

.readout-unit {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #8b8f85;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat {
  background: #fff;
  border: 1px solid var(--panel-border);
  border-radius: 7px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.stat__value {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 19px;
  color: var(--ink);
}

.stat__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.table-wrap { overflow-x: auto; }

.breakdown {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 620px;
}

.breakdown th {
  text-align: left;
  font-family: var(--font-body);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
}

.breakdown td {
  padding: 9px 10px;
  font-family: var(--font-mono);
  color: var(--ink);
  border-bottom: 1px solid #e2ded4;
}

.breakdown tbody tr:last-child td { border-bottom: none; }

.breakdown td:first-child, .breakdown th:first-child { font-family: var(--font-mono); }

/* ---------- Methodology ---------- */

.panel--methodology { padding-bottom: 20px; }
.methodology-body { margin-top: 14px; }
.methodology-body p {
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.methodology-caveat { font-style: italic; }

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

.confirm-dialog {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 24px;
  max-width: 380px;
  width: calc(100% - 48px);
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 24px 60px -16px rgba(0,0,0,0.5);
}

.confirm-dialog::backdrop {
  background: rgba(10,12,14,0.55);
  backdrop-filter: blur(1px);
}

.confirm-dialog__message {
  margin: 0 0 22px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
}

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.confirm-dialog__actions .btn {
  width: auto;
  margin-top: 0;
  padding: 9px 18px;
}

@media (prefers-reduced-motion: no-preference) {
  .confirm-dialog {
    animation: confirm-in 0.15s ease;
  }
}

@keyframes confirm-in {
  from { opacity: 0; transform: translateY(4px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Print report ---------- */

.print-report { display: none; }

@media print {
  body > *:not(.print-report) { display: none !important; }

  body {
    background: #fff;
    padding: 0;
    margin: 0;
    min-height: 0;
  }

  @page {
    margin: 0.4in;
  }

  .print-report {
    display: block;
    max-width: 240px;
    color: #000;
  }

  .print-report__title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    line-height: 1.35;
    letter-spacing: 0.01em;
    margin: 0 0 10px;
  }

  .print-report__label {
    font-family: var(--font-body);
    font-size: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #555;
    margin: 0 0 3px;
  }

  .print-report__segments {
    list-style: none;
    padding: 0;
    margin: 0;
    font-family: var(--font-mono);
    font-size: 10.5px;
  }

  .print-report__segments li {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 3px 0;
    border-bottom: 1px solid #ddd;
  }
}

/* ---------- Footer ---------- */

.footer {
  text-align: center;
  padding: 20px 0 4px;
  font-size: 12px;
  color: var(--ink-soft);
}

/* ---------- Focus states ---------- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--safety);
  outline-offset: 2px;
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Responsive ---------- */

@media (max-width: 560px) {
  .header { flex-direction: column; align-items: flex-start; }
  .btn--ghost { width: 100%; }
  .segment__grid { grid-template-columns: repeat(2, 1fr); }
}
