/* ── Design tokens (match landing page) ── */
:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111111;
  --bg-card: #161616;
  --bg-input: #1a1a1a;
  --fg-primary: #f0f0f0;
  --fg-secondary: #888888;
  --fg-muted: #555555;
  --accent: #c8ff00;
  --accent-dim: rgba(200, 255, 0, 0.08);
  --accent-glow: rgba(200, 255, 0, 0.15);
  --accent-border: rgba(200, 255, 0, 0.25);
  --border: #222222;
  --border-light: #2a2a2a;
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --nav-h: 60px;
}

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

html, body {
  height: 100%;
  background: var(--bg-primary);
  color: var(--fg-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── Nav ── */
.app-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-decoration: none;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}

.nav-tab:hover { color: var(--fg-secondary); }
.nav-tab.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ── Main ── */
.app-main {
  position: fixed;
  top: var(--nav-h);
  left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
}
.view.active { display: flex; flex-direction: column; }

.view-inner {
  padding: 28px 20px 40px;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* ── Chat ── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

.chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

.msg {
  display: flex;
  gap: 12px;
  animation: msgIn 0.25s ease-out;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.msg.assistant .msg-avatar {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
  font-size: 0.7rem;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.msg-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.55;
}

.msg.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.user .msg-bubble {
  background: var(--accent);
  color: #0a0a0a;
  font-weight: 500;
  border-bottom-right-radius: 4px;
}

/* Markdown-style within bubbles */
.msg-bubble strong { font-weight: 600; }
.msg-bubble em { font-style: italic; }
.msg-bubble code {
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.88em;
}
.msg.user .msg-bubble code { background: rgba(0,0,0,0.15); }
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin-top: 8px; }
.msg-bubble li { margin-bottom: 4px; }
.msg-bubble p + p { margin-top: 8px; }
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Typing indicator */
.msg-typing .msg-bubble {
  padding: 14px 18px;
}
.typing-dots {
  display: flex; gap: 4px; align-items: center;
}
.typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg-muted);
  animation: dot-bounce 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Program card inside chat */
.program-generated {
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.program-generated span { font-size: 0.9rem; color: var(--accent); font-weight: 500; }
.program-generated button {
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Chat input */
.chat-input-area {
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg-primary);
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
}

textarea#chatInput {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  color: var(--fg-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 10px 14px;
  resize: none;
  line-height: 1.5;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s;
}
textarea#chatInput:focus { border-color: var(--accent-border); }
textarea#chatInput::placeholder { color: var(--fg-muted); }

.btn-send {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: var(--accent);
  border: none;
  color: #0a0a0a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.btn-send:hover { transform: scale(1.05); }
.btn-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

/* ── Program View ── */
.program-header {
  margin-bottom: 28px;
}
.program-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}
.program-header p { color: var(--fg-secondary); font-size: 0.95rem; }

.program-week-badge {
  display: inline-block;
  padding: 3px 12px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 100px;
  font-size: 0.75rem;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.exercise-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.exercise-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.exercise-item:hover { background: #1a1a1a; border-color: var(--border-light); }
.exercise-item.done { border-color: var(--accent-border); background: var(--accent-dim); }

.exercise-check {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  transition: all 0.2s;
}
.exercise-item.done .exercise-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
}

.exercise-info { flex: 1; }
.exercise-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 3px;
}
.exercise-info .exercise-meta {
  font-size: 0.8rem;
  color: var(--fg-secondary);
}

.exercise-cat-tag {
  padding: 3px 9px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  font-size: 0.72rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Library View ── */
.library-header {
  margin-bottom: 20px;
}
.library-header h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.library-header .sub { color: var(--fg-secondary); font-size: 0.9rem; }

.category-filter {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.cat-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--fg-secondary);
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
}
.cat-btn:hover { color: var(--fg-primary); }
.cat-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent);
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.lib-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.lib-card:hover {
  background: #1a1a1a;
  border-color: var(--border-light);
  transform: translateY(-1px);
}

.lib-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}
.lib-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  flex: 1;
}
.lib-diff {
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-left: 10px;
  flex-shrink: 0;
}
.lib-diff.beginner { background: rgba(16,185,129,0.12); color: #10b981; }
.lib-diff.intermediate { background: rgba(245,158,11,0.12); color: #f59e0b; }
.lib-diff.advanced { background: rgba(239,68,68,0.12); color: #ef4444; }

.lib-card p {
  font-size: 0.85rem;
  color: var(--fg-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}
.lib-card-meta {
  display: flex;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.lib-card-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Tracker View ── */
.tracker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.tracker-header h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.streak-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
}
.streak-num {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.streak-label {
  font-size: 0.7rem;
  color: var(--fg-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.today-program-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 16px;
}

.progress-bar-wrap {
  margin: 14px 0;
}
.progress-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--fg-secondary);
  margin-bottom: 6px;
}
.progress-bar {
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.tracker-exercises {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.tracker-ex-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.tracker-ex-item.done { border-color: var(--accent-border); }

.tracker-ex-check {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  background: none;
  color: transparent;
}
.tracker-ex-item.done .tracker-ex-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
  font-size: 0.8rem;
}

.tracker-ex-info { flex: 1; }
.tracker-ex-info h4 { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.tracker-ex-info span { font-size: 0.78rem; color: var(--fg-secondary); }

/* Progress history */
.progress-history {
  margin-top: 32px;
}
.history-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-secondary);
  margin-bottom: 14px;
}
.history-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-width: 320px;
}
.history-day {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--fg-muted);
  flex-direction: column;
  gap: 1px;
}
.history-day.done {
  background: var(--accent-dim);
  border-color: var(--accent-border);
}
.history-day.done .day-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}
.empty-icon { font-size: 2.5rem; margin-bottom: 16px; }
.empty-state h3 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.empty-state p { color: var(--fg-secondary); font-size: 0.9rem; margin-bottom: 24px; line-height: 1.5; }

/* ── Buttons ── */
.btn-accent {
  background: var(--accent);
  color: #0a0a0a;
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
.btn-accent:hover { transform: translateY(-1px); opacity: 0.9; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(6px);
  animation: fadeIn 0.2s ease;
}
.modal-overlay[hidden] { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-close {
  position: absolute;
  top: 16px; right: 18px;
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--fg-primary); }

.modal-cat-tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  border-radius: 6px;
  font-size: 0.72rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.modal-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.modal-desc {
  font-size: 0.92rem;
  color: var(--fg-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
}

.modal-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.modal-stat {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  text-align: center;
}
.modal-stat .val {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
}
.modal-stat .lbl {
  font-size: 0.7rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg-muted);
  margin-bottom: 10px;
}

.modal-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.modal-steps li {
  display: flex;
  gap: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.modal-step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.modal-science {
  background: var(--bg-secondary);
  border-left: 2px solid var(--accent-border);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  font-size: 0.82rem;
  color: var(--fg-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.modal-tips {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.modal-tips li {
  font-size: 0.85rem;
  color: var(--fg-secondary);
  padding-left: 14px;
  position: relative;
}
.modal-tips li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.75rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  .nav-tabs { gap: 2px; }
  .nav-tab { padding: 5px 10px; font-size: 0.78rem; }
  .exercise-grid { grid-template-columns: 1fr; }
  .chat-input-area { padding: 10px 14px; }
  .view-inner { padding: 20px 16px 40px; }
  .tracker-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
