/* ── Long Run Planner Styles ── */

body {
  line-height: 1.5;
  padding: var(--safeT) env(safe-area-inset-right) var(--safeB) env(safe-area-inset-left);
  min-height: 100dvh;
  overflow-x: hidden;
}

.app-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

/* Cards */
.card {
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.card-header svg { color: var(--muted); flex-shrink: 0; }

.card-body { padding: 16px; }

/* Form inputs */
.form-group { margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.2);
}

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

.remember-key {
  margin-top: 8px;
}

/* Buttons */
.btn {
  width: 100%;
}

/* Slider */
.slider-container { position: relative; }

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.slider-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.slider-value.safe { color: var(--success); }
.slider-value.caution { color: var(--warn); }
.slider-value.danger { color: var(--danger); }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  background: var(--border);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  border: 2px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted2);
  margin-top: 24px;
}

/* Risk bar */
.risk-bar {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg,
    var(--accent) 0%,
    var(--accent) 20%,
    var(--success) 28%,
    var(--warn) 44%,
    var(--danger) 80%,
    #ff2020 100%
  );
  position: relative;
  margin: 12px 0 4px;
  cursor: pointer;
  touch-action: none;
}

.risk-sweet-spot {
  position: absolute;
  top: 100%;
  transform: translateX(-50%);
  margin-top: 2px;
  pointer-events: none;
  text-align: center;
}

.risk-sweet-spot-line {
  display: block;
  width: 2px;
  height: 8px;
  margin: 0 auto;
  border-radius: 999px;
  background: var(--success);
}

.risk-sweet-spot-text {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  line-height: 1.1;
  color: var(--success);
  font-weight: 700;
  white-space: nowrap;
}

.risk-bar-marker {
  appearance: none;
  position: absolute;
  top: 50%;
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.08s linear;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  cursor: grab;
  padding: 0;
}

.risk-bar-marker:active {
  cursor: grabbing;
}

.risk-bar-marker:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border-radius: var(--radiusMd);
  overflow: hidden;
}

.stat-cell {
  background: var(--surface);
  padding: 14px;
  text-align: center;
}

.stat-cell.full-width { grid-column: 1 / -1; }

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted2);
  font-weight: 600;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-unit {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.stat-value.accent { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.attention { color: var(--warn); }
.stat-value.danger { color: var(--danger); }

/* Risk zones table */
.risk-zones {
  width: 100%;
  border-collapse: collapse;
}

.risk-zones td {
  padding: 8px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--borderMuted);
  vertical-align: middle;
}

.risk-zones tr:last-child td { border-bottom: none; }

.risk-zones .zone-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 8px;
}

.risk-zones .zone-range { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.risk-zones .zone-hrr { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Timeline */
.timeline { padding: 4px 0; }

.timeline-controls {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}

.timeline-head {
  display: flex;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--borderMuted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted2);
}

.timeline-bar-label {
  flex: 1;
  min-width: 80px;
  text-align: left;
}

.timeline-head .timeline-date,
.timeline-head .timeline-dist,
.timeline-head .timeline-risk {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted2);
}

.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--borderMuted);
  align-items: center;
}

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

.timeline-date {
  font-size: 12px;
  color: var(--muted2);
  min-width: 70px;
  font-variant-numeric: tabular-nums;
}

.timeline-bar-wrap { flex: 1; position: relative; }

.timeline-bar {
  height: 20px;
  border-radius: 3px;
  min-width: 4px;
  transition: width 0.3s;
}

.timeline-dist {
  font-size: 12px;
  font-weight: 600;
  min-width: 70px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.timeline-bar.longest {
  box-shadow: 0 0 0 2px var(--accent);
}

.timeline-risk {
  font-size: 12px;
  font-weight: 700;
  min-width: 84px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--muted2);
}

.timeline-disclaimer {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.45;
  color: var(--muted2);
}


.risk-actions {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.risk-actions .btn {
  width: auto;
  flex: 1 1 0;
}

/* Callout — now in shared/css/components.css */

/* Loading spinner — now in shared/css/components.css as .spin */

/* Unit toggle */
.card-header-spacer { flex: 1; }

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-with-unit .form-input { flex: 1; }

.input-unit {
  min-width: 64px;
  text-align: center;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radiusMd);
}

.fetch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 10px;
}

.fetch-days { width: 100%; }
.risk-days { width: 140px; }
.fetch-row .btn { width: 100%; }

/* Paper citation */
.paper-ref {
  font-size: 12px;
  color: var(--muted2);
  padding: 12px 16px;
  border-top: 1px solid var(--borderMuted);
  line-height: 1.5;
}

.paper-ref a {
  color: var(--accent);
  text-decoration: none;
}

.paper-ref a:hover { text-decoration: underline; }

/* Transitions */
.fade-in {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radiusLg);
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background: rgba(63,185,80,0.15);
  color: var(--success);
}

.divider {
  border: none;
  border-top: 1px solid var(--borderMuted);
  margin: 16px 0;
}

/* Estimated pace / time row */
.suggestion-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}

.suggestion-row .label { color: var(--muted); }
.suggestion-row .value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Workout panel */
.workout-inline {
  margin: 12px 16px 16px;
  padding-top: 12px;
  border-top: 1px solid var(--borderMuted);
}

.workout-inline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.workout-inline-body {
  max-height: 80vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.workout-inline.open {
  animation: fadeIn 0.22s ease;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

.workout-header-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.workout-date-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.workout-date-row .form-label {
  margin-bottom: 0;
}

.workout-date-hint {
  font-size: 11px;
  color: var(--muted2);
  text-align: right;
}

#workout-date {
  display: block;
  inline-size: 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-inline-size: 0;
  box-sizing: border-box;
}

.workout-toggle-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 8px;
  margin: 0 0 12px;
  padding: 0;
}

.workout-toggle-item {
  display: block;
  min-width: 0;
}

.workout-toggle-card {
  display: grid;
  width: 100%;
  gap: 6px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
}

.workout-toggle-card:hover {
  border-color: transparent;
}

.workout-toggle-card:focus-within {
  border-color: transparent;
  box-shadow: none;
}

.workout-toggle-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted2);
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  width: 100%;
}

.workout-toggle {
  width: 100%;
  justify-self: stretch;
  min-height: 32px;
  padding: 2px;
}

.workout-toggle button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 30px;
  padding: 5px 8px;
  font-size: 11px;
  letter-spacing: 0.04em;
}

@media (max-width: 520px) {
  .workout-date-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .workout-date-hint {
    flex: 1 1 100%;
    text-align: left;
  }

  #workout-date {
    font-size: 16px;
  }
}

@media (max-width: 460px) {
  .workout-toggle-row {
    grid-template-columns: 1fr;
  }
}

.workout-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.workout-label-row .form-label {
  margin-bottom: 0;
}

.copy-workout-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.copy-workout-btn:hover {
  background: var(--surface);
  color: var(--text);
}

.copy-workout-btn:active {
  transform: scale(0.98);
}
