@font-face { font-family: 'Inter'; font-style: normal; font-weight: 300; font-display: swap; src: url('/fonts/inter-300.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/inter-700.woff2') format('woff2'); }

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

:root {
  --bg: #0a0a0a;
  --card: #111111;
  --card-border: rgba(255,255,255,0.06);
  --card-hover: rgba(255,255,255,0.13);
  --text: #f0f0f0;
  --text-secondary: rgba(255,255,255,0.38);
  --text-label: rgba(255,255,255,0.28);
  --accent: #38bdf8;
  --accent-dim: rgba(56,189,248,0.15);
  --accent-text: #1d6fa5;
  --danger: #ef4444;
  --danger-dim: rgba(239,68,68,0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────── */
#header {
  padding: calc(12px + var(--safe-top)) 20px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
  z-index: 10;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

/* ── Main content ───────────────────────────── */
#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 34px) + 16px);
}

/* ── Tab bar ────────────────────────────────── */
#tab-bar {
  display: flex;
  background: #0d0d0d;
  border-top: 1px solid var(--card-border);
  padding-bottom: env(safe-area-inset-bottom, 34px);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0 8px;
  background: none;
  border: none;
  color: var(--text-label);
  font-family: inherit;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: color 0.2s;
}

.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); }

/* ── Cards ──────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

/* ── Category tabs ──────────────────────────── */
.category-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
  scrollbar-width: none;
}
.category-bar::-webkit-scrollbar { display: none; }

.cat-pill {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.cat-pill.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

.cat-pill-add {
  background: none;
  border-style: dashed;
  color: var(--text-label);
}

/* ── Lists ──────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.list-item:last-child { border-bottom: none; }

.list-item.checked .item-name {
  text-decoration: line-through;
  color: var(--text-label);
}

.item-check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--text-label);
  background: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}
.item-check.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.item-check.checked::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translateY(-1px);
}

.drag-handle {
  color: var(--text-label);
  font-size: 1.2rem;
  cursor: grab;
  padding: 0 2px;
  flex-shrink: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  line-height: 1;
}

.list-item.dragging {
  position: fixed;
  z-index: 50;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px;
  opacity: 0.9;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  pointer-events: none;
}

.drag-placeholder {
  border: 2px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  margin: 4px 0;
}

.item-qty {
  background: var(--accent-dim);
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  min-width: 28px;
  text-align: center;
}

.item-qty-input {
  width: 44px !important;
  padding: 2px 4px !important;
  font-size: 16px;
  text-align: center;
  border-radius: 6px;
  flex-shrink: 0;
}

.item-name {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text);
  min-width: 0;
  word-break: break-word;
}

.item-delete {
  background: none;
  border: none;
  color: var(--text-label);
  cursor: pointer;
  padding: 4px;
  font-size: 1.1rem;
  line-height: 1;
  opacity: 0.5;
  transition: opacity 0.2s;
}
.item-delete:hover { opacity: 1; color: var(--danger); }

/* ── Input row ──────────────────────────────── */
.input-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

input, textarea, select {
  font-family: inherit;
  font-size: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
input::placeholder, textarea::placeholder { color: var(--text-label); }

.input-row input {
  flex: 1;
  min-width: 0;
}

/* ── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:active { background: #2196d4; }

.btn-secondary {
  background: var(--accent-dim);
  color: var(--accent);
}
.btn-secondary:active { background: rgba(20,184,166,0.25); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
}

.btn-ghost {
  background: none;
  color: var(--text-secondary);
  padding: 10px 12px;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.btn-block {
  width: 100%;
}

/* ── Action bar ─────────────────────────────── */
.action-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

/* ── Section title ──────────────────────────── */
.section-title {
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-label);
  margin-bottom: 10px;
  margin-top: 20px;
}
.section-title:first-child { margin-top: 0; }

/* ── Exercise card ──────────────────────────── */
.exercise-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.exercise-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exercise-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.exercise-meta {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.exercise-notes {
  font-size: 0.78rem;
  color: var(--text-label);
  margin-top: 6px;
  font-style: italic;
}

.exercise-actions {
  display: flex;
  gap: 4px;
}

.exercise-actions button {
  background: none;
  border: none;
  color: var(--text-label);
  cursor: pointer;
  padding: 4px 6px;
  font-size: 0.85rem;
  border-radius: 6px;
  transition: all 0.2s;
}
.exercise-actions button:hover { color: var(--text); background: rgba(255,255,255,0.05); }

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

.modal {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 34px));
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  overflow-x: hidden;
  animation: slideUp 0.25s ease-out;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal .form-group {
  margin-bottom: 14px;
}

.modal label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal input, .modal textarea, .modal select {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.modal input[type="time"],
.modal input[type="number"] {
  width: auto;
  min-width: 120px;
}

.modal textarea { resize: vertical; min-height: 60px; }

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
}
.modal-actions .btn { flex: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── Toggle switch ──────────────────────────── */
.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}
.toggle input { display: none; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider {
  background: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ── Notification item ──────────────────────── */
.notif-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.notif-item:last-child { border-bottom: none; }

.notif-info { flex: 1; min-width: 0; }
.notif-title { font-size: 0.9rem; font-weight: 500; color: var(--text); }
.notif-body { font-size: 0.78rem; color: var(--text-secondary); margin-top: 2px; }
.notif-schedule { font-size: 0.72rem; color: var(--text-label); margin-top: 4px; }

/* ── Progress / Charts ──────────────────────── */
.chart-container {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.chart-container canvas {
  width: 100% !important;
  height: 200px !important;
}

/* ── Workout log ────────────────────────────── */
.log-set {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.log-set label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  width: 50px;
  flex-shrink: 0;
}
.log-set input {
  width: 80px;
  padding: 8px 10px;
  font-size: 0.85rem;
  text-align: center;
}

/* ── Empty state ────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-label);
}
.empty-state p {
  font-size: 0.88rem;
  margin-bottom: 16px;
}

/* ── Standard basket manager ────────────────── */
.basket-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.basket-item:last-child { border-bottom: none; }
.basket-item-name {
  flex: 1;
  font-size: 0.82rem;
  color: var(--text);
}

/* ── Workout history ────────────────────────── */
.history-date {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  margin-top: 12px;
  margin-bottom: 6px;
}

.history-entry {
  font-size: 0.82rem;
  color: var(--text-secondary);
  padding: 4px 0;
}

/* ── Plan selector ──────────────────────────── */
.plan-selector {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}
.plan-selector::-webkit-scrollbar { display: none; }

/* ── Sub-tabs ───────────────────────────────── */
.sub-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.04);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.sub-tab {
  flex: 1;
  padding: 8px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.sub-tab.active {
  background: var(--card);
  color: var(--text);
}

/* ── Radio group ────────────────────────────── */
.radio-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.radio-option {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}
.radio-option.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Day picker ─────────────────────────────── */
.day-picker {
  display: flex;
  gap: 6px;
}
.day-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.day-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
