:root {
  color-scheme: light dark;
  --bg: #f5f3ef;
  --panel: #ffffff;
  --panel-soft: #fbfaf7;
  --field: #ffffff;
  --image-bg: #f8f8f5;
  --ink: #202426;
  --muted: #6d7377;
  --line: #dedbd3;
  --accent: #1f7a68;
  --accent-soft: #dff1ed;
  --accent-ink: #145f50;
  --warn: #a8462d;
  --topbar-bg: rgba(245, 243, 239, 0.92);
  --overlay: rgba(32, 36, 38, 0.36);
  --hero-bg: #dff5f7;
  --glass: rgba(255, 255, 255, 0.92);
  --streak-bg: linear-gradient(180deg, #ffffff 0%, #eef8f5 100%);
  --shadow: 0 18px 45px rgba(37, 41, 44, 0.1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101413;
    --panel: #171d1b;
    --panel-soft: #1d2421;
    --field: #111614;
    --image-bg: #202825;
    --ink: #f1f5f2;
    --muted: #a4aea9;
    --line: #303a36;
    --accent: #54c7a9;
    --accent-soft: #153a33;
    --accent-ink: #bff4e8;
    --warn: #ff9a7f;
    --topbar-bg: rgba(16, 20, 19, 0.92);
    --overlay: rgba(0, 0, 0, 0.58);
    --hero-bg: #162825;
    --glass: rgba(23, 29, 27, 0.9);
    --streak-bg: linear-gradient(180deg, #171d1b 0%, #10231f 100%);
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

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

button,
input {
  font: inherit;
}

input {
  background: var(--field);
  color: var(--ink);
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ai-routine-pill {
  display: inline-flex;
  align-items: center;
  max-width: 160px;
  margin-left: 8px;
  padding: 3px 8px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1;
  text-transform: none;
  vertical-align: middle;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 2.1rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

.brand-wordmark {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h3 {
  margin-bottom: 4px;
  font-size: 1.25rem;
}

.muted,
.asset-name,
.instruction {
  color: var(--muted);
}

.panel-header,
.exercise-title-row,
.topbar,
.modal-header,
.sets-head,
.set-row {
  display: flex;
  align-items: center;
}

.panel-header,
.exercise-title-row,
.topbar,
.modal-header {
  justify-content: space-between;
  gap: 16px;
}

.icon-button,
.edit-exercise,
.edit-workout-session,
.remove-set {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-weight: 800;
}

.remove-set {
  color: var(--warn);
}

.edit-exercise {
  color: var(--accent);
}

.edit-exercise svg,
.edit-workout-session svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.edit-workout-session {
  color: var(--accent);
}

.search-wrap input {
  width: 100%;
  margin-top: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-top: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.search-mode-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.search-mode-button.active {
  background: var(--panel);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(20, 24, 26, 0.08);
}

.modal-results {
  display: grid;
  gap: 8px;
  max-height: min(54vh, 520px);
  margin-top: 12px;
  overflow: auto;
}

.search-result {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  text-align: left;
}

.search-result strong,
.search-result span {
  display: block;
}

.search-result span {
  color: var(--muted);
  font-size: 0.8rem;
}

main {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
  padding: 28px;
}

.back-button,
.nav-link-button,
.primary-button,
.open-routine,
.add-exercise-bottom {
  border-radius: 8px;
  font-weight: 800;
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  text-decoration: none;
}

.nav-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  line-height: 1;
  text-decoration: none;
}

.nav-sign-in {
  width: auto;
  min-width: 0;
  padding: 9px 14px;
  border: 1px solid rgba(31, 122, 104, 0.28);
  border-radius: 999px;
  background: var(--field);
  color: var(--accent);
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(37, 41, 44, 0.08);
}

.primary-button,
.open-routine,
.add-exercise-bottom {
  padding: 11px 14px;
  border: 0;
  background: var(--accent);
  color: #fff;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: -28px -28px 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
}

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

.loading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.skeleton-card {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent) -120% 0 / 70% 100% no-repeat,
    var(--panel);
  box-shadow: var(--shadow);
  animation: skeleton-sheen 1.4s ease-in-out infinite;
}

.skeleton-card.wide {
  grid-column: 1 / -1;
  min-height: min(42vh, 320px);
}

.skeleton-line,
.skeleton-button {
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--ink) 7%, transparent), transparent) -120% 0 / 70% 100% no-repeat,
    var(--panel-soft);
  animation: skeleton-sheen 1.4s ease-in-out infinite;
}

.skeleton-eyebrow {
  width: 86px;
  height: 13px;
  margin: 0 0 8px;
}

.skeleton-title {
  width: 140px;
  height: 24px;
  margin: 0;
}

.skeleton-button {
  width: 112px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.skeleton-button.primary {
  width: 148px;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, #fff 20%, transparent), transparent) -120% 0 / 70% 100% no-repeat,
    var(--accent-soft);
}

.auth-page {
  display: grid;
  gap: 22px;
  min-height: 62vh;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: 28px;
  min-height: min(620px, calc(100vh - 120px));
  align-items: center;
}

.hero-copy {
  display: grid;
  gap: 18px;
  align-content: center;
}

.hero-copy h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 5.8rem);
  line-height: 0.95;
}

.hero-copy p:not(.eyebrow) {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.hero-actions a {
  text-decoration: none;
}

.hero-actions span {
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-visual {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--hero-bg);
  box-shadow: var(--shadow);
}

.hero-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

.hero-data-card {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid rgba(222, 219, 211, 0.9);
  border-radius: 8px;
  background: var(--glass);
  backdrop-filter: blur(10px);
}

.hero-data-card.secondary {
  top: 16px;
  right: 16px;
  bottom: auto;
  left: auto;
  width: min(250px, calc(100% - 32px));
}

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

.hero-data-card span {
  color: var(--muted);
  font-size: 0.84rem;
}

.content-hero {
  display: grid;
  gap: 14px;
  max-width: 900px;
  padding: 40px 0 12px;
}

.content-hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.9rem);
  line-height: 0.98;
}

.content-hero p:not(.eyebrow) {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

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

.geo-card,
.faq-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.geo-card {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 190px;
  padding: 20px;
}

.geo-card h2,
.faq-section h2 {
  font-size: 1.35rem;
}

.geo-card p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.faq-section {
  display: grid;
  gap: 0;
  padding: 20px;
}

.faq-section > div {
  margin-bottom: 10px;
}

.faq-section details {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.faq-section details:last-child {
  padding-bottom: 0;
}

.faq-section summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 850;
}

.faq-section p {
  max-width: 780px;
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-card {
  display: grid;
  gap: 18px;
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sign-in-page {
  align-self: start;
  margin-top: min(12vh, 110px);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label,
.auth-form label span {
  display: grid;
  gap: 6px;
}

.auth-form label span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-form input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-form input[readonly] {
  background: var(--panel-soft);
  color: var(--muted);
}

.auth-message {
  margin: 0;
  color: var(--accent);
  font-weight: 750;
}

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

.summary-grid div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.summary-grid span {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
}

.summary-grid small {
  color: var(--muted);
}

.routine-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.workout-timer {
  min-width: 64px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  font-weight: 850;
  text-align: center;
}

.routine-summary-panel {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.routine-list {
  display: grid;
  gap: 18px;
}

.add-exercise-bottom {
  width: 100%;
  min-height: 56px;
  margin-top: 4px;
  font-size: 1rem;
}

.app-credit {
  padding: 24px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.app-credit a {
  color: inherit;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow-y: auto;
  background: var(--overlay);
}

.modal-overlay[hidden] {
  display: none;
}

.exercise-modal,
.edit-modal,
.ai-modal {
  display: grid;
  width: min(720px, 100%);
  max-height: min(760px, calc(100dvh - max(36px, env(safe-area-inset-top) + env(safe-area-inset-bottom) + 36px)));
  margin: 0 auto;
  padding: 18px;
  overflow: hidden;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(20, 24, 26, 0.28);
}

.exercise-modal {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.edit-modal,
.ai-modal {
  grid-template-rows: auto minmax(0, 1fr);
}

.exercise-modal > :last-child,
.edit-modal > :last-child,
.ai-modal > :last-child {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 2px;
}

.edit-modal {
  width: min(460px, 100%);
}

.ai-modal {
  width: min(620px, 100%);
}

.ai-modal-body {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.ai-mode-toggle,
.ai-access-copy,
.secret-box,
.connection-box,
.token-list,
.token-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.ai-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--panel-soft);
}

.ai-mode-toggle button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}

.ai-mode-toggle button.active {
  background: var(--field);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(20, 24, 26, 0.08);
}

.ai-access-copy {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.ai-access-copy p {
  margin-bottom: 0;
}

.ai-access-copy .primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ai-token-name-field {
  display: grid;
  gap: 5px;
}

.ai-token-name-field span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-token-name-field small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: none;
}

.ai-token-name-field input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.secret-box {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.secret-box textarea {
  width: 100%;
  min-height: 68px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font: 0.82rem ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  resize: vertical;
}

.connection-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  padding: 12px;
}

.connection-box div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.connection-box span,
.token-row small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.connection-box code {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.82rem;
}

.token-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.token-list-header,
.token-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.token-list-header span {
  display: grid;
  min-width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 900;
}

.token-row {
  padding: 10px;
  background: var(--panel-soft);
}

.token-row > div:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.token-row small {
  overflow-wrap: anywhere;
  text-transform: none;
}

.token-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.rename-ai-token,
.revoke-ai-token {
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  font-weight: 800;
}

.rename-ai-token {
  border: 1px solid var(--line);
  color: var(--accent);
}

.revoke-ai-token {
  border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line));
  color: var(--warn);
}

.edit-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.edit-action {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  text-align: left;
}

.edit-action strong,
.edit-action span {
  display: block;
}

.edit-action span {
  color: var(--muted);
  font-size: 0.86rem;
}

.edit-action.danger strong {
  color: var(--warn);
}

.workouts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.calendar-panel {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: minmax(0, 2fr) minmax(190px, 1fr);
  gap: 16px;
  align-items: stretch;
  height: min(42vh, 360px);
  min-height: 300px;
}

.calendar-card,
.streak-counter {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.calendar-card {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: 14px;
  overflow: hidden;
}

.calendar-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.view-history-button {
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 850;
}

.streak-counter {
  position: relative;
  display: grid;
  gap: 7px;
  place-items: center;
  border: 1px solid var(--line);
  min-height: 0;
  padding: 14px;
  border: 1px solid rgba(31, 122, 104, 0.22);
  background: var(--streak-bg);
  color: var(--accent-ink);
  text-align: center;
}

.streak-counter strong {
  font-size: 2.1rem;
  line-height: 1;
}

.streak-counter span {
  font-size: 0.9rem;
  font-weight: 800;
}

.streak-flame {
  position: relative;
  width: 48px;
  height: 58px;
  animation: flame-float 1.8s ease-in-out infinite;
}

.streak-flame::before,
.streak-flame::after,
.streak-flame span {
  position: absolute;
  content: "";
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  border-radius: 70% 70% 58% 58% / 86% 86% 46% 46%;
  clip-path: polygon(50% 0%, 72% 22%, 90% 51%, 82% 78%, 62% 100%, 38% 100%, 18% 78%, 10% 51%, 28% 22%);
}

.streak-flame::before {
  width: 38px;
  height: 48px;
  background: linear-gradient(135deg, #ff4d2d 0%, #ff9a31 62%, #ffd36a 100%);
  box-shadow: 0 10px 28px rgba(255, 114, 43, 0.34);
  animation: flame-pulse 1.25s ease-in-out infinite;
}

.streak-flame::after {
  bottom: 8px;
  width: 25px;
  height: 33px;
  background: linear-gradient(135deg, #ffd967 0%, #fff1b2 100%);
  animation: flame-pulse 1.25s ease-in-out -0.15s infinite;
}

.streak-flame span {
  bottom: 16px;
  width: 11px;
  height: 17px;
  background: #fff8cf;
  opacity: 0.85;
}

.calendar-weekdays,
.calendar-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekdays {
  display: grid;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
}

.calendar-grid {
  display: grid;
}

.calendar-day {
  position: relative;
  display: grid;
  height: clamp(44px, 6.2vh, 62px);
  min-height: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-weight: 850;
  text-decoration: none;
}

.calendar-day.trained {
  border-color: rgba(31, 122, 104, 0.3);
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.calendar-day > span:first-child {
  position: relative;
  z-index: 1;
}

.calendar-day.trained > span:first-child {
  color: var(--ink);
  text-shadow: 0 1px 2px var(--field);
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px rgba(31, 122, 104, 0.42);
}

.calendar-day.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.calendar-day i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 32px;
  height: 38px;
  opacity: 0.92;
  transform: translate(-50%, -48%);
}

.calendar-day i::before,
.calendar-day i::after,
.calendar-day i span {
  position: absolute;
  content: "";
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  border-radius: 70% 70% 58% 58% / 86% 86% 46% 46%;
  clip-path: polygon(50% 0%, 72% 22%, 90% 51%, 82% 78%, 62% 100%, 38% 100%, 18% 78%, 10% 51%, 28% 22%);
}

.calendar-day i::before {
  width: 26px;
  height: 32px;
  background: #ff7a2f;
}

.calendar-day i::after {
  bottom: 5px;
  width: 17px;
  height: 22px;
  background: #ffd766;
}

.calendar-day i span {
  bottom: 10px;
  width: 7px;
  height: 10px;
  background: #fff4b7;
}

.day-detail-page {
  display: grid;
  gap: 16px;
}

.day-detail-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.day-detail-card h3 {
  margin-bottom: 0;
}

.day-detail-list {
  display: grid;
  gap: 12px;
}

.day-detail-list article {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.day-detail-workout-header,
.day-edit-exercise-header,
.day-edit-set {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.day-detail-workout-header > div {
  display: grid;
  gap: 2px;
}

.day-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.day-detail-actions[hidden] {
  display: none;
}

.day-detail-list small {
  color: var(--muted);
}

.save-workout-edit,
.add-logged-set,
.delete-workout-session {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.save-workout-edit,
.add-logged-set {
  background: var(--accent);
  color: #fff;
}

.save-workout-edit {
  padding: 8px 10px;
}

.delete-workout-session {
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line));
  background: transparent;
  color: var(--warn);
}

.save-workout-edit:disabled,
.delete-workout-session:disabled {
  opacity: 0.62;
}

.day-edit-exercises,
.day-edit-exercise,
.day-edit-sets {
  display: grid;
  gap: 10px;
}

.day-edit-exercise {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.day-edit-head,
.day-edit-set {
  display: grid;
  grid-template-columns: 36px minmax(82px, 1fr) minmax(82px, 1fr) 32px;
  gap: 8px;
  align-items: center;
}

.day-edit-head {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.day-edit-set > span {
  font-weight: 850;
}

.day-edit-set input {
  min-width: 0;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.day-edit-set input:disabled {
  opacity: 1;
  color: var(--ink);
  background: transparent;
}

.remove-logged-set {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--warn);
  font-weight: 900;
}

.day-detail-workout:not(.editing) .remove-logged-set,
.day-detail-workout:not(.editing) .add-logged-set {
  display: none;
}

.add-logged-set {
  width: max-content;
  padding: 8px 10px;
}

@keyframes flame-float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes flame-pulse {
  0%, 100% {
    transform: translateX(-50%) scale(1);
  }
  50% {
    transform: translateX(-50%) scale(1.07, 0.96);
  }
}

@keyframes skeleton-sheen {
  0% {
    background-position: -120% 0, 0 0;
  }
  100% {
    background-position: 220% 0, 0 0;
  }
}

.workout-card {
  display: grid;
  gap: 16px;
  min-height: 260px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.workout-card h3 {
  font-size: 1.35rem;
}

.workout-preview {
  display: flex;
  min-height: 86px;
  align-items: center;
}

.workout-preview img {
  width: 64px;
  height: 64px;
  margin-right: -10px;
  border: 2px solid var(--panel);
  border-radius: 50%;
  background: var(--image-bg);
  object-fit: contain;
}

.exercise-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.exercise-media {
  display: grid;
  min-height: 180px;
  max-height: 210px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--image-bg);
}

.exercise-media img {
  width: 100%;
  height: auto;
  max-height: 190px;
  object-fit: contain;
}

.asset-name {
  margin-bottom: 0;
  font-size: 0.86rem;
}

.muscle-dropdown {
  margin: 12px 0;
}

.muscle-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.muscle-details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
  list-style: none;
}

.muscle-details summary::-webkit-details-marker {
  display: none;
}

.muscle-details summary::after {
  content: "⌄";
  color: var(--muted);
  font-size: 1.05rem;
}

.muscle-details[open] summary::after {
  transform: rotate(180deg);
}

.muscle-details summary strong {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.78rem;
}

.muscle-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  padding: 0 10px 10px;
}

.muscle-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.muscle-thumb {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--image-bg);
}

.muscle-thumb img {
  width: 92%;
  height: 92%;
  object-fit: contain;
}

.muscle-row strong,
.muscle-row small {
  display: block;
}

.muscle-row strong {
  overflow: hidden;
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.muscle-row code {
  color: var(--muted);
  font-family: inherit;
  font-size: 0.76em;
  font-weight: 700;
}

.muscle-row small {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: capitalize;
}

.instruction {
  margin-bottom: 16px;
  line-height: 1.45;
}

.sets {
  min-width: 0;
  overflow-x: auto;
}

.sets-head,
.set-row {
  display: grid;
  grid-template-columns: 42px 52px 92px minmax(82px, 1fr) minmax(82px, 1fr) 38px;
  gap: 10px;
  min-width: 590px;
  align-items: center;
}

.sets-head > *,
.set-row > * {
  min-width: 0;
}

.sets-head {
  padding: 0 0 8px;
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
}

.set-row {
  padding: 7px 0;
  border-top: 1px solid var(--line);
}

.set-index {
  font-weight: 800;
}

.prev-button {
  padding: 8px 10px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 800;
  white-space: normal;
  overflow-wrap: anywhere;
}

.prev-button:disabled {
  color: var(--muted);
  border-color: var(--line);
  background: var(--field);
  cursor: default;
}

.set-done {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: #fff;
  font-weight: 900;
}

.set-done.checked {
  border-color: var(--accent);
  background: var(--accent);
}

.set-done:disabled {
  cursor: default;
  opacity: 0.45;
}

.set-row input {
  min-width: 0;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.add-set {
  margin-top: 12px;
  padding: 10px 13px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.status {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

  .calendar-panel {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    max-height: none;
  }

  .streak-counter {
    grid-template-columns: auto 1fr;
    column-gap: 16px;
    min-height: 86px;
    justify-items: start;
  }

  .streak-flame {
    grid-row: span 2;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions button {
    flex: 1;
  }

  .auth-mode .topbar-actions {
    width: auto;
    margin-left: auto;
  }

  .auth-mode .topbar-actions button {
    flex: none;
  }

  .auth-page {
    min-height: 68vh;
  }

  .auth-card {
    padding: 16px;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    gap: 16px;
    min-height: auto;
  }

  .hero-copy {
    gap: 12px;
  }

  .hero-copy h1 {
    font-size: 2.8rem;
  }

  .hero-copy p:not(.eyebrow) {
    font-size: 0.98rem;
  }

  .hero-visual {
    min-height: 290px;
  }

  .hero-data-card {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }

  .hero-data-card.secondary {
    top: 10px;
    right: 10px;
  }

  .content-hero {
    padding-top: 22px;
  }

  .content-hero h1 {
    font-size: 2.65rem;
  }

  .content-hero p:not(.eyebrow) {
    font-size: 0.98rem;
  }

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

  .geo-card {
    min-height: 0;
    padding: 16px;
  }

  .faq-section {
    padding: 16px;
  }

  .exercise-card {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .exercise-media {
    aspect-ratio: 16 / 10;
    min-height: 0;
    max-height: 260px;
  }

  .exercise-media img {
    max-height: 240px;
  }
}

@media (max-width: 560px) {
  main {
    padding: 12px;
  }

  .topbar {
    margin: -12px -12px 12px;
    padding: 14px 12px;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .auth-mode .topbar {
    align-items: center;
    flex-direction: row;
  }

  .auth-mode .topbar-actions {
    width: auto;
    margin-left: auto;
  }

  .auth-mode .topbar-actions button {
    flex: none;
    white-space: nowrap;
  }

  .modal-overlay {
    padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
  }

  .exercise-modal,
  .edit-modal,
  .ai-modal {
    max-height: calc(100dvh - max(28px, env(safe-area-inset-top) + env(safe-area-inset-bottom) + 28px));
    padding: 14px;
  }

  .secret-box textarea {
    min-height: 58px;
  }

  .connection-box {
    grid-template-columns: 1fr;
  }

  .connection-box .back-button {
    width: max-content;
  }

  .token-row {
    align-items: flex-start;
  }

  .summary-grid {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .summary-grid div {
    padding: 8px;
  }

  .summary-grid span {
    font-size: 0.98rem;
  }

  .workouts-grid {
    grid-template-columns: 1fr;
  }

  .calendar-panel {
    gap: 10px;
  }

  .calendar-card {
    overflow: visible;
  }

  .calendar-card {
    gap: 9px;
    padding: 14px;
    background: var(--panel);
    color: var(--ink);
  }

  .calendar-card .eyebrow {
    color: var(--accent);
  }

  .calendar-card h3 {
    color: var(--ink);
  }

  .view-history-button {
    color: var(--accent);
  }

  .calendar-weekdays,
  .calendar-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
  }

  .calendar-weekdays span {
    color: var(--muted);
  }

  .calendar-day {
    height: clamp(42px, 11vw, 48px);
    min-height: 0;
    border-color: var(--line);
    background: var(--field);
    color: var(--ink);
  }

  .calendar-day.trained {
    border-color: var(--line);
    background: var(--accent-soft);
  }

  .calendar-day.today {
    box-shadow: inset 0 0 0 2px var(--accent);
  }

  .calendar-day.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
  }

  .streak-counter {
    grid-template-columns: auto 1fr;
    column-gap: 16px;
    min-height: 88px;
    justify-items: start;
    padding: 14px;
  }

  .streak-flame {
    grid-row: span 2;
    width: 42px;
    height: 52px;
  }

  .streak-counter strong {
    font-size: 1.75rem;
  }

  .routine-list {
    gap: 12px;
  }

  .exercise-card {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 10px 12px;
    padding: 10px;
  }

  .exercise-media {
    width: 88px;
    min-height: 88px;
    max-height: 88px;
    aspect-ratio: 1;
  }

  .exercise-media img {
    max-height: 86px;
  }

  .exercise-body {
    display: contents;
  }

  .exercise-title-row {
    align-self: center;
    gap: 8px;
  }

  .exercise-title-row h3 {
    font-size: 1.08rem;
    line-height: 1.15;
  }

  .asset-name {
    display: none;
  }

  .edit-exercise {
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
  }

  .muscle-dropdown,
  .instruction,
  .sets,
  .add-set {
    grid-column: 1 / -1;
  }

  .muscle-dropdown {
    margin: 0;
  }

  .muscle-details summary {
    min-height: 36px;
    padding: 0 10px;
    font-size: 0.86rem;
  }

  .muscle-list {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 0 8px 8px;
  }

  .muscle-row {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 7px;
    padding: 6px;
  }

  .muscle-thumb {
    width: 34px;
    height: 34px;
  }

  .muscle-row strong {
    font-size: 0.76rem;
  }

  .muscle-row code {
    display: block;
    margin-top: 1px;
  }

  .muscle-row small {
    font-size: 0.64rem;
  }

  .instruction {
    display: none;
  }

  .sets {
    overflow-x: visible;
  }

  .sets-head,
  .set-row {
    grid-template-columns: 22px 30px 58px minmax(42px, 1fr) minmax(42px, 1fr) 26px;
    gap: 6px;
    min-width: 0;
  }

  .sets-head {
    font-size: 0.62rem;
  }

  .set-row {
    padding: 5px 0;
  }

  .prev-button {
    padding: 6px 4px;
    font-size: 0.72rem;
  }

  .set-row input {
    padding: 7px 6px;
    font-size: 0.84rem;
  }

  .remove-set {
    width: 26px;
    height: 26px;
  }

  .set-done {
    width: 26px;
    height: 26px;
  }

  .add-set {
    width: max-content;
    margin-top: 2px;
    padding: 8px 10px;
    font-size: 0.86rem;
  }

  .day-detail-card {
    padding: 14px;
  }

  .day-detail-workout-header {
    align-items: center;
  }

  .day-detail-actions {
    width: 100%;
    justify-content: stretch;
  }

  .save-workout-edit,
  .delete-workout-session {
    flex: 1;
    padding: 7px 9px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .day-edit-exercise {
    padding: 10px;
  }

  .day-edit-head,
  .day-edit-set {
    grid-template-columns: 24px minmax(58px, 1fr) minmax(58px, 1fr) 28px;
    gap: 6px;
  }

  .day-edit-head {
    font-size: 0.64rem;
  }

  .day-edit-set input {
    padding: 7px 6px;
    font-size: 0.84rem;
  }

  .remove-logged-set {
    width: 26px;
    height: 26px;
  }

  .add-logged-set {
    padding: 7px 9px;
    font-size: 0.82rem;
  }
}
