:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-strong: #f4e8e8;
  --ink: #201718;
  --muted: #665c5d;
  --line: #e5d8d8;
  --red: #b01825;
  --red-dark: #7c111b;
  --red-soft: #f6e1e3;
  --silver: #efefed;
  --charcoal: #211719;
  --shadow: 0 20px 60px rgba(70, 20, 26, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px;
  background: var(--charcoal);
  color: #f8fbf5;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  object-fit: cover;
}

.brand-block h1,
.topbar h2,
.section-heading h3,
.profile-panel h2,
.group-panel h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: rgba(248, 251, 245, 0.62);
}

.profile-panel,
.group-panel {
  display: grid;
  gap: 14px;
}

.profile-panel label,
.plan-form label,
.note-form label {
  display: grid;
  gap: 7px;
  color: inherit;
  font-size: 0.84rem;
  font-weight: 700;
}

.auth-label {
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 0.86rem;
  font-weight: 850;
}

.social-stack {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.social-button {
  display: grid;
  min-height: 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(245, 241, 241, 0.94)),
    #ffffff;
  color: #111111;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 10px 24px rgba(0, 0, 0, 0.22);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.social-button:hover {
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    0 14px 30px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.social-button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.48);
  outline-offset: 2px;
}

.provider-logo {
  width: 25px;
  height: 25px;
}

.microsoft-logo {
  display: grid;
  width: 24px;
  height: 24px;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2px;
}

.microsoft-logo span:nth-child(1) {
  background: #f25022;
}

.microsoft-logo span:nth-child(2) {
  background: #7fba00;
}

.microsoft-logo span:nth-child(3) {
  background: #00a4ef;
}

.microsoft-logo span:nth-child(4) {
  background: #ffb900;
}

.auth-status {
  margin: -2px 0 0;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
  line-height: 1.35;
}

.profile-panel input,
.profile-panel select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  padding: 11px 12px;
}

.profile-panel option {
  color: #172019;
}

.primary-button,
.secondary-button {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 800;
}

.primary-button {
  background: var(--red);
  color: #ffffff;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--red-dark);
}

.group-list {
  display: grid;
  gap: 8px;
}

.group-button {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.82);
  padding: 11px 12px;
  text-align: left;
  font-weight: 750;
}

.group-button.active {
  background: #ffffff;
  color: var(--red-dark);
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar,
.today-card,
.editor-panel,
.calendar-panel,
.notes-panel,
.roster-panel,
.performance-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px;
  margin-bottom: 18px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-strip span,
.pill {
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--red-dark);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 850;
}

.today-grid,
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.content-grid {
  grid-template-columns: minmax(340px, 0.85fr) minmax(0, 1fr) minmax(300px, 0.75fr);
  margin-top: 18px;
}

.today-card,
.editor-panel,
.calendar-panel,
.notes-panel,
.roster-panel,
.performance-panel {
  padding: 18px;
}

.plan-stack {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.plan-item {
  border-left: 4px solid var(--red);
  padding: 9px 0 9px 12px;
}

.plan-item strong {
  display: block;
  margin-bottom: 3px;
}

.plan-item p,
.coach-detail,
.note-body {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.plan-form,
.note-form,
.roster-form,
.tfrrs-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.plan-form input,
.plan-form textarea,
.note-form textarea,
.roster-form input,
.roster-form select,
.tfrrs-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 11px 12px;
  resize: vertical;
}

.week-list,
.notes-list,
.roster-list,
.race-history-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.week-list {
  grid-auto-flow: column;
  grid-auto-columns: minmax(178px, 1fr);
  overflow-x: auto;
  padding-bottom: 6px;
  scroll-snap-type: x proximity;
}

.day-row,
.note-row,
.roster-row,
.race-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.day-row {
  display: grid;
  min-height: 150px;
  grid-template-rows: auto 1fr;
  gap: 10px;
  text-align: left;
  scroll-snap-align: start;
}

.day-date {
  color: var(--red-dark);
  font-weight: 850;
}

.day-summary,
.note-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.note-row {
  display: grid;
  gap: 5px;
}

.roster-panel {
  grid-column: 2 / -1;
}

.performance-panel {
  grid-column: 1 / -1;
}

.roster-form {
  grid-template-columns: minmax(150px, 1fr) minmax(190px, 1fr) 120px auto;
  align-items: end;
}

.tfrrs-form {
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
}

.roster-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.race-row {
  display: grid;
  gap: 4px;
}

.race-row span {
  color: var(--muted);
}

.strava-panel,
.prediction-panel,
.comparison-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.comparison-list {
  display: grid;
  gap: 10px;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.comparison-metric {
  display: grid;
  gap: 2px;
}

.comparison-metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.inline-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--ink);
  font-weight: 850;
}

.inline-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
}

.roster-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  overflow: hidden;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.roster-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-editor {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.avatar-preview {
  position: relative;
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: #ffffff;
  color: var(--red-dark);
  font-weight: 900;
}

.avatar-preview img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-preview.has-photo img {
  display: block;
}

.avatar-preview.has-photo span {
  display: none;
}

.avatar-controls {
  display: grid;
  gap: 9px;
}

.avatar-controls label,
.roster-form label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 800;
}

.avatar-controls input[type="file"] {
  width: 100%;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.78rem;
}

.avatar-controls input[type="range"] {
  width: 100%;
  accent-color: var(--red);
}

.hidden {
  display: none;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .content-grid,
  .today-grid {
    grid-template-columns: 1fr;
  }

  .roster-panel,
  .performance-panel {
    grid-column: auto;
  }

  .roster-form,
  .tfrrs-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .week-list {
    grid-auto-columns: minmax(156px, 72vw);
  }

  .comparison-row {
    grid-template-columns: 1fr;
  }
}
