:root {
  --bg-main: #212121;
  --bg-sidebar: #171717;
  --bg-input: #2f2f2f;
  --bg-card: #2a2a2a;
  --bg-hover: #2f2f2f;
  --bg-user-msg: #2f2f2f;
  --text: #ececec;
  --text-dim: #b4b4b4;
  --text-faint: #8e8e8e;
  --border: #3a3a3a;
  --accent: #10a37f;
  --accent-hover: #0d8a6c;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.app { display: flex; height: 100vh; width: 100vw; overflow-x: hidden; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  padding: 12px;
  flex-shrink: 0;
  transition: none;
}

/* Dashboard mode toggles .sidebar-nav via visibility (not display) so its
   flex:1 space is always reserved - sidebar-bottom (Dashboard button +
   profile chip) must stay pinned to the bottom exactly like the default
   screen, never collapse upward. No transitions on any of these: mode
   switches must be instant, not an animated/sliding handoff. */
.sidebar, .sidebar-nav, .sidebar-bottom, .app, .main, .section {
  transition: none !important;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  padding: 8px 12px 16px;
  letter-spacing: -0.5px;
}
.logo span { color: var(--accent); }

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.new-chat-btn:hover { background: var(--bg-hover); }

.sidebar-nav { flex: 1; margin-top: 20px; overflow-y: auto; }

.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-faint);
  padding: 0 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-hover); color: var(--text); font-weight: 600; }

.sidebar-bottom { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 12px; color: var(--text); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; color: #fff;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-plan { font-size: 11px; color: var(--text-faint); }

/* ============ MAIN ============ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.section { display: none; flex: 1; flex-direction: column; overflow: hidden; height: 100%; }
.section.active { display: flex; }

/* ---- Chat ---- */
.chat-container { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

/* Smart auto-scroll: shown only while the user has scrolled away from the
   bottom during a streaming (or just-finished) response. A flex item that
   sits after .messages (so it isn't wiped by .messages.innerHTML resets)
   using position:sticky - it sticks to the bottom of .chat-container's own
   scrollport regardless of total content height or scroll offset, which is
   more robust than position:absolute here (a scrolling flex container). */
.jump-to-latest {
  display: none;
  align-items: center;
  gap: 6px;
  position: sticky;
  bottom: 12px;
  align-self: center;
  flex-shrink: 0;
  width: fit-content;
  margin-top: 8px;
  padding: 8px 16px;
  background: var(--bg-card, #2a2a2a);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  z-index: 5;
  transition: background 0.15s;
}
.jump-to-latest:hover { background: var(--bg-hover); }
.jump-to-latest.visible { display: flex; }

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 20px;
}
.hero-title { font-size: 30px; font-weight: 700; letter-spacing: -1px; }
.hero-sub { color: var(--text-dim); margin-top: 6px; font-size: 14px; }
.hero-chips { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }

.chip {
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }

.messages { max-width: 760px; width: 100%; margin: 0 auto; padding: 10px 20px 4px; }

/* Messaging-app layout: no avatars or labels.
   User messages sit right in a green bubble; assistant messages sit
   left as plain text with no bubble. */
.msg { display: flex; margin-bottom: 8px; }
.msg-body { font-size: 15px; line-height: 1.55; overflow-wrap: break-word; white-space: pre-wrap; }
.msg-body code {
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.msg.user { justify-content: flex-end; }
.msg.user .msg-body {
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 18px;
  border-bottom-right-radius: 5px;
  max-width: 75%;
}

.msg.assistant { justify-content: flex-start; }
.msg.assistant .msg-body {
  color: var(--text);
  max-width: 92%;
  flex: 1;
}

/* quick replies */
.quick-replies { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.qr-btn {
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.qr-btn:hover { background: var(--accent); color: #fff; }
.qr-btn:disabled { opacity: 0.4; cursor: default; }

/* redirect proposal */
.redirect-card {
  margin-top: 10px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.redirect-actions { display: flex; gap: 10px; margin-top: 12px; }
.confirm-btn {
  padding: 8px 20px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.confirm-btn:hover { background: var(--accent-hover); }
.decline-btn {
  padding: 8px 20px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}
.decline-btn:hover { border-color: var(--text-dim); color: var(--text); }

/* session card */
.session-card {
  margin-top: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.session-head {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.session-title { font-size: 17px; font-weight: 700; }
.session-meta { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(16, 163, 127, 0.15);
  color: var(--accent);
  font-weight: 600;
}
.badge.gray { background: rgba(255,255,255,0.07); color: var(--text-dim); }
.session-focus { font-size: 13px; color: var(--text-dim); margin-top: 8px; }
.exercise-list { padding: 6px 0; }
.exercise-row {
  display: flex;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.exercise-row:last-child { border-bottom: none; }
.exercise-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-dim);
  flex-shrink: 0;
  margin-top: 2px;
}
.exercise-name { font-weight: 600; font-size: 14px; }
.exercise-rx { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* typing dots */
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  animation: blink 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* streaming typing cursor + note */
.stream-cursor {
  display: inline-block;
  width: 8px; height: 1em;
  margin-left: 1px;
  background: var(--text-dim);
  vertical-align: text-bottom;
  animation: blink 1s steps(1) infinite;
}
.stream-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
}

/* ---- Input bar ---- */
.input-bar { padding: 6px 20px 10px; }
.input-wrap {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 8px 8px 8px 22px;
  transition: border-color 0.15s;
}
.input-wrap:focus-within { border-color: var(--text-faint); }
.input-wrap textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  resize: none;
  max-height: 160px;
  line-height: 1.5;
  padding: 6px 0;
}
.input-wrap textarea::placeholder { color: var(--text-faint); }
.send-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--border); cursor: default; }
.send-btn.stop-mode { background: var(--border); }
.send-btn.stop-mode:hover { background: var(--text-faint); }
.input-hint {
  max-width: 760px;
  margin: 8px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
}

/* ---- Panels (non-chat sections) ---- */
.panel {
  flex: 1;
  overflow-y: auto;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 60px;
}
.panel h1 { font-size: 28px; letter-spacing: -0.5px; }
.panel-sub { color: var(--text-dim); margin: 8px 0 24px; font-size: 15px; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 17px; margin-bottom: 16px; }
.muted-card p { color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.muted-card .primary-btn { margin-top: 14px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.inline-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}
.inline-field { margin-bottom: 14px; }
input, select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.checkbox-field { flex-direction: row !important; align-items: center; gap: 8px !important; font-size: 13px !important; }
.checkbox-field input { width: auto; }

/* ---- Custom file upload dropzone (English UI, independent of browser locale) ---- */
.upload-field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.upload-field-label { font-size: 12px; color: var(--text-dim); }
.file-drop {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 26px 20px;
  background: var(--bg-input);
  transition: border-color 0.15s, background 0.15s;
}
.file-drop:hover, .file-drop.dragover { border-color: var(--accent); background: rgba(16, 163, 127, 0.06); }
.file-drop-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.file-drop-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  pointer-events: none;
}
.file-drop-icon { color: var(--text-faint); margin-bottom: 4px; }
.file-drop-title { font-size: 14px; font-weight: 600; color: var(--text); }
.file-drop-hint { font-size: 12px; color: var(--text-faint); }
.file-drop-btn {
  margin-top: 10px;
  padding: 7px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.file-drop:hover .file-drop-btn { border-color: var(--accent); color: var(--accent); }
.file-drop-selected {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--accent);
}
.file-drop-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 320px;
}
.file-drop-remove {
  position: relative;
  z-index: 2;
  pointer-events: auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.file-drop-remove:hover { border-color: #e5484d; color: #e5484d; }
.file-drop-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ---- Gym exercise logging ---- */
.gym-exercise-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.gym-exercise-row input { width: 100%; }
.gym-remove-btn {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.gym-remove-btn:hover { border-color: var(--danger); color: var(--danger); }
.gym-remove-btn::after {
  content: "Remove Exercise";
  position: absolute;
  bottom: 120%;
  right: 0;
  background: var(--bg-card, #222);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--text);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.gym-remove-btn:hover::after { opacity: 1; }
@media (max-width: 720px) {
  .gym-exercise-row { grid-template-columns: 1fr 1fr; }
}

/* ---- Meal planner ---- */
#mpResults:not(:empty) { margin-top: 20px; }
#hResults:not(:empty) { margin-top: 20px; }
.mp-day-card { background: var(--bg-input); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.mp-day-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.mp-day-head h3 { margin: 0; font-size: 15px; }
.mp-meal-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 8px 0; border-bottom: 0.5px solid var(--border); }
.mp-meal-row:last-child { border-bottom: none; }
.mp-meal-name { font-weight: 600; font-size: 13px; }
.mp-meal-type { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; }
.mp-meal-ingredients { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.mp-meal-macros { font-size: 12px; color: var(--text-dim); white-space: nowrap; text-align: right; }

.primary-btn {
  padding: 10px 22px;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* results */
.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.metric {
  background: var(--bg-input);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.metric-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; }
.metric-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.metric-value small { font-size: 12px; font-weight: 400; color: var(--text-dim); }

.result-note {
  margin-top: 14px;
  padding: 12px 16px;
  background: rgba(16, 163, 127, 0.08);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.6;
}
.result-note.warn { background: rgba(245, 158, 11, 0.08); border-left-color: var(--warning); }
.result-note.danger { background: rgba(239, 68, 68, 0.08); border-left-color: var(--danger); }

.red-flags { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.red-flags .rf-label { font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.rf-item { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); }
.rf-item input { width: auto; }

/* explore encyclopedia */
#exploreAbout { margin: 8px 0 28px; }
#exploreAbout h2 { font-size: 18px; margin-bottom: 10px; }
.about-text { color: var(--text-dim); font-size: 14px; line-height: 1.7; max-width: 720px; }

.discover-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: 16px;
  cursor: pointer;
  text-align: left;
}
.discover-toggle h2 { font-size: 18px; margin: 0; color: var(--text); }
.discover-toggle .discover-hint {
  font-size: 13px;
  color: var(--accent);
  transition: color 0.15s;
}
.discover-toggle:hover .discover-hint { color: var(--accent-hover); }

.encyclopedia-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.encyclopedia-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.encyclopedia-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.enc-card-banner {
  height: 64px;
  background: linear-gradient(135deg, rgba(16,163,127,0.25), rgba(16,163,127,0.08));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: var(--accent);
  letter-spacing: 1px;
}
.enc-card-body { padding: 14px 16px; }
.enc-card-name { font-weight: 600; font-size: 15px; }
.enc-card-tagline { font-size: 12px; color: var(--text-faint); margin-top: 6px; line-height: 1.5; min-height: 32px; }
.enc-card-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.hero-banner {
  height: 140px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(16,163,127,0.3), rgba(16,163,127,0.06));
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 700; color: var(--accent);
  letter-spacing: 2px;
}

.org-card { background: var(--bg-input); border-radius: 8px; padding: 14px 16px; }
.org-name { font-weight: 600; font-size: 15px; }
.org-link { color: var(--accent); font-size: 13px; text-decoration: none; }
.org-link:hover { text-decoration: underline; }

.facts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 20px;
}
.fact-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 0.5px solid var(--border); }
.fact-label { color: var(--text-faint); }
.fact-value { color: var(--text-dim); text-align: right; }

.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-pill {
  padding: 6px 14px;
  background: var(--bg-input);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-dim);
}

.session-list { margin-top: 24px; }
.session-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.session-item:hover { border-color: var(--accent); }
.session-item .si-name { font-weight: 600; font-size: 14px; }
.session-item .si-meta { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-dim);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  margin-bottom: 16px;
}
.back-btn:hover { color: var(--text); }
.role-choice.active { border-color: var(--accent); color: var(--text); background: var(--bg-hover); }

@media (max-width: 720px) {
  .sidebar { width: 68px; }
  .sidebar .logo, .sidebar .nav-label, .sidebar .user-info,
  .sidebar .new-chat-btn span, .nav-item { font-size: 0; gap: 0; }
  .nav-item svg { width: 20px; height: 20px; }
}

/* ============ CALENDAR ============ */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cal-header .back-btn { margin: 0; }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
  margin-bottom: 6px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-dim);
  transition: transform 0.1s, border-color 0.15s;
}
.cal-day:hover { transform: translateY(-1px); border-color: var(--text-faint); }
.cal-day.trained { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.cal-day.planned { background: rgba(59, 130, 246, 0.25); border-color: #3b82f6; color: #93c5fd; }
.cal-day.missed { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.5); color: #fca5a5; }
.cal-day.rest { background: rgba(255, 255, 255, 0.06); border-color: var(--border); color: var(--text-dim); font-style: italic; }
.cal-day.today { box-shadow: 0 0 0 2px var(--accent); }
.cal-day.selected { box-shadow: 0 0 0 2px #fff; }

.cal-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-dim);
  align-items: center;
}
.cal-legend .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 3px;
  margin-right: 5px;
}
.dot.trained { background: var(--accent); }
.dot.planned { background: #3b82f6; }
.dot.missed { background: #ef4444; }
.dot.rest { background: rgba(255,255,255,0.15); }
.cal-toggle { display: flex; align-items: center; gap: 6px; margin-left: auto; cursor: pointer; }
.cal-toggle input { width: auto; }

/* ---- Organization Calendar: event-type colors, reusing the .dot convention ---- */
.dot.org-event-game { background: var(--accent); }
.dot.org-event-tournament { background: #a855f7; }
.dot.org-event-training_camp { background: #3b82f6; }
.dot.org-event-meeting { background: #f59e0b; }
.dot.org-event-travel { background: #14b8a6; }
.dot.org-event-other { background: var(--text-faint); }

.cal-day .org-event-dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 2px; }
.cal-day .org-event-dots .dot { width: 5px; height: 5px; margin: 0; border-radius: 50%; }
.cal-day.has-events { flex-direction: column; gap: 1px; }
.cal-day .org-event-more { font-size: 9px; color: var(--text-faint); }

.org-event-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 8px;
  margin-bottom: 8px; cursor: pointer;
}
.org-event-row:hover { border-color: var(--text-faint); }

.org-facility-row, .org-booking-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 8px;
}
.org-facility-group { margin-bottom: 18px; }
.org-facility-group h3 { margin: 0 0 8px; font-size: 14px; }

.org-booking-bar-track {
  position: relative; height: 8px; border-radius: 4px;
  background: rgba(255,255,255,0.06); margin-top: 6px;
}
.org-booking-bar {
  position: absolute; top: 0; bottom: 0; border-radius: 4px;
  background: var(--accent); min-width: 3%;
}

.cal-session {
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.cal-session.done { border-left: 3px solid var(--accent); }
.cal-session.pending { border-left: 3px solid #3b82f6; }
.cal-session.empty { font-style: italic; }

/* Training-adaptation transparency card ("what changed & why") */
.adapt-card { border-left: 3px solid #3b82f6; }
.adapt-head {
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim); font-weight: 700; margin-bottom: 12px;
}
.adapt-row { padding: 10px 0; border-top: 1px solid var(--border, rgba(255,255,255,0.06)); }
.adapt-row:first-of-type { border-top: none; padding-top: 0; }
.adapt-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.adapt-summary { font-weight: 600; font-size: 14px; color: var(--text); }
.adapt-meta { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.adapt-reason { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

.cal-session[data-session-id] { cursor: pointer; }
.cal-session[data-session-id]:hover { background: var(--bg-hover, var(--bg-input)); }
.cal-session-expand {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.cal-session-detail { margin-top: 10px; }
.cal-session-loading { font-size: 12px; color: var(--text-faint); font-style: italic; }
.cal-session-detail-inner {
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
  padding-top: 10px;
}
.cal-detail-name { font-weight: 700; color: var(--text); margin-bottom: 4px; }
.cal-detail-focus { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.cal-detail-exercises { list-style: none; padding: 0; margin: 0; }
.cal-detail-exercises li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.05));
  color: var(--text-dim);
}
.cal-detail-exercises li:last-child { border-bottom: none; }
.cal-detail-meta { color: var(--text-faint); font-weight: 400; }
.cal-detail-note { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.cal-detail-progression { margin-top: 10px; font-size: 12px; color: var(--text-dim); }

/* Rich session actions (P1) inside an expanded session */
.sess-actions { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sess-actions .sess-act { margin: 0; padding: 6px 12px; font-size: 12px; }
.sess-locked { flex-basis: 100%; font-size: 12px; color: var(--warn, #d99a00); margin-bottom: 4px; }
.sess-act-result { flex-basis: 100%; font-size: 12px; color: var(--text-dim); min-height: 16px; }
.vdrill-tag.sess-act { cursor: pointer; border: none; }

/* Coach alerts (P2) */
.org-alerts-card { border-left: 3px solid #e0a800; }
.org-alerts-head { font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); font-weight: 700; margin-bottom: 10px; }
.org-alert-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border, rgba(255,255,255,0.06)); }
.org-alert-row:first-of-type { border-top: none; }
.org-alert-msg { font-size: 13.5px; color: var(--text); }
.org-alert-row.sev-critical .org-alert-msg { font-weight: 600; }

/* Readiness meter (P3) */
.readiness-card { display: flex; align-items: center; gap: 14px; }
.readiness-score { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.readiness-track { flex: 1; height: 8px; border-radius: 4px; background: var(--bg-input); overflow: hidden; }
.readiness-fill { height: 100%; border-radius: 4px; }
.readiness-note { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.heatmap {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.heat-cell { width: 11px; height: 11px; border-radius: 2px; }
.heat-cell.level-0 { background: var(--bg-input); border: 1px solid var(--border); box-sizing: border-box; }
.heat-cell.level-1 { background: rgba(16, 163, 127, 0.35); }
.heat-cell.level-2 { background: rgba(16, 163, 127, 0.65); }
.heat-cell.level-3 { background: var(--accent); }

/* ---- Plans ---- */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.plan-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.plan-card.featured { border: 2px solid var(--accent); }
.plan-card-name { font-size: 16px; font-weight: 700; }
.plan-card-price { font-size: 26px; font-weight: 700; margin: 8px 0 14px; }
.plan-card-price small { font-size: 13px; font-weight: 400; color: var(--text-dim); }
.plan-card-features { list-style: none; padding: 0; margin: 0 0 16px; flex: 1; }
.plan-card-features li {
  font-size: 13px;
  color: var(--text-dim);
  padding: 6px 0;
  border-bottom: 0.5px solid var(--border);
}
.plan-card-features li:last-child { border-bottom: none; }
.plan-card-note {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  padding: 8px 0;
}

/* ---- Video Review ---- */
.video-keyframe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.video-keyframe-card { background: var(--bg-input); border-radius: 10px; overflow: hidden; }
.video-keyframe-card img { width: 100%; display: block; }
.video-keyframe-card .vk-label { font-weight: 700; font-size: 13px; padding: 10px 12px 2px; }
.video-keyframe-card .vk-note { font-size: 12px; color: var(--text-dim); padding: 0 12px 12px; }

.vphase-row { border-bottom: 0.5px solid var(--border); padding: 14px 0; }
.vphase-row:last-child { border-bottom: none; }
.vphase-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.vphase-head .vphase-name { font-weight: 700; font-size: 14px; }
.vphase-score { font-weight: 700; color: var(--accent); }
.vphase-score.low { color: var(--danger); }
.vphase-row ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--text-dim); }

#vProComparison p { margin-top: 12px; }
#vProComparison p:first-child { margin-top: 0; }
#vProComparison ul { margin: 6px 0 0; padding-left: 20px; font-size: 13px; color: var(--text-dim); }
#vProComparison li { margin-bottom: 5px; }
#vProComparison li:last-child { margin-bottom: 0; }

.vmistake-card { background: var(--bg-input); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.vmistake-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.vmistake-name { font-weight: 700; font-size: 14px; }
.vmistake-card p { font-size: 13px; color: var(--text-dim); margin: 4px 0; }

.vsuggestion-card { background: var(--bg-input); border-radius: 10px; padding: 14px; margin-bottom: 10px; }
.vsuggestion-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.vsuggestion-title { font-weight: 700; font-size: 14px; }

/* Catalog-linked drill chips */
.vdrill-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.vdrill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card, rgba(255,255,255,0.03));
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px; padding: 6px 10px; font-size: 12.5px; color: var(--text-dim);
}
.vdrill-tag { font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; padding: 2px 6px; border-radius: 5px; }
.vdrill-tag.catalog { color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, transparent); }
.vdrill-tag.generated { color: var(--text-faint); background: rgba(128,128,128,0.15); }
.vrec-group { margin-bottom: 14px; }
.vrec-group-label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 6px; }

/* Honest analysis metadata + richer biomechanics */
.vanalysis-meta {
  font-size: 12.5px; color: var(--text-dim); line-height: 1.5;
  padding: 10px 12px; margin-bottom: 12px; border-radius: 8px;
  background: var(--bg-input); border-left: 3px solid var(--accent);
}
.vanalysis-note { color: var(--text-faint); }
.vbio-est { color: var(--text-faint); font-size: 11px; }
.vbio-unavailable { opacity: 0.6; }
.vbio-unavailable .usage-count { font-style: italic; color: var(--text-faint); }

.video-history-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 0.5px solid var(--border); cursor: pointer;
}
.video-history-row:last-child { border-bottom: none; }
.video-history-row:hover { color: var(--text); }
.video-history-row input[type="checkbox"] { width: auto; }
.video-history-score { font-weight: 700; color: var(--accent); margin-left: auto; }
.plan-card-trial {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: rgba(var(--accent-rgb, 60, 200, 130), 0.12);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
  width: fit-content;
}
.plan-card-audience {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.billing-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
}
.billing-toggle-btn.active { background: var(--bg-card); color: var(--text); }

/* ---- Usage bars ---- */
.usage-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.usage-label { flex: 0 0 200px; font-size: 13px; color: var(--text-dim); }
.usage-bar-track { flex: 1; height: 8px; background: var(--bg-input); border-radius: 4px; overflow: hidden; }
.usage-bar-fill { height: 100%; background: var(--accent); }
.usage-bar-fill.full { background: var(--danger); }
.usage-count { flex: 0 0 70px; text-align: right; font-size: 12px; color: var(--text-faint); }

/* ---- Organizations dashboard ---- */
.org-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.org-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.org-tab {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}
.org-tab:hover { color: var(--text); }
.org-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.athlete-row, .team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
}
.athlete-row:hover, .team-row:hover { background: var(--bg-hover); }
.athlete-row-name { font-weight: 600; font-size: 14px; }
.athlete-row-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

.locked-feature {
  padding: 16px;
  background: var(--bg-input);
  border-radius: 8px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ---- Auth ---- */
.user-chip:hover { background: var(--bg-hover) !important; border-radius: 8px; }
.user-menu-popup {
  position: fixed;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  min-width: 180px;
  z-index: 60;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.user-menu-popup button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  border-radius: 6px;
}
.user-menu-popup button:hover { background: var(--bg-hover); }
