:root {
  --ink: #f7f7f7;
  --muted: #a7a7a7;
  --line: #323232;
  --paper: #0d0d0d;
  --surface: #151515;
  --surface-2: #1f1f1f;
  --surface-3: #292929;
  --primary: #c41e24;
  --primary-light: #ff4545;
  --gold: #caa45d;
  --green: #216b5a;
  --red: #a53e34;
  --blue: #325f8f;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(196, 30, 36, 0.17), transparent 34%),
    linear-gradient(135deg, rgba(202, 164, 93, 0.08), transparent 38%),
    linear-gradient(315deg, rgba(33, 107, 90, 0.12), transparent 36%),
    var(--paper);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #111;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.25rem;
  letter-spacing: 0;
}

.brand small,
.sync-card small {
  color: #cfcfcf;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.ghost-btn,
.primary-btn,
.danger-btn,
.icon-btn {
  border-radius: 8px;
  min-height: 42px;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.nav-item {
  width: 100%;
  text-align: left;
  color: #e7e7e7;
  background: transparent;
  border: 0;
  padding: 12px;
}

.nav-item span {
  color: var(--gold);
  margin-right: 10px;
  font-size: 0.78rem;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
}

.sync-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.sync-card p {
  margin: 0 0 10px;
  color: var(--gold);
  font-weight: 700;
}

.sync-card label {
  margin-top: 12px;
  color: #cfcfcf;
  font-size: 0.84rem;
}

.sync-card input {
  width: 100%;
  margin: 8px 0;
  background: #111;
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}

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

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

.topbar h1 {
  margin: 0;
  max-width: 850px;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary-light);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.75rem;
  letter-spacing: 0;
}

.section-note {
  max-width: 440px;
  color: var(--muted);
  text-align: right;
}

.form-grid,
.planner-layout,
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel,
.metric {
  background: rgba(26, 26, 26, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel.wide,
.wide {
  grid-column: 1 / -1;
}

.panel h3,
.metric span {
  margin: 0 0 14px;
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field-grid.thirds {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-grid.quarters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.compact-grid {
  margin-top: 14px;
}

label,
.full-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.full-label {
  grid-column: 1 / -1;
  margin-top: 14px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(196, 30, 36, 0.16);
}

.choice-list,
.exercise-library,
.training-grid,
.selected-exercises,
.review-content,
.plan-output {
  display: grid;
  gap: 14px;
}

.choice-card {
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
}

.choice-card strong,
.choice-card span {
  display: block;
}

.choice-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.choice-card.selected {
  border-color: var(--primary);
  background: rgba(196, 30, 36, 0.16);
}

.toggle-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.toggle-grid.single-toggle {
  grid-template-columns: minmax(0, 1fr);
}

.toggle-grid label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
}

.toggle-grid input,
.exercise-checkline input {
  width: 18px;
  min-height: 18px;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  border: 0;
  padding: 0 18px;
}

.ghost-btn,
.icon-btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 14px;
}

.sync-card .ghost-btn {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.24);
  width: 100%;
}

.danger-btn {
  background: rgba(165, 62, 52, 0.18);
  color: #ff9a8f;
  border: 1px solid rgba(165, 62, 52, 0.55);
  padding: 0 14px;
}

.primary-btn:hover,
.ghost-btn:hover,
.danger-btn:hover,
.icon-btn:hover,
.choice-card:hover {
  transform: translateY(-1px);
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.exercise-group,
.selected-category,
.training-card,
.review-section,
.plan-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.exercise-group h4,
.training-card header,
.selected-category h4,
.review-section h3 {
  margin: 0;
  padding: 13px 14px;
  background: rgba(196, 30, 36, 0.14);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.exercise-group h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exercise-group h4 span {
  color: var(--primary-light);
  font-size: 0.78rem;
}

.exercise-row,
.training-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 70px 78px 84px;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.exercise-row:last-child,
.training-row:last-child {
  border-bottom: 0;
}

.exercise-row input,
.training-row input {
  min-height: 34px;
  padding: 6px 8px;
}

.exercise-checkline {
  display: flex;
  align-items: center;
  grid-template-columns: none;
  gap: 9px;
  color: var(--ink);
  min-width: 0;
}

.exercise-checkline input {
  flex: 0 0 18px;
}

.exercise-checkline span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.selected-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.selected-row span,
.training-card header p,
.review-section li span {
  color: var(--muted);
}

.custom-exercise {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.custom-exercise h4 {
  margin: 0 0 12px;
  color: var(--primary-light);
}

.upload-panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px dashed rgba(255, 69, 69, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  display: grid;
  gap: 12px;
}

.upload-panel h4,
.upload-panel p {
  margin: 0;
}

.upload-panel h4 {
  color: var(--ink);
}

.upload-panel p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.88rem;
}

.upload-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}

.upload-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.image-preview {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 78px;
}

.empty-preview {
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.preview-tile {
  position: relative;
  width: 126px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.preview-tile img {
  display: block;
  width: 108px;
  height: 108px;
  object-fit: cover;
  border-radius: 8px;
}

.preview-tile figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.preview-remove {
  width: 100%;
  min-height: 30px;
  margin-top: 6px;
  border: 1px solid rgba(165, 62, 52, 0.55);
  border-radius: 8px;
  background: rgba(165, 62, 52, 0.18);
  color: #ff9a8f;
}

.review-photo-strip {
  padding: 14px;
}

.review-photo-strip img {
  width: 132px;
  height: 132px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.training-program-builder {
  grid-column: 1 / -1;
}

.training-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.training-card > label {
  padding: 12px;
}

.plan-day {
  padding: 14px;
}

.plan-day h4 {
  margin: 0 0 10px;
}

.plan-day ul {
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
}

.plan-day li {
  margin: 5px 0;
}

.plan-day li span {
  color: var(--muted);
}

.plan-note {
  padding: 14px;
  background: rgba(202, 164, 93, 0.12);
  border: 1px solid rgba(202, 164, 93, 0.34);
  border-radius: 8px;
  color: #ead8b0;
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  font-size: 2rem;
  line-height: 1;
}

.chart-panel {
  min-width: 0;
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
  border-radius: 8px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

td button {
  min-height: 34px;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
}

.review-grid div {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.review-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.review-section ul {
  margin: 0;
  padding: 12px 30px;
}

.review-section h4 {
  margin: 12px 14px 0;
  color: var(--primary-light);
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.summary-strip span {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 8px 10px;
}

.photo-timeline {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
}

.photo-timeline figure {
  flex: 0 0 160px;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--surface-2);
  scroll-snap-align: start;
}

.photo-timeline img {
  width: 138px;
  height: 138px;
  display: block;
  object-fit: cover;
  border-radius: 8px;
}

.photo-timeline figcaption {
  margin-top: 8px;
  color: var(--muted);
  text-align: center;
}

#toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 13px 15px;
  border-radius: 8px;
  background: #1f1f1f;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

.report {
  display: none;
}

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

  .sidebar {
    position: relative;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid,
  .planner-layout,
  .dashboard-grid,
  .field-grid.thirds,
  .field-grid.quarters,
  .training-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    display: grid;
  }

  .section-note {
    text-align: left;
  }
}

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

  .nav,
  .field-grid,
  .toggle-grid,
  .exercise-row,
  .training-row,
  .selected-row {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 2.2rem;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .topbar-actions button {
    flex: 1;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell,
  #toast {
    display: none;
  }

  .report {
    display: block;
    color: #181818;
    padding: 18mm;
  }

  .report header {
    display: flex;
    gap: 16px;
    align-items: center;
    border-bottom: 3px solid #181818;
    padding-bottom: 16px;
    margin-bottom: 18px;
  }

  .report img {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 8px;
  }

  .report .report-photo {
    width: 110px;
    height: 110px;
  }

  .report-photos {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
  }

  .report-photos img {
    width: 85px;
    height: 85px;
  }

  .report h1 {
    margin: 0;
    font-size: 28px;
  }

  .report p {
    margin: 0 0 6px;
  }

  .report section {
    margin: 18px 0;
  }

  .report table {
    color: #181818;
    font-size: 12px;
  }
}
