/* ---------- Base / Mobile-first ---------- */
* { box-sizing: border-box; }
:root {
  --bg: #0b0c10;
  --panel: #141821;
  --panel-2: #1f2833;
  --text: #dfe7ef;
  --muted: #a9b4c0;
  --accent: #66fcf1;
  --accent-2: #45a29e;
  --danger: #ff6b6b;
  --success: #4ade80;
  --shadow: 0 0 24px #66fcf122, 0 0 4px #000 inset;
  --radius: 16px;
}

html, body {
  height: 100%;
  background: radial-gradient(1200px 600px at 50% -10%, #10202a66, transparent 60%), var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
}

.status-bar-safe { height: env(safe-area-inset-top, 0); }

.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: calc(100dvh - env(safe-area-inset-top));
  display: grid;
  grid-template-rows: auto 1fr;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(180deg, #0b0c10 0%, #0b0c10ee 70%, #0b0c1000 100%);
  padding: 10px 14px 6px;
  backdrop-filter: blur(6px);
  border-bottom: 1px solid #3a445533;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.logo .neuron { filter: drop-shadow(0 0 4px #66fcf177); }
.logo .brand { color: var(--accent); letter-spacing: .4px; }

.meta {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.xp-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.xp-bar {
  width: 100%;
  height: 8px;
  background: #0f1420;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px #3a445566;
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .4s ease;
}

.streak {
  font-size: 12px;
  color: #ffd166;
  background: #2b1d00;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #8a5c00aa;
}

/* ---------- Views ---------- */
.view { display: none; }
.view.active { display: grid; grid-template-rows: 1fr auto; }

.chat {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.msg { display: flex; }
.msg.ai { justify-content: flex-start; }
.msg.user { justify-content: flex-end; }

.bubble {
  max-width: 82%;
  background: var(--panel);
  border: 1px solid #2a3444;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.45;
  font-size: 15px;
}
.msg.user .bubble {
  background: var(--accent-2);
  border-color: transparent;
  color: #06221f;
}
.tiplist { margin: 8px 0 0 14px; color: var(--muted); font-size: 13px; }

.typing .bubble { position: relative; }
.dots { display: inline-flex; gap: 6px; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted);
  opacity: .5; animation: blink 1s infinite ease-in-out;
}
.dots i:nth-child(2){ animation-delay: .15s; }
.dots i:nth-child(3){ animation-delay: .3s; }
@keyframes blink {
  0%, 100% { opacity: .3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

/* ---------- Input ---------- */
.input {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, #0b0c10 0%, #0b0c10ee 70%, #0b0c1000 100%);
  border-top: 1px solid #3a445533;
  backdrop-filter: blur(6px);
}
.input input {
  height: 44px;
  background: var(--panel-2);
  border: 1px solid #2a3444;
  color: var(--text);
  border-radius: 12px;
  padding: 0 12px;
  outline: none;
}
.btn {
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 0;
  cursor: pointer;
  background: var(--accent-2);
  color: #08211e;
  font-weight: 700;
  box-shadow: 0 4px 14px #45a29e33;
}
.btn:hover { filter: brightness(1.08); }
.btn.send { width: 52px; }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid #3a445566;
}

/* ---------- Workout Cards ---------- */
.workout { padding: 0 14px 12px; }
.workout.hidden { display: none; }
.workout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 10px;
}
.workout-list { display: grid; gap: 10px; }

.card-ex {
  background: var(--panel);
  border: 1px solid #2a3444;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  box-shadow: var(--shadow);
}
.ex-title { font-weight: 700; }
.ex-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.actions { display: flex; gap: 8px; }
.small { height: 36px; padding: 0 10px; font-size: 14px; }
.btn.swap { background: #223047; color: var(--text); border: 1px solid #365076; }
.btn.done { background: var(--success); color: #06221f; }
.card-ex.completed { opacity: .6; filter: saturate(.8); }
.card-ex.completed .ex-title { text-decoration: line-through; }

/* ---------- Buttons ---------- */
.finish {
  background: linear-gradient(90deg, #2dd4bf, #22d3ee);
  color: #012a27;
  font-weight: 800;
}
.finish:disabled { opacity: .5; filter: grayscale(1); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; display: none; z-index: 20; }
.modal.show { display: block; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: #0008;
  backdrop-filter: blur(2px);
  z-index: 0;               /* 🟢 ensures it sits behind content */
}
.modal-content {
  position: absolute;
  z-index: 1;               /* 🟢 ensures it's above backdrop */
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 460px);
  background: var(--panel-2);
  border: 1px solid #2a3444;
  border-radius: 14px;
  box-shadow: var(--shadow);
  max-height: 78vh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px; border-bottom: 1px solid #2a3444; }
.icon-btn { background: transparent; border: 0; color: var(--text); font-size: 20px; cursor: pointer; }
.swap-list { overflow: auto; padding: 10px; display: grid; gap: 8px; }
.swap-item {
  background: var(--panel);
  border: 1px solid #2a3444;
  border-radius: 10px; padding: 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.swap-name { font-weight: 600; }
.swap-tags { font-size: 12px; color: var(--muted); }

/* ---------- Summary ---------- */
.summary { padding: 18px 14px 24px; display: grid; gap: 16px; }
.summary h2 { color: var(--accent); }
.summary-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.summary .card {
  background: var(--panel);
  border: 1px solid #2a3444;
  border-radius: 12px; padding: 12px; text-align: center;
}
.card-title { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.card-value { font-size: 22px; font-weight: 800; }

.supp-row { margin-top: 6px; }
.supp-card {
  display: grid; grid-template-columns: 92px 1fr; gap: 10px;
  background: var(--panel-2); border: 1px solid #2a3444; border-radius: 12px; padding: 10px;
}
.supp-card img { width: 92px; height: 92px; object-fit: contain; background: #0f1420; border-radius: 10px; }
.supp-title { font-weight: 800; }
.supp-note { font-size: 13px; color: var(--muted); margin: 4px 0 10px; }
.btn.shop { background: var(--accent); color: #032a27; }

.summary-actions { display: grid; gap: 10px; margin-top: 6px; }

/* ---------- Responsive tweaks ---------- */
@media (min-width: 480px) {
  .bubble { max-width: 70%; }
}

@keyframes modalPop {
  from { opacity: 0; transform: translate(-50%, -45%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.modal-content {
  animation: modalPop 0.25s ease;
}
