:root {
  --bg-primary: #060a13;
  --bg-secondary: #0d1321;
  --bg-card: #111827;
  --bg-card-hover: #1a2332;
  --bg-elevated: #1f2937;
  --accent: #00d4aa;
  --accent-glow: rgba(0, 212, 170, 0.15);
  --accent-dim: rgba(0, 212, 170, 0.08);
  --accent-bright: #00f5c4;
  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --info: #3b82f6;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(0, 212, 170, 0.2);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font: 'Outfit', -apple-system, sans-serif;
  --mono: 'JetBrains Mono', monospace;
  --nav-height: 72px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

/* Mobile Polish */
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
[contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* Eliminate 300ms tap delay */
a,
button,
.btn,
.nav-item,
.exercise-card,
.template-card {
  touch-action: manipulation;
}

/* Light Mode */
[data-theme="light"] {
  --bg-primary: #f5f7fa;
  --bg-secondary: #edf0f5;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f2f5;
  --bg-elevated: #e8ecf1;
  --accent: #00b894;
  --accent-glow: rgba(0, 184, 148, 0.12);
  --accent-dim: rgba(0, 184, 148, 0.06);
  --accent-bright: #00d4aa;
  --text-primary: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --danger: #e53e3e;
  --warning: #dd6b20;
  --success: #38a169;
  --info: #3182ce;
  --border: rgba(0, 0, 0, 0.08);
  --border-accent: rgba(0, 184, 148, 0.25);
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .topbar {
  background: rgba(245, 247, 250, 0.92);
}

[data-theme="light"] .bottomnav {
  background: rgba(245, 247, 250, 0.95);
}

[data-theme="light"] .toast-success {
  background: #f0fff4;
  color: #276749;
  border-color: #38a169;
}

[data-theme="light"] .toast-error {
  background: #fff5f5;
  color: #9b2c2c;
  border-color: #e53e3e;
}

[data-theme="light"] .toast-info {
  background: #ebf8ff;
  color: #2a4365;
  border-color: #3182ce;
}

[data-theme="light"] .modal {
  background: var(--bg-card);
}

[data-theme="light"] .set-check.done {
  color: #fff;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 4px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* Loading */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
  transition: opacity 0.5s, visibility 0.5s;
}

.loading-screen.hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-logo {
  font-size: 64px;
  animation: pulse-glow 2s ease-in-out infinite;
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar::after {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  animation: loading-slide 1.2s ease-in-out infinite;
}

@keyframes loading-slide {
  0% {
    transform: translateX(-100%)
  }

  100% {
    transform: translateX(350%)
  }
}

@keyframes pulse-glow {

  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 20px var(--accent-glow))
  }

  50% {
    transform: scale(1.1);
    filter: drop-shadow(0 0 40px var(--accent))
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px)
  }

  to {
    opacity: 1;
    transform: translateX(0)
  }
}

/* Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 10, 19, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + var(--safe-top)) 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-brand {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--bg-card);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  position: relative;
}

.topbar-btn:hover {
  background: var(--bg-elevated);
  color: var(--accent);
}

.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #0a7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--bg-primary);
  cursor: pointer;
}

/* Page */
.page {
  flex: 1;
  padding: 20px 20px calc(var(--nav-height) + var(--safe-bottom) + 20px);
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  animation: fadeUp 0.3s ease-out;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 20px;
}

/* Bottom Nav */
.bottomnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(6, 10, 19, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.25s;
  color: var(--text-muted);
  border: none;
  background: none;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: var(--accent);
}

.nav-item.active .nav-icon {
  background: var(--accent-glow);
  box-shadow: 0 0 20px var(--accent-glow);
}

.nav-icon {
  width: 42px;
  height: 32px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.25s;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 64px;
  text-align: center;
}

.bottomnav.hidden {
  display: none !important;
}

.input[type="date"] {
  max-width: 100%;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
}

.card:hover {
  border-color: var(--border-accent);
}

.card-glow {
  border-color: var(--border-accent);
  box-shadow: 0 0 30px var(--accent-dim);
}

/* Section */
.section {
  margin-bottom: 28px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-link {
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: var(--font);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #00b894);
  color: var(--bg-primary);
  box-shadow: 0 4px 16px rgba(0, 212, 170, 0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 212, 170, 0.4);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-xs);
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Inputs */
.input-group {
  margin-bottom: 16px;
}

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  transition: all 0.2s;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  cursor: pointer;
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

.input:disabled,
select.input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: var(--bg-elevated);
  border-style: dashed;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 80vh;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.3);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.bottom-sheet.open {
  transform: translateY(0);
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
  margin: 10px auto;
  opacity: 0.4;
}

.bottom-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Exercise Card */
.exercise-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.exercise-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
}

.ex-gif {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-xs);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
}

.ex-gif img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ex-info {
  flex: 1;
  min-width: 0;
}

.ex-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ex-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.ex-muscle {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ex-actions {
  display: flex;
  gap: 6px;
}

/* Chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.chip.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--border-accent);
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Builder Canvas */
.builder-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.builder-sidebar {
  max-height: 60vh;
  overflow-y: auto;
}

.builder-canvas {
  min-height: 300px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-secondary);
  transition: all 0.2s;
}

.builder-canvas.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.builder-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  color: var(--text-muted);
  gap: 12px;
}

.builder-empty-icon {
  font-size: 48px;
  opacity: 0.3;
}

.builder-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: fadeUp 0.2s ease-out;
}

.builder-item.dragging {
  opacity: 0.4;
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
  flex-shrink: 0;
  font-size: 14px;
}

.bi-gif {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}

.bi-gif img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bi-info {
  flex: 1;
  min-width: 0;
}

.bi-name {
  font-weight: 600;
  font-size: 13px;
}

.bi-config {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.bi-config input {
  width: 46px;
  padding: 4px 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

.bi-config input:focus {
  border-color: var(--accent);
  outline: none;
}

.bi-config span {
  font-size: 10px;
  color: var(--text-muted);
}

.bi-remove {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
}

/* Session */
.session-timer {
  text-align: center;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.timer-value {
  font-size: 48px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--accent);
}

.session-exercise {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.se-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}

.se-gif {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.se-gif img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.se-name {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
}

.se-toggle {
  color: var(--text-muted);
  transition: transform 0.2s;
}

.se-toggle.open {
  transform: rotate(180deg);
}

.se-body {
  padding: 0 16px 16px;
}

.set-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr 1fr 44px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.set-row:last-child {
  border-bottom: none;
}

.set-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.set-input {
  padding: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-family: var(--mono);
  font-size: 14px;
  text-align: center;
  width: 100%;
}

.set-input:focus {
  border-color: var(--accent);
  outline: none;
}

.set-check {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 16px;
  color: transparent;
}

.set-check.done {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-primary);
}

.set-header {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

.modal {
  background: var(--bg-secondary);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
  padding: 24px;
}

@keyframes slideUp {
  from {
    transform: translateY(100%)
  }

  to {
    transform: translateY(0)
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Auth Pages */
.auth-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-primary);
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  font-size: 56px;
  margin-bottom: 12px;
  display: block;
}

.auth-logo-text {
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 24px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  transition: all 0.2s;
  border: none;
  background: none;
  font-family: var(--font);
}

.auth-tab.active {
  background: var(--accent);
  color: var(--bg-primary);
}

.verification-code {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 24px 0;
}

.verification-code input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  font-family: var(--mono);
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
}

.verification-code input:focus {
  border-color: var(--accent);
  outline: none;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  animation: slideIn 0.3s ease-out;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast-success {
  background: #065f46;
  color: #6ee7b7;
  border: 1px solid #10b981;
}

.toast-error {
  background: #7f1d1d;
  color: #fca5a5;
  border: 1px solid #ef4444;
}

.toast-info {
  background: #1e3a5f;
  color: #93c5fd;
  border: 1px solid #3b82f6;
}

/* Template Card */
.template-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.template-card:hover {
  border-color: var(--border-accent);
}

.tc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.tc-name {
  font-weight: 700;
  font-size: 16px;
}

.tc-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.tc-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Profile */
.profile-header {
  text-align: center;
  padding: 24px 0;
}

.profile-avatar {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), #0a7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 800;
  color: var(--bg-primary);
}

.profile-name {
  font-size: 22px;
  font-weight: 700;
}

.profile-role {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  margin-top: 4px;
}

.profile-stat {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 16px;
}

.profile-stat div {
  text-align: center;
}

.profile-stat .ps-val {
  font-size: 20px;
  font-weight: 800;
  font-family: var(--mono);
}

.profile-stat .ps-label {
  font-size: 11px;
  color: var(--text-muted);
}

/* Admin */
.admin-card {
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.user-row:last-child {
  border-bottom: none;
}

.user-row .ur-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-row .ur-info {
  flex: 1;
}

.user-row .ur-name {
  font-weight: 600;
  font-size: 14px;
}

.user-row .ur-email {
  font-size: 12px;
  color: var(--text-muted);
}

.role-select {
  padding: 6px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 12px;
  font-family: var(--font);
}

/* Color picker */
.color-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-option {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.color-option.active {
  border-color: white;
  transform: scale(1.1);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-text {
  font-size: 15px;
  margin-bottom: 20px;
}

/* Tab bar */
.tabs {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
}

.tab {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  text-align: center;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  border: none;
  background: none;
  font-family: var(--font);
  transition: all 0.2s;
}

.tab.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

/* Responsive */
@media (max-width:640px) {
  .builder-area {
    grid-template-columns: 1fr;
  }

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

  .stat-value {
    font-size: 22px;
  }

  .page {
    padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 16px);
  }

  .set-row {
    grid-template-columns: 32px 1fr 1fr 1fr 36px;
    gap: 4px;
  }
}

@media (min-width:641px) {
  .modal {
    border-radius: var(--radius);
    margin-bottom: 40px;
  }

  .modal-overlay {
    align-items: center;
  }
}

/* Misc */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-12 {
  margin-bottom: 12px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.mt-16 {
  margin-top: 16px;
}

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

.text-muted {
  color: var(--text-muted);
}

.text-accent {
  color: var(--accent);
}

.text-sm {
  font-size: 13px;
}

.font-bold {
  font-weight: 700;
}

.hidden {
  display: none !important;
}

/* Theme Toggle */
.theme-switch {
  position: relative;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.theme-switch input {
  display: none;
}

.theme-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.3s;
}

.theme-slider::before {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  left: 3px;
  top: 2px;
  background: var(--accent);
  border-radius: 50%;
  transition: all 0.3s;
}

.theme-switch input:checked+.theme-slider::before {
  transform: translateX(23px);
}

/* Settings */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.settings-section h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 14px;
  font-weight: 500;
}

.setting-sublabel {
  font-size: 12px;
  color: var(--text-muted);
}

/* Avatar */
.topbar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.profile-avatar {
  position: relative;
  overflow: hidden;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload-btn {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg-primary);
  border: 2px solid var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

/* Exercise Detail Modal */
.ex-detail-header {
  text-align: center;
  margin-bottom: 20px;
}

.ex-detail-gif {
  width: 100%;
  max-width: 280px;
  height: 200px;
  margin: 0 auto 16px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ex-detail-gif img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ex-detail-gif .no-gif {
  font-size: 64px;
  opacity: 0.3;
}

.ex-detail-name {
  font-size: 22px;
  font-weight: 800;
}

.ex-detail-badges {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.ex-detail-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.ex-detail-section {
  margin-top: 20px;
}

.ex-detail-section h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.ex-detail-section p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.ex-detail-video {
  width: 100%;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* ====== SET COMPLETION EXPLOSION ====== */
.set-pop {
  position: relative;
}

.set-pop .particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  pointer-events: none;
  animation: particleBurst 0.6s ease-out forwards;
}

@keyframes particleBurst {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(var(--px), var(--py)) scale(0);
  }
}

.set-check.done {
  animation: setDone 0.4s ease;
}

@keyframes setDone {
  0% {
    transform: scale(1);
  }

  30% {
    transform: scale(1.5);
  }

  60% {
    transform: scale(0.9);
  }

  100% {
    transform: scale(1);
  }
}

.exercise-complete-flash {
  position: fixed;
  inset: 0;
  background: var(--accent);
  opacity: 0;
  z-index: 999;
  animation: exFlash 0.5s ease-out forwards;
  pointer-events: none;
}

@keyframes exFlash {
  0% {
    opacity: 0.3;
  }

  100% {
    opacity: 0;
  }
}

/* Celebration overlay */
.celebration-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  animation: confettiFall 1.5s ease-in forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

/* Countdown overlay */
.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.countdown-number {
  font-size: 120px;
  font-weight: 900;
  color: var(--accent);
  animation: countPulse 0.8s ease;
  text-shadow: 0 0 40px var(--accent-glow);
}

@keyframes countPulse {
  0% {
    transform: scale(2);
    opacity: 0;
  }

  50% {
    transform: scale(1);
    opacity: 1;
  }

  90% {
    transform: scale(1.1);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 0.8;
  }
}

.countdown-label {
  color: var(--text-muted);
  font-size: 16px;
  margin-top: 12px;
  font-weight: 600;
}

/* ====== MOOD TRACKER ====== */
.mood-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(6, 10, 19, 0.97);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

[data-theme="light"] .mood-overlay {
  background: rgba(245, 247, 250, 0.97);
}

.mood-label {
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.mood-title {
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  line-height: 1.3;
  margin-bottom: 40px;
}

.mood-blob {
  width: 160px;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  position: relative;
}

.mood-blob-bg {
  position: absolute;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  filter: blur(25px);
  opacity: 0.5;
  transition: background 0.5s;
}

.mood-face {
  font-size: 80px;
  z-index: 1;
  transition: all 0.3s;
  animation: blobFloat 3s ease-in-out infinite;
}

@keyframes blobFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

.mood-value-text {
  font-size: 22px;
  font-weight: 700;
  margin-top: 16px;
  margin-bottom: 40px;
  transition: all 0.3s;
  min-height: 32px;
}

.mood-slider-wrap {
  width: 100%;
  max-width: 340px;
}

.mood-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  outline: none;
}

.mood-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 0 12px var(--accent-glow);
}

.mood-range-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.mood-range-labels span {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
}

.mood-submit {
  margin-top: 32px;
  padding: 16px 48px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  max-width: 340px;
}

.mood-submit:active {
  transform: scale(0.97);
}

.mood-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: none;
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Mood Analytics */
.mood-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 100px;
  margin: 12px 0;
}

.mood-bar {
  flex: 1;
  min-width: 4px;
  border-radius: 3px 3px 0 0;
  transition: height 0.3s;
  position: relative;
}

.mood-bar:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
  z-index: 5;
}

.mood-period-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.mood-period-tab {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.mood-period-tab.active {
  background: var(--accent);
  color: var(--bg-primary);
  border-color: var(--accent);
}

.mood-insight {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.6;
}

/* ====== MOBILE BUILDER ====== */
@media(max-width:768px) {
  .builder-area {
    display: block !important;
  }

  .builder-area>div {
    margin-bottom: 16px;
  }

  .builder-sidebar {
    max-height: 200px !important;
  }

  .builder-item {
    padding: 10px !important;
  }

  .bi-config {
    flex-wrap: wrap;
  }

  .bi-config input {
    width: 44px;
  }
}

/* ====== NUTRITION MODULE ====== */
.nutrition-summary {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.cal-progress-wrap {
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  margin: 12px 0;
  overflow: hidden;
  position: relative;
}

.cal-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #0a7);
  border-radius: 4px;
  transition: width 0.5s ease;
}

.macro-grid {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.macro-item {
  flex: 1;
  text-align: center;
}

.macro-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.macro-val {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.macro-bar-wrap {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.macro-bar {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s ease;
}

.macro-p {
  background: #3b82f6;
}

/* Protein */
.macro-c {
  background: #eab308;
}

/* Carbs */
.macro-f {
  background: #ef4444;
}

/* Fat */
.macro-target {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.meal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.meal-header {
  padding: 12px 14px;
  background: var(--bg-elevated);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 14px;
}

.meal-cal {
  font-size: 12px;
  color: var(--text-muted);
}

.meal-foods {
  padding: 8px 0;
}

.food-item {
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.food-item:last-child {
  border-bottom: none;
}

.food-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.food-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.food-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.food-cal {
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  margin-left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.food-del {
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.food-del:hover {
  color: var(--danger);
}

.add-food-btn {
  width: 100%;
  padding: 10px;
  text-align: center;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-top: 1px solid var(--border);
  transition: background 0.2s;
}

.add-food-btn:active {
  background: var(--bg-elevated);
}

.water-widget {
  background: linear-gradient(135deg, #3b82f620, #00d4aa10);
  border: 1px solid #3b82f640;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
  position: relative;
}

.water-controls {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.water-btn {
  padding: 6px 12px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: #3b82f6;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
}

.water-btn:active {
  transform: scale(0.95);
}

/* Food Search Modal */
.fs-recent {
  margin-top: 12px;
}

.fs-cats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.fs-cat {
  padding: 6px 12px;
  background: var(--bg-elevated);
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid transparent;
}

.fs-cat.active {
  background: var(--accent);
  color: var(--bg-primary);
}

.fs-list {
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 12px;
}

.fs-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.fs-item:active {
  background: var(--bg-elevated);
}

.fs-cal {
  font-weight: 700;
  color: var(--accent);
  font-size: 12px;
}

.date-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.date-nav-btn {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 8px;
}

.date-display {
  font-weight: 700;
  font-size: 16px;
}