/* ===== CSS カスタムプロパティ ===== */
:root {
  --color-primary: #06b6d4;
  --color-primary-dark: #0891b2;
  --color-primary-light: rgba(6, 182, 212, 0.15);
  --color-danger: #f43f5e;
  --color-success: #10b981;
  --color-bg: #0f172a;
  --color-card: #1e293b;
  --color-card-elevated: #273548;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-border: #334155;
  --tab-height: 68px;
  --header-height: 54px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
  --font: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", sans-serif;
}

/* ===== リセット & ベース ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}
body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  padding-top: var(--header-height);
  padding-bottom: calc(var(--tab-height) + env(safe-area-inset-bottom));
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== ヘッダー ===== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  z-index: 100;
  border-bottom: 1px solid var(--color-border);
}
.header-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-icon { font-size: 1.4rem; }
.app-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* ===== ボトムタブナビ ===== */
.tab-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--tab-height);
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  z-index: 100;
}
.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-size: 0.65rem;
  font-family: var(--font);
  padding: 0.5rem 0;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-btn .tab-icon { font-size: 1.3rem; line-height: 1; }
.tab-btn.active {
  color: var(--color-primary);
  font-weight: 600;
}

/* ===== タブパネル ===== */
.tab-content-area {
  padding: 1rem;
  max-width: 640px;
  margin: 0 auto;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.hidden { display: none !important; }

/* ===== ダッシュボード — バナー ===== */
.dash-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 3px solid transparent;
  border-image: linear-gradient(180deg, #06b6d4, #8b5cf6) 1;
}
.dash-banner-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.dash-banner-value {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.dash-banner-date {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  margin-left: auto;
}

/* ===== ダッシュボード — 統計グループ ===== */
.stat-group {
  margin-bottom: 1rem;
}
.stat-group-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
  padding-left: 0.25rem;
  cursor: pointer;
  user-select: none;
}
.collapse-icon {
  display: inline-block;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--color-text-muted);
  margin-left: 0.4rem;
  vertical-align: middle;
  transition: transform 0.25s ease;
}
.stat-group-label.collapsed-label .collapse-icon {
  transform: rotate(-90deg);
}
.stat-group-body {
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.stat-group-body.collapsed {
  max-height: 0 !important;
}
.stat-col-headers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.3rem;
  padding: 0 0.25rem;
}
.stat-col-headers span {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  font-weight: 600;
}
.stat-col-header-wide {
  display: none;
}

/* ===== ダッシュボード — 統計グリッド ===== */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.stat-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 0.75rem;
  text-align: center;
  border-top: 2px solid transparent;
  border-image: linear-gradient(90deg, #06b6d4, #8b5cf6) 1;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-unit {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 0.1rem;
}
.stat-sub {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
  min-height: 0.9rem;
}

/* ===== セクションタイトル ===== */
.section-title-row {
  display: flex;
  align-items: center;
  margin: 0.5rem 0 0.75rem;
}
.section-title-row .section-title {
  margin: 0;
}
.garmin-quick-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: auto;
  background: none;
  border: none;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
}
.garmin-quick-btn:disabled { opacity: 0.4; cursor: default; }

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0.5rem 0 0.75rem;
  color: var(--color-text);
  padding-left: 0.6rem;
  position: relative;
}
.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.1em;
  bottom: 0.1em;
  width: 3px;
  border-radius: 2px;
  background: linear-gradient(180deg, #06b6d4, #8b5cf6);
}

.section-subtitle {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 1.2rem 0 0.5rem;
  padding-left: 0.6rem;
  position: relative;
}
.section-subtitle::before {
  content: '';
  position: absolute;
  left: 0; top: 0.1em; bottom: 0.1em;
  width: 3px; border-radius: 2px;
  background: linear-gradient(180deg, #06b6d4, #8b5cf6);
}

/* ===== 直近のランカード（ダッシュボード） ===== */
.recent-list { display: flex; flex-direction: column; gap: 0.5rem; }
.recent-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.875rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-left: 3px solid var(--color-primary);
}
.run-date { font-size: 0.72rem; color: var(--color-text-muted); margin-bottom: 0.2rem; }
.run-dist { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.2rem; }
.run-meta { font-size: 0.78rem; color: var(--color-text-muted); }
.run-right { text-align: right; font-size: 0.78rem; color: var(--color-text-muted); }

/* ===== 追加フォーム ===== */
.training-form { display: flex; flex-direction: column; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text-muted);
}
input[type="text"],
input[type="number"],
input[type="date"],
textarea {
  width: 100%;
  padding: 0.7rem 0.875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  background: var(--color-card);
  color: var(--color-text);
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #64748b; }

/* ペースプレビュー */
.pace-preview {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.875rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* 自動計算フィールド */
.calc-field {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.875rem;
  font-size: 0.95rem;
  font-weight: 600;
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

/* ===== ボタン ===== */
.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.2s;
}
.btn-primary:active {
  background: var(--color-primary-dark);
  transform: scale(0.98);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}
.btn-full { width: 100%; }

.btn-secondary {
  background: var(--color-card-elevated);
  color: var(--color-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}
.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
}
.btn-icon-danger {
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  flex-shrink: 0;
}

/* ===== メッセージ ===== */
.error-msg {
  color: var(--color-danger);
  font-size: 0.875rem;
  padding: 0.625rem 0.875rem;
  background: rgba(244, 63, 94, 0.1);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(244, 63, 94, 0.3);
}
.success-msg {
  color: var(--color-success);
  font-size: 0.875rem;
  padding: 0.625rem 0.875rem;
  background: rgba(16, 185, 129, 0.1);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.empty-msg {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 2rem 0;
}

/* ===== 履歴 ===== */
.history-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0;
}
.history-count { font-size: 0.8rem; color: var(--color-text-muted); }
.history-filter {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.filter-input, .filter-select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background-color: var(--color-card);
  color: var(--color-text);
  font-size: 0.8rem;
}
.filter-input { flex: 1; min-width: 0; }
.filter-select { flex-shrink: 0; }
.filter-select, .chart-season-select, .race-target-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  padding-right: 1.8rem;
}
.history-month-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 1rem 0 0.5rem;
  padding-left: 0.6rem;
  border-left: 3px solid transparent;
  border-image: linear-gradient(180deg, #06b6d4, #8b5cf6) 1;
}
.history-month-header:first-child { margin-top: 0.25rem; }
.history-month-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
}
.history-month-summary {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}
.session-list { display: flex; flex-direction: column; gap: 0.625rem; }
.session-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.875rem 1rem;
  border-left: 3px solid var(--color-primary);
  transition: transform 0.1s, box-shadow 0.15s;
}
.session-card:active {
  transform: scale(0.985);
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.15);
}
.session-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.375rem;
}
.session-card-date { font-size: 0.72rem; color: var(--color-text-muted); margin-bottom: 0.15rem; }
.session-card-dist { font-size: 1.25rem; font-weight: 700; }
.session-card-details {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}
.session-card-detail-item {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}
.session-card-memo {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  font-style: italic;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

/* ===== グラフ サブタブ ===== */
.graph-subnav {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  white-space: nowrap;
  padding: 0.5rem 0 0.75rem;
  scrollbar-width: none;
}
.graph-subnav::-webkit-scrollbar {
  display: none;
}

.graph-tab-btn {
  flex-shrink: 0;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  border: none;
  background: var(--color-card-elevated);
  color: var(--color-text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.graph-tab-btn.active {
  background: linear-gradient(135deg, #06b6d4, #0891b2);
  color: #fff;
  box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

.graph-panel {
  display: none;
}
.graph-panel.active {
  display: block;
}

/* ===== グラフ 横スクロール ===== */
.chart-scroll-outer {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  position: relative;
}
.y-axis-overlay {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  background: var(--color-card, #fff);
}
.y-axis-overlay-right {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  pointer-events: none;
  background: var(--color-card, #fff);
}
.chart-scroll-inner {
  position: relative;
  height: 240px;
  min-width: 560px;
}
.chart-scroll-inner.wide {
  min-width: 760px;
}

/* ===== グラフ ===== */
.chart-container {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.chart-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 0.25rem;
}
.chart-group-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 1.5rem 0 0.5rem;
  padding: 0.3rem 0.6rem;
  background: var(--color-surface);
  border-left: 3px solid var(--color-accent);
  border-radius: 0 4px 4px 0;
}
.graph-panel > .chart-group-title:first-child {
  margin-top: 0;
}
.chart-export-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  opacity: 0.4;
  flex-shrink: 0;
}
.chart-export-btn:active { opacity: 1; }

.chart-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0 0 0.75rem;
}

.race-color-legend {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 4px;
  font-size: 11px;
  color: #94a3b8;
}
.race-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.race-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.chart-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.chart-season-select {
  padding: 0.35rem 1.8rem 0.35rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background-color: var(--color-card);
  color: var(--color-text);
  font-size: 0.85rem;
  cursor: pointer;
}

/* ===== Garmin インポート ===== */
.garmin-import-box {
  background: var(--color-card);
  border: 1.5px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.2rem;
}

.garmin-import-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 0.6rem;
  letter-spacing: 0.03em;
}

.garmin-import-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.garmin-file-label {
  padding: 0.35rem 0.75rem;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.garmin-file-input {
  display: none;
}

.garmin-file-name {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ===== モーダル ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}
.modal-content {
  position: relative;
  z-index: 201;
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: min(320px, 90vw);
  box-shadow: var(--shadow-lg);
}
.modal-content p {
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ===== 詳細モーダル ===== */
.detail-modal-content {
  width: min(480px, 92vw);
  max-height: 82vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.detail-modal-sticky-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: sticky;
  top: -1.5rem;
  margin: -1.5rem -1.5rem 0;
  padding: 1rem 1rem 0.75rem 1.5rem;
  background: var(--color-card);
  z-index: 1;
}
.btn-modal-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  flex-shrink: 0;
}
.detail-modal-header {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 1rem;
}
.detail-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.detail-field-grid + .detail-field-grid {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}
.detail-field {
  background: var(--color-bg);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
}
.detail-field-editable {
  cursor: pointer;
}
.edit-icon {
  font-size: 0.58rem;
  opacity: 0.6;
}
.detail-field-label {
  font-size: 0.62rem;
  color: var(--color-text-muted);
  margin-bottom: 0.15rem;
}
.detail-field-value {
  font-size: 0.88rem;
  font-weight: 600;
}
.detail-field-edit,
.detail-field-full {
  grid-column: 1 / -1;
}
.detail-edit-input {
  width: 100%;
  box-sizing: border-box;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.25rem 0.4rem;
  border: 1.5px solid var(--color-primary);
  border-radius: 4px;
  background: var(--color-card);
  color: var(--color-text);
  outline: none;
}

/* 接続ステータス（設定・同期共通） */
.conn-status {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; margin-bottom: 0.5rem;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.conn-dot.connected { background: #4ade80; }
.conn-dot.disconnected { background: #f87171; }
.conn-btn-connect {
  display: inline-block; padding: 0.3rem 0.8rem;
  font-size: 0.8rem; font-weight: 600;
  background: none;
  border: 1px solid var(--color-primary); color: var(--color-primary);
  border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.conn-btn-connect:active { background: var(--color-primary); color: #fff; }

/* 同期タブ 接続誘導メッセージ */
.sync-connect-msg {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--color-text-muted);
  background: var(--color-card-elevated);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.75rem;
}

/* ===== セッション評価カード ===== */
.eval-section {
  margin-top: 0.75rem;
  padding: 0.6rem;
  background: var(--color-card-elevated);
  border-radius: 8px;
  border: 1px solid var(--color-border);
}
.eval-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 0.15rem;
}
.eval-subtitle {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}
.eval-row {
  display: grid;
  grid-template-columns: 5rem 1fr auto auto;
  gap: 0.3rem;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 0.8rem;
}
.eval-row:last-child { border-bottom: none; }
.eval-label {
  font-size: 0.68rem;
  color: var(--color-text-muted);
}
.eval-value { font-weight: 600; }
.eval-delta {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-align: right;
}
.eval-badge {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 0.25rem;
}
.eval-badge-good { background: #22c55e; }
.eval-badge-neutral { background: #eab308; }
.eval-badge-bad { background: #ef4444; }
.eval-row-na .eval-value { color: var(--color-text-muted); }
.eval-reason { font-size: 0.62rem; font-style: italic; }
.eval-legend {
  font-size: 0.58rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* 目標メニュー */
.goal-input-toggle {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
}
.goal-toggle-btn {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--color-border, #ddd);
  background: var(--color-card, #fff);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}
.goal-toggle-btn.active {
  background: var(--color-primary, #06b6d4);
  color: #fff;
  border-color: var(--color-primary, #06b6d4);
}
.goal-toggle-btn:first-child { border-radius: 8px 0 0 8px; }
.goal-toggle-btn:last-child  { border-radius: 0 8px 8px 0; }
.goal-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.goal-input-row input {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  font-size: 1rem;
}
.goal-input-unit {
  font-size: 0.85rem;
  color: var(--color-text-muted, #888);
  white-space: nowrap;
}
.race-target-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.race-target-label {
  font-size: 0.85rem;
  color: var(--color-sub);
  white-space: nowrap;
}
.race-target-select {
  width: 100%;
  padding: 0.55rem 1.8rem 0.55rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: var(--font);
  background-color: var(--color-surface);
  color: var(--color-text);
}
.goal-filter-nav {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
}
.goal-filter-btn {
  flex: 1;
  padding: 0.35rem 0;
  border: 1px solid var(--color-border, #ddd);
  background: transparent;
  cursor: pointer;
  font-size: 0.78rem;
}
.goal-filter-btn.active {
  background: var(--color-primary, #06b6d4);
  color: #fff;
  border-color: var(--color-primary, #06b6d4);
}
.goal-filter-btn:first-child { border-radius: 6px 0 0 6px; }
.goal-filter-btn:last-child  { border-radius: 0 6px 6px 0; }

.eval-tab-nav {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
}
.eval-tab-btn {
  flex: 1;
  padding: 0.35rem 0;
  border: 1px solid var(--color-border, #ddd);
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font-size: 0.78rem;
}
.eval-tab-btn.active {
  background: var(--color-primary, #06b6d4);
  color: #fff;
  border-color: var(--color-primary, #06b6d4);
}
.eval-tab-btn:first-child { border-radius: 6px 0 0 6px; }
.eval-tab-btn:last-child  { border-radius: 0 6px 6px 0; }

.detail-laps-title {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}
.detail-laps-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  margin-bottom: 1rem;
}
.detail-lap-item {
  background: var(--color-bg);
  border-radius: 4px;
  padding: 0.3rem 0.2rem;
  text-align: center;
}
.detail-lap-num {
  font-size: 0.58rem;
  color: var(--color-text-muted);
}
.detail-lap-time {
  font-size: 0.78rem;
  font-weight: 600;
}
.detail-laps-table {
  margin-bottom: 1rem;
}
.detail-laps-header,
.detail-laps-row {
  display: grid;
  grid-template-columns: 2.2rem 1fr 1fr 1fr;
  gap: 0.25rem;
  padding: 0.2rem 0.4rem;
  align-items: center;
}
.detail-laps-header {
  font-size: 0.62rem;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.3rem;
  margin-bottom: 0.15rem;
}
.detail-laps-row {
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--color-bg);
  border-radius: 4px;
  margin-bottom: 0.15rem;
}
.detail-laps-row span:first-child {
  font-size: 0.68rem;
  color: var(--color-text-muted);
  font-weight: 400;
}
.detail-laps-simple .detail-laps-header,
.detail-laps-simple .detail-laps-row {
  grid-template-columns: 2.2rem 1fr;
}
.session-card[data-id] {
  cursor: pointer;
}

/* ===== 同期タブ UI ===== */
.sync-status-card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.sync-status-icon { font-size: 1.75rem; line-height: 1; flex-shrink: 0; }
.sync-status-text { font-size: 0.95rem; font-weight: 700; }
.sync-status-sub  { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 0.1rem; word-break: break-all; }
.sync-status-connected    { color: var(--color-success); }
.sync-status-disconnected { color: var(--color-danger); }

.sync-btn { margin-bottom: 0.25rem; }
.sync-hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin: 0 0 1.25rem;
  line-height: 1.4;
}

.sync-guide {
  background: rgba(234, 179, 8, 0.08);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
}
.sync-guide-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 0.75rem; }
.sync-guide-steps {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  line-height: 1.5;
}
.sync-guide-steps a { color: var(--color-primary); }
.sync-guide-steps code {
  background: rgba(255,255,255,0.1);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.8rem;
}

/* ===== Lucide Icons ===== */
.lucide {
  width: 1em;
  height: 1em;
  stroke-width: 2;
  vertical-align: -0.125em;
}
.tab-icon .lucide {
  width: 1.3rem;
  height: 1.3rem;
}
.header-icon .lucide {
  width: 1.4rem;
  height: 1.4rem;
}
.sync-status-icon .lucide {
  width: 1.75rem;
  height: 1.75rem;
}
.icon-inline {
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.1em;
  display: inline-block;
}
.btn-icon-danger .icon-inline {
  width: 1.1rem;
  height: 1.1rem;
}
.edit-icon .icon-inline {
  width: 0.6rem;
  height: 0.6rem;
}
.btn-modal-close .lucide {
  width: 1.2rem;
  height: 1.2rem;
}
.lucide-loader {
  animation: spin 1.5s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== デスクトップ補正 ===== */
@media (min-width: 640px) {
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .stat-col-headers { grid-template-columns: repeat(4, 1fr); }
  .stat-col-header-wide { display: inline; }
  .stat-value { font-size: 2.2rem; }
}
