:root {
  --bg: #0e131b;
  --surface: #171e28;
  --surface-elevated: rgba(23, 30, 40, 0.9);
  --surface-soft: #111821;
  --header-bg: rgba(14, 19, 27, 0.86);
  --bottom-bg: rgba(17, 24, 33, 0.9);
  --text: #f4f7fb;
  --muted: #a9b4c6;
  --line: rgba(226, 232, 240, 0.12);
  --border: rgba(226, 232, 240, 0.13);
  --image-bg: #ffffff;
  --pastel-mix-base: #111821;
  --primary-surface: linear-gradient(135deg, #f5b7b1, #a3e4d7);
  --primary-text: #111821;
  --shadow: 0 18px 52px rgba(0, 0, 0, 0.38);
  --shadow-soft: 0 8px 28px rgba(0, 0, 0, 0.28);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --max: 1180px;
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-elevated: rgba(255, 255, 255, 0.92);
  --surface-soft: #eef3f8;
  --header-bg: rgba(248, 250, 252, 0.88);
  --bottom-bg: rgba(255, 255, 255, 0.9);
  --text: #16202e;
  --muted: #596779;
  --line: rgba(15, 23, 42, 0.08);
  --border: rgba(15, 23, 42, 0.11);
  --image-bg: #ffffff;
  --pastel-mix-base: #ffffff;
  --primary-text: #101828;
  --shadow: 0 18px 52px rgba(53, 68, 88, 0.14);
  --shadow-soft: 0 8px 26px rgba(53, 68, 88, 0.1);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  padding-bottom: 132px;
  background:
    linear-gradient(180deg, rgba(174, 214, 241, 0.14), transparent 430px),
    linear-gradient(135deg, rgba(245, 183, 177, 0.1), transparent 360px),
    var(--bg);
  color: var(--text);
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -120px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
}

.skip-link:focus {
  top: 16px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  justify-content: space-between;
  padding: 12px max(22px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--header-bg);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.brand-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 14px;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.22));
}

.brand-text {
  font-size: 1.02rem;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.theme-toggle {
  display: inline-flex;
  width: 42px;
  height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-elevated);
  color: var(--text);
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.theme-toggle svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: color-mix(in srgb, #a3e4d7 54%, var(--border));
  background: color-mix(in srgb, #a3e4d7 22%, var(--surface));
  transform: translateY(-1px);
  outline: 0;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.top-nav a,
.nav-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.top-nav a {
  --accent: #f7f7f7;
  padding: 10px 12px;
  border-color: color-mix(in srgb, var(--accent) 34%, var(--border));
  background: color-mix(in srgb, var(--accent) 22%, rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.top-nav a:hover,
.top-nav a:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 58%, var(--border));
  background: color-mix(in srgb, var(--accent) 34%, var(--pastel-mix-base));
  color: color-mix(in srgb, var(--accent) 48%, var(--text));
  transform: translateY(-1px);
  outline: 0;
}

.bottom-bar {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(2, minmax(126px, 1fr));
  gap: 8px;
  width: min(430px, calc(100vw - 28px));
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--bottom-bg);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.34);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.bottom-bar-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 18px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 850;
  line-height: 1;
  text-decoration: none;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

.bottom-bar-item svg {
  width: 21px;
  height: 21px;
  flex: 0 0 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.bottom-bar-item:hover {
  transform: translateY(-1px);
}

.bottom-bar-item.is-active {
  border-color: transparent;
  background: var(--primary-surface);
  color: var(--primary-text);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

main {
  width: min(100% - 32px, var(--max));
  margin: 0 auto;
}

.calendar-page {
  min-height: calc(100svh - 96px);
  padding-top: 28px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(320px, 0.98fr);
  gap: 38px;
  align-items: center;
  min-height: calc(84svh - 70px);
  padding: 42px 0 30px;
}

.hero-copy {
  display: grid;
  gap: 24px;
}

.hero h1 {
  margin: 0;
  max-width: 760px;
  color: var(--text);
  font-size: clamp(2.55rem, 6vw, 5.6rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-subtitle {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.08rem, 2vw, 1.5rem);
  line-height: 1.55;
}

.hero-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  max-width: 390px;
}

.hero-meta-item,
.stat-card,
.guide-card,
.active-rest-card,
.exercise-card {
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  box-shadow: var(--shadow-soft);
}

.hero-meta-item {
  border-radius: var(--radius-md);
  padding: 18px;
}

.meta-label,
.card-label,
.table-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.meta-value {
  display: block;
  margin-top: 5px;
  font-size: 1rem;
  font-weight: 800;
}

.hero-panel {
  border: 1px solid var(--border);
  border-radius: 32px;
  padding: 14px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  box-shadow: var(--shadow);
}

.hero-panel-inner {
  display: grid;
  gap: 14px;
  border-radius: 24px;
  padding: 20px;
  background: var(--surface);
}

.today-panel {
  --accent: #a3e4d7;
}

.today-panel .hero-panel-inner {
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 52%),
    var(--surface);
}

.today-summary {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.today-dot {
  width: 14px;
  height: 14px;
  margin-top: 8px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 20%, transparent);
}

.today-summary h2,
.today-empty h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.05;
  color: color-mix(in srgb, var(--accent) 56%, var(--text));
}

.today-summary p,
.today-empty p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.today-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

.today-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: color-mix(in srgb, var(--accent) 13%, var(--pastel-mix-base));
}

.today-item span {
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 999px;
  background: var(--accent);
}

.today-item p {
  margin: 0;
  color: var(--text);
  font-weight: 760;
  line-height: 1.35;
}

.week-card {
  display: grid;
  gap: 10px;
}

.week-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  min-height: 58px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-left: 10px solid var(--accent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 26%, var(--pastel-mix-base));
}

.week-day {
  padding-left: 16px;
  color: var(--text);
  font-weight: 850;
}

.week-focus {
  min-width: 0;
  padding: 0 18px;
  font-weight: 800;
}

.section-block,
.training-section {
  padding: 68px 0;
}

.section-block,
.training-section,
.active-rest-block {
  scroll-margin-top: 96px;
}

.section-heading {
  display: grid;
  gap: 12px;
  margin-bottom: 34px;
}

.section-heading h2,
.section-heading h1,
.training-title h2 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.section-kicker {
  display: inline-flex;
  width: fit-content;
  min-height: 34px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 12px;
  background: color-mix(in srgb, #a3e4d7 24%, var(--pastel-mix-base));
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.section-heading p,
.training-title p {
  max-width: 820px;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.65;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 22px;
}

.guide-card {
  border-radius: var(--radius-lg);
  padding: 22px;
}

.guide-card h3,
.active-rest-card h3,
.exercise-card h3 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.guide-card ul,
.active-rest-card ul,
.exercise-card ul,
.notes-list {
  margin: 14px 0 0;
  padding-left: 1.15rem;
  color: var(--muted);
  line-height: 1.55;
}

.training-section {
  --accent: #a3e4d7;
}

.training-section-header {
  display: grid;
  gap: 30px;
  scroll-margin-top: 100px;
}

.training-title {
  display: grid;
  gap: 10px;
  border-left: 12px solid var(--accent);
  padding-left: 20px;
}

.training-section.is-today-workout .training-title {
  border-radius: 24px;
  padding: 20px;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 42%, transparent);
}

.training-section.is-today-workout .training-title::before {
  content: "Allenamento di oggi";
  display: inline-flex;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: var(--primary-surface);
  color: var(--primary-text);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.training-title h2 {
  color: color-mix(in srgb, var(--accent) 64%, var(--text));
}

.training-hero-image {
  width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--image-bg);
  box-shadow: var(--shadow);
}

.workout-details {
  display: grid;
  gap: 32px;
  margin-top: 34px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 24px;
  align-items: start;
}

.exercise-table-wrap,
.notes-panel,
.calendar-table-wrap {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.exercise-table,
.calendar-table {
  width: 100%;
  border-collapse: collapse;
}

.exercise-table th,
.exercise-table td,
.calendar-table th,
.calendar-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.exercise-table th,
.calendar-table th {
  background: color-mix(in srgb, var(--accent, #a3e4d7) 38%, var(--pastel-mix-base));
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.exercise-table tr:last-child td,
.calendar-table tr:last-child td {
  border-bottom: 0;
}

.exercise-name {
  font-weight: 850;
}

.notes-panel {
  padding: 22px;
}

.notes-panel h3 {
  margin: 0 0 10px;
}

.notes-stack {
  display: grid;
  gap: 22px;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 26px;
}

.exercise-card {
  display: grid;
  gap: 14px;
  border-radius: 26px;
  padding: 20px;
  background: var(--surface-elevated);
  box-shadow: var(--shadow-soft);
}

.exercise-card img {
  width: 100%;
  height: 230px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--image-bg);
}

.exercise-card h3 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exercise-card h3::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border-radius: 999px;
  background: var(--accent);
}

.active-rest-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.active-rest-card {
  border-radius: var(--radius-lg);
  padding: 24px;
}

.calendar-tools {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.calendar-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.calendar-heading {
  max-width: 900px;
}

.calendar-priority-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 980px;
  margin-top: 8px;
}

.calendar-info-card {
  display: grid;
  gap: 8px;
  min-height: 132px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--border));
  border-radius: 22px;
  padding: 18px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 24%, transparent), transparent 70%),
    var(--surface-elevated);
  box-shadow: var(--shadow-soft);
}

.calendar-info-card strong {
  color: color-mix(in srgb, var(--accent) 54%, var(--text));
  font-size: clamp(1.12rem, 2vw, 1.45rem);
  line-height: 1.1;
}

.calendar-info-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.focus-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 38%, var(--pastel-mix-base));
  font-weight: 800;
  font-size: 0.86rem;
}

.focus-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--row-color) 44%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--row-color) 34%, var(--pastel-mix-base));
  color: var(--text);
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    transform 180ms ease;
}

.focus-link:hover,
.focus-link:focus-visible {
  border-color: color-mix(in srgb, var(--row-color) 72%, var(--border));
  background: color-mix(in srgb, var(--row-color) 48%, var(--pastel-mix-base));
  transform: translateY(-1px);
  outline: 0;
}

.calendar-table tr {
  background: color-mix(in srgb, var(--row-color) 42%, var(--pastel-mix-base));
}

.calendar-table tr.is-today {
  position: relative;
  outline: 2px solid color-mix(in srgb, var(--row-color) 76%, #ffffff);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--row-color) 70%, transparent);
}

.calendar-table td:first-child {
  font-weight: 850;
}

.calendar-table tr.is-today td:first-child::after {
  content: "Oggi";
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 10px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--primary-surface);
  color: var(--primary-text);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.calendar-table-wrap + .active-rest-block {
  margin-top: 58px;
}

.load-error {
  margin: 48px auto;
  max-width: 720px;
  border: 1px solid rgba(245, 183, 177, 0.8);
  border-radius: 18px;
  padding: 24px;
  background: color-mix(in srgb, #f5b7b1 24%, var(--surface));
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 920px) {
  .site-header {
    align-items: center;
  }

  .top-nav {
    justify-content: flex-end;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 48px 0 34px;
  }

  .detail-grid,
  .active-rest-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  body {
    padding-bottom: 132px;
  }

  main {
    width: min(100% - 24px, var(--max));
  }

  .site-header {
    padding: 12px;
    align-items: center;
    flex-wrap: wrap;
  }

  .brand-logo {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 13px;
  }

  .header-actions {
    margin-left: auto;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }

  .top-nav {
    order: 3;
    display: flex;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 2px;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .top-nav::-webkit-scrollbar {
    display: none;
  }

  .top-nav a {
    flex: 0 0 auto;
  }

  .top-nav a:hover,
  .top-nav a:focus-visible {
    transform: none;
  }

  .bottom-bar {
    bottom: max(12px, env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
    border-radius: 22px;
  }

  .bottom-bar-item {
    min-height: 50px;
    font-size: 0.93rem;
  }

  .hero h1 {
    font-size: clamp(2.55rem, 15vw, 4.2rem);
  }

  .hero-meta {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    border-radius: 24px;
    padding: 12px;
  }

  .today-list {
    max-height: none;
    overflow: visible;
  }

  .week-row {
    grid-template-columns: 98px minmax(0, 1fr);
  }

  .week-day {
    padding-left: 12px;
  }

  .week-focus {
    padding: 0 12px 0 10px;
  }

  .section-block,
  .training-section {
    padding: 58px 0;
  }

  .section-heading {
    margin-bottom: 28px;
  }

  .workout-details {
    gap: 28px;
    margin-top: 30px;
  }

  .detail-grid {
    gap: 22px;
  }

  .notes-stack {
    gap: 18px;
  }

  .exercise-table-wrap,
  .calendar-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .calendar-table-wrap + .active-rest-block {
    margin-top: 46px;
  }

  .calendar-priority-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .calendar-info-card {
    min-height: auto;
    padding: 16px;
  }

  .exercise-table,
  .calendar-table {
    display: block;
    min-width: 0;
  }

  .exercise-table thead,
  .calendar-table thead {
    display: none;
  }

  .exercise-table tbody,
  .calendar-table tbody {
    display: grid;
    gap: 12px;
  }

  .exercise-table tr,
  .calendar-table tr {
    display: grid;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 16px;
    background: var(--surface-elevated);
    box-shadow: var(--shadow-soft);
  }

  .calendar-table tr.is-today {
    outline-offset: 0;
  }

  .calendar-table tr.is-today td:first-child::after {
    grid-column: 2;
    width: fit-content;
    margin: 4px 0 0;
  }

  .calendar-table tr {
    border-left: 8px solid var(--row-color);
    background: color-mix(in srgb, var(--row-color) 20%, var(--surface));
  }

  .exercise-table td,
  .calendar-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 12px;
    align-items: baseline;
    border: 0;
    padding: 0;
  }

  .exercise-table td::before,
  .calendar-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 850;
    text-transform: uppercase;
  }

  .exercise-card {
    padding: 16px;
  }

  .exercise-card img {
    height: 190px;
    border-radius: 20px;
  }
}
