/* ===== TOKENS ===== */
:root {
  --bg:           #e8f4fb;
  --bg-mid:       #d0e8f5;
  --surface:      #ffffff;
  --surface-2:    #f0f8fd;
  --border:       #b0d4ec;
  --border-dark:  #7ab8d9;

  --blue-deep:    #0077b6;
  --blue-mid:     #0096c7;
  --blue-light:   #48cae4;
  --blue-pale:    #ade8f4;
  --blue-accent:  #023e8a;

  --text-main:    #0a2540;
  --text-sub:     #2d6a8f;
  --text-muted:   #5b9ab5;
  --text-dim:     #9cc4d8;

  --gold:         #f4a614;
  --good:         #1ab87a;
  --danger:       #e05252;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0,100,180,0.10);
  --shadow-md: 0 4px 20px rgba(0,100,180,0.15);
  --glow: 0 0 20px rgba(0,150,200,0.2);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Helvetica Neue', 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  background: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
}

/* ===== HEADER ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--blue-deep);
  box-shadow: 0 2px 12px rgba(0,80,160,0.18);
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  padding: 0 2rem; height: 60px;
  display: flex; align-items: center; gap: 2rem;
}
.logo { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.logo-wave { color: var(--blue-pale); font-size: 1.6rem; line-height: 1; }
.logo-text { font-size: 1.15rem; font-weight: 800; letter-spacing: 0.06em; color: #fff; }
.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav-btn {
  background: none; border: none; color: rgba(255,255,255,0.7);
  font-size: 0.88rem; font-weight: 600;
  padding: 0.4rem 1rem; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.2s, color 0.2s; white-space: nowrap;
}
.nav-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,0.2); color: #fff; }

/* ===== MAIN ===== */
.main { max-width: 1100px; margin: 0 auto; padding: 2.5rem 2rem 4rem; }
.view { display: none; }
.view.active { display: block; }
.section-header { margin-bottom: 2rem; }
.section-header h1 { font-size: 1.8rem; font-weight: 800; color: var(--blue-accent); letter-spacing: -0.02em; }
.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.2rem; }
.section-label {
  font-size: 0.8rem; font-weight: 700; color: var(--text-muted);
  text-transform: none; letter-spacing: 0.08em;
}

/* ===== CHART ===== */
.chart-row { margin-bottom: 2rem; }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.chart-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.2rem; flex-wrap: wrap; gap: 0.5rem; }
.chart-title { font-size: 0.85rem; font-weight: 700; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.06em; }
.chart-filters { display: flex; gap: 0.5rem; }

/* ===== YEARLY PB ===== */
.yearly-pb-section { margin-bottom: 1rem; }
.yearly-pb-header { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1rem; }
.pb-count-badge {
  background: var(--blue-mid); color: #fff;
  font-size: 0.75rem; font-weight: 700;
  padding: 2px 10px; border-radius: 20px;
}
.pb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.7rem; }
.pb-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 0.2rem;
}
.pb-card.is-new { border-color: var(--gold); background: #fffbf0; }
.pb-stroke { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; text-transform: none; letter-spacing: 0.04em; }
.pb-time { font-size: 1.5rem; font-weight: 800; color: var(--blue-deep); letter-spacing: -0.02em; }
.pb-meta { font-size: 0.75rem; color: var(--text-muted); }
.pb-new-tag { font-size: 0.72rem; color: var(--gold); font-weight: 700; }

/* ===== STATS FOOTER ===== */
.stats-footer {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  margin-top: 2rem; padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem; color: var(--text-muted);
}
.stats-footer span::before { content: attr(data-label) '　'; color: var(--text-dim); }

/* ===== RECORD LIST ===== */
.recent-section { }
.record-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.8rem; }
.record-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.9rem 1.2rem;
  display: grid; grid-template-columns: auto 1fr auto auto;
  align-items: center; gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.record-item:hover { border-color: var(--blue-mid); box-shadow: var(--shadow-md); }
.record-stroke-badge {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--blue-pale);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.record-info { min-width: 0; }
.record-main { font-weight: 700; font-size: 0.95rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-sub { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.record-time { font-size: 1.25rem; font-weight: 800; color: var(--blue-deep); letter-spacing: -0.02em; white-space: nowrap; }
.record-delete { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; padding: 0.3rem; border-radius: var(--radius-sm); transition: color 0.2s; }
.record-delete:hover { color: var(--danger); }
.record-pb { color: var(--gold); font-size: 0.72rem; font-weight: 700; margin-left: 5px; }
.pool-badge {
  display: inline-block; font-size: 0.68rem; padding: 1px 6px;
  border-radius: 3px; margin-left: 5px; font-weight: 700;
  background: var(--bg-mid); color: var(--blue-mid);
}
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); font-size: 0.9rem; }
.empty-state .empty-icon { font-size: 2.5rem; display: block; margin-bottom: 0.5rem; }

/* ===== FORM ===== */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 700px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}
.form-section-label {
  font-size: 0.73rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--blue-mid);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem; margin-bottom: 1.2rem;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-bottom: 1.2rem; }
.form-row.full { grid-template-columns: 1fr; }
label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.78rem; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.05em; }
.input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.95rem; padding: 0.6rem 0.9rem;
  outline: none; transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%; font-family: inherit;
}
.input:focus { border-color: var(--blue-mid); box-shadow: 0 0 0 3px rgba(0,150,200,0.15); }
.textarea { resize: vertical; min-height: 80px; }
.input.small { font-size: 0.85rem; padding: 0.45rem 0.8rem; }
select.input option { background: var(--surface); }
/* ネイティブselectの矢印を年度ドロップダウンと同じ共通▼に統一（OS依存の標準矢印を置き換え） */
select.input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235b9ab5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 1.9rem;
}
/* iOS Safari: 日付入力が不自然に広がる・高さがずれるのを補正 */
input[type="date"].input {
  -webkit-appearance: none;
  appearance: none;
  height: calc(0.6rem * 2 + 0.95rem * 1.4);
  min-height: 0;
  box-sizing: border-box;
  display: block;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; }

/* ===== EVENT TABS ===== */
.event-tabs {
  display: flex; gap: 0.4rem; margin-bottom: 1.2rem;
  background: var(--bg-mid); border-radius: var(--radius-sm); padding: 4px;
}
.event-tab {
  flex: 1; background: none; border: none;
  color: var(--text-sub); font-size: 0.88rem; font-weight: 700;
  padding: 0.5rem; border-radius: 4px; cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.event-tab.active { background: var(--blue-deep); color: #fff; }

/* ===== RELAY MEMBER GRID ===== */
.relay-member-grid { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.5rem; }
.relay-member-row { display: grid; grid-template-columns: 3rem 1fr 1fr; align-items: center; gap: 0.7rem; }
.relay-member-label { font-size: 0.8rem; color: var(--text-sub); font-weight: 700; white-space: nowrap; }
.relay-rt { font-size: 0.85rem; }

/* ===== BUTTONS ===== */
.btn-primary {
  background: var(--blue-deep); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.92rem; font-weight: 700; padding: 0.75rem 2rem;
  cursor: pointer; letter-spacing: 0.02em;
  transition: background 0.2s, transform 0.1s;
}
.btn-primary:hover { background: var(--blue-mid); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background: transparent; color: var(--text-sub);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.85rem; padding: 0.5rem 1.2rem;
  cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.btn-secondary:hover { border-color: var(--blue-mid); color: var(--blue-mid); }

/* ===== FILTER BAR ===== */
.filter-bar { display: flex; gap: 0.8rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.filter-actions { margin-left: auto; }

/* ===== GOALS ===== */
.goals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }
.goal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 0.85rem 0.9rem;
  box-shadow: var(--shadow-sm);
}
.goal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.goal-title { font-weight: 700; font-size: 0.85rem; color: var(--text-main); line-height: 1.3; }
.goal-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 1px; }
.goal-edit, .goal-delete { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 0.9rem; transition: color 0.2s; padding: 0 2px; }
.goal-delete:hover { color: var(--danger); }
.goal-edit:hover { color: var(--blue-deep); }
.goal-target { font-size: 1.3rem; font-weight: 800; color: var(--gold); letter-spacing: -0.02em; }
.goal-current { font-size: 0.74rem; color: var(--text-muted); margin-top: 0.2rem; line-height: 1.35; }
.goal-progress-bar { margin-top: 0.6rem; height: 5px; background: var(--bg-mid); border-radius: 3px; overflow: hidden; }
.goal-progress-fill { height: 100%; border-radius: 3px; background: var(--good); transition: width 0.5s; }
.goal-deadline { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.35rem; }
.goal-achieved { display: inline-block; font-size: 0.72rem; background: rgba(26,184,122,0.12); color: var(--good); border-radius: 3px; padding: 1px 7px; margin-top: 0.35rem; font-weight: 700; }

/* ===== SAVE MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(2,40,90,0.45);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  animation: fadeIn 0.18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--blue-light);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 40px rgba(0,100,180,0.2);
  padding: 2rem; width: 100%; max-width: 380px;
  text-align: center;
  margin: auto;
  animation: slideUp 0.2s ease;
}
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.modal-title { font-size: 1.3rem; font-weight: 800; color: var(--blue-accent); margin-bottom: 1.2rem; }
.modal-detail {
  background: var(--surface-2); border-radius: var(--radius-md);
  padding: 1rem 1.2rem; margin-bottom: 1.5rem; text-align: left;
}
.modal-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 1rem; padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.modal-row:last-child { border-bottom: none; }
.modal-row span { color: var(--text-muted); flex-shrink: 0; }
.modal-row strong { color: var(--text-main); text-align: right; }
.modal-time { color: var(--blue-deep) !important; font-size: 1.2rem; }
.modal-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }
.modal-actions .btn-primary { flex: 1; }
.modal-actions .btn-secondary { flex: 1; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 2rem; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--blue-deep); color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.7rem 1.5rem; font-size: 0.88rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999; white-space: normal; max-width: 90vw;
  text-align: center; line-height: 1.45;
  box-shadow: var(--shadow-md);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-inner {
    padding: 0.5rem 1rem; gap: 0.5rem; height: auto;
    flex-wrap: wrap;
  }
  .logo { order: 1; }
  .mode-badge, .header-meta { order: 2; margin-left: auto; }
  .nav {
    order: 3; width: 100%; flex: 1 0 100%;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 0.15rem; padding-bottom: 0.3rem;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-btn { font-size: 0.82rem; padding: 0.35rem 0.7rem; flex-shrink: 0; }
  .main { padding: 1.5rem 1rem 3rem; }
  .form-row { grid-template-columns: 1fr; }
  .chart-filters { flex-wrap: wrap; }
  .pb-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .record-item { grid-template-columns: auto 1fr auto; }
  .record-delete { display: none; }
  .relay-member-row { grid-template-columns: 2.5rem 1fr; }
  .relay-rt { display: none; }
}

/* ===== CELEBRATION MODAL ===== */
.celebration-box {
  position: relative;
  overflow: hidden;
  border-color: var(--gold) !important;
  box-shadow: 0 8px 40px rgba(244,166,20,0.25) !important;
}
.celebration-icon { font-size: 3rem; animation: bounce 0.6s ease infinite alternate; }
@keyframes bounce { from { transform: scale(1); } to { transform: scale(1.15); } }
.celebration-title {
  font-size: 1.5rem; font-weight: 800;
  color: var(--blue-accent); margin: 0.5rem 0 0.3rem;
}
.celebration-event { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 1.2rem; }
.celebration-times {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; margin-bottom: 0.8rem;
}
.cel-block { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.cel-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.cel-time { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.target-time { color: var(--text-muted); text-decoration: line-through; }
.achieved-time { color: var(--blue-deep); }
.cel-arrow { font-size: 1.3rem; color: var(--blue-light); margin-top: 1rem; }
.cel-diff { font-size: 0.88rem; color: var(--text-sub); }
.cel-diff strong { color: var(--good); font-size: 1rem; }

/* ===== CONFETTI ===== */
.confetti-wrap {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none; overflow: hidden;
}
.confetti-piece {
  position: absolute;
  top: -10px;
  animation: fall linear forwards;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(400px) rotate(720deg); opacity: 0; }
}

/* ===== NEXT GOAL IN CELEBRATION MODAL ===== */
.next-goal-divider {
  font-size: 0.8rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  border-top: 1px solid var(--border);
  padding-top: 1.2rem; margin-top: 1.2rem; margin-bottom: 1rem;
}
.next-goal-form { display: flex; flex-direction: column; gap: 0.6rem; text-align: left; }
.next-goal-row { display: flex; flex-direction: column; gap: 0.3rem; }
.next-goal-label { font-size: 0.75rem; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== SETUP SCREEN ===== */
.setup-screen {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}
.setup-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.5rem 2rem;
  width: 100%; max-width: 480px;
  box-shadow: var(--shadow-md);
  margin: auto;
}
.setup-logo { font-size: 1.3rem; font-weight: 800; color: var(--blue-deep); margin-bottom: 1rem; }
.setup-logo span { color: var(--blue-light); }
.setup-title { font-size: 1.6rem; font-weight: 800; color: var(--blue-accent); }
.setup-sub { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.3rem; margin-bottom: 1.5rem; }
.setup-form { display: flex; flex-direction: column; gap: 1rem; }
.setup-label { display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.78rem; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.05em; }
.setup-mode-label { font-size: 0.78rem; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem; }
.athlete-input-list { display: flex; flex-direction: column; gap: 0.5rem; }
.athlete-input-row .input { width: 100%; }

/* ===== MODE CARDS ===== */
.mode-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.mode-card {
  border: 2px solid var(--border); border-radius: var(--radius-md);
  padding: 1rem; cursor: pointer; text-align: center;
  transition: border-color 0.2s, background 0.2s;
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
}
.mode-card input[type="radio"] { display: none; }
.mode-card.active { border-color: var(--blue-deep); background: rgba(0,119,182,0.06); }
.mode-icon { font-size: 1.8rem; }
.mode-title { font-weight: 700; font-size: 0.9rem; color: var(--text-main); }
.mode-desc { font-size: 0.75rem; color: var(--text-muted); }
.settings-mode-cards { margin-top: 0.5rem; }

/* ===== HEADER META ===== */
.header-meta { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.header-org { font-size: 0.82rem; color: rgba(255,255,255,0.75); }
.mode-badge {
  font-size: 0.7rem; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: rgba(255,255,255,0.2); color: #fff;
}
.mode-badge.manager { background: var(--gold); color: var(--water-deep, #0a2540); }

/* ===== AUTOCOMPLETE ===== */
.suggestions-box {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 50;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 160px; overflow-y: auto;
}
.suggestion-item {
  padding: 0.55rem 0.9rem; font-size: 0.9rem; cursor: pointer;
  transition: background 0.15s;
}
.suggestion-item:hover { background: var(--bg-mid); }
.relay-member-input-wrap { position: relative; flex: 1; }

/* ===== ATHLETE TAG ===== */
.athlete-tag {
  display: inline-block; background: var(--blue-pale);
  color: var(--blue-accent); font-size: 0.72rem; font-weight: 700;
  padding: 1px 7px; border-radius: 3px; margin-right: 5px;
}
.pb-athlete { font-size: 0.78rem; font-weight: 700; color: var(--blue-mid); margin-bottom: 2px; }

/* ===== SETTINGS ATHLETE LIST ===== */
.athlete-list { display: flex; flex-direction: column; gap: 0.4rem; }
.athlete-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.8rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.athlete-delete {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 0.8rem; transition: color 0.2s;
}
.athlete-delete:hover { color: var(--danger); }

/* ===== BEST 20 ===== */
.best20-section { }
.best20-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.8rem; margin-bottom: 1rem; }
.best20-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.best20-list {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.best20-row {
  display: grid; grid-template-columns: 2.5rem 1fr auto;
  align-items: center; gap: 1rem;
  padding: 0.7rem 1.2rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.best20-row:last-child { border-bottom: none; }
.best20-row:hover { background: var(--surface-2); }
.best20-row.top3 { background: var(--surface-2); }
.best20-rank {
  font-size: 1rem; font-weight: 800; color: var(--text-dim);
  text-align: center; width: 2rem;
}
.rank-gold   { color: #c9a227; }
.rank-silver { color: #888; }
.rank-bronze { color: #a0522d; }
.best20-info { min-width: 0; }
.best20-athlete { font-weight: 700; font-size: 0.92rem; color: var(--text-main); }
.best20-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.best20-time { font-size: 1.15rem; font-weight: 800; color: var(--blue-deep); letter-spacing: -0.02em; white-space: nowrap; }

.best20-year {
  font-weight: 700; color: var(--blue-mid); font-size: 0.78rem;
}

/* ===== RECORD CLICKABLE ===== */
.record-item-clickable { cursor: pointer; }
.record-edit-hint {
  font-size: 1.3rem; color: var(--text-dim);
  transition: color 0.2s;
}
.record-item-clickable:hover .record-edit-hint { color: var(--blue-mid); }

/* ===== DETAIL MODAL ===== */
.detail-box { max-width: 420px; }
.detail-event { font-size: 1.1rem; font-weight: 800; color: var(--blue-accent); margin-bottom: 1rem; }
.detail-actions { display: flex; gap: 0.8rem; }
.detail-actions .btn-primary { flex: 1; }
.btn-danger {
  flex: 1; background: var(--danger); color: #fff;
  border: none; border-radius: var(--radius-sm);
  font-size: 0.92rem; font-weight: 700; padding: 0.75rem 1rem;
  cursor: pointer; transition: opacity 0.2s;
}
.btn-danger:hover { opacity: 0.85; }

/* ===== EDIT MODAL ===== */
.edit-box { max-width: 500px; max-height: 90vh; display: flex; flex-direction: column; }
.edit-scroll { overflow-y: auto; flex: 1; padding-right: 0.3rem; }
.edit-section-label {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--blue-mid);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.4rem; margin-bottom: 0.8rem;
}
.edit-field { display: flex; flex-direction: column; margin-bottom: 0.8rem; }
.edit-field label { font-size: 0.75rem; color: var(--text-sub); text-transform: uppercase; letter-spacing: 0.05em; display: flex; flex-direction: column; gap: 0.3rem; }
.edit-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }
.edit-row.edit-member-times { grid-template-columns: 3fr 1fr; }

/* ===== TEAM CODE DISPLAY ===== */
.team-code-display {
  font-size: 2rem; font-weight: 800; letter-spacing: 0.3em;
  color: var(--blue-deep); background: var(--bg-mid);
  border-radius: var(--radius-md); padding: 0.8rem 1.5rem;
  display: inline-block; margin-top: 0.3rem;
}

/* ===== TEAM STATUS BOX ===== */
.team-status-box {
  padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin-bottom: 0.8rem;
}
.status-ok { background: rgba(26,184,122,0.1); color: var(--good); border: 1px solid var(--good); }
.status-ng { background: rgba(224,82,82,0.1); color: var(--danger); border: 1px solid var(--danger); }

/* ===== PERSONAL MODE BADGE ===== */
.mode-badge.personal { background: var(--blue-mid); color: #fff; }

/* ===== TIME TRIPLE INPUT ===== */
.time-triple {
  display: flex; align-items: center; gap: 0.3rem;
}
.time-triple .input { text-align: center; padding-left: 0.3rem; padding-right: 0.3rem; }
.tt-min, .tt-sec, .tt-hun { width: 100%; }
.tt-sep { color: var(--text-muted); font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }
/* hide number spinners */
.time-triple input::-webkit-outer-spin-button,
.time-triple input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.time-triple input[type=number] { -moz-appearance: textfield; }
/* すべての数値入力の上下矢印（スピナー）を非表示に */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }
#rec-rank::-webkit-outer-spin-button, #rec-rank::-webkit-inner-spin-button,
#rec-points::-webkit-outer-spin-button, #rec-points::-webkit-inner-spin-button,
#rec-heat::-webkit-outer-spin-button, #rec-heat::-webkit-inner-spin-button,
#rec-lane::-webkit-outer-spin-button, #rec-lane::-webkit-inner-spin-button,
#edit-rank::-webkit-outer-spin-button, #edit-rank::-webkit-inner-spin-button,
#edit-points::-webkit-outer-spin-button, #edit-points::-webkit-inner-spin-button,
#edit-heat::-webkit-outer-spin-button, #edit-heat::-webkit-inner-spin-button,
#edit-lane::-webkit-outer-spin-button, #edit-lane::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#rec-rank, #rec-points, #rec-heat, #rec-lane, #edit-rank, #edit-points, #edit-heat, #edit-lane { -moz-appearance: textfield; }

/* ===== RELAY MEMBER GRID V2 ===== */
.relay-member-grid-v2 { display: flex; flex-direction: column; gap: 0.5rem; }
.relay-head {
  display: grid; grid-template-columns: 2.8rem 1fr 1.3fr 0.7fr; gap: 0.5rem;
  font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0 0.2rem;
}
.relay-head span:first-child { grid-column: 1; }
.relay-member-row-v2 {
  display: grid; grid-template-columns: 2.8rem 1fr 1.3fr 0.7fr;
  gap: 0.5rem; align-items: center;
}
.input-sm { font-size: 0.82rem; padding: 0.45rem 0.5rem; }
.time-triple-sm { gap: 0.15rem; }
.time-triple-sm .tt-sep { font-size: 0.85rem; }
.time-triple-sm .input-sm { padding: 0.45rem 0.2rem; }

/* ===== EDIT MEMBER BLOCK ===== */
.edit-member-block {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0.8rem; margin-bottom: 0.6rem; background: var(--surface-2);
}

@media (max-width: 480px) {
  /* スマホ：メンバー1人分を2行に。1行目=泳順ラベル+名前、2行目=タイム(広)+RT(狭) */
  .relay-head { display: none; } /* 見出し行はスマホでは隠す（密になるため） */
  .relay-member-row-v2 {
    grid-template-columns: 2.2rem 1fr 4.5rem;
    grid-template-areas:
      "leg  name name"
      "time time rt";
    gap: 0.35rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    background: var(--surface-2);
    align-items: center;
  }
  .relay-member-row-v2 > .relay-member-label { grid-area: leg; align-self: center; font-size: 0.72rem; }
  .relay-member-row-v2 > .relay-member-input-wrap { grid-area: name; }
  .relay-member-row-v2 > .time-triple { grid-area: time; }
  .relay-member-row-v2 > .rt-input { grid-area: rt; }
  /* タイム欄は3つの数字が入るので各入力を均等に広げる */
  .relay-member-row-v2 > .time-triple .input-sm { min-width: 0; }
  /* RT欄に何の欄か分かるよう、プレースホルダーを活かしつつ中央寄せ */
  .relay-member-row-v2 > .rt-input { text-align: center; }
  .input-sm { font-size: 0.82rem; padding: 0.45rem 0.35rem; }
}

/* ===== PARENT ROLE BADGE ===== */
.mode-badge.parent { background: #8a9bb0; color: #fff; }

/* ===== ATHLETE MANAGEMENT (retire/restore) ===== */
.athlete-group-label {
  font-size: 0.72rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}
.athlete-row.inactive { opacity: 0.65; }
.btn-retire {
  background: none; border: 1px solid var(--border); color: var(--text-sub);
  border-radius: var(--radius-sm); font-size: 0.78rem; padding: 0.3rem 0.8rem;
  cursor: pointer; transition: border-color 0.2s, color 0.2s;
}
.btn-retire:hover { border-color: var(--warn, #e67e22); color: var(--warn, #e67e22); }
.btn-restore {
  background: var(--good); border: none; color: #fff;
  border-radius: var(--radius-sm); font-size: 0.78rem; padding: 0.3rem 0.8rem;
  cursor: pointer;
}
.btn-restore:hover { opacity: 0.85; }

/* ===== RELAY LEG HIGHLIGHT ===== */
.relay-member-row-v2.leg-highlight {
  background: rgba(0,150,200,0.12);
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 2px var(--blue-light);
  padding: 0.3rem 0.4rem;
  margin: 0 -0.4rem;
}
.relay-member-row-v2 { transition: background 0.2s, box-shadow 0.2s; }

/* ===== RELAY LEG TAG (first-leg individual record) ===== */
.relay-leg-tag {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  background: rgba(244,166,20,0.15); color: #c9870a;
  padding: 1px 6px; border-radius: 3px; margin-left: 5px;
}

/* ===== EXISTING TEAMS LIST ===== */
.existing-teams-list { display: flex; flex-direction: column; gap: 0.5rem; }
.existing-team-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0.8rem 1rem;
  cursor: pointer; transition: border-color 0.2s, box-shadow 0.2s;
}
.existing-team-card:hover { border-color: var(--blue-mid); box-shadow: var(--shadow-sm); }
.existing-team-info { min-width: 0; text-align: left; }
.existing-team-name { font-weight: 700; font-size: 0.95rem; color: var(--text-main); }
.existing-team-role { font-size: 0.78rem; color: var(--text-muted); margin-top: 1px; }
.existing-team-go { font-size: 0.82rem; color: var(--blue-mid); font-weight: 600; white-space: nowrap; }
.existing-team-remove {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 0.9rem; padding: 0.2rem 0.4rem;
  flex-shrink: 0; transition: color 0.2s;
}
.existing-team-remove:hover { color: var(--danger); }
.setup-divider {
  display: flex; align-items: center; text-align: center;
  color: var(--text-dim); font-size: 0.78rem; margin: 1.2rem 0 0;
}
.setup-divider::before, .setup-divider::after {
  content: ''; flex: 1; border-bottom: 1px solid var(--border);
}
.setup-divider span { padding: 0 0.8rem; }

/* ===== ATHLETE BIRTHDATE ===== */
.athlete-row-bd { align-items: center; }
.athlete-name-bd { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.athlete-bd { font-size: 0.72rem; color: var(--text-muted); }
.athlete-bd.none { color: var(--text-dim); font-style: italic; }
.btn-edit-bd,
.btn-edit-gender {
  background: none; border: 1px solid var(--border); color: var(--text-sub);
  border-radius: var(--radius-sm); font-size: 0.75rem; padding: 0.3rem 0.7rem;
  cursor: pointer; transition: border-color 0.2s, color 0.2s; white-space: nowrap;
}
.btn-edit-bd:hover,
.btn-edit-gender:hover { border-color: var(--blue-mid); color: var(--blue-mid); }
/* メールアカウント連携済みマーク（選手名の直後に表示） */
.athlete-linked { font-size: 0.85em; margin-left: 0.15em; cursor: default; }

/* ===== 設定プロフィール：生年月日(date)と性別(select)の高さ揃え ===== */
/* 下端そろえは既存の .form-row.field-row-bottom（label > .input に margin-top:auto）が担う。
   ここでは iOS Safari で input[type=date] が select より背高/背低になる差だけを補正し、
   両方を .input 本来の自然な高さ（メール欄などと同じ padding）にそろえる。
   ※固定 height は使わない（入力時ズーム対策として文字サイズ・パディングは縮めない）。 */
.field-row-bottom input[type="date"].input,
.field-row-bottom select.input {
  box-sizing: border-box;
  line-height: 1.4;
}

/* ===== 選手名変更ボタン ===== */
.btn-edit-name {
  background: none; border: 1px solid var(--border); color: var(--text-sub);
  border-radius: var(--radius-sm); font-size: 0.75rem; padding: 0.3rem 0.7rem;
  cursor: pointer; transition: border-color 0.2s, color 0.2s; white-space: nowrap;
}
.btn-edit-name:hover { border-color: var(--blue-mid); color: var(--blue-mid); }

/* グラフ凡例のフォント調整 */
#chart-time { min-height: 200px; }

/* ===== グラフ空表示メッセージ（DOM・くっきり表示） ===== */
.chart-empty-msg {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  width: 100%;
  color: var(--text-muted, #5b9ab5);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}



/* ===== 年度ドロップダウン（外観は通常のセレクトと同一） ===== */
.year-select { position: relative; width: 100%; }
.year-select-trigger {
  cursor: pointer;
  position: relative;
  padding-right: 1.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%235b9ab5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}
.year-select-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 100%;
  max-height: 252px;
  overflow-y: auto;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #cfe2ee);
  border-radius: var(--radius-sm, 8px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.16);
  padding: 0.25rem 0;
}
.year-select-panel[hidden] { display: none; }
.year-opt {
  padding: 0.42rem 0.9rem;
  font-size: 0.85rem;
  color: var(--text-main, #234);
  cursor: pointer;
  white-space: nowrap;
}
/* マウスホバー／開いた瞬間のカーソル位置（現在年度）を同じ見た目でハイライト */
.year-opt:hover,
.year-opt.cursor { background: rgba(0,150,200,0.15); }
.year-opt.selected { font-weight: 600; color: #0096c7; }
/* ===================================================================
   フィルターのレイアウト調整（フィルター項目が増えても折り返してスッキリ）
   このブロックを css/style.css の末尾に追記してください
   =================================================================== */

/* フィルター行：折り返しを有効化し、行間も確保 */
.filter-bar,
.best20-filters,
.chart-filters {
  display: flex;
  flex-wrap: wrap;          /* 横幅が足りなければ次の行へ */
  gap: 0.5rem 0.6rem;       /* 縦 0.5rem / 横 0.6rem の隙間 */
  align-items: center;
}

/* フィルター内のコントロール幅をそろえる（固定幅できっちり揃える） */
.filter-bar .input.small,
.filter-bar .filter-ac,
.filter-bar .year-select,
.best20-filters .input.small,
.best20-filters .filter-ac,
.best20-filters .year-select,
.chart-filters .input.small,
.chart-filters .filter-ac {
  flex: 0 0 9.5rem;         /* 伸び縮みせず一律9.5remで揃える */
  width: 9.5rem;
  box-sizing: border-box;
}

/* オートコンプリート欄の入力は親いっぱいに */
.filter-ac { position: relative; }
.filter-ac .input.small { width: 100%; flex: none; }

/* 年度ドロップダウンも他と同じ幅感に（詳細度を上げて確実に9.5rem） */
.filter-bar .year-select,
.best20-filters .year-select,
.chart-filters .year-select { flex: 0 0 9.5rem; width: 9.5rem; box-sizing: border-box; }
/* 中のトリガーは input.small の固定幅を打ち消し、親いっぱいに */
.filter-bar .year-select .year-select-trigger,
.best20-filters .year-select .year-select-trigger,
.chart-filters .year-select .year-select-trigger { flex: none; width: 100%; box-sizing: border-box; }

/* フィルター内コントロールの高さを統一（select/div/inputの要素差によるズレを解消） */
/* select 要素：display は変えず高さと行高だけ揃える（ネイティブ表示を壊さない） */
.filter-bar select.input.small,
.best20-filters select.input.small,
.chart-filters select.input.small {
  height: 2.25rem;
  padding-top: 0; padding-bottom: 0;
  box-sizing: border-box;
}
/* div(year-select-trigger) と input(filter-ac) は中央寄せで高さを揃える */
.filter-bar .filter-ac .input.small,
.filter-bar .year-select-trigger,
.best20-filters .filter-ac .input.small,
.best20-filters .year-select-trigger,
.chart-filters .filter-ac .input.small,
.chart-filters .year-select-trigger,
#dash-athlete-filter-wrap .filter-ac .input.small {
  height: 2.25rem;
  padding-top: 0; padding-bottom: 0;
  display: flex; align-items: center;
  box-sizing: border-box;
}

/* CSVエクスポート等のアクションは右端へ（折り返し時は次行で右寄せ） */
.filter-actions { margin-left: auto; flex: 0 0 auto; }

/* ダッシュボード上部の選手・大会名フィルター行 */
#dash-athlete-filter-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.6rem;
  align-items: center;
}
#dash-athlete-filter-wrap .filter-ac { flex: 0 1 12rem; min-width: 8rem; max-width: 16rem; }
#dash-athlete-filter-wrap .filter-ac .input.small { width: 100%; }

/* スマホ幅では各コントロールを伸縮させて画面に収める（2列前後） */
@media (max-width: 480px) {
  .filter-bar .input.small,
  .filter-bar .filter-ac,
  .filter-bar .year-select,
  .best20-filters .input.small,
  .best20-filters .filter-ac,
  .best20-filters .year-select,
  .chart-filters .input.small,
  .chart-filters .filter-ac {
    flex: 1 1 8rem;
    width: auto;
  }
  /* スマホでも全コントロールの高さを統一（オートコンプリート入力が低くなるのを防ぐ） */
  .filter-bar .filter-ac .input.small,
  .best20-filters .filter-ac .input.small,
  .chart-filters .filter-ac .input.small,
  #dash-athlete-filter-wrap .filter-ac .input.small,
  .filter-bar select.input.small,
  .best20-filters select.input.small,
  .chart-filters select.input.small,
  .filter-bar .year-select-trigger,
  .best20-filters .year-select-trigger,
  .chart-filters .year-select-trigger {
    height: 2.25rem;
    box-sizing: border-box;
  }
  /* オートコンプリート欄を隣のドロップダウンと同じ幅に揃える
     （filter-ac のインライン display:inline-block を打ち消し、中の入力を親いっぱいに） */
  .filter-bar .filter-ac,
  .best20-filters .filter-ac,
  .chart-filters .filter-ac {
    display: flex !important;
  }
  .filter-bar .filter-ac .input.small,
  .best20-filters .filter-ac .input.small,
  .chart-filters .filter-ac .input.small {
    width: 100%;
    box-sizing: border-box;
  }
  .filter-actions { width: 100%; margin-left: 0; }
  .filter-actions .btn-secondary { width: 100%; }
}

/* ===== PAGINATION (履歴のページ送り) ===== */
.pager {
  display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center;
  justify-content: center; margin-top: 1.2rem;
}
.pager-btn {
  min-width: 2rem; height: 2rem; padding: 0 0.5rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-sub);
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pager-btn:hover:not(:disabled) { border-color: var(--blue-mid); color: var(--blue-mid); }
.pager-btn.active {
  background: var(--blue-deep); border-color: var(--blue-deep); color: #fff;
}
.pager-btn:disabled { opacity: 0.4; cursor: default; }
.pager-ellipsis { color: var(--text-dim); padding: 0 0.2rem; font-size: 0.85rem; }

/* ===== 性別バッジ（選手管理） ===== */
.athlete-gender {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  padding: 1px 7px; border-radius: 3px; margin-left: 4px;
}
.athlete-gender.male   { background: rgba(0,119,182,0.12); color: var(--blue-deep); }
.athlete-gender.female { background: rgba(224,82,82,0.12);  color: var(--danger); }
.athlete-gender.none   { background: var(--bg-mid); color: var(--text-muted); font-style: italic; }

/* ===== ベスト20 性別ブロック ===== */
.best20-gender-block { margin-bottom: 1.5rem; }
.best20-gender-block:last-child { margin-bottom: 0; }
.best20-gender-head {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.88rem; font-weight: 700; color: var(--text-sub);
  background: var(--surface-2);
  padding: 0.45rem 0.9rem; margin-bottom: 0.6rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--blue-light);
}
.best20-sublist {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
/* 性別ブロック内は直近の記録と同じ白ベースに統一（top3の色付けはしない） */
.best20-sublist .best20-row.top3 { background: var(--surface); }
.best20-sublist .best20-row:hover { background: var(--surface-2); }

/* 性別ブロックを内包するときは外枠を消す（各ブロックがカードになるため） */
.best20-list.has-gender-blocks {
  background: none; border: none; box-shadow: none; overflow: visible;
}
/* ===================================================================
   ヘッダーの更新ボタン（個人モード・チームモード共通）
   このブロックを css/style.css の末尾に追記してください。
   既存の #btn-refresh のインライン指定（個人モードの絵文字版）より
   優先させたいので、できるだけ末尾に置きます。
   =================================================================== */

/* ヘッダーに置く更新ボタン本体。ナビと同じ「透明地＋白文字」の質感に合わせ、
   濃紺ヘッダーに溶け込ませる。丸いアイコンボタン。 */
.header .header-refresh-btn,
.header #btn-refresh {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;                 /* SVGは stroke="currentColor" なのでこの色になる */
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.header .header-refresh-btn:hover,
.header #btn-refresh:hover {
  background: rgba(255, 255, 255, 0.22);
}
.header .header-refresh-btn:active,
.header #btn-refresh:active {
  transform: scale(0.92);
}
.header .header-refresh-btn:disabled,
.header #btn-refresh:disabled {
  opacity: 0.55;
  cursor: default;
}
.header .header-refresh-btn svg,
.header #btn-refresh svg {
  display: block;
}

/* 読み込み中の回転アニメ（HTML側の .refreshing 付与で回る）。
   HTML側の <style> でも定義しているが、CSSにも置いて確実に効かせる。 */
#btn-refresh.refreshing svg { animation: swimlog-spin 0.8s linear infinite; }
@keyframes swimlog-spin { to { transform: rotate(360deg); } }

/* スマホ表示時：ヘッダーが折り返す。並びは ロゴ(1) → メタ(2) → 更新ボタン(3) → ナビ(4)。
   既存CSSでは logo=1 / header-meta(=mode-badge)=2 / nav=3 なので、
   更新ボタンを3、ナビを4に上書きして、メタの右隣に更新ボタンが来るようにする。 */
@media (max-width: 768px) {
  .header .header-refresh-btn,
  .header #btn-refresh {
    order: 3;
    width: 1.9rem;
    height: 1.9rem;
    margin-left: 0.4rem;   /* メタ（右寄せ済み）の右隣に少し離して置く */
  }
  .header .nav { order: 4; }   /* ナビは更新ボタンより後（次の行）に */
}
/* ===================================================================
   ラップタイム（スプリット）入力・表示（個人モード）
   このブロックを css/style.css の末尾に追記してください。
   （前回のヘッダー更新ボタンのブロックの、さらに下に足してOKです）
   =================================================================== */

/* ラップ入力（「タイム」セクションの中に控えめに置く。カード感は出さない） */
.split-card {
  margin-top: 0.8rem;
}

/* 折りたたみの開閉ボタン（地味版）：フォームのラベル（「タイム」等）と同じ見た目に揃える。
   label のスタイル：font-size 0.78rem / color var(--text-sub) / uppercase / letter-spacing 0.05em */
.split-toggle-plain {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0.2rem 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
}
.split-toggle-plain:hover { color: var(--text-main); }
.split-toggle-icon { font-size: 0.6rem; display: inline-block; color: var(--text-muted); }

.split-body { margin-top: 0.5rem; }
.split-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  line-height: 1.5;
}

/* 入力欄の見出し行 */
.split-head {
  display: grid;
  grid-template-columns: 4rem 1fr 5rem;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 0.2rem 0.3rem;
}

/* 各区間の入力行 */
.split-row {
  display: grid;
  grid-template-columns: 4rem 1fr 5rem;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}
.split-seg-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub);
  white-space: nowrap;
}
.split-goal-tag {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  background: rgba(0,150,200,0.12);
  color: var(--blue-mid);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 0.3rem;
}
/* 区間ラップ（自動計算）の表示 */
.split-lap {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ゴール行：入力欄を出さず、ゴールタイムを参考表示（入力不可・グレー） */
.split-row-goal { opacity: 0.9; }
.split-goal-pass {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding-left: 0.2rem;
}
.split-goal-note {
  font-size: 0.74rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  line-height: 1.4;
}

/* 保存完了モーダル等で使うラップ一覧 */
.split-summary {
  background: var(--surface-2);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  margin-bottom: 1.2rem;
  text-align: left;
}
.split-summary-head {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}
.split-summary-row {
  display: grid;
  grid-template-columns: 3.5rem 1fr auto;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.2rem 0;
  font-size: 0.88rem;
}
.split-summary-seg { color: var(--text-sub); font-weight: 700; }
.split-summary-pass { color: var(--blue-deep); font-weight: 700; font-variant-numeric: tabular-nums; }
.split-summary-lap { color: var(--text-muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* スマホ：入力の3列を少し詰める */
@media (max-width: 480px) {
  .split-head { grid-template-columns: 3rem 1fr 4rem; }
  .split-row { grid-template-columns: 3rem 1fr 4rem; }
  .split-seg-label { font-size: 0.8rem; }
  .split-lap { font-size: 0.78rem; }
}
/* ===================================================================
   ラウンド（予選・決勝など）の入力欄・タグ
   このブロックを css/style.css の末尾に追記してください。
   （ラップ用ブロックのさらに下に足してOKです）
   =================================================================== */

/* 大会情報セクション内のラウンド欄 */
.round-field {
  margin-top: 0.6rem;
}

/* 折りたたみの開閉ボタン（ラップ欄と同じ控えめなトーンに揃える） */
.round-toggle {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 0.2rem 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
}
.round-toggle:hover { color: var(--text-main); }
.round-toggle-icon { font-size: 0.6rem; display: inline-block; color: var(--text-muted); }

.round-body { margin-top: 0.5rem; max-width: 50%; }
@media (max-width: 480px) {
  .round-body { max-width: 100%; }
}

/* 一覧に出すラウンドのタグ */
.round-tag {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.5rem;
  border-radius: 0.8rem;
  margin-left: 0.3rem;
  vertical-align: middle;
}
/* 決勝・タイム決勝：目立つ（オレンジ系アクセント） */
.round-tag-final {
  background: var(--accent, #f4a614);
  color: #fff;
}
/* 予選・準決勝：控えめ（グレー系） */
.round-tag-prelim {
  background: var(--surface-3, #e8eef2);
  color: var(--text-sub, #5b9ab5);
}
/* ===================================================================
   編集履歴（変更履歴）の表示
   このブロックを css/style.css の末尾に追記してください。
   =================================================================== */

.history-card {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
  text-align: left;
}

/* 折りたたみボタン（ラップ欄と同じ控えめなトーン） */
.history-toggle {
  background: none;
  border: none;
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 0.2rem 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: inherit;
}
.history-toggle:hover { color: var(--text-main); }
.history-toggle-icon { font-size: 0.6rem; display: inline-block; color: var(--text-muted); }

.history-body { margin-top: 0.6rem; }

/* 1回の編集 */
.history-entry {
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.5rem;
  background: var(--surface-2, #f3f7fa);
  border-radius: var(--radius-md, 8px);
}
.history-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.history-editor {
  background: var(--blue-mid, #48cae4);
  color: #fff;
  font-size: 0.68rem;
  padding: 0.05rem 0.45rem;
  border-radius: 0.7rem;
}

/* 変更1項目（タイム：1:02.00 → 1:00.50） */
.history-change {
  font-size: 0.82rem;
  color: var(--text-main);
  line-height: 1.6;
}
.history-field {
  color: var(--text-sub);
  font-weight: 700;
}
.history-arrow {
  color: var(--accent, #f4a614);
  font-weight: 700;
  margin: 0 0.1rem;
}
/* ===================================================================
   World Aquatics ポイント（基準タイムとの比較で算出する点数）
   このブロックを css/style.css の末尾に追記してください。
   =================================================================== */

.points-card {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  background: linear-gradient(135deg, var(--surface-2, #eef5fa), var(--surface-3, #e3eef5));
  border: 0.5px solid var(--border, #d4e2ec);
  border-radius: var(--radius-md, 10px);
  text-align: left;
}

.points-head {
  font-size: 0.72rem;
  color: var(--text-sub, #5b9ab5);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
  font-weight: 700;
}

.points-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 0.5px solid var(--border-light, rgba(0,0,0,0.05));
}
.points-row:last-child { border-bottom: none; }

.points-label {
  font-size: 0.86rem;
  color: var(--text-main, #1a3a4a);
}

.points-value {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent, #f4a614);
  font-variant-numeric: tabular-nums;
}
.points-unit {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-sub, #5b9ab5);
  margin-left: 0.1rem;
}

/* 性別未設定の案内 */
.points-card-nogender { background: var(--surface-2, #f0f4f7); }
.points-nogender {
  font-size: 0.82rem;
  color: var(--text-sub, #5b9ab5);
  line-height: 1.5;
}
/* ===================================================================
   インライン → クラス化（保守: CSS寄せ ステップ1）
   このブロックを css/style.css の末尾に追記してください。
   shared.js のインライン直書きを下記クラスに移したものです。
   （見た目は変わりません）
   =================================================================== */

/* 記録カードの「団体」ラベル（青いピル） */
.record-team-line { margin-top: 4px; }
.team-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  background: var(--blue-mid, #0096c7);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.12rem 0.6rem;
  border-radius: 999px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 今年の自己ベストカード：タップ可能なときのカーソル */
.pb-card-clickable { cursor: pointer; }
/* ===================================================================
   インライン → クラス化（保守: CSS寄せ ステップ2）
   このブロックを css/style.css の末尾に追記してください。
   shared.js でインライン上書きしていた「ポイント箱」「ラップ一覧」を
   クラスに集約したものです。現在の見た目（フラット・統一）に揃えます。
   ※ 既存の .points-card / .split-summary 系の値を上書きします
     （後方の定義が優先されるCSSの仕組みを利用）。
   =================================================================== */

/* World Aquatics ポイント箱：グラデ＋枠線をやめてフラットに */
.points-card {
  margin-top: 1rem;
  padding: 0.5rem 1.1rem;
  background: var(--surface-2, #f0f8fd);
  border: none;
  border-radius: 14px;
}

/* ラップ一覧（保存完了モーダル等）の外箱 */
.split-summary {
  margin-top: 1rem;
  padding: 0.5rem 1.1rem;
  border-radius: 14px;
}
.split-summary-head { margin-bottom: 0.35rem; }

/* ラップ各行：3カラムgrid → flex に。区切り線つき */
.split-summary-row {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.55rem 0.2rem;
  border-top: 1px solid #eef5fa;
}
.split-summary-seg { min-width: 3.6em; }
.split-summary-pass { flex: 1; font-weight: 800; }
/* ===================================================================
   iOS の自動ズーム防止（オートコンプリート含む全テキスト入力）
   このブロックを css/style.css の末尾に追記してください。

   iOS Safari は、フォーカスした入力欄のフォントが16px未満だと画面を
   自動で拡大表示する。これを防ぐため、全入力欄を16pxにする。
   入力が少し大きくなるが、同じ行にある選択肢（ドロップダウン）や
   ゴミ箱ボタンなども同じクラスなので一緒に揃う。
   =================================================================== */

/* フォーム・フィルター・リレー欄など、全テキスト入力を16pxに */
.input,
.input.small,
.input-sm {
  font-size: 16px;
}

/* フィルター行のボタン（CSVエクスポート等）も入力と同じ高さ・文字サイズに揃える。
   ゴミ箱ボタンは .input.small なので上のルールで自動的に揃う。 */
.filter-bar .btn-secondary,
.filter-actions .btn-secondary,
.best20-filters .btn-secondary,
.chart-filters .btn-secondary {
  font-size: 16px;
  height: 2.25rem;
  padding-top: 0;
  padding-bottom: 0;
}
/* ===================================================================
   「ゴミ箱」ボタンの文字位置を中央に
   このブロックを css/style.css の末尾に追記してください。

   #btn-trash は高さをJSでフィルターの選択肢に合わせて固定しているが、
   中身が縦中央寄せされておらず文字が下に寄っていた。flexで中央に揃える。
   =================================================================== */
#btn-trash {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}
/* ===== ラップ「ゴール」行：ゴールタグとゴールタイムの重なり解消 ===== */
/* 「ゴール」バッジを通過地点（左列）からタイム列へ移したので、左列は「100m」だけになり
   重ならなくなる。ここではタイム列内でバッジ＋通過タイムを綺麗に中央へ並べる。 */
.split-goal-pass-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 0;
}
.split-goal-pass-wrap .split-goal-pass {
  white-space: nowrap;
}
/* 念のため：バッジが絶対配置でも重ならないように通常フローへ */
.split-goal-tag {
  position: static;
}
/* ===================================================================
   インライン → クラス化（保守: CSS寄せ・最終）
   このブロックを css/style.css の末尾に追記してください。
   詳細モーダル等の内箱 .modal-detail を「フラット見た目」に統一します。
   これまで shared.js 側だけインラインで上書きしていたものをクラスに集約し、
   personal.js / team.js のモーダルも同じ見た目に揃えます。
   （余白 margin-bottom など他のプロパティは基底定義のまま継承）
   =================================================================== */
.modal-detail {
  background: var(--surface-2, #f0f8fd);
  border: none;
  border-radius: 14px;
  padding: 0.5rem 1.1rem;
}
/* ===== 招待参加：同名選手の自動提案ボックス（これではないですか？）===== */
/* このブロックを css/style.css の末尾に追記してください。 */
.join-suggest {
  margin-top: 0.6rem;
  padding: 0.7rem 0.8rem;
  background: var(--surface-2, #f0f8fd);
  border: 1px solid var(--blue-pale, #ade8f4);
  border-radius: var(--radius-md, 12px);
}
.join-suggest-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-sub, #2d6a8f);
  margin-bottom: 0.5rem;
}
.join-suggest .existing-team-card { margin-bottom: 0.4rem; }
.join-suggest .existing-team-card:last-of-type { margin-bottom: 0; }
.join-suggest-no {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.4rem;
  background: transparent;
  border: none;
  color: var(--text-muted, #5b9ab5);
  font-size: 0.8rem;
  text-decoration: underline;
  cursor: pointer;
}
/* ===================================================================
   自己ベストカード（新デザイン v3・2026-07）
   ★ここはファイル末尾に置くこと。上の「YEARLY PB」内の旧 .pb-card 系は
     この末尾定義がカスケードで上書きするため、そのまま残っていても無害。
     .pb-grid は既存のまま使用。
   個人モード=.pb-solo（種目チップ＋種目名フル幅＋距離行の右端に水路バッジ）。
   チーム=名前あり＝ネイビー配色（従来インライン表示）。
   =================================================================== */

/* ===== 共通の土台（コンパクト） ===== */
.pb-card{
  position:relative; display:flex; flex-direction:column; gap:5px;
  padding:12px 13px 11px; border-radius:13px;
  background:#fff; border:1px solid var(--border,#e3eef6);
  box-shadow:0 1px 2px rgba(10,37,64,.04), 0 4px 12px rgba(10,37,64,.05);
  transition:transform .15s, box-shadow .15s, border-color .15s;
  overflow:hidden;
}
.pb-card::before{
  content:""; position:absolute; left:0; top:0; bottom:0; width:4px;
  background:var(--blue-deep,#0096c7);
}
.pb-card-clickable{ cursor:pointer; }
.pb-card-clickable:hover{
  transform:translateY(-2px);
  box-shadow:0 2px 4px rgba(10,37,64,.06), 0 10px 22px rgba(10,37,64,.10);
  border-color:#c7e2f2;
}
.pb-card-clickable:active{ transform:translateY(0); }

.pb-card-top{ display:flex; align-items:center; gap:9px; min-width:0; }
.pb-chip{
  flex-shrink:0; width:34px; height:34px; border-radius:50%;
  background:#e3f3fc; display:flex; align-items:center; justify-content:center;
  color:var(--blue-deep,#0096c7);
}
.pb-nameblock{ min-width:0; flex:1; display:flex; flex-direction:column; gap:2px; line-height:1.1; }
.pb-stroke{
  font-size:.92rem; font-weight:800; color:var(--text-main,#0a2540);
}
/* 距離＋水路バッジを同じ行に。距離は左、バッジは右端 */
.pb-dist-row{ display:flex; align-items:center; justify-content:space-between; gap:6px; }
.pb-dist{
  font-size:.86rem; font-weight:800; color:var(--blue-accent,#0077b6);
  font-variant-numeric:tabular-nums;
}
.pb-dist small{ font-size:.62rem; font-weight:800; margin-left:1px; }
.pb-card .pool-badge{ flex-shrink:0; }

.pb-time{
  font-size:1.5rem; font-weight:800; line-height:1.05; letter-spacing:-.01em;
  color:var(--blue-accent,#0077b6); font-variant-numeric:tabular-nums;
}
.pb-meta{
  font-size:.71rem; color:var(--text-muted,#5b9ab5);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.pb-new-tag{
  display:inline-flex; align-items:center; gap:3px; align-self:flex-start;
  margin-top:1px; padding:2px 8px; border-radius:999px;
  font-size:.7rem; font-weight:800; color:#a86a06; background:#fdeecb;
}
.pb-athlete{
  font-size:.95rem; font-weight:800; margin-bottom:2px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}

/* 「今年更新」カード（個人モード：金アクセント） */
.pb-card.is-new{ border-color:#f3d290; background:#fffdf7; }
.pb-card.is-new::before{ background:var(--gold,#f4a614); }
.pb-card.is-new .pb-chip{ background:#fdf1d8; color:#d9970f; }

/* ===== チームモード（名前あり）：インライン種目表示＋ネイビー配色 ===== */
.pb-icon{ color:var(--blue-deep,#0096c7); display:inline-flex; flex-shrink:0; }
.pb-event{
  font-size:.82rem; font-weight:700; color:var(--text-main,#0a2540);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0;
}
.pb-card:not(.pb-solo) .pb-card-top .pool-badge{ margin-left:auto; }
.pb-card:not(.pb-solo)::before{ background:#1e3a5f; }
.pb-card:not(.pb-solo) .pb-icon{ color:#1e3a5f; }
.pb-card:not(.pb-solo) .pb-time{ color:#13345c; }
.pb-card:not(.pb-solo).is-new{ background:#fffdf6; border-color:#e6d3a3; }
.pb-card:not(.pb-solo).is-new::before{ background:#c8952a; }
.pb-card:not(.pb-solo).is-new .pb-chip{ background:#e3f3fc; color:#1e3a5f; }
/* ===================================================================
   設定「プロフィール」行：ラベルの文言の長さが左右で違っても
   入力欄（生年月日／性別）を下端でそろえる。
   （このクラスが付いた form-row だけに効く。他フォームには影響なし）
   =================================================================== */
.form-row.field-row-bottom label { justify-content: flex-start; }
.form-row.field-row-bottom label > .input { margin-top: auto; }
/* ===================================================================
   自己ベストカード 案B：個人モードのタイム・日付を種目名の左に揃える。
   チップ幅(34px)+間隔(9px)=43px ぶん字下げして左端を1本にそろえる。
   （.pb-solo のみ。チームモードのタイムには影響しない）
   =================================================================== */
.pb-card.pb-solo .pb-time,
.pb-card.pb-solo .pb-meta { padding-left: 43px; }
/* ===================================================================
   チームモードの自己ベストカードも個人モードと同じ左そろえに整える。
   チップ（アイコン）を左に置き、選手名／種目／タイム／日付の左端をそろえる。
   （.pb-card:not(.pb-solo) のみ。個人モード=.pb-solo には影響しない）
   =================================================================== */
.pb-card:not(.pb-solo) .pb-chip{ background:#e6edf5; color:#1e3a5f; }
.pb-card:not(.pb-solo).is-new .pb-chip{ background:#fdf1d8; color:#c8952a; }
.pb-card:not(.pb-solo) .pb-athlete{ margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.pb-card:not(.pb-solo) .pb-dist{ color:#23477e; }
.pb-card:not(.pb-solo) .pb-event{ font-size:.8rem; }
.pb-card:not(.pb-solo) .pb-time,
.pb-card:not(.pb-solo) .pb-meta{ padding-left:43px; }
.pb-card:not(.pb-solo) .pb-new-tag{ margin-left:43px; }

/* エントリー集計：カードは静的な影（見た目のみ）、タップ反応は名前だけ */
.es-row-card { box-shadow: 0 2px 8px rgba(3,80,140,.10); }
.es-name-tap { border-radius: 6px; padding: 1px 5px; margin: -1px -5px; transition: background .12s, transform .1s; }
.es-name-tap:hover { background: rgba(0,119,182,.08); }
.es-name-tap:active { background: rgba(0,119,182,.16); transform: scale(0.97); }

/* 「エントリーから」記録入力チップ：ボタンらしさを強調 */
.rep-chip:hover, .rep-relay-chip:hover { box-shadow: 0 4px 12px rgba(3,80,140,.2); }
.rep-chip:active, .rep-relay-chip:active { transform: scale(0.96); box-shadow: 0 1px 4px rgba(3,80,140,.15); }
