*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #E85D04;
  --bg: #f4f4f4;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #888;
  --border: #e0e0e0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== Layout ===== */
.container     { max-width: 480px; margin: 0 auto; padding: 0 16px; }
.page-content  { padding-top: 16px; padding-bottom: 84px; }

/* ===== Header ===== */
.header {
  background: #1a1a1a;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-title { font-size: 18px; font-weight: 800; }

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
  text-decoration: none;
  line-height: 1;
  -webkit-appearance: none;
}
.btn:active     { opacity: .75; }
.btn-primary    { background: var(--primary); color: #fff; }
.btn-secondary  { background: #e8e8e8; color: var(--text); }
.btn-danger     { background: #dc2626; color: #fff; }
.btn-sm         { padding: 8px 14px; font-size: 13px; }
.btn-full       { width: 100%; }

/* ===== Forms ===== */
.form-group   { margin-bottom: 16px; }
.form-label   {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  transition: border-color .2s;
  -webkit-appearance: none;
  color: var(--text);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
}
.form-textarea { resize: vertical; min-height: 120px; }

/* ===== Category badges ===== */
.badge           { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-heavy     { background: #fde8d8; color: #c2410c; }
.badge-benchmark { background: #dbeafe; color: #1d4ed8; }
.badge-partner   { background: #dcfce7; color: #15803d; }
.badge-hero      { background: #ede9fe; color: #6d28d9; }
.badge-other     { background: #f3f4f6; color: #374151; }

/* ===== Toggle buttons (score type / category) ===== */
.toggle-group  { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle-option {
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
  transition: all .15s;
  -webkit-appearance: none;
  color: var(--text);
}
.toggle-option.selected { border-color: var(--primary); background: var(--primary); color: #fff; }

/* ===== Leaderboard ===== */
.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.lb-row:last-child   { border-bottom: none; }
.lb-row.me           { background: #fff7ed; border-radius: 8px; padding: 11px 8px; margin: 0 -8px; }
.lb-rank             { font-size: 18px; font-weight: 800; min-width: 30px; text-align: center; }
.lb-name             { flex: 1; font-size: 15px; font-weight: 600; }
.lb-score            { font-size: 14px; color: var(--muted); text-align: right; }
.lb-rx               { font-size: 10px; background: #dcfce7; color: #15803d; padding: 1px 6px; border-radius: 10px; font-weight: 700; margin-left: 4px; }

/* ===== Bottom navigation ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.nav-item.active { color: var(--primary); }
.nav-icon        { font-size: 22px; }

/* ===== Message boxes ===== */
.message-box     { padding: 12px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; line-height: 1.5; }
.message-error   { background: #fee2e2; color: #991b1b; }
.message-success { background: #d1fae5; color: #065f46; }
.message-info    { background: #dbeafe; color: #1e40af; }

/* ===== Login page ===== */
.login-page   {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #111;
}
.login-logo   { color: #fff; font-size: 30px; font-weight: 900; margin-bottom: 6px; letter-spacing: -1px; }
.login-sub    { color: #666; font-size: 14px; margin-bottom: 28px; }
.login-card   { background: #fff; border-radius: 16px; padding: 24px; width: 100%; max-width: 360px; }
.login-tabs   { display: flex; gap: 0; margin-bottom: 20px; background: #f0f0f0; border-radius: 10px; padding: 4px; }
.login-tab    {
  flex: 1; padding: 9px; border-radius: 7px;
  font-size: 14px; font-weight: 700; cursor: pointer;
  border: none; background: transparent; color: var(--muted);
}
.login-tab.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.15); }

/* ===== WOD description ===== */
.wod-desc {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.8;
  font-family: 'Courier New', monospace;
  background: #1a1a1a;
  color: #f0f0f0;
  padding: 16px;
  border-radius: 10px;
  overflow-x: auto;
}

/* ===== Section title ===== */
.section-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 12px;
}

/* ===== Modal (bottom sheet) ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end;
  z-index: 200;
}
.modal {
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title  { font-size: 18px; font-weight: 800; }
.modal-close  { font-size: 28px; cursor: pointer; color: var(--muted); background: none; border: none; line-height: 1; padding: 0; }

/* ===== Input with unit ===== */
.input-row            { display: flex; gap: 8px; align-items: center; }
.input-row .form-input { flex: 1; }
.unit-sel             { width: 78px; }

/* ===== Member list ===== */
.member-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.member-item:last-child { border-bottom: none; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; flex-shrink: 0;
}
.member-info         { flex: 1; min-width: 0; }
.member-name-text    { font-weight: 700; font-size: 15px; }
.member-email-text   { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-badge        { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 700; display: inline-block; }
.status-active       { background: #d1fae5; color: #065f46; }
.status-inactive     { background: #fee2e2; color: #991b1b; }
.role-admin          { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 700; display: inline-block; background: #dbeafe; color: #1e40af; }

/* ===== Admin tabs ===== */
.admin-tabs  { display: flex; background: #fff; border-bottom: 1px solid var(--border); }
.admin-tab   {
  flex: 1; padding: 14px; border: none; background: none;
  font-size: 14px; font-weight: 700; color: var(--muted);
  cursor: pointer; border-bottom: 3px solid transparent;
}
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== Loading / empty ===== */
.loading     { text-align: center; padding: 48px 20px; color: var(--muted); font-size: 15px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon  { font-size: 44px; margin-bottom: 12px; }

/* ===== Checkbox ===== */
.check-row                   { display: flex; align-items: center; gap: 10px; }
.check-row input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); cursor: pointer; }
.check-row label             { font-size: 15px; font-weight: 600; cursor: pointer; }

/* ===== TODAY tag ===== */
.today-tag { font-size: 11px; background: #fff0e0; color: var(--primary); padding: 2px 9px; border-radius: 10px; font-weight: 800; }

/* ===== Calendar ===== */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 2px 0 10px;
}
.cal-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  gap: 3px;
}
.cal-cell.has-score          { background: #fff0e0; cursor: pointer; }
.cal-cell.has-score:active   { background: #fdd9b5; }
.cal-day-num                 { font-size: 13px; font-weight: 600; color: #ccc; line-height: 1; }
.cal-cell.has-score .cal-day-num { color: #1a1a1a; }
.cal-cell.is-today  .cal-day-num { color: var(--primary); font-weight: 900; }
.cal-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
