:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #fff7ed;
  --text: #111827;
  --muted: #64748b;
  --line: #dbe3ef;
  --primary: #f97316;
  --primary-dark: #ea580c;
  --primary-soft: #ffedd5;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.12);
  --radius: 22px;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #ffedd5 0, transparent 34rem), radial-gradient(circle at top right, #fed7aa 0, transparent 28rem), var(--bg);
  color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text);
  font-weight: 850;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.brand:hover { text-decoration: none; }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: block;
  box-shadow: 0 10px 30px rgba(249, 115, 22, 0.30);
}

.button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.78rem 1.08rem;
  background: #fff;
  color: var(--text);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  font-weight: 750;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease;
  text-decoration: none;
  min-height: 42px;
}

.button:hover {
  transform: translateY(-1px);
  text-decoration: none;
  border-color: #fdba74;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 10px 30px rgba(249, 115, 22, 0.24);
}

.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: rgba(255,255,255,0.72); }
.button.full { width: 100%; }
.button.small { min-height: 34px; padding: 0.45rem 0.8rem; font-size: 0.88rem; }
.button.danger { color: var(--danger); border-color: rgba(220, 38, 38, .24); }
.button.danger:hover { background: #fff1f2; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.3rem 1rem 3rem;
}

.topnav,
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-actions,
.hero-actions,
.app-user {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 2rem;
  align-items: center;
  min-height: 68vh;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-weight: 850;
  color: var(--primary);
  font-size: .8rem;
}

.hero h1 {
  margin: .5rem 0 1rem;
  font-size: clamp(2.5rem, 6vw, 5.4rem);
  line-height: .96;
  letter-spacing: -0.07em;
}

.hero-copy {
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.75;
  max-width: 650px;
}

.hero-card {
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(219, 227, 239, .9);
  border-radius: 30px;
  padding: 1rem;
  box-shadow: var(--shadow);
  display: grid;
  gap: 1rem;
}

.home-gym-card {
  padding: .85rem;
}

.home-gym-visual {
  display: block;
  width: 100%;
  border-radius: 24px;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.10);
}

.metric-grid {
  display: grid;
  gap: .85rem;
}

.dashboard-home-gym {
  width: 230px;
  max-width: 32vw;
  border-radius: 24px;
  border: 1px solid #fed7aa;
  background: #fff7ed;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

.metric {
  border-radius: 24px;
  background: linear-gradient(135deg, #ffffff, #fff7ed);
  border: 1px solid var(--line);
  padding: 1.15rem;
}

.metric strong {
  display: block;
  font-size: 3.2rem;
  line-height: 1;
  letter-spacing: -0.08em;
}

.metric span { color: var(--muted); font-weight: 700; }

.landing-sections,
.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem;
}

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.feature-row article,
.panel,
.auth-card {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.feature-row article { padding: 1.25rem; }
.feature-row h2 { margin-top: 0; letter-spacing: -0.03em; }
.feature-row p, .footer, .muted { color: var(--muted); }
.footer { padding-bottom: 2.5rem; }

.auth-page {
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-shell {
  width: min(100%, 470px);
}

.auth-card {
  padding: 2rem;
}

.auth-card h1 {
  font-size: 2.4rem;
  margin: 1.6rem 0 .4rem;
  letter-spacing: -0.06em;
}

.auth-card p { color: var(--muted); line-height: 1.65; }
.auth-brand { font-size: 1.1rem; }
.switch-auth { text-align: center; }

.form-stack {
  display: grid;
  gap: 1rem;
  margin-top: 1.2rem;
}

label {
  display: grid;
  gap: .45rem;
  color: #334155;
  font-weight: 750;
}

input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 14px;
  padding: .82rem .95rem;
  color: var(--text);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
}

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

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, .14);
}

.alert {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  color: #9f1239;
  padding: .85rem 1rem;
  border-radius: 16px;
  font-weight: 750;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 1rem max(1rem, calc((100vw - 1380px)/2));
  background: rgba(245, 247, 251, .82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(219, 227, 239, .78);
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: grid;
  gap: 1.2rem;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
}

.dashboard-hero h1 {
  margin: 0 0 .35rem;
  font-size: clamp(2rem, 4vw, 3.6rem);
  letter-spacing: -0.07em;
}

.dashboard-hero p { margin: 0; color: var(--muted); line-height: 1.65; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .8rem;
}

.stat-card {
  background: linear-gradient(135deg, #ffffff, #eef4ff);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  letter-spacing: -0.06em;
}

.stat-card span { color: var(--muted); font-weight: 750; }

.layout-grid {
  display: grid;
  grid-template-columns: 355px minmax(0, 1fr);
  gap: 1.2rem;
  align-items: start;
}

.side-column,
.main-column {
  display: grid;
  gap: 1rem;
}

.panel {
  padding: 1.15rem;
  overflow: hidden;
}

.panel.compact { max-width: 720px; margin: 2rem auto; padding: 1.6rem; }
.panel h2, .panel h3 { margin: 0 0 .75rem; letter-spacing: -0.04em; }
.panel p { color: var(--muted); line-height: 1.6; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .9rem;
}

.section-title h2,
.section-title h3 { margin: 0; }

.workout-list,
.template-list,
.exercise-list,
.item-list {
  display: grid;
  gap: .75rem;
}

.workout-card,
.template-card,
.exercise-card,
.item-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 18px;
  padding: .95rem;
}

.workout-card.active { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, .1); }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .7rem;
}
.card-head h3, .card-head h4 { margin: 0; letter-spacing: -0.03em; }
.card-actions { display: flex; gap: .45rem; flex-wrap: wrap; justify-content: flex-end; }

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .7rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: 999px;
  padding: .28rem .58rem;
  background: var(--surface-soft);
  color: #9a3412;
  font-size: .78rem;
  font-weight: 800;
}

.badge.gray { background: #f1f5f9; color: #334155; }
.badge.success { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }

.filters {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(130px, 1fr));
  gap: .65rem;
  align-items: end;
  margin-bottom: 1rem;
}

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

.exercise-card {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: .85rem;
  align-items: start;
}

.exercise-card .card-head,
.exercise-card .badge-row {
  grid-column: 2;
}

.exercise-card-photo {
  grid-row: 1 / span 2;
  width: 118px;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #e2e8f0;
}

.exercise-card h3 { margin: 0; letter-spacing: -0.035em; }
.exercise-card p { margin: .45rem 0 0; font-size: .92rem; }

.workout-detail-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: start;
}

.add-item-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) repeat(4, minmax(90px, .75fr));
  gap: .65rem;
  align-items: end;
}

.add-item-grid .wide { grid-column: 1 / -2; }

.calendar-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px 96px;
  gap: .65rem;
  align-items: end;
}

.calendar-form .wide {
  grid-column: 1 / -2;
}

.calendar-list {
  display: grid;
  gap: .65rem;
  margin-top: .9rem;
}

.calendar-event {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .7rem;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: .85rem;
}

.calendar-event time {
  display: inline-flex;
  color: #9a3412;
  font-weight: 850;
  font-size: .84rem;
  margin-bottom: .25rem;
}

.calendar-event h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.calendar-event p {
  margin: .35rem 0 0;
  font-size: .9rem;
}

.item-card {
  padding: 0;
}

.item-top {
  padding: 1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 1rem;
  align-items: start;
}

.item-top h3 { margin: 0 .5rem .35rem 0; letter-spacing: -0.04em; }
.item-meta { color: var(--muted); font-weight: 700; line-height: 1.5; }
.item-notes { margin-top: .55rem; color: #475569; }

.timer-box {
  border-radius: 18px;
  background: linear-gradient(135deg, #fff7ed, #ffffff);
  border: 1px solid #fed7aa;
  padding: .85rem;
  display: grid;
  gap: .65rem;
}

.timer-display {
  font-variant-numeric: tabular-nums;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.06em;
  color: #111827;
}

.timer-label { color: #1e3a8a; font-weight: 800; font-size: .85rem; }
.timer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }

.steps-details {
  border-top: 1px solid var(--line);
  background: #fbfdff;
}

.steps-details summary {
  cursor: pointer;
  padding: .9rem 1rem;
  font-weight: 850;
  color: #9a3412;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
  padding: 0 1rem 1rem;
}

.step-figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: white;
}

.step-figure-wide {
  margin: 0 1rem 1rem;
}

.step-figure img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #fff7ed;
}

.step-figure figcaption {
  padding: .85rem;
  color: #334155;
  line-height: 1.45;
  font-size: .92rem;
}

.step-caption-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: .35rem;
}

.empty-state {
  border: 1px dashed #b9c7dc;
  background: #fffaf5;
  border-radius: 18px;
  padding: 1.2rem;
  text-align: center;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  background: #0f172a;
  color: #fff;
  padding: .85rem 1rem;
  border-radius: 16px;
  box-shadow: var(--shadow);
  max-width: min(90vw, 420px);
  font-weight: 750;
}

.hidden { display: none !important; }

.loading-panel { text-align: center; }

@media (max-width: 1080px) {
  .hero-grid,
  .layout-grid,
  .workout-detail-header,
  .item-top { grid-template-columns: 1fr; }
  .hero-grid { min-height: auto; padding: 4rem 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .exercise-list { grid-template-columns: 1fr; }
  .exercise-card { grid-template-columns: 108px minmax(0, 1fr); }
  .exercise-card-photo { width: 108px; }
  .add-item-grid { grid-template-columns: 1fr 1fr; }
  .add-item-grid .wide { grid-column: 1 / -1; }
  .calendar-form { grid-template-columns: 1fr 1fr; }
  .calendar-form .wide { grid-column: 1 / -1; }
  .steps-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topnav,
  .app-header,
  .dashboard-hero,
  .section-title,
  .card-head {
    align-items: stretch;
    flex-direction: column;
  }
  .app-user { justify-content: space-between; }
  .feature-row { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .exercise-card { grid-template-columns: 96px minmax(0, 1fr); }
  .exercise-card-photo { width: 96px; }
  .calendar-form,
  .add-item-grid { grid-template-columns: 1fr; }
  .calendar-form .wide { grid-column: auto; }
  .calendar-event { grid-template-columns: 1fr; }
  .calendar-event .button { width: 100%; }
  .hero-actions .button, .nav-actions .button { width: 100%; }
  .hero h1 { font-size: 2.55rem; }
  .dashboard-home-gym { width: 100%; max-width: 100%; }
  .auth-card { padding: 1.25rem; }
}
