:root{
  --bg:#0b0d10;
  --card:#12161c;
  --text:#e8eef6;
  --muted:#aebfd3;
  --line:#222a34;
  --accent:#4ea1ff;
  --ok:#3ddc97;
  --danger:#ff5d5d;
  --radius:16px;
  --shadow:0 10px 34px rgba(0,0,0,.45);
  --mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
  --sans:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,"Apple Color Emoji","Segoe UI Emoji";
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family:var(--sans);
  color:var(--text);
  background:radial-gradient(1200px 700px at 20% 0%, #111a25 0%, var(--bg) 55%);
  min-height:100vh;
}

.wrap{
  max-width:640px;
  margin:0 auto;
  padding:14px 12px 120px;
}

header{
  display:flex;
  flex-direction:column;
  gap:16px;
  margin:6px 0 20px;
}

h1{
  margin:0;
  font-size:23px;
  font-weight:800;
  letter-spacing:.2px;
  color:#f3f7ff;
}

.sub{
  margin:0;
  font-size:16px;
  color:rgba(232,238,246,.70);
  line-height:1.35;
}

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

/* Big prominent mode selector */
.modeSelector{
  display:flex;
  width:100%;
  background:rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.15);
  border-radius:20px;
  padding:6px;
  gap:6px;
  margin:8px 0;
}
.modeSelector button{
  flex:1;
  border:0;
  border-radius:16px;
  padding:18px 24px;
  background:transparent;
  color:rgba(232,238,246,.75);
  font-weight:900;
  font-size:21px;
  cursor:pointer;
  transition:all 0.2s ease;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
}
.modeSelector button:before{
  content:'💪';
  font-size:18px;
  opacity:0.7;
}
.modeSelector button:last-child:before{
  content:'🧘‍♂️';
}
.modeSelector button.active{
  background:linear-gradient(135deg, rgba(78,161,255,.25), rgba(78,161,255,.15));
  color:#f3f7ff;
  border:1px solid rgba(78,161,255,.40);
  box-shadow:0 4px 16px rgba(78,161,255,.15);
  transform:translateY(-1px);
}
.modeSelector button.active:before{
  opacity:1;
}
.modeSelector button:hover:not(.active){
  background:rgba(255,255,255,.08);
  color:#f3f7ff;
}

.seg{
  display:inline-flex;
  background:rgba(255,255,255,.04);
  border:1px solid rgba(255,255,255,.10);
  border-radius:999px;
  padding:4px;
  gap:4px;
}
.seg button{
  border:0;
  border-radius:999px;
  padding:10px 14px;
  background:transparent;
  color:rgba(232,238,246,.72);
  font-weight:800;
  font-size:13px;
  cursor:pointer;
}
.seg button.active{
  background:rgba(78,161,255,.18);
  color:#f3f7ff;
}

.grid{ display:grid; gap:12px; margin-top:10px; }

.card{
  background:linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.02));
  border:1px solid rgba(255,255,255,.10);
  border-radius:var(--radius);
  padding:14px;
  box-shadow:var(--shadow);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#sportsList .card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
  transform: translateY(-2px);
}

.cardTitle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:0 0 10px;
}
.cardTitle h2{
  margin:0;
  font-size:18px;
  font-weight:900;
  color:#f3f7ff;
  letter-spacing:.2px;
}

.pill{
  font-family:var(--mono);
  font-size:14px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  color:rgba(232,238,246,.72);
  background:rgba(0,0,0,.18);
}

label{
  display:block;
  font-size:16px;
  font-weight:800;
  color:rgba(232,238,246,.80);
  margin:0 0 6px;
}

input[type="text"], input[type="number"], textarea, select{
  width:100%;
  padding:12px 12px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(0,0,0,.25);
  color:var(--text);
  outline:none;
  font-size:19px;
}

/* RPE Slider Styles */
.rpe-container {
  position: relative;
  margin-top: 24px;
}

.rpe-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(
    to right,
    #3ddc97 0%, #3ddc97 30%,    /* Green: 1-3 (Easy) */
    #ffd166 30%, #ffd166 70%,   /* Yellow: 4-7 (Moderate) */
    #ff5d5d 70%, #ff5d5d 100%   /* Red: 8-10 (Hard) */
  );
  outline: none;
  cursor: pointer;
  margin: 20px 0 12px;
}

.rpe-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #3d8bff);
  border: 2px solid rgba(255,255,255,.20);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  transition: all 0.15s ease;
}

.rpe-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(78,161,255,.4);
}

.rpe-slider::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #3d8bff);
  border: 2px solid rgba(255,255,255,.20);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.rpe-value {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 12px;
  background: rgba(78,161,255,.15);
  border: 1px solid rgba(78,161,255,.30);
  color: #f3f7ff;
  font-family: var(--mono);
  font-weight: 900;
  font-size: 18px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.rpe-value.easy {
  background: rgba(61, 220, 151, 0.2);
  border-color: rgba(61, 220, 151, 0.5);
  color: #3ddc97;
}

.rpe-value.moderate {
  background: rgba(255, 209, 102, 0.2);
  border-color: rgba(255, 209, 102, 0.5);
  color: #ffd166;
}

.rpe-value.hard {
  background: rgba(255, 93, 93, 0.2);
  border-color: rgba(255, 93, 93, 0.5);
  color: #ff5d5d;
}

.rpe-intensity-label {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  margin-top: 8px;
  color: rgba(232, 238, 246, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.3s ease;
}

.rpe-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  margin-bottom: 8px;
  font-size: 10px;
  color: rgba(232,238,246,.50);
  font-family: var(--mono);
}

textarea{ min-height:96px; resize:vertical; }

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

.field{
  flex:1 1 220px;
  min-width:170px;
  margin-top:16px;
}

.field:first-child {
  margin-top: 0;
}

.small{ flex:0 0 120px; width:120px; }

.muted{
  color:rgba(232,238,246,.68);
  font-size:16px;
}

.divider{
  height:1px;
  background:rgba(255,255,255,.07);
  margin:12px 0;
}

.btn{
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.04);
  color:var(--text);
  border-radius:12px;
  padding:12px 14px;
  font-weight:900;
  font-size:17px;
  cursor:pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn:disabled{ opacity:.55; cursor:not-allowed; }
.btn:not(:disabled):hover{
  background:rgba(255,255,255,.08);
  transform: translateY(-2px);
}
.btn:active:not(:disabled){
  transform: translateY(0) scale(0.97);
}

/* Orange primary button */
button.btn.primary,
#submitTraining.btn.primary,
#submitSauna.btn.primary {
  background: linear-gradient(135deg, rgba(255,152,0,.35), rgba(255,152,0,.25)) !important;
  border: 1px solid rgba(255,152,0,.60) !important;
  color: #fff !important;
  font-size: 16px !important;
  padding: 18px 48px !important;
  font-weight: 950 !important;
  border-radius: 14px !important;
  transition: all 0.2s ease !important;
  transform: translateY(0) !important;
  min-width: 200px !important;
  display: block !important;
  margin: 0 auto !important;
}

button.btn.primary:hover:not(:disabled),
#submitTraining.btn.primary:hover:not(:disabled),
#submitSauna.btn.primary:hover:not(:disabled) {
  transform: translateY(-2px) !important;
  box-shadow: 0 12px 32px rgba(255,152,0,.40) !important;
  background: linear-gradient(135deg, rgba(255,152,0,.45), rgba(255,152,0,.35)) !important;
}

button.btn.primary:active:not(:disabled),
#submitTraining.btn.primary:active:not(:disabled),
#submitSauna.btn.primary:active:not(:disabled) {
  transform: translateY(0) !important;
  box-shadow: 0 6px 20px rgba(255,152,0,.25) !important;
}

.btn.danger{
  background:rgba(255,93,93,.12);
  border-color:rgba(255,93,93,.35);
  color:#ffd7d7;
}
.btn.danger:hover:not(:disabled){
  background:rgba(255,93,93,.18);
  box-shadow: 0 4px 12px rgba(255, 93, 93, 0.3);
}

/* BIG green Add button: centered, sticky */
.addDock{
  position:fixed;
  left:0;
  right:0;
  bottom:16px;
  display:flex;
  justify-content:center;
  pointer-events:none;
  z-index:50;
}
.addBtn{
  pointer-events:auto;
  width:min(520px, calc(100% - 24px));
  border-radius:16px;
  border:1px solid rgba(61,220,151,.55);
  background:linear-gradient(180deg, rgba(61,220,151,.25), rgba(61,220,151,.16));
  box-shadow:0 14px 44px rgba(0,0,0,.55);
  color:#eafff5;
  font-weight:950;
  font-size:21px;
  padding:16px 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  cursor:pointer;
  user-select:none;
  transition: all 0.2s ease;
}
.addBtn:active{ transform:translateY(1px); }
.addIcon{
  width:26px;
  height:26px;
  border-radius:10px;
  display:grid;
  place-items:center;
  background:rgba(0,0,0,.20);
  border:1px solid rgba(255,255,255,.14);
  font-size:18px;
  line-height:1;
}

/* Submit button dock: centered, sticky, above Add button */
.submitDock{
  position:fixed;
  left:0;
  right:0;
  bottom:90px;
  display:none;
  justify-content:center;
  pointer-events:none;
  z-index:49;
}
.submitDock.active{
  display:flex;
}
.submitBtn{
  pointer-events:auto;
  width:min(520px, calc(100% - 24px));
  border-radius:16px;
  border:1px solid rgba(255,152,0,.60);
  background:linear-gradient(180deg, rgba(255,152,0,.35), rgba(255,152,0,.25));
  box-shadow:0 14px 44px rgba(0,0,0,.55);
  color:#fff;
  font-weight:950;
  font-size:21px;
  padding:16px 18px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  cursor:pointer;
  user-select:none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.submitBtn:disabled{
  opacity:.55;
  cursor:not-allowed;
}
.submitBtn:hover:not(:disabled){
  transform:translateY(-2px);
  box-shadow:0 16px 48px rgba(255,152,0,.40);
  background:linear-gradient(180deg, rgba(255,152,0,.45), rgba(255,152,0,.35));
}
.submitBtn:active:not(:disabled){
  transform:translateY(0);
}

/* Sport cards */
.sportHeader{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:0 0 10px;
}
.sportHeader .left{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}
.sportHeader .tag{
  font-family:var(--mono);
  font-size:11px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  color:rgba(232,238,246,.78);
  background:rgba(0,0,0,.18);
}
.sportHeader .name{
  font-weight:950;
  font-size:13px;
  color:#f3f7ff;
}
.sportHeader .actions{
  display:flex;
  gap:6px;
}
.sportHeader .actions .btn{
  padding:14px 14px;
  border-radius:12px;
  min-width:48px;
  min-height:48px;
  font-size:20px;
}

.sportHeader .actions .btn:hover:not(:disabled){
  box-shadow: 0 4px 12px rgba(78, 161, 255, 0.25);
}

.disc{
  display:grid;
  grid-template-columns: 1.2fr .8fr .8fr auto;
  gap:8px;
  align-items:end;
  margin-top:10px;
  padding:10px;
  border-radius:14px;
  border:1px dashed rgba(255,255,255,.10);
  background:rgba(0,0,0,.14);
}
.disc .x{
  padding:16px 16px;
  border-radius:12px;
  min-width:48px;
  min-height:48px;
}

/* Modal */
.modal{
  position:fixed; inset:0;
  display:none;
  align-items:flex-end;
  justify-content:center;
  background:rgba(0,0,0,.58);
  padding:14px 12px;
  z-index:60;
}
.modal.open{ display:flex; }
.panel{
  width:min(640px, 100%);
  border-radius:18px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(18,22,28,.98);
  box-shadow:var(--shadow);
  padding:14px;
}
.panel h3{
  margin:2px 0 10px;
  font-size:14px;
  font-weight:950;
  color:#f3f7ff;
}
.choices{ display:grid; gap:10px; }
.choice{
  text-align:left;
  padding:14px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.03);
  cursor:pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.choice:hover{
  background:rgba(255,255,255,.06);
  border-color:rgba(255,255,255,.20);
  transform: translateY(-2px);
}
.choice:active{
  transform: scale(0.97);
}
.choice strong{ display:block; font-size:14px; font-weight:950; color:#f3f7ff; }
.choice span{ display:block; margin-top:4px; color:rgba(232,238,246,.70); font-size:12.5px; }
.footer{ margin-top:12px; display:flex; justify-content:flex-end; gap:10px; }

.status{
  margin-top:12px;
  font-size:13px;
  padding:12px 12px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(0,0,0,.18);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.status.ok{ border-color: rgba(61,220,151,.40); }
.status.err{ border-color: rgba(255,93,93,.40); }
.status.warn{ border-color: rgba(255,209,102,.40); }
.status.hiding{
  opacity: 0;
  transform: translateY(-10px);
}
.mono{ font-family:var(--mono); font-size:12px; white-space:pre-wrap; word-break:break-word; }

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Micro-animations */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes successPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes successGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0); }
  50% { box-shadow: 0 0 20px 5px rgba(61, 220, 151, 0.3); }
}

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

@keyframes ripple {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 152, 0, 0.5);
  }
  100% {
    box-shadow: 0 0 0 20px rgba(255, 152, 0, 0);
  }
}

/* Apply animations */
#sportsList .card {
  animation: slideInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Stagger animation for multiple cards */
#sportsList .card:nth-child(1) { animation-delay: 0s; }
#sportsList .card:nth-child(2) { animation-delay: 0.05s; }
#sportsList .card:nth-child(3) { animation-delay: 0.1s; }
#sportsList .card:nth-child(4) { animation-delay: 0.15s; }
#sportsList .card:nth-child(5) { animation-delay: 0.2s; }

.status.ok {
  animation: successPulse 0.6s ease-out, successGlow 1s ease-out;
}

.modal.open .panel {
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn.primary:active:not(:disabled),
.submitBtn:active:not(:disabled) {
  animation: ripple 0.6s ease-out;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: rgba(232, 238, 246, 0.6);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 8px;
  color: rgba(232, 238, 246, 0.8);
}

.empty-state p {
  font-size: 14px;
  margin: 0;
  line-height: 1.5;
}

.empty-state strong {
  color: rgba(232, 238, 246, 0.9);
  font-weight: 900;
}

/* Make modal choices + grids mobile-friendly */
@media (max-width: 520px){
  .disc{
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px 10px;
    padding: 12px;
  }
  .disc > div:first-child{
    grid-column: 1 / -1;
  }
  .disc > div{
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .disc .x{
    align-self: end;
    padding: 14px;
    min-width: 48px;
    min-height: 48px;
  }
  .disc label{
    font-size: 11px;
    font-weight: 700;
    color: rgba(232, 238, 246, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .disc input,
  .disc select{
    width: 100%;
  }
  .small{ flex:0 0 110px; width:110px; }
  input, textarea, select{ font-size:21px; }
  .modeSelector button{
    font-size:19px;
    padding:16px 20px;
  }
  .field{
    margin-top: 20px;
  }
  .grid{
    gap: 16px;
  }
}

/* Reduced motion support for accessibility */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Statistics display */
.statsSection {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid rgba(255,255,255,.10);
}

.statsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.statItem {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.14);
}

.statLabel {
  font-size: 13px;
  font-weight: 700;
  color: rgba(232,238,246,.70);
  text-transform: capitalize;
}

.statValue {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 900;
  color: #4ea1ff;
}

@media (max-width: 520px){
  .statsGrid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}
