/* Mies van der Rohe Architectural Minimalism — Raw HTML Light & Complementary Grayscale Dark */

:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f7;
  --bg-hover: #f2f2f2;
  --fg: #111111;
  --fg-secondary: #4a4a4a;
  --fg-muted: #737373;
  --border: #e2e2e2;
  --border-strong: #111111;
  --hr-accent: #b42318;
  --bar-fill: rgba(17, 17, 17, 0.045);
  --bar-fill-active: rgba(17, 17, 17, 0.09);
  --bar-fill-hover: rgba(17, 17, 17, 0.12);
  --bar-stroke: rgba(17, 17, 17, 0.25);
  --bar-stroke-active: rgba(17, 17, 17, 0.65);
  --grid-line: #eaeaea;
  --grid-base: #9a9a9a;
  --font-sans: "Helvetica Neue", Helvetica, Arial, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

html.dark {
  --bg: #0b0b0b;
  --bg-subtle: #141414;
  --bg-hover: #1b1b1b;
  --fg: #ededed;
  --fg-secondary: #b0b0b0;
  --fg-muted: #7a7a7a;
  --border: #262626;
  --border-strong: #ededed;
  --hr-accent: #cf6b65;
  --bar-fill: rgba(237, 237, 237, 0.05);
  --bar-fill-active: rgba(237, 237, 237, 0.1);
  --bar-fill-hover: rgba(237, 237, 237, 0.13);
  --bar-stroke: rgba(237, 237, 237, 0.24);
  --bar-stroke-active: rgba(237, 237, 237, 0.65);
  --grid-line: #1e1e1e;
  --grid-base: #5a5a5a;
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
  border-radius: 0;
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.sans {
  font-family: var(--font-sans);
}

.muted {
  color: var(--fg-muted);
}

.hr-text {
  color: var(--hr-accent);
}

.right {
  text-align: right;
}

.is-hidden {
  display: none !important;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px;
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-left,
.header-right,
.nav {
  display: flex;
  align-items: baseline;
  gap: 24px;
}

.header-right {
  gap: 18px;
  font-size: 12px;
}

.wordmark {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav-link {
  font-size: 12px;
  color: var(--fg-muted);
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--fg);
}

.nav-link.is-active {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.ws-dot {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
}

.ws-dot.is-online {
  color: var(--fg);
}

/* Main Layout */
.main-content {
  padding-top: 32px;
  padding-bottom: 56px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
  font-weight: 400;
  margin: 0;
}

/* Primary 4-Instrument Strip */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px 32px;
}

.value-row {
  margin-top: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.value {
  font-size: 38px;
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.08;
}

.unit {
  font-size: 12px;
  color: var(--fg-muted);
}

.sub {
  margin-top: 6px;
  font-size: 11px;
  color: var(--fg-muted);
}

.secondary-strip {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--fg-muted);
  word-spacing: 2px;
}

/* Graph Section */
.graph-section {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}

.graph-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px 24px;
  padding-bottom: 14px;
}

.graph-seg-line {
  font-size: 12px;
  font-weight: 500;
}

.graph-cue {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--fg-muted);
}

.graph-header-right {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 18px;
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 2px;
}

.swatch-pwr {
  background: var(--fg);
}

.swatch-hr {
  background: var(--hr-accent);
}

.graph-toggles {
  display: inline-flex;
  gap: 12px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
  font-size: 11px;
}

.graph-stage {
  position: relative;
  user-select: none;
}

.graph-stage svg {
  width: 100%;
  height: 330px;
  display: block;
  overflow: visible;
  cursor: crosshair;
}

.graph-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 12px;
  font-size: 11px;
  color: var(--fg-secondary);
}

.graph-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

/* Controls & Buttons */
.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: var(--border-strong);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
  font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.86;
}

.btn-sm {
  padding: 3px 8px;
  font-size: 11px;
}

.text-btn {
  background: none;
  border: 0;
  padding: 0;
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
  white-space: nowrap;
}

.text-btn.is-muted {
  color: var(--fg-muted);
}

.text-btn:hover {
  color: var(--fg);
}

.text-btn.is-active {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.select {
  padding: 6px 10px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  max-width: 340px;
}

.select:focus,
.text-input:focus,
.editor:focus {
  outline: none;
  border-color: var(--border-strong);
}

/* Architectural 3-Column Parameters */
.params-grid {
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 36px;
}

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

.col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.mode-tabs,
.inline-actions {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.ctrl-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ctrl-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 12px;
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-row input[type="range"] {
  flex: 1;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 1px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 9px;
  height: 14px;
  background: var(--fg);
  border: 0;
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 9px;
  height: 14px;
  background: var(--fg);
  border: 0;
  border-radius: 0;
  cursor: pointer;
}

.profile-inputs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 14px;
}

.field {
  display: block;
}

.field-label {
  display: block;
  font-size: 11px;
  color: var(--fg-muted);
  margin-bottom: 4px;
}

.line-input {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
  font-size: 12px;
}

.line-input:focus {
  outline: none;
  border-bottom-color: var(--border-strong);
}

.inline-roster {
  padding-top: 6px;
  font-size: 11px;
  color: var(--fg-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.roster-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.small-note {
  font-size: 11px;
  color: var(--fg-muted);
  min-height: 14px;
}

.debug-strip {
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  font-size: 12px;
}

/* Workouts View */
.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.view-title {
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

.view-sub {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--fg-muted);
}

.dropzone {
  border: 1px dashed var(--border);
  padding: 12px 16px;
  font-size: 12px;
  color: var(--fg-muted);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dropzone.is-drag {
  border-color: var(--border-strong);
  background: var(--bg-subtle);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.notice {
  padding: 8px 12px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.workouts-list {
  border-top: 1px solid var(--border);
}

.workout-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 6fr 4fr 2fr;
  gap: 18px;
  align-items: center;
}

.workout-meta {
  font-size: 11px;
  color: var(--fg-muted);
}

.workout-title {
  margin: 4px 0 3px;
  font-size: 14px;
  font-weight: 500;
}

.workout-desc {
  margin: 0;
  font-size: 12px;
  color: var(--fg-muted);
}

.sparkline {
  height: 40px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.spark-bar {
  background: var(--fg-muted);
  opacity: 0.45;
}

.spark-bar.hi {
  background: var(--fg);
  opacity: 0.85;
}

.spark-bar.med {
  background: var(--fg);
  opacity: 0.55;
}

.spark-bar.lo {
  background: var(--fg-muted);
  opacity: 0.25;
}

/* Protocol Inspector */
.proto-grid {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 24px;
  align-items: start;
}

.proto-table-wrap {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.proto-table-head,
.proto-row {
  display: grid;
  grid-template-columns: 72px 54px 1fr 70px;
  gap: 10px;
  padding: 7px 6px;
  font-size: 11px;
}

.proto-table-head {
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
}

.proto-rows {
  max-height: 360px;
  overflow-y: auto;
}

.proto-row {
  width: 100%;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
}

.proto-row:hover,
.proto-row.is-selected {
  background: var(--bg-subtle);
}

.proto-row .hex {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proto-detail,
.inject-form {
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preset-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
}

.text-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  font-size: 12px;
  background: transparent;
  border: 1px solid var(--border);
}

/* Native Dialog Modals */
.modal {
  width: min(700px, calc(100vw - 32px));
  max-height: 90vh;
  padding: 24px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--fg);
}

.modal-wide {
  width: min(980px, calc(100vw - 32px));
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

.modal-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
}

.modal-sub {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--fg-muted);
}

.modal-body {
  padding-top: 18px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.two-col-tight {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.three-col-tight {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.divider-top {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.roster-list {
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

.roster-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.editor {
  width: 100%;
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  resize: vertical;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--fg-muted);
  cursor: pointer;
}

.preview-table {
  max-height: 210px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.preview-row {
  display: grid;
  grid-template-columns: 1fr 56px 76px 46px;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}

/* Crash Recovery Banner */
.recovery-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  padding: 10px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  font-size: 12px;
}

.recovery-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 14px;
}

/* Finish Ride Summary Modal */
.finish-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px 20px;
}

.finish-stat {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.finish-val {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Hosted Account Chip & Danger Button */
.account-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
  font-size: 12px;
}

.btn-danger {
  border-color: var(--hr-accent);
  color: var(--hr-accent);
}

.btn-danger:hover:not(:disabled) {
  background: var(--hr-accent);
  color: var(--bg);
  border-color: var(--hr-accent);
}

/* Hosted Auth Gate */
.auth-gate {
  display: flex;
  justify-content: center;
  padding: 56px 0 32px;
}

.auth-card {
  width: min(440px, 100%);
  padding: 32px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
}

.auth-title {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.auth-sub {
  margin: 0;
  font-size: 12px;
}

.auth-btn {
  width: 100%;
  padding: 10px 14px;
}

.auth-legal {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 11px;
  padding-top: 6px;
}

/* Ride History View */
.history-list {
  border-top: 1px solid var(--border);
}

.history-item {
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 18px;
}

.history-title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.history-metrics {
  font-size: 12px;
  color: var(--fg-secondary);
}

.history-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--border);
  color: var(--fg-secondary);
}

.pill-ok {
  border-color: var(--border-strong);
  color: var(--fg);
}

.pill-pending {
  border-style: dashed;
  color: var(--fg-muted);
}

.pill-err {
  border-color: var(--hr-accent);
  color: var(--hr-accent);
}

/* Settings & Integrations */
.integration-card,
.admin-cred-card {
  border: 1px solid var(--border);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.integration-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.integration-name {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.stat-table-wrap {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stat-table-head,
.stat-table-row {
  display: grid;
  grid-template-columns: 1.5fr 0.7fr 0.7fr 0.7fr 1.6fr;
  gap: 10px;
  padding: 7px 4px;
  font-size: 11px;
}

.stat-table-head {
  color: var(--fg-muted);
  border-bottom: 1px solid var(--border);
}

.stat-table-rows {
  max-height: 240px;
  overflow-y: auto;
}

.stat-table-row {
  border-bottom: 1px solid var(--border);
}

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

.cred-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

.invite-form {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 14px;
  align-items: end;
}

.invites-list {
  border-top: 1px solid var(--border);
}

.invite-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.account-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
}

@media (max-width: 820px) {
  .metrics-grid,
  .finish-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .profile-inputs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .params-grid,
  .proto-grid,
  .two-col,
  .workout-item,
  .cred-form-grid,
  .invite-form {
    grid-template-columns: 1fr;
  }
  .three-col-tight {
    grid-template-columns: 1fr;
  }
  .stat-table-head,
  .stat-table-row {
    grid-template-columns: 1.3fr 0.6fr 0.6fr 0.6fr 1fr;
  }
}
