:root {
  --bg: #0b0f14;
  --bg-2: #111827;
  --card: #0f141b;
  --card-2: #151c24;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #34d399;
  --accent-2: #10b981;
  --border: #1f2937;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background-image:
    url("data:image/svg+xml,%3Csvg width='200' height='40' viewBox='0 0 200 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 26 L10 20 L20 26 L30 14 L40 26 L50 8 L60 26 L70 8 L80 26 L90 20 L100 26 L110 20 L120 26 L130 14 L140 26 L150 8 L160 26 L170 8 L180 26 L190 20 L200 26' fill='none' stroke='%2334d399' stroke-opacity='0.12' stroke-width='1.4'/%3E%3C/svg%3E"),
    radial-gradient(circle at 10% 10%, rgba(52, 211, 153, 0.12), transparent 45%),
    radial-gradient(circle at 90% 0%, rgba(14, 116, 94, 0.22), transparent 55%),
    linear-gradient(140deg, #0a0f14, #0d141c 40%, #0b1016);
  background-color: #0b1016;
  background-size: 240px 56px, 100% 100%, 100% 100%, 100% 100%;
  background-repeat: repeat, no-repeat, no-repeat, no-repeat;
  font-family: "Noto Sans JP", "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

h1, h2 {
  margin: 0 0 8px;
  letter-spacing: -0.02em;
}

h1 {
  font-family: "Sora", "Inter", sans-serif;
}

h2 {
  font-family: "Noto Sans JP", "Open Sans", "Inter", sans-serif;
  font-weight: 600;
}

header p {
  margin-top: 0;
  color: var(--muted);
}

.site-logo {
  font-family: "Space Mono", "Sora", monospace;
  font-size: 36px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ecfdf5;
}

.top-nav {
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
  margin-top: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.top-nav a {
  color: #a7f3d0;
  text-decoration: none;
  font-family: "Noto Sans JP", "Inter", sans-serif;
  font-weight: 600;
  font-size: 18px;
}

.top-nav a.active {
  color: #ecfdf5;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
}

.top-nav a:hover {
  color: #ecfdf5;
  text-decoration: none;
}

.logout-form {
  margin: 0 0 0 auto;
}

.btn-logout {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 500;
}

.btn-logout:hover {
  background: #1f2937;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.intro-page {
  min-height: 78vh;
  display: grid;
  place-items: center;
}

.intro-card {
  width: fit-content;
  display: grid;
  gap: 18px;
  padding: 28px;
}

.intro-cta-link {
  display: inline-block;
  text-decoration: none;
}

.intro-cta-image {
  width: 225px;
  max-width: 100%;
  height: 40px;
  display: block;
  border-radius: 8px;
}

.gate-form {
  display: grid;
  gap: 12px;
}

.gate-label {
  font-family: "Noto Sans JP", "Inter", sans-serif;
  font-size: 14px;
  font-weight: 400;
}

.gate-input {
  min-width: 280px;
  text-transform: none;
}

.gate-error {
  margin: 0;
  color: #fca5a5;
  font-size: 14px;
}

.gate-submit {
  justify-self: start;
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  column-gap: 12px;
  row-gap: 4px;
  align-items: start;
  margin-bottom: 16px;
  font-family: "Noto Sans JP", "Inter", sans-serif;
  text-transform: lowercase;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 16px;
}

input, select, button {
  font: inherit;
}

input, select {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 16px;
}

select {
  min-height: 96px;
}

input::placeholder {
  color: #6b7280;
}

.btn {
  background: var(--accent);
  color: #051309;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-weight: 600;
}

.btn:hover {
  background: var(--accent-2);
}

.btn-alt {
  background: #111827;
  color: #e2e8f0;
}

.btn-alt:hover {
  background: #0b1220;
}

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

.buttons .btn {
  font-size: 16px;
  font-weight: 400;
}

.grade-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.grade-controls .label {
  color: var(--text);
}

.grade-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.grade-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn-chip {
  background: var(--card-2);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
}

.btn-chip:hover {
  background: #1f2937;
}

.btn-chip.active {
  background: var(--accent);
  color: #04110c;
}

.btn-chip-apply {
  background: #0f172a;
  color: #e2e8f0;
  padding: 6px 12px;
}

.btn-chip-apply:hover {
  background: #111827;
}

.quick-range {
  grid-column: 1 / span 2;
  grid-row: 2;
  display: flex;
  gap: 8px;
  margin-top: -4px;
}

.btn-range {
  background: #0f172a;
  color: #e2e8f0;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 300;
}

.btn-range:hover {
  background: #111827;
}

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

.stacked-grid {
  display: grid;
  gap: 16px;
}

.trend-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  gap: 16px;
}

.summary-grid {
  align-items: start;
}

.feed-grid {
  align-items: stretch;
}

.feed-sections {
  display: grid;
  gap: 16px;
}

.feed-activity-section {
  padding: 0;
}

.feed-info-card {
  min-height: 520px;
  padding: 16px;
}

.feed-activity-name {
  margin-bottom: 6px;
}

.feed-activity-date {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.feed-metric-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.feed-incline-panel {
  display: grid;
  grid-template-columns: minmax(90px, auto) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.feed-incline-value {
  margin: 0;
  white-space: nowrap;
  font-size: 24px;
}

.feed-incline-box-chart {
  width: 100%;
  min-height: 124px;
}

.feed-metric-incline-card {
  grid-column: 1 / -1;
  padding-bottom: 4px;
}

.feed-metric-positive-card {
  grid-column: auto;
}

.feed-metric-heart-rate-change-card {
  grid-column: auto;
}

.feed-empty-message {
  margin: 0;
  color: var(--muted);
}

.feed-controls {
  margin-top: 16px;
}

.feed-controls .feed-activity-field {
  grid-column: 3 / span 2;
  grid-row: 2;
}

.feed-controls #feed-activity-select {
  min-height: 40px;
}

.feed-controls #feed-status {
  grid-column: 1 / -1;
}

.feed-map-empty {
  margin: 0;
  min-height: 520px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.feed-map-empty[hidden] {
  display: none !important;
}

.feed-map-card {
  display: flex;
  padding: 16px;
}

.kpi-panel {
  min-height: 520px;
}

.kpi-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "distance elevation"
    "time time";
  gap: 12px;
}

.kpi-distance {
  grid-area: distance;
}

.kpi-elevation {
  grid-area: elevation;
}

.kpi-time {
  grid-area: time;
}

.kpi-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 12px;
  background: var(--card-2);
}

.kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi-value {
  margin: 8px 0 0;
  font-size: 28px;
  font-weight: 700;
  color: #ecfdf5;
  font-family: "Space Mono", "Sora", monospace;
  font-weight: 400;
}

.feed-positive-arrow {
  margin-left: 8px;
  color: #34d399;
  font-size: 0.95em;
  vertical-align: middle;
}

.feed-heart-rate-good-arrow {
  margin-left: 8px;
  color: #34d399;
  font-size: 0.95em;
  vertical-align: middle;
}

.controls label,
.controls .quick-range,
.controls .buttons {
  align-self: start;
}

.activities-grid {
  align-items: start;
}

.activities-select-inline {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.activities-select-label {
  color: var(--muted);
  font-size: 14px;
}

.activities-select {
  min-height: 40px;
  width: 100%;
}

.activities-detail-card {
  margin-bottom: 16px;
}

.activities-charts-stack {
  display: grid;
  gap: 16px;
}

.activities-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.activity-list-wrap {
  max-height: 560px;
  overflow: auto;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.activity-table th {
  color: #cbd5f5;
  font-weight: 600;
}

.activity-table th,
.activity-table td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 8px 6px;
}

.activity-table tbody tr {
  cursor: pointer;
}

.activity-table tbody tr:hover {
  background: rgba(15, 23, 42, 0.6);
}

.activity-table tbody tr.selected {
  background: rgba(16, 185, 129, 0.2);
}

.hint {
  color: var(--muted);
  margin-top: 8px;
}

.map-frame {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 0;
  border-radius: 8px;
  background: #0b0f14;
}

#status {
  color: var(--muted);
  margin: 0;
}

@media (max-width: 960px) {
  .controls,
  .grid {
    grid-template-columns: 1fr;
  }

  .kpi-cards {
    grid-template-columns: 1fr;
    grid-template-areas:
      "distance"
      "elevation"
      "time";
  }

  .feed-metric-cards {
    grid-template-columns: 1fr;
  }

  .feed-incline-panel {
    grid-template-columns: 1fr;
    gap: 4px;
  }

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

  .activities-charts-grid {
    grid-template-columns: 1fr;
  }

  .feed-controls .feed-activity-field {
    grid-column: auto;
    grid-row: auto;
  }
}
.sport-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
}

.btn-sport {
  background: var(--card-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  height: 36px;
  padding: 0 14px;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  font-weight: 400;
}

.btn-sport:hover {
  background: #1f2937;
}

.btn-sport.active {
  background: var(--accent);
  color: #04110c;
  border-color: transparent;
}

#refresh-btn {
  background: #FC5200;
  color: #ffffff;
  border-color: #FC5200;
}

#refresh-btn:hover {
  background: #e44b00;
  border-color: #e44b00;
}

#heart-rate-btn {
  background: #0F141B;
  color: #ffffff;
  border-color: #ffffff;
}

#heart-rate-btn:hover {
  background: #111111;
  color: #ffffff;
  border-color: #ffffff;
}

#heart-rate-btn.active,
#heart-rate-btn.active:hover {
  background: #ffffff;
  color: #0f172a;
  border-color: #ffffff;
}

.controls .sport-field {
  grid-column: 3 / span 2;
  grid-row: 1;
  align-self: start;
}

.sport-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.sport-row .buttons {
  flex-direction: column;
  align-items: flex-start;
}
