/* ============================================================
   Ultra Training AI — Mobile-First PWA Styles
   ============================================================ */

/* --- PWA Install Banner --- */
#pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-top: 2px solid var(--accent);
  padding: 14px 16px;
  padding-bottom: calc(14px + var(--sab));
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 480px;
  margin: 0 auto;
}
.pwa-banner-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pwa-banner-text strong {
  font-size: 0.95rem;
  color: var(--text);
}
.pwa-banner-text span {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.pwa-banner-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* --- Auth Screen --- */
#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  padding: 20px;
}
#auth-screen.hidden { display: none !important; }

.auth-container {
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.auth-logo {
  margin-bottom: 12px;
  padding: 0;
}
.auth-logo img {
  width: 100%;
  max-width: 380px;
  height: auto;
  border-radius: 24px;
}
.auth-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}
.auth-subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 28px;
}
.auth-field {
  margin-bottom: 12px;
}
.auth-field input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.auth-field input:focus {
  border-color: var(--accent);
}
.auth-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 4px;
}
.auth-btn:hover { opacity: 0.9; }
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.google-btn {
  background: white;
  color: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 0;
}
.google-btn:hover { background: #f5f5f5; opacity: 1; }
.auth-divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  gap: 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}
.auth-error {
  color: var(--red, #ef4444);
  font-size: 0.85rem;
  margin-bottom: 8px;
  text-align: left;
  padding: 0 4px;
}
.auth-toggle {
  margin-top: 20px;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.auth-toggle a:hover { text-decoration: underline; }

.sidebar-user {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 4px;
}
.btn-logout:hover { color: var(--red, #ef4444); border-color: var(--red, #ef4444); }

/* --- Disclaimer Modal --- */
#disclaimer-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
}
#disclaimer-overlay.visible { opacity: 1; }
#disclaimer-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 90vw);
  max-height: 85vh;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  z-index: 201;
  overflow-y: auto;
}
.disclaimer-icon { font-size: 2.5rem; text-align: center; margin-bottom: 8px; }
.disclaimer-content h2 {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 16px;
  color: var(--text);
}
.disclaimer-text {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-dim);
  margin-bottom: 20px;
}
.disclaimer-text p { margin-bottom: 10px; }
.disclaimer-text ul {
  margin: 8px 0 12px 20px;
  list-style: disc;
}
.disclaimer-text li { margin-bottom: 6px; }
.disclaimer-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  cursor: pointer;
  color: var(--text);
}
.disclaimer-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* --- Feedback Button & Modal --- */
.feedback-btn {
  background: none;
  border: 1px solid var(--border);
  font-size: 0.7rem;
  color: #ffffff;
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.2s;
  padding: 3px 6px;
  border-radius: 6px;
  margin-top: 4px;
  align-self: flex-start;
}
.msg:hover .feedback-btn { opacity: 0.7; }
.feedback-btn:hover { opacity: 1 !important; background: var(--surface); }
.msg-content { display: flex; flex-direction: column; min-width: 0; flex: 1; }

.feedback-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
}
.move-date-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
}
.move-date-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, 85vw);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  z-index: 301;
}
.move-date-modal h3 { margin-bottom: 4px; font-size: 1.1rem; }

/* Run Log Modal */
.run-log-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 300;
}
.run-log-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, 90vw);
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  z-index: 301;
}
.run-log-modal h3 { margin-bottom: 4px; font-size: 1.1rem; }
.run-log-fields { display: flex; flex-direction: column; gap: 10px; }
.run-log-fields label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 0.85rem; color: var(--text-dim);
}
.run-log-fields input {
  padding: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 1rem;
}

.feedback-modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, 90vw);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  z-index: 301;
}
.feedback-modal h3 { margin-bottom: 8px; font-size: 1.1rem; }
.feedback-hint { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 12px; }
.feedback-modal textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 12px;
}
.feedback-modal textarea:focus { border-color: var(--accent); outline: none; }
.feedback-actions { display: flex; gap: 8px; justify-content: flex-end; }
.feedback-actions button { padding: 8px 16px; font-size: 0.9rem; }
.feedback-upload { margin-bottom: 12px; }
.feedback-upload-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.feedback-upload-label {
  display: inline-block;
  padding: 6px 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: none;
  font-family: inherit;
  transition: border-color 0.2s, color 0.2s;
}
.feedback-upload-label:hover { border-color: var(--accent); color: var(--accent); }
.feedback-preview-img {
  max-width: 100%;
  max-height: 150px;
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid var(--border);
}
.feedback-remove-img {
  background: var(--red, #ef4444);
  color: white;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 0.7rem;
  cursor: pointer;
  position: relative;
  top: -60px;
  margin-left: -24px;
}

:root {
  /* Dark athletic palette */
  --bg:          #0f172a;
  --bg-surface:  #1e293b;
  --bg-card:     #334155;
  --text:        #f1f5f9;
  --text-muted:  #94a3b8;
  --accent:      #22d3ee;   /* Cyan — energetic */
  --accent-dim:  #0891b2;
  --green:       #34d399;
  --orange:      #fb923c;
  --red:         #f87171;
  --border:      #475569;
  --shadow:      rgba(0,0,0,0.4);

  /* Coach colors */
  --color-ultra: #22d3ee;
  --color-iron:  #fb923c;
  --color-fuel:  #34d399;
  --color-team:  #a78bfa;

  --topbar-h:    56px;
  --input-h:     60px;
  --sidebar-w:   280px;

  /* Safe area for notch phones */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh; /* dynamic viewport height for mobile keyboards */
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* --- Top Bar --- */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  padding-top: var(--sat);
  height: calc(var(--topbar-h) + var(--sat));
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

#topbar-coach {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

#topbar-emoji {
  font-size: 1.6rem;
  line-height: 1;
}

#topbar-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#topbar-tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-card); }

/* --- Sidebar --- */
#sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 20;
  opacity: 0;
  transition: opacity 0.25s;
}
#sidebar-overlay.visible { opacity: 1; }

#sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  z-index: 30;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid var(--border);
}
#sidebar.visible { transform: translateX(0); }

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

#user-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
#user-selector label {
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
#user-select {
  flex: 1;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.85rem;
  cursor: pointer;
}
#btn-add-user {
  font-size: 1.1rem;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}
#btn-add-user:hover { opacity: 0.85; }

#coach-list {
  overflow-y: visible;
  padding: 0;
  flex-shrink: 0;
}

/* Sidebar collapsible sections */
.sidebar-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  user-select: none;
}
.sidebar-section-header:hover {
  color: var(--text);
}
.section-chevron {
  font-size: 0.9rem;
  transition: transform 0.2s;
}
.sidebar-section-body {
  overflow: hidden;
  transition: max-height 0.3s ease;
  max-height: 800px;
  padding: 0 8px;
}
.sidebar-section-body.collapsed {
  max-height: 0;
  padding: 0 8px;
}

.coach-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.coach-card:hover { background: var(--bg-card); }
.coach-card:active { background: var(--bg-card); }

.coach-list-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.coach-card .coach-emoji {
  font-size: 1.8rem;
  line-height: 1;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--bg);
}

.coach-card .coach-info h3 {
  font-size: 0.9rem;
  font-weight: 700;
}

.coach-card .coach-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Chat History */
#chat-history {
  border-top: 1px solid var(--border);
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}
.history-item {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.history-item:hover {
  background: var(--bg-card);
}
.history-item.active {
  background: var(--bg-card);
  border-left: 3px solid var(--accent);
}
.history-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.history-empty {
  padding: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover { background: var(--border); }

/* --- Knowledge Panel --- */
#knowledge-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 20;
  opacity: 0;
  transition: opacity 0.25s;
}
#knowledge-overlay.visible { opacity: 1; }

#knowledge-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(360px, 85vw);
  background: var(--bg-surface);
  z-index: 30;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 1px solid var(--border);
}
#knowledge-panel.visible { transform: translateX(0); }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 1rem; font-weight: 700; }

#knowledge-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.knowledge-file {
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
}

.knowledge-file summary {
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.knowledge-file summary:hover { background: var(--bg-card); }

.knowledge-file pre {
  padding: 12px;
  font-size: 0.75rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-muted);
  max-height: 300px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

/* --- Chat Area --- */
#chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  scroll-behavior: smooth;
  font-size: 14px;
}

#messages {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Welcome message */
.welcome {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}
.welcome .welcome-emoji {
  font-size: 3rem;
  margin-bottom: 12px;
}
.welcome h2 {
  font-size: 1.2rem;
  color: var(--text);
  margin-bottom: 6px;
}
.welcome p {
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Dashboard */
.dashboard {
  padding: 16px;
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 32px;
}
.dash-loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.dash-header {
  margin-bottom: 16px;
}
.dash-greeting h2 {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.dash-date {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Card base */
.dash-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.dash-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.dash-card-icon {
  font-size: 1rem;
}
.dash-card-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* --- Rebuild banner --- */
.dash-rebuild-banner {
  border: 1px solid var(--accent);
  background: rgba(34, 211, 238, 0.08);
}

/* --- Motivation Card --- */
.dash-mantra-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(34, 211, 238, 0.2);
  text-align: center;
  padding: 20px 16px;
  position: relative;
  overflow: hidden;
}
.dash-mantra-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at center, rgba(34, 211, 238, 0.05) 0%, transparent 70%);
  pointer-events: none;
}
.dash-mantra-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}
.dash-mantra-text {
  font-size: 0.95rem;
  font-weight: 600;
  font-style: italic;
  color: var(--text);
  line-height: 1.5;
  position: relative;
}

/* --- Today's Plan Card --- */
.dash-today-card {
  border-left: 3px solid var(--accent);
}
.dash-workout-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card);
  border-radius: 10px;
  margin-bottom: 6px;
  transition: background 0.15s, transform 0.1s;
  cursor: pointer;
}
.dash-workout-item:hover {
  background: var(--border);
  transform: translateX(2px);
}
.dash-workout-item:last-child { margin-bottom: 0; }
.dash-workout-item.done {
  opacity: 0.6;
}
.dash-workout-item.skipped .dash-workout-name {
  text-decoration: line-through;
  opacity: 0.5;
}
.dash-workout-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.dash-workout-name {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
}
.dash-go-btn {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--bg);
  background: var(--accent);
  padding: 4px 12px;
  border-radius: 12px;
  animation: pulse-go 2s ease-in-out infinite;
}
@keyframes pulse-go {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.dash-rest-day {
  text-align: center;
  padding: 16px 8px;
}
.dash-rest-emoji {
  font-size: 2rem;
  margin-bottom: 4px;
}
.dash-rest-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- 7-Day Week Calendar --- */
.dash-weekcal-card {
  padding-bottom: 12px;
}
.dash-weekcal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.week-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 2px 6px;
  border-radius: 10px;
  transition: background 0.15s;
  cursor: pointer;
  position: relative;
}
.week-day:hover {
  background: var(--bg-card);
}
.week-day.is-today {
  background: rgba(34, 211, 238, 0.1);
  border: 1px solid rgba(34, 211, 238, 0.3);
}
.week-day.all-done {
  background: rgba(34, 211, 153, 0.08);
}
.week-day-name {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.week-day.is-today .week-day-name {
  color: var(--accent);
}
.week-day-num {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.week-day.is-today .week-day-num {
  background: var(--accent);
  color: var(--bg);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.week-day-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-bottom: 3px;
}
.dot-empty { background: var(--bg-card); }
.dot-planned { background: var(--orange); }
.dot-done { background: var(--green); }
.dot-partial { background: var(--accent); }
.dot-rest { background: var(--bg-card); border: 1px solid var(--text-muted); }
.week-day-icons {
  font-size: 0.6rem;
  height: 14px;
  color: var(--text-muted);
}

/* --- Week Focus Badge --- */
.dash-week-focus {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}
.dash-focus-badge {
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}
.dash-focus-text {
  font-size: 0.7rem;
  color: var(--text-muted);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Weekly Stats Card --- */
.dash-progress {
  margin-bottom: 12px;
}
.dash-progress-bar {
  height: 10px;
  background: var(--bg-card);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 6px;
}
.dash-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  border-radius: 5px;
  transition: width 0.8s ease;
}
.dash-progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.dash-stats {
  display: flex;
  gap: 8px;
}
.dash-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  padding: 6px 0;
}
.dash-stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}
.dash-stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* --- Countdown Card (standalone) --- */
.dash-chart-container {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.dash-chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.dash-chart-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-bar-chart {
  width: 100%;
  height: auto;
}
.dash-unit-toggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 10px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: background 0.15s;
}
.dash-unit-toggle:hover {
  background: var(--border);
}

/* --- Countdown Card --- */
.dash-countdown-card {
  text-align: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.dash-countdown-top {
  margin-bottom: 10px;
}
.dash-countdown-number {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--orange);
  line-height: 1;
  text-shadow: 0 0 20px rgba(251, 146, 60, 0.3);
}
.dash-countdown-unit {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.dash-countdown-race {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.dash-countdown-flag {
  font-size: 1.4rem;
}
.dash-countdown-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}
.dash-countdown-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* --- Plan Progress Card (full-width) --- */
.dash-plan-progress-card {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid rgba(34, 211, 238, 0.15);
}
.dash-phase-badge {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent);
  background: rgba(34, 211, 238, 0.1);
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.dash-plan-row {
  display: flex;
  align-items: center;
  gap: 20px;
}
.dash-plan-cumulative {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.dash-cum-stat {
  display: flex;
  flex-direction: column;
}
.dash-cum-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.dash-cum-unit {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dash-ring-container {
  position: relative;
  width: 90px;
  height: 90px;
  flex-shrink: 0;
}
.dash-ring {
  width: 90px;
  height: 90px;
}
.dash-ring-bg {
  fill: none;
  stroke: var(--bg-card);
  stroke-width: 8;
}
.dash-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
}
.dash-ring-label {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--accent);
}
.dash-ring-sublabel {
  position: absolute;
  top: 62%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Countdown Card (now standalone) --- */
.dash-countdown-card {
  text-align: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 1px solid rgba(248, 113, 113, 0.2);
}
.dash-event {
  padding: 8px 10px;
  background: var(--bg-card);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s;
}
.dash-event:hover {
  background: var(--border);
}
.dash-empty {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 4px 0;
}
.dash-checkin {
  font-size: 0.95rem;
  font-weight: 600;
}

.welcome .suggestions, .dash-card .suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

.suggestion-chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.suggestion-chip:hover {
  background: var(--border);
  border-color: var(--accent);
}

/* Message bubbles */
.msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: fadeInUp 0.2s ease-out;
}

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

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

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

.msg.user .msg-avatar { background: var(--accent-dim); }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: inherit;
  line-height: 1.6;
  word-break: break-word;
}

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

.msg.user .msg-bubble {
  background: var(--accent-dim);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Markdown in assistant messages */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  margin-top: 12px;
  margin-bottom: 4px;
  font-size: 0.95rem;
}
.msg-bubble h1 { font-size: 1.05rem; }
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin-bottom: 8px; }
.msg-bubble li { margin-bottom: 3px; }
.msg-bubble code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82rem;
}
.msg-bubble pre {
  background: var(--bg);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 0.8rem;
}
.msg-bubble strong { color: var(--accent); }
.msg-bubble em { color: var(--text-muted); font-style: italic; }

/* Tables: desktop = regular table, mobile = stacked cards */
.table-desktop { display: none; }
.table-mobile { display: block; }
@media (min-width: 640px) {
  .table-desktop { display: block; }
  .table-mobile { display: none; }
}
.msg-bubble table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 0.8rem; }
.msg-bubble th, .msg-bubble td { padding: 6px 8px; border: 1px solid var(--border); text-align: left; }
.msg-bubble th { background: var(--bg); font-weight: 600; }

/* Mobile table cards */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.table-card:last-child { margin-bottom: 0; }
.table-card-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.table-card-row:last-child { border-bottom: none; }
.table-card-label { color: var(--text-dim); font-weight: 600; font-size: 0.75rem; }
.table-card-value { text-align: right; color: var(--text); }

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  min-height: 36px;
}
.typing-indicator span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.4s infinite ease-in-out both;
  flex-shrink: 0;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
.working-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}
.working-indicator .typing-indicator {
  padding: 0;
}

/* --- Input Bar --- */
#input-bar {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  padding-bottom: calc(8px + var(--sab));
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#msg-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  overflow-y: auto;
  outline: none;
  transition: border-color 0.15s;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
#msg-input::-webkit-scrollbar { display: none; }
#msg-input:focus { border-color: var(--accent); }
#msg-input::placeholder { color: var(--text-muted); }

#btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#btn-send:hover { background: var(--accent-dim); }
#btn-send:active { transform: scale(0.92); }
#btn-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Utilities --- */
.hidden { display: none !important; }

/* On desktop, sidebar should always be visible even with .hidden class */
@media (min-width: 1024px) {
  #sidebar.hidden { display: flex !important; }
}

/* Error toast */
.error-toast {
  position: fixed;
  bottom: calc(var(--input-h) + 20px + var(--sab));
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 100;
  animation: fadeInUp 0.25s ease-out;
  box-shadow: 0 4px 12px var(--shadow);
}
.success-toast {
  position: fixed;
  bottom: calc(var(--input-h) + 20px + var(--sab));
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #0f172a;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  z-index: 100;
  animation: fadeInUp 0.25s ease-out;
  box-shadow: 0 4px 12px var(--shadow);
}

/* --- Responsive --- */
@media (min-width: 640px) {
  #messages { padding: 20px 0; }
  .msg { max-width: 75%; }
}

/* --- Calendar Panel --- */
#calendar-panel {
  position: fixed;
  top: 0; right: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  border-left: 1px solid var(--border);
  overflow: hidden;
}
#calendar-panel.visible { transform: translateX(0); }
#calendar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 55;
  opacity: 0;
  transition: opacity 0.3s;
}
#calendar-overlay.visible { opacity: 1; }

#calendar-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
#cal-month-label {
  font-weight: 700;
  font-size: 1.15rem;
  min-width: 160px;
  text-align: center;
}
.btn-sm { font-size: 0.8rem; padding: 5px 12px; }

#calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: auto;
  grid-auto-rows: 1fr;
  gap: 1px;
  padding: 0;
  background: var(--border);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.cal-header-cell {
  background: var(--surface);
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  padding: 6px 0;
  text-transform: uppercase;
}
.cal-cell {
  background: var(--bg);
  padding: 2px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.cal-cell:hover { background: var(--surface); }
.cal-cell.other-month { opacity: 0.35; }
.cal-cell.other-month .cal-day-num { color: var(--text-dim); }
.cal-cell.today { background: transparent; }
.cal-cell.selected { background: var(--surface); }

.cal-day-num {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  margin: 0 auto 1px;
}
.cal-cell.today .cal-day-num {
  background: var(--accent);
  color: white;
}
.cal-events {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.cal-event {
  font-size: 0.5rem;
  line-height: 1.1;
  padding: 1px 2px;
  border-radius: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
}
.cal-event.race { background: #ff6b35; color: white; font-weight: 700; }
.cal-event.travel { background: #70ad47; color: white; }
.cal-event.activity { background: #4472c4; color: white; }
.cal-event.log { background: #7c3aed; color: white; }
.cal-event.plan { background: #3b82f6; color: white; }
.cal-event.plan-gym { background: #f59e0b; color: #1a1a1a; }
.cal-event.plan-long { background: #06b6d4; color: white; font-weight: 600; }
.cal-event.plan-hard { background: #ef4444; color: white; font-weight: 600; }
.cal-event.plan-rest { background: #6b7280; color: white; }
.cal-event.skipped { text-decoration: line-through; opacity: 0.5; }
.cal-event.workout { background: #f59e0b; color: #1a1a1a; font-weight: 600; cursor: pointer; }
.cal-event.workout:hover { background: #d97706; }

/* --- Workout Detail Panel --- */
#workout-panel {
  position: fixed;
  top: 0; right: 0;
  width: 100vw;
  height: 100vh;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}
#workout-panel.visible { transform: translateX(0); }
#workout-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 190;
  opacity: 0;
  transition: opacity 0.3s;
}
#workout-overlay.visible { opacity: 1; }

.workout-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.workout-header h2 { font-size: 1.1rem; }
.workout-date { font-size: 0.85rem; color: var(--text-dim); margin-top: 2px; }
.workout-status {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
}
.workout-status.planned { background: #f59e0b; color: #1a1a1a; }
.workout-status.completed { background: #22c55e; color: white; }

.workout-exercises {
  padding: 12px 20px;
  flex: 1;
}
.workout-exercise {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.exercise-header {
  padding: 10px 14px;
  background: var(--surface);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.exercise-demo-link {
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.exercise-demo-link:hover, .exercise-demo-link:active {
  color: var(--accent);
}
.demo-icon {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-left: 4px;
}
.exercise-demo-link:hover .demo-icon {
  color: var(--accent);
}
/* Exercise demo popup */
.demo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9998;
}
.demo-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #1a1a2e;
  border-radius: 16px;
  max-width: 400px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  z-index: 9999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.demo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px 8px;
}
.demo-header h3 {
  margin: 0;
  font-size: 1.05rem;
  text-transform: capitalize;
}
.demo-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px 8px;
}
.demo-gif {
  width: 100%;
  border-radius: 0;
  display: block;
}
.demo-meta {
  padding: 6px 16px;
  font-size: 0.82rem;
  color: var(--text-dim);
  text-transform: capitalize;
}
.demo-instructions {
  padding: 8px 16px 16px 32px;
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text);
}
.demo-instructions li {
  margin-bottom: 4px;
}
.demo-loading {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-dim);
}
.exercise-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
}
.exercise-cues {
  padding: 6px 14px;
  font-size: 0.8rem;
  color: var(--accent);
  font-style: italic;
  border-bottom: 1px solid var(--border);
}
.exercise-sets {
  padding: 0;
}
.set-row {
  display: grid;
  grid-template-columns: 50px 1fr 1fr 1fr;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 0.85rem;
}
.set-row:last-child { border-bottom: none; }
.set-row.header {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
}
.set-row input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  text-align: center;
}
.set-row input:focus { border-color: var(--accent); outline: none; }
.set-label { font-weight: 600; text-align: center; }

.workout-actions {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}
.workout-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  border: none;
}
.btn-start-workout { background: var(--accent); color: white; }
.btn-start-workout:hover { opacity: 0.9; }
.btn-complete-workout { background: #22c55e; color: white; }
.btn-complete-workout:hover { opacity: 0.9; }
.btn-skip-workout { background: var(--surface); color: var(--text-dim); border: 1px solid var(--border) !important; }

#calendar-details {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 20px;
  background: var(--bg);
  overflow-y: auto;
  z-index: 10;
  display: none;
}
#calendar-details.visible {
  display: block;
}
#calendar-details .cal-detail-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
#calendar-details .cal-detail-arrows {
  display: flex;
  gap: 8px;
}
#calendar-details .cal-detail-arrow {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#calendar-details .cal-detail-arrow:hover {
  background: var(--accent);
  color: white;
}
#calendar-details .cal-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  font-weight: 600;
}
#calendar-details h3 {
  font-size: 1.2rem;
  margin-bottom: 14px;
  color: var(--accent);
}
.cal-detail-item {
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.95rem;
  line-height: 1.5;
}
.cal-detail-item:last-child { margin-bottom: 0; }
.cal-detail-title { font-weight: 700; margin-bottom: 4px; font-size: 1rem; }
.cal-detail-body {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.5;
}
.cal-detail-body strong { color: var(--accent); }
.cal-detail-body p { margin-bottom: 6px; }
.cal-detail-body p:last-child { margin-bottom: 0; }
.cal-detail-body ul { padding-left: 18px; margin-bottom: 6px; }
.cal-detail-body li { margin-bottom: 2px; }

/* Calendar event action buttons */
.cal-event-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.cal-action-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.cal-action-btn:hover { background: var(--accent); color: white; border-color: var(--accent); }
.cal-action-skip:hover { background: #e6a817; border-color: #e6a817; }
.cal-action-delete:hover { background: var(--red); border-color: var(--red); }

/* --- Settings Panel --- */

/* --- Weekly Review Card --- */
.dash-review-card {
  background: linear-gradient(135deg, #1a2332 0%, #162030 100%);
  border: 2px solid var(--accent);
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  animation: pulse-border 2s ease-in-out infinite;
}
@keyframes pulse-border {
  0%, 100% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); }
  50% { border-color: var(--accent); box-shadow: 0 0 12px 2px rgba(34, 211, 238, 0.15); }
}
.dash-review-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 8px;
}
.dash-review-icon {
  font-size: 1.8rem;
}
.dash-review-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}
.dash-review-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.dash-review-prompt {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  padding: 4px 16px 12px;
}
.dash-review-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 16px 16px;
}
.dash-review-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: left;
}
.dash-review-btn:hover {
  background: var(--bg-card);
  transform: translateY(-1px);
}
.dash-review-btn:active {
  transform: translateY(0);
}
.dash-review-btn-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}
.dash-review-good:hover { border-color: var(--green); }
.dash-review-ok:hover { border-color: var(--accent); }
.dash-review-sore:hover { border-color: var(--orange); }
.dash-review-hard:hover { border-color: var(--red); }
.dash-review-easy:hover { border-color: var(--accent); }
.dash-review-life:hover { border-color: var(--orange); }

@media (max-width: 380px) {
  .dash-review-options {
    grid-template-columns: 1fr;
  }
}

/* --- Settings Panel --- */
#settings-panel {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: min(400px, 90vw);
  max-height: 80vh;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  z-index: 201;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}
#settings-panel.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
#settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.25s;
}
#settings-overlay.visible { opacity: 1; }
.settings-content {
  padding: 16px 20px 24px;
}
.settings-group {
  margin-bottom: 20px;
}
.settings-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.settings-toggle-row {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.settings-opt {
  flex: 1;
  padding: 10px 12px;
  border: none;
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.settings-opt:not(:last-child) {
  border-right: 1px solid var(--border);
}
.settings-opt.active {
  background: var(--accent);
  color: var(--bg);
}
.settings-opt:hover:not(.active) {
  background: var(--bg-card);
  color: var(--text);
}
.settings-push-status {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 0;
}

/* Manual log workout button */
.cal-log-workout-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 12px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: none;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.cal-log-workout-btn:hover {
  background: rgba(34, 211, 238, 0.08);
  border-color: var(--accent);
}

@media (min-width: 1024px) {
  #sidebar {
    position: relative;
    transform: none !important;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
  }
  #sidebar-overlay { display: none !important; }
  #btn-sidebar { display: none; }
  #app {
    flex-direction: row;
  }
  #app > :not(#sidebar):not(#sidebar-overlay):not(#knowledge-overlay):not(#knowledge-panel) {
    flex: 1;
    min-width: 0;
  }
  /* Stack the main column */
  #app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: auto 1fr auto;
  }
  #sidebar {
    grid-row: 1 / -1;
    grid-column: 1;
  }
  #topbar { grid-column: 2; grid-row: 1; }
  #chat-area { grid-column: 2; grid-row: 2; }
  #input-bar { grid-column: 2; grid-row: 3; }
}
