/* ===== RESET & BASE ===== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Cormorant+Garamond:wght@600;700&family=Rajdhani:wght@600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #cfd4dd;
  --primary-light: rgba(207,212,221,.15);
  --primary-dark: #a8b0bd;
  --accent: #f4f5f7;
  --accent-light: rgba(244,245,247,.12);
  --accent-dark: #cfd4dc;
  --orange: #d9dde5;
  --orange-light: rgba(217,221,229,.12);
  --bg: #0d0f14;
  --bg-elevated: #13161d;
  --bg-card: #1a1f28;
  --bg-card-hover: #232a35;
  --bg-input: #1f2530;
  --text: #f1f3f7;
  --text-light: #afb7c4;
  --text-muted: #8791a2;
  --border: rgba(255,255,255,.14);
  --border-light: rgba(255,255,255,.08);
  --danger: #ef4444;
  --danger-light: rgba(239,68,68,.12);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
  --shadow-md: 0 4px 24px rgba(0,0,0,.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.5);
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

html {
  background: var(--bg);
  min-height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
  position: relative;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body > * {
  position: relative;
  z-index: 1;
}

body::before,
body::after {
  content: '';
  position: fixed;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
  z-index: 0;
  opacity: .24;
}

body::before {
  top: -220px;
  right: -180px;
  background: radial-gradient(circle, rgba(244,245,247,.16) 0%, rgba(244,245,247,0) 68%);
  animation: floatOrbA 13s ease-in-out infinite;
}

body::after {
  bottom: -250px;
  left: -180px;
  background: radial-gradient(circle, rgba(194,200,212,.14) 0%, rgba(194,200,212,0) 68%);
  animation: floatOrbB 15s ease-in-out infinite;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes floatOrbA {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(-24px, 16px, 0) scale(1.08); }
}
@keyframes floatOrbB {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(24px, -20px, 0) scale(1.06); }
}
@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
@keyframes shimmer {
  from { transform: translateX(-160%); }
  to { transform: translateX(180%); }
}

.animate-in {
  animation: fadeInUp .5s var(--transition) both;
}

/* ===== NAV (TOP BAR) ===== */
nav {
  background: var(--bg-elevated);
  color: #fff;
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: max(1.5rem, env(safe-area-inset-right, 0px));
  padding-left: max(1.5rem, env(safe-area-inset-left, 0px));
  min-height: calc(88px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
nav .logo {
  font-family: 'Rajdhani', 'Inter', sans-serif;
  display: flex;
  align-items: center;
  gap: .8rem;
}
nav .logo-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(148,163,184,.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 0 20px rgba(255,255,255,.16);
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.16), rgba(255,255,255,.04));
}
nav .logo .logo-lockup {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
nav .logo .brand-mark {
  font-size: 1.36rem;
  font-weight: 700;
  letter-spacing: 1.1px;
  color: #f7f7f7;
}
nav .logo .brand-sub {
  font-family: 'Cormorant Garamond', serif;
  font-size: .95rem;
  color: var(--text-light);
  letter-spacing: .2px;
}
nav .logo-image {
  height: 72px;
  width: auto;
  display: block;
  filter: none;
}
nav .nav-links { display: flex; gap: .25rem; }
nav .nav-links a {
  color: var(--text-light);
  text-decoration: none;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .85rem;
  transition: all var(--transition);
}
nav .nav-links a:hover {
  color: var(--text);
  background: rgba(255,255,255,.05);
}
nav .nav-links a.active {
  color: var(--accent);
  background: var(--accent-light);
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  padding: .28rem .6rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  margin-left: .45rem;
  border: 1px solid transparent;
}

.sync-badge.sync-ready {
  color: #86efac;
  border-color: rgba(134,239,172,.45);
  background: rgba(22,163,74,.18);
}

.sync-badge.sync-syncing,
.sync-badge.sync-connecting {
  color: #fef08a;
  border-color: rgba(253,224,71,.45);
  background: rgba(202,138,4,.18);
}

.sync-badge.sync-error {
  color: #fca5a5;
  border-color: rgba(248,113,113,.45);
  background: rgba(185,28,28,.18);
}

.sync-badge.sync-local {
  color: #cbd5e1;
  border-color: rgba(148,163,184,.45);
  background: rgba(100,116,139,.2);
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 68px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  padding: 0 max(.5rem, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(.5rem, env(safe-area-inset-left, 0px));
}
.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: .68rem;
  font-weight: 600;
  padding: .35rem .75rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  min-width: 60px;
}
.bottom-nav a .nav-icon {
  font-size: 1.35rem;
  line-height: 1;
}
.bottom-nav a:hover,
.bottom-nav a.active {
  color: var(--accent);
}
.bottom-nav .fab-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 300;
  margin-top: -22px;
  box-shadow: 0 4px 20px rgba(255,255,255,.22);
  transition: all var(--transition);
  text-decoration: none;
  flex-direction: row;
}
.bottom-nav .fab-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(255,255,255,.3);
}

/* ===== LAYOUT ===== */
.container {
  max-width: 800px;
  margin: 1.5rem auto;
  padding: 0 max(1.25rem, env(safe-area-inset-right, 0px)) 0 max(1.25rem, env(safe-area-inset-left, 0px));
}

.app-copyright {
  margin: 1.5rem auto 0;
  padding: 0 max(1.25rem, env(safe-area-inset-right, 0px)) 1rem max(1.25rem, env(safe-area-inset-left, 0px));
  text-align: center;
  font-size: .76rem;
  color: var(--text-muted);
  letter-spacing: .2px;
}

h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  letter-spacing: -.75px;
  color: var(--text);
}
h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: .85rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
h2 .section-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
}
h2 .section-icon.purple { background: var(--primary-light); }
h2 .section-icon.green { background: var(--accent-light); }
h2 .section-icon.orange { background: var(--orange-light); }

/* ===== TILE GRID ===== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .85rem;
  margin-bottom: 1.75rem;
}
.tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  animation: fadeInUp .4s var(--transition) both;
  position: relative;
  overflow: hidden;
}
.tile::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(255,255,255,0), rgba(255,255,255,.22), rgba(255,255,255,0));
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.tile:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,.12);
  transform: translateY(-4px);
  box-shadow: 0 14px 26px rgba(0,0,0,.28);
}
.tile:hover::before {
  opacity: 1;
}
.tile:active { transform: scale(.97); }
.tile .tile-icon {
  font-size: 2rem;
  margin-bottom: .65rem;
  display: block;
  line-height: 1;
}
.tile .tile-label {
  font-weight: 600;
  font-size: .82rem;
  color: var(--text-light);
  line-height: 1.3;
}
.tile .tile-value {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: .15rem;
}
.tile .tile-value.purple { color: var(--primary); }
.tile .tile-value.green { color: var(--accent); }
.tile .tile-value.orange { color: var(--orange); }

/* ===== CARD ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  animation: fadeInUp .45s var(--transition) both;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255,255,255,.08), transparent 42%);
  pointer-events: none;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: rgba(255,255,255,.11);
}

/* ===== FORM ELEMENTS ===== */
label {
  display: block;
  font-weight: 600;
  margin-bottom: .35rem;
  font-size: .78rem;
  color: var(--text-light);
  letter-spacing: .3px;
  text-transform: uppercase;
}
input, select, textarea {
  width: 100%;
  padding: .7rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  transition: all var(--transition);
  font-family: inherit;
  background: var(--bg-input);
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(244,245,247,.14);
}
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}
select option {
  background: var(--bg-card);
  color: var(--text);
}
textarea { resize: vertical; min-height: 60px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.form-group { margin-bottom: 1rem; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(120deg, rgba(255,255,255,0), rgba(255,255,255,.24), rgba(255,255,255,0));
  transform: translateX(-160%);
  pointer-events: none;
}
.btn:hover::after {
  animation: shimmer .8s ease;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: #2a2f38;
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 2px 10px rgba(255,255,255,.16);
}
.btn-primary:hover {
  background: #353b45;
  box-shadow: 0 4px 20px rgba(255,255,255,.2);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(120deg, #f4f5f7, #d8dde6, #f4f5f7);
  background-size: 220% 220%;
  animation: gradientShift 6s ease infinite;
  color: #0b0f17;
  font-weight: 700;
  box-shadow: 0 2px 14px rgba(244,245,247,.18);
}
.btn-accent:hover {
  box-shadow: 0 6px 24px rgba(244,245,247,.22);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-outline {
  background: var(--bg-card);
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-light);
  padding: .5rem .75rem;
}
.btn-ghost:hover {
  background: rgba(255,255,255,.05);
  color: var(--text);
}

.btn-sm { padding: .38rem .8rem; font-size: .8rem; }
.btn-lg { padding: .8rem 1.6rem; font-size: .95rem; }

/* ===== EXERCISE ROW ===== */
.exercise-grid-wrap {
  overflow-x: auto;
  padding-bottom: .25rem;
}

.exercise-row {
  display: grid;
  grid-template-columns: 34px minmax(210px, 1.5fr) minmax(210px, 1.5fr) 82px 82px 100px 140px 42px;
  gap: .65rem;
  align-items: center;
  min-width: 940px;
  padding: .75rem .65rem;
  border-bottom: 1px solid rgba(255,255,255,.14);
  border-radius: var(--radius-xs);
  transition: background var(--transition);
  background: rgba(255,255,255,.02);
}
.exercise-row:hover {
  background: rgba(255,255,255,.06);
}
.exercise-row:last-child { border-bottom: none; }
.exercise-row .reorder-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.exercise-row .reorder-btns button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  width: 26px;
  height: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  color: var(--text-light);
  transition: all var(--transition);
  padding: 0;
}
.exercise-row .reorder-btns button:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}

.exercise-header {
  display: grid;
  grid-template-columns: 34px minmax(210px, 1.5fr) minmax(210px, 1.5fr) 82px 82px 100px 140px 42px;
  gap: .65rem;
  min-width: 940px;
  font-weight: 700;
  font-size: .72rem;
  color: #c2cad7;
  text-transform: uppercase;
  letter-spacing: .75px;
  padding: 0 .65rem .55rem;
  border-bottom: 2px solid rgba(255,255,255,.18);
}

.exercise-header span {
  white-space: nowrap;
}

.exercise-row > button.btn-danger {
  width: 42px;
  min-width: 42px;
  padding: .35rem 0;
  justify-self: center;
}

/* ===== DAY TABS ===== */
.day-tabs {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.day-tab {
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 600;
  font-size: .83rem;
  transition: all var(--transition);
  color: var(--text-light);
}
.day-tab:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.day-tab.active {
  background: var(--accent);
  color: #0a0a1a;
  border-color: transparent;
  box-shadow: 0 2px 10px rgba(255,255,255,.24);
  font-weight: 700;
}

/* ===== SCHEMA LIST ===== */
.schema-list { display: grid; gap: .65rem; }

.schema-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition);
  animation: fadeInUp .4s var(--transition) both;
  position: relative;
  overflow: hidden;
}
.schema-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--primary));
  opacity: .75;
}
.schema-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255,255,255,.1);
}
.schema-info h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: .25rem;
  letter-spacing: -.2px;
}
.schema-info p { color: var(--text-light); font-size: .83rem; line-height: 1.4; }
.schema-actions { display: flex; gap: .35rem; flex-shrink: 0; }

/* ===== CLIENT VIEW ===== */
.workout-day {
  margin-bottom: 1.75rem;
}
.workout-day h3 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: .75rem;
  padding-bottom: .55rem;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.workout-day h3::before {
  content: '';
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--primary));
}

/* ===== CLIENT CODE BOX ===== */
.code-box {
  background: var(--bg-card);
  color: #fff;
  padding: 2.5rem 1.75rem;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 1.75rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.code-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 50%, rgba(255,255,255,.1) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(220,220,220,.12) 0%, transparent 50%);
  pointer-events: none;
}
.code-box p { opacity: .75; font-size: .9rem; line-height: 1.5; position: relative; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-light);
  animation: fadeIn .5s ease;
}
.empty-state .icon {
  font-size: 3rem;
  margin-bottom: .85rem;
  filter: grayscale(.2);
}
.empty-state p { font-size: .9rem; max-width: 340px; margin: 0 auto; line-height: 1.5; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  padding: 1rem;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: slideDown .3s var(--transition);
}
.modal h2 { margin-bottom: 1.25rem; }
.modal-actions {
  display: flex;
  gap: .65rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ===== TEMPLATE CARDS ===== */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .85rem;
  margin-bottom: 1.25rem;
}
.template-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.template-card::before {
  content: '';
  position: absolute;
  width: 180px;
  height: 180px;
  right: -70px;
  top: -90px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.16), rgba(255,255,255,0) 70%);
  opacity: 0;
  transition: opacity .25s ease;
}
.template-card:hover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.template-card:hover::before {
  opacity: 1;
}
.template-card .template-icon {
  font-size: 1.8rem;
  margin-bottom: .65rem;
}
.template-card .template-name {
  font-weight: 700;
  font-size: .9rem;
  margin-bottom: .2rem;
}
.template-card .template-desc {
  font-size: .78rem;
  color: var(--text-light);
  line-height: 1.4;
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .18rem .6rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-primary { background: var(--primary-light); color: #e8e8e8; }
.badge-accent { background: var(--accent-light); color: #f3f3f3; }
.badge-orange { background: var(--orange-light); color: #e7e7e7; }
.badge-outline {
  background: rgba(255,255,255,.04);
  color: var(--text-light);
  border: 1px solid rgba(255,255,255,.18);
}

/* ===== STATS ROW ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .85rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  text-align: center;
  box-shadow: var(--shadow);
  animation: fadeInUp .4s var(--transition) both;
}
.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -1px;
}
.stat-card .stat-value.purple { color: var(--primary); }
.stat-card .stat-value.green { color: var(--accent); }
.stat-card .stat-value.orange { color: var(--orange); }
.stat-card .stat-label {
  font-size: .78rem;
  color: var(--text-light);
  margin-top: .15rem;
  font-weight: 500;
}

/* ===== DIVIDER ===== */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 1.75rem 0;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 1.2rem;
  right: 1.5rem;
  background: var(--bg-card);
  color: #fff;
  padding: .75rem 1.3rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .87rem;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: slideDown .3s var(--transition);
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 1px solid var(--border);
}
.toast .toast-action {
  border: 1px solid rgba(255,255,255,.42);
  background: rgba(0,0,0,.18);
  color: #fff;
  border-radius: 999px;
  padding: .22rem .62rem;
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
}
.toast .toast-action:hover {
  background: rgba(255,255,255,.22);
}
.toast.success { background: #059669; border-color: #059669; }
.toast.error { background: var(--danger); border-color: var(--danger); }
.toast.info { background: var(--primary); border-color: var(--primary); }

.ios-install-toast {
  right: 50%;
  bottom: calc(1.35rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(50%);
  max-width: min(92vw, 460px);
  padding: 0;
  border-radius: 18px;
  background: rgba(10,14,22,.98);
  border-color: rgba(255,255,255,.2);
  color: var(--text);
  box-shadow: 0 16px 34px rgba(0,0,0,.35);
  text-align: left;
  line-height: 1.45;
  overflow: hidden;
}

.ios-install-toast-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .82rem .88rem;
  background: linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.03));
}

.ios-install-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #f4f5f7;
  background: rgba(255,255,255,.06);
}

.ios-install-copy {
  font-size: .84rem;
  font-weight: 600;
  color: var(--text);
}

.ios-install-close {
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.08);
  color: var(--text);
  border-radius: 999px;
  padding: .34rem .7rem;
  font-size: .72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform var(--transition);
}

.ios-install-close:hover {
  background: rgba(255,255,255,.16);
  border-color: rgba(255,255,255,.32);
  transform: translateY(-1px);
}

@media (max-width: 768px) {
  .ios-install-toast {
    left: max(.85rem, env(safe-area-inset-left, 0px));
    right: max(.85rem, env(safe-area-inset-right, 0px));
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    transform: none;
    max-width: none;
    justify-content: center;
  }

  .ios-install-toast-card {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      'icon copy'
      'close close';
    gap: .55rem .7rem;
    padding: .8rem .82rem;
  }

  .ios-install-icon {
    grid-area: icon;
  }

  .ios-install-copy {
    grid-area: copy;
    font-size: .8rem;
  }

  .ios-install-close {
    grid-area: close;
    width: 100%;
    min-height: 36px;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  nav, .bottom-nav, .btn, .check-col { display: none !important; }
  body { background: #fff; color: #000; padding-bottom: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; background: #fff; }
  .container { max-width: 100%; margin: 0; padding: 1rem; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  body::before,
  body::after {
    width: 360px;
    height: 360px;
    opacity: .24;
  }

  nav {
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    min-height: calc(72px + env(safe-area-inset-top, 0px));
    height: auto;
  }
  nav .logo-image { height: 52px; }
  nav .logo { font-size: 1.15rem; }
  .container { padding: 0 .85rem; margin: 1rem auto; }
  h1 { font-size: 1.4rem; }

  .tile-grid { grid-template-columns: repeat(3, 1fr); gap: .65rem; }

  .schema-card {
    flex-direction: column;
    align-items: flex-start;
    gap: .65rem;
  }
  .schema-actions { width: 100%; }
  .schema-actions .btn { flex: 1; justify-content: center; }

  .exercise-row {
    gap: .55rem;
  }
  .exercise-header { display: none; }

  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .template-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .template-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .tile { padding: 1.1rem .75rem; }
  .tile .tile-icon { font-size: 1.6rem; }
}