/* ============================================
   Coach-Me - Running Coach AI
   Modern, clean design with fitness aesthetic
   ============================================ */

:root {
  /* Primary palette - teal/green fitness feel */
  --accent: #00d4aa;
  --accent-hover: #00e8bb;
  --accent-dim: #00b894;
  --accent-glow: rgba(0, 212, 170, 0.15);
  --accent-subtle: rgba(0, 212, 170, 0.08);

  /* Surface hierarchy (3 levels) */
  --surface-0: #0d1117;
  --surface-1: #151d2b;
  --surface-2: #1c2536;
  --surface-3: #243044;

  /* Dark sidebar */
  --sidebar-bg: #121820;
  --sidebar-surface: var(--surface-1);
  --sidebar-hover: var(--surface-2);
  --sidebar-text: #a0aec0;
  --sidebar-text-bright: #e2e8f0;

  /* Dark content area (was light) */
  --chat-bg: var(--surface-0);
  --chat-surface: var(--surface-1);
  --chat-border: rgba(255, 255, 255, 0.06);

  /* Text (dark theme) */
  --text-primary: #e2e8f0;
  --text-secondary: #a0aec0;
  --text-muted: #a0aec0;
  --text: var(--text-primary);

  /* Messages */
  --msg-user-bg: #00d4aa;
  --msg-user-text: #0a1628;
  --msg-assistant-bg: var(--surface-1);
  --msg-assistant-text: #e2e8f0;
  --msg-assistant-border: rgba(255, 255, 255, 0.06);

  /* Surfaces — aliases to new tokens */
  --card-bg: var(--surface-1);
  --surface: var(--surface-1);
  --bg-secondary: var(--surface-1);
  --border: rgba(255, 255, 255, 0.06);

  /* Misc */
  --danger: #e53e3e;
  --warning: #ed8936;
  --success: #00d4aa;
  --accent-warning: #f0b429;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Typography scale */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-lg: 18px;
  --text-xl: 24px;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;

  /* Layout */
  --sidebar-width: 240px;
  --header-height: 60px;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--chat-bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  font-size: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

/* ============================================
   Auth Page
   ============================================ */

#auth-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0d1117 0%, #121820 40%, #1a2230 100%);
  padding: 20px;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 40px;
}

.auth-logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 16px;
  box-shadow: 0 8px 32px rgba(0, 212, 170, 0.25);
}

.auth-logo h1 {
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-logo p {
  color: var(--sidebar-text);
  font-size: 14px;
  margin-top: 4px;
}

.auth-card {
  background: var(--sidebar-surface);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 28px;
  background: var(--sidebar-bg);
  border-radius: var(--radius-sm);
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 14px;
  border-radius: var(--radius-xs);
  transition: var(--transition);
}

.auth-tab:hover {
  color: var(--sidebar-text-bright);
}

.auth-tab.active {
  background: var(--accent);
  color: var(--msg-user-text);
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.auth-form.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  color: var(--sidebar-text);
  font-weight: 500;
}

.form-group input {
  background: var(--sidebar-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: #fff;
  transition: var(--transition);
}

.form-group input::placeholder {
  color: var(--text-muted);
}

.form-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: var(--msg-user-text);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 212, 170, 0.3);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-outline {
  background: transparent;
  color: var(--sidebar-text-bright);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-subtle);
}

.btn-strava {
  background: #fc4c02;
  color: #fff;
}

.btn-strava:hover {
  background: #e8440a;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(252, 76, 2, 0.3);
}

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

.btn-danger:hover {
  background: #c53030;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-block {
  width: 100%;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  padding: 10px 14px;
  background: rgba(229, 62, 62, 0.1);
  border-radius: var(--radius-xs);
  display: none;
}

.auth-error.visible {
  display: block;
}

/* ============================================
   App Layout (post-login)
   ============================================ */

#app-view {
  display: none;
  height: 100vh;
  height: 100dvh;
}

#app-view.active {
  display: flex;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-brand h2 {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-brand span {
  color: var(--sidebar-text);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-bright);
}

.nav-item.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.nav-item .nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  margin: 8px 6px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--sidebar-surface);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--msg-user-text);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  color: var(--sidebar-text-bright);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  color: var(--sidebar-text);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-logout {
  background: none;
  color: var(--sidebar-text);
  padding: 6px;
  border-radius: var(--radius-xs);
  font-size: 16px;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-logout:hover {
  color: var(--danger);
  background: rgba(229, 62, 62, 0.1);
}

/* ============================================
   Main Content Area
   ============================================ */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.content-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  background: var(--surface-0);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.content-header h1 {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

.header-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: var(--space-2);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-action {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 16px;
  transition: var(--transition);
}

.header-action:hover {
  background: var(--surface-2);
  color: var(--text-primary);
}

.mobile-menu-btn {
  display: none;
  padding: 8px;
  font-size: 22px;
  color: var(--text-secondary);
}

/* ============================================
   Chat View
   ============================================ */

.view-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.view-panel.active {
  display: flex;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--chat-border);
  border-radius: 3px;
}

.chat-welcome {
  text-align: center;
  padding: 60px 20px;
  max-width: 480px;
  margin: auto;
}

.chat-welcome-icon {
  font-size: 56px;
  margin-bottom: 20px;
}

.chat-welcome h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-welcome p {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.7;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 720px;
  animation: messageIn 0.3s ease;
}

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

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

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 4px;
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
}

.message.user .message-avatar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text-bright);
  font-size: 13px;
  font-weight: 700;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 14px;
  word-wrap: break-word;
}
.message.user .message-bubble { white-space: pre-wrap; }
/* Markdown rendering in assistant bubbles */
.message.assistant .message-bubble p { margin: 0.4em 0; }
.message.assistant .message-bubble p:first-child { margin-top: 0; }
.message.assistant .message-bubble p:last-child { margin-bottom: 0; }
.message.assistant .message-bubble h2, .message.assistant .message-bubble h3 { margin: 0.8em 0 0.3em; font-size: 1.05em; }
.message.assistant .message-bubble ul, .message.assistant .message-bubble ol { margin: 0.3em 0; padding-left: 1.5em; }
.message.assistant .message-bubble li { margin: 0.2em 0; }
.message.assistant .message-bubble table { border-collapse: collapse; margin: 0.5em 0; font-size: 0.9em; width: 100%; }
.message.assistant .message-bubble th, .message.assistant .message-bubble td { border: 1px solid var(--border, #444); padding: 4px 8px; text-align: left; }
.message.assistant .message-bubble th { background: rgba(255,255,255,0.05); font-weight: 600; }
.message.assistant .message-bubble code { background: rgba(255,255,255,0.08); padding: 1px 4px; border-radius: 3px; font-size: 0.9em; }
.message.assistant .message-bubble strong { color: var(--text-primary, #fff); }
.message.assistant .message-bubble hr { border: none; border-top: 1px solid var(--border, #444); margin: 0.8em 0; }

.message.assistant .message-bubble {
  background: var(--surface-1);
  color: var(--msg-assistant-text);
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: 4px 16px 16px 16px;
  box-shadow: none;
  max-width: 85%;
}

.message.user .message-bubble {
  background: var(--msg-user-bg);
  color: var(--msg-user-text);
  border-radius: 16px 16px 4px 16px;
  max-width: 75%;
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.message.user .message-time {
  text-align: right;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 4px;
  padding: 0 4px;
}
.message.user .message-meta { justify-content: flex-end; }

.msg-delete-from-here,
.msg-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.4;
  transition: opacity 0.2s, background 0.2s;
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.message.user:hover .msg-delete-from-here,
.message.user:hover .msg-edit {
  opacity: 0.8;
}

.msg-delete-from-here:hover,
.msg-edit:hover {
  opacity: 1 !important;
  background: var(--surface);
}

/* Touch devices: no hover, keep actions fully visible */
@media (hover: none) {
  .msg-delete-from-here,
  .msg-edit {
    opacity: 0.8;
  }
}

.edit-textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.edit-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
}

.edit-cancel, .edit-submit {
  padding: 4px 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
}

.edit-cancel {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.edit-submit {
  background: var(--accent);
  color: white;
}

/* Coach Thinking */
.coach-thinking {
  margin: 0.75rem 1rem;
  padding: 1rem 1.25rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.05));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-left: 3px solid rgba(99, 102, 241, 0.5);
  font-size: 0.85rem;
  color: var(--text-secondary, #bbb);
  min-height: 120px;
  max-height: 40vh;
  overflow-y: auto;
  animation: thinkingAppear 0.4s ease;
  scroll-behavior: smooth;
}
.coach-thinking.active {
  border-left-color: rgba(99, 102, 241, 0.8);
  animation: thinkingAppear 0.4s ease, thinkingPulse 3s ease-in-out infinite;
}
.thinking-header {
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: rgba(139, 92, 246, 0.9);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.thinking-header::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.8);
  animation: thinkingDot 1.5s ease-in-out infinite;
}
.thinking-content {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  font-family: inherit;
}
@keyframes thinkingAppear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes thinkingPulse { 0%, 100% { border-left-color: rgba(99, 102, 241, 0.4); } 50% { border-left-color: rgba(139, 92, 246, 0.8); } }
@keyframes thinkingDot { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Typing indicator */
.typing-indicator {
  display: none;
  gap: 12px;
  max-width: 720px;
  padding: 0;
  animation: messageIn 0.3s ease;
}

.typing-indicator.visible {
  display: flex;
}

.typing-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 16px 18px;
  background: var(--surface-1);
  border: none;
  border-left: 3px solid var(--accent);
  border-radius: 4px 16px 16px 16px;
  box-shadow: none;
}

.typing-status {
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 4px;
  animation: fadeIn 0.2s ease;
}

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

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* Chat input */
.chat-input-area {
  padding: 16px 24px 24px;
  background: var(--chat-bg);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2);
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow), var(--shadow);
}

.chat-input {
  flex: 1;
  resize: none;
  border: none;
  background: none;
  min-height: 24px;
  max-height: 120px;
  padding: 8px 0;
  color: var(--text-primary);
  line-height: 1.5;
}

.chat-input::placeholder {
  color: var(--text-muted);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface-0);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  transition: var(--transition);
}

.chat-send-btn:hover { background: var(--accent-hover); }

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ============================================
   Profile View
   ============================================ */

.scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  max-width: 900px;
}

.profile-card {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.profile-card h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.profile-card .value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.profile-card .value.accent {
  color: var(--accent);
}

.profile-card .value.empty {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 400;
  font-style: italic;
}

.profile-section {
  margin-bottom: 32px;
}

.profile-section h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-section h2 .section-icon {
  font-size: 20px;
}

.strava-connect-card {
  background: linear-gradient(135deg, #fc4c02 0%, #e8440a 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(252, 76, 2, 0.2);
}

.strava-connect-card.connected {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
}

.strava-connect-card .strava-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.strava-connect-card .strava-info h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  text-transform: none;
  letter-spacing: 0;
  margin-bottom: 4px;
}

.strava-connect-card .strava-info p {
  font-size: 13px;
  opacity: 0.85;
}

.strava-connect-card .btn {
  margin-left: auto;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.strava-connect-card .btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.strava-sync-buttons {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.strava-sync-buttons .btn-outline {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.5);
  opacity: 0.85;
}

.strava-sync-buttons .btn-outline:hover {
  background: rgba(255, 255, 255, 0.15);
  opacity: 1;
}

/* Sync progress overlay */
.sync-progress-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

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

.sync-progress-modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.sync-progress-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.sync-progress-icon {
  font-size: 28px;
  animation: bounce 1s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.sync-progress-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.sync-progress-bar-track {
  background: var(--surface);
  border-radius: 8px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.sync-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 8px;
  width: 0%;
  transition: width 0.4s ease;
}

.sync-progress-bar-fill.complete {
  background: linear-gradient(90deg, var(--accent), #2ecc71);
}

.sync-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
}

.sync-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.sync-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.sync-stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sync-status-text {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ============================================
   Sync Banner (Activities View)
   ============================================ */

.sync-banner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.sync-banner:empty {
  display: none;
}

.sync-global-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: var(--msg-user-text);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 6px;
}
.sync-global-btn:hover { background: var(--accent-hover); }
.sync-global-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.sync-source {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.sync-source-indicator {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  font-size: 12px;
}
.sync-source-indicator.syncing { color: var(--accent); }
.sync-source-indicator.done { color: var(--success); }
.sync-source-indicator.error { color: var(--danger); }

.sync-source-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.sync-source-info {
  flex: 1;
  min-width: 0;
}

.sync-source-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.sync-source-status {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-source-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.sync-source-actions .btn {
  padding: 6px 10px;
  font-size: 12px;
}

.sync-source-chevron {
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.sync-source-chevron.open { transform: rotate(90deg); }

.sync-source-options {
  display: none;
  gap: 4px;
  padding: 4px 0 0 36px;
  width: 100%;
}
.sync-source-options.open { display: flex; flex-wrap: wrap; }

.sync-source-options .btn-xs {
  padding: 4px 8px;
  font-size: 11px;
}

.sync-source.disconnected {
  border-style: dashed;
  opacity: 0.7;
}

.sync-source.disconnected:hover {
  opacity: 1;
  border-color: var(--accent);
}

/* ============================================
   Activities View
   ============================================ */

.activities-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 900px;
}

.activity-card {
  background: var(--chat-surface);
  border: 1px solid var(--chat-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
  cursor: pointer;
}

.activity-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px var(--accent-glow);
}

/* Card hover lift (desktop only) */
@media (hover: hover) {
  .profile-section:hover,
  .activity-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
  }
}

.activity-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.activity-main {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.activity-date {
  font-size: 12px;
  color: var(--text-muted);
}

.activity-stats {
  display: flex;
  gap: 20px;
  flex-shrink: 0;
}

.activity-stat {
  text-align: right;
}

.activity-stat .stat-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.activity-stat .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  max-width: 380px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ============================================
   Loading states
   ============================================ */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--chat-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex: 1;
}

/* ============================================
   Overlay for mobile sidebar
   ============================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}

.sidebar-overlay.visible {
  display: block;
}

.load-more-container {
  text-align: center;
  padding: 16px 0;
}

.load-more-container .btn {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 10px 24px;
}

.load-more-container .btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.activities-total {
  text-align: center;
  padding: 12px 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================
   Skeleton Loading
   ============================================ */

.skeleton {
  background: var(--surface);
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent);
  animation: shimmer 1.5s infinite;
}

.skeleton-card {
  height: 80px;
  width: 100%;
}

.skeleton-text {
  height: 16px;
  width: 60%;
}

.skeleton-bar {
  height: 72px;
  width: 100%;
}

.skeleton-hero {
  height: 100px;
  width: 100%;
  border-radius: var(--radius);
}

/* ============================================
   Animations (shared)
   ============================================ */

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

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

.profile-card,
.activity-card {
  animation: staggerIn 0.3s ease backwards;
}

.profile-card:nth-child(1), .activity-card:nth-child(1) { animation-delay: 0ms; }
.profile-card:nth-child(2), .activity-card:nth-child(2) { animation-delay: 50ms; }
.profile-card:nth-child(3), .activity-card:nth-child(3) { animation-delay: 100ms; }
.profile-card:nth-child(4), .activity-card:nth-child(4) { animation-delay: 150ms; }
.profile-card:nth-child(5), .activity-card:nth-child(5) { animation-delay: 200ms; }
.profile-card:nth-child(6), .activity-card:nth-child(6) { animation-delay: 250ms; }
.profile-card:nth-child(7), .activity-card:nth-child(7) { animation-delay: 300ms; }
.profile-card:nth-child(8), .activity-card:nth-child(8) { animation-delay: 350ms; }
.profile-card:nth-child(9), .activity-card:nth-child(9) { animation-delay: 400ms; }
.profile-card:nth-child(10), .activity-card:nth-child(10) { animation-delay: 450ms; }

.view-panel.active {
  animation: fadeIn 0.2s ease;
}

/* ============================================
   Auto-fill Indicators
   ============================================ */

.profile-card {
  position: relative;
}

.auto-fill-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 12px;
  opacity: 0.6;
  cursor: help;
}

/* ============================================
   Mobile Bottom Tab Bar
   ============================================ */

.bottom-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 10px;
  min-height: 44px;
  transition: var(--transition);
}

.bottom-tab-icon { font-size: 18px; }
.bottom-tab-label { font-size: 10px; }
.bottom-tab.active { color: var(--accent); }

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  .sidebar {
    display: none;
  }

  .bottom-bar {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding-bottom: calc(56px + env(safe-area-inset-bottom));
  }

  .mobile-menu-btn {
    display: none;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-input-area {
    padding: 12px 16px 16px;
  }

  .activity-stats {
    gap: 12px;
  }

  .activity-stat .stat-value {
    font-size: 13px;
  }

  .profile-grid {
    grid-template-columns: 1fr;
  }

  .content-header {
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .scroll-content {
    padding: 16px;
  }

  .strava-connect-card {
    flex-direction: column;
    text-align: center;
  }

  .strava-connect-card .btn {
    margin-left: 0;
    width: 100%;
  }

  .dash-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .week-navigator {
    flex-direction: column;
    gap: var(--space-3);
  }

  .week-summary {
    justify-content: space-around;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .activity-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .activity-stats {
    width: 100%;
    justify-content: space-between;
  }

  .activity-stat {
    text-align: left;
  }
}

/* ---- Stryd / Shoes ---- */

.stryd-connect-card {
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.2);
}

.stryd-connect-card.connected {
  background: var(--chat-surface);
  color: var(--text-primary);
  border: 1px solid var(--chat-border);
  box-shadow: var(--shadow);
}

.stryd-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stryd-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.stryd-info {
  flex: 1;
}

.stryd-info h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.stryd-info p {
  font-size: 13px;
  color: var(--text-secondary);
}

.stryd-connect-card:not(.connected) .stryd-info h3,
.stryd-connect-card:not(.connected) .stryd-info p {
  color: #fff;
}

.stryd-connect-card:not(.connected) .stryd-info p {
  opacity: 0.85;
}

.stryd-connect-card:not(.connected) .btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.stryd-buttons {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.shoes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.shoe-card {
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  border-radius: 8px;
  padding: 10px 12px;
  position: relative;
}

.shoe-card.default {
  border-color: var(--accent);
}

.shoe-card.warn {
  border-color: #f39c12;
}

.shoe-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shoe-stats {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.shoe-bar-track {
  height: 4px;
  background: var(--chat-border);
  border-radius: 2px;
  overflow: hidden;
}

.shoe-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

.shoe-bar-fill.warn {
  background: #f39c12;
}

.shoe-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.shoe-card.retired {
  opacity: 0.45;
  border-color: var(--chat-border);
}

.shoe-card.retired .shoe-bar-fill {
  background: var(--text-muted);
}

.shoes-retired-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 0;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
}

.shoes-retired-toggle:hover {
  color: var(--text-secondary);
}

.shoes-retired-toggle .toggle-arrow {
  transition: transform 0.2s;
  display: inline-block;
}

.shoes-retired-toggle.open .toggle-arrow {
  transform: rotate(90deg);
}

.shoes-retired-grid {
  display: none;
}

.shoes-retired-grid.open {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

/* ============================================
   Tooltips
   ============================================ */

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  padding: 6px 10px;
  background: var(--sidebar-bg);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  width: max-content;
  max-width: 250px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 50;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

@media (max-width: 768px) {
  [data-tooltip]::after {
    max-width: 180px;
  }
}

@media (max-width: 640px) {
  .stryd-header {
    flex-wrap: wrap;
  }

  .stryd-buttons {
    width: 100%;
    margin-top: 8px;
  }

  .shoes-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Dashboard Tabs
   ============================================ */

.dash-tabs {
  display: flex;
  gap: 2px;
  padding: var(--space-4) var(--space-4) 0;
  background: var(--surface-0);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.dash-tabs::-webkit-scrollbar { display: none; }

.dash-tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
  transition: var(--transition);
  background: none;
  border: none;
  cursor: pointer;
}
.dash-tab:hover { color: var(--text-primary); background: var(--surface-1); }
.dash-tab.active { color: var(--accent); background: var(--surface-1); border-bottom: 2px solid var(--accent); }

.dash-tab-content {
  flex: 1;
  overflow-y: auto;
  background: var(--surface-1);
  margin: 0 var(--space-4) var(--space-4);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: var(--space-4);
}

.dash-tab-panel { display: none; }
.dash-tab-panel.active { display: block; animation: fadeIn 150ms ease; }

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

.dash-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  gap: var(--space-4);
  color: var(--text-muted);
}

.trends-period-selector {
  display: flex;
  gap: var(--space-1);
  justify-content: flex-end;
  margin-bottom: var(--space-3);
}
.period-btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  transition: var(--transition);
  background: none;
  border: none;
  cursor: pointer;
}
.period-btn:hover { background: var(--surface-2); }
.period-btn.active { background: var(--surface-3); color: var(--accent); }

/* ---- Dashboard Analysis ---- */
.dash-analysis-title { color: var(--accent); font-weight: 600; margin-bottom: 12px; }
.dash-insight {
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  margin-bottom: 12px;
  background: rgba(0, 212, 170, 0.05);
  border-radius: 0 8px 8px 0;
}
.dash-insight.warning { border-color: #ffd93d; background: rgba(255, 217, 61, 0.05); }
.dash-insight.positive { border-color: #4ecdc4; background: rgba(78, 205, 196, 0.05); }
.dash-insight-title { color: var(--text-primary); font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.dash-insight-body { color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.dash-insight-sources { color: var(--text-muted); font-size: 11px; font-style: italic; margin-top: 6px; }
.dash-insight-loading { color: var(--text-muted); text-align: center; padding: 20px; }

/* Responsive — dashboard */
@media (max-width: 768px) {
  .dash-tabs { padding: var(--space-2) var(--space-2) 0; }
  .dash-tab-content { margin: 0 var(--space-2) var(--space-2); padding: var(--space-3); }
}

/* ---- Biomechanics Panel ---- */
.biomech-panel { margin-bottom: 16px; padding: 1rem; border-radius: var(--radius); background: var(--card-bg); border: 1px solid var(--border); }
.biomech-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; font-weight: 600; color: var(--text-primary); }
.biomech-coverage { font-size: 0.8rem; color: var(--text-muted); }
.biomech-metric { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.biomech-metric:last-child { margin-bottom: 0; }
.biomech-label { width: 120px; font-size: 0.875rem; color: var(--text-secondary); }
.biomech-bar { flex: 1; height: 8px; background: var(--surface); border-radius: 4px; overflow: hidden; }
.biomech-bar-fill { height: 100%; border-radius: 4px; transition: width 0.5s ease; }
.biomech-bar-fill.ok { background: var(--success); }
.biomech-bar-fill.warning { background: var(--warning); }
.biomech-bar-fill.danger { background: var(--danger); }
.biomech-value { width: 100px; text-align: right; font-size: 0.875rem; color: var(--text-primary); }
.biomech-note { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.75rem; font-style: italic; }

@media (max-width: 768px) {
  .biomech-label { width: 90px; font-size: 0.8rem; }
  .biomech-value { width: 80px; font-size: 0.8rem; }
}

/* ============================================
   Conversation Sidebar
   ============================================ */

.chat-layout {
  display: flex;
  height: 100%;
}

.conv-sidebar {
  width: 220px;
  min-width: 220px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
}

.conv-sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

.conv-new-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: var(--surface-0);
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.conv-new-btn:hover { opacity: 0.8; }

.conv-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.conv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  transition: background 0.15s;
  margin-bottom: 2px;
}

.conv-item:hover { background: var(--sidebar-hover); }
.conv-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 500; }

.conv-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.conv-item-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.conv-item:hover .conv-item-delete { opacity: 1; }
.conv-item-delete:hover { color: var(--danger); }

.conv-item-clear {
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 0.75rem;
  padding: 2px 4px;
}

.conv-item:hover .conv-item-clear {
  opacity: 0.6;
}

.conv-item-clear:hover {
  opacity: 1 !important;
}

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ============================================
   Date Separators
   ============================================ */

.date-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 8px;
}

.date-separator::before,
.date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.date-separator-text {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Error toast for chat errors (e.g. Claude unavailable) */
.error-toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  margin: 8px 16px;
  background: rgba(229, 62, 62, 0.15);
  border: 1px solid rgba(229, 62, 62, 0.4);
  border-radius: var(--radius-sm);
  color: #fc8181;
  font-size: 14px;
  animation: fadeIn 0.2s ease;
}

.error-toast-text {
  flex: 1;
}

.error-toast-close {
  flex-shrink: 0;
  color: #fc8181;
  font-size: 18px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.error-toast-close:hover {
  opacity: 1;
}

/* Mobile: hide conversation sidebar */
@media (max-width: 768px) {
  .conv-sidebar { display: none; }
}

/* ============================================
   Diagnostics
   ============================================ */

.diagnostics-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.diagnostics-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.diagnostics-filters select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.85rem;
}

.diagnostics-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  height: calc(100vh - 140px);
  overflow: hidden;
}

.diagnostics-list {
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 0.5rem;
}

.diagnostics-detail {
  overflow-y: auto;
  padding: 1rem;
}

.diag-item {
  background: var(--surface-1);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  cursor: pointer;
  margin-bottom: var(--space-1);
  transition: var(--transition);
}

.diag-item:hover {
  background: var(--surface-2);
}

.diag-item.active {
  background: var(--surface-3);
  border-left: 3px solid var(--accent);
}

.diag-item-header {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.diag-item-title {
  font-weight: 500;
  font-size: 0.9rem;
}

.diag-item-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.diag-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

.diag-badge-critical { background: #dc354520; color: #dc3545; }
.diag-badge-warning { background: #ffc10720; color: #ffc107; }
.diag-badge-info { background: #0d6efd20; color: #0d6efd; }
.diag-badge-resolved { background: #19875420; color: #198754; }

.diag-type {
  font-size: var(--text-xs);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

.diag-finding-type {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.diag-detail-content {
  background: var(--surface-1);
  border-radius: var(--radius);
  padding: var(--space-5);
}

.diag-detail-content h3 {
  margin: 0.75rem 0;
}

.diag-detail-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.diag-section {
  margin: 1rem 0;
}

.diag-section h4 {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.diag-markdown {
  line-height: 1.6;
}

.diag-actions {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.diag-actions textarea {
  width: 100%;
  padding: var(--space-2);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-primary);
  resize: vertical;
  margin-bottom: var(--space-2);
}

.diag-action-buttons {
  display: flex;
  gap: 0.5rem;
}

.diag-resolved-info {
  margin-top: var(--space-4);
  padding: var(--space-3);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

.nav-badge {
  font-size: 0.65rem;
  background: #dc3545;
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 10px;
  margin-left: 0.25rem;
}

.sidebar-danger-zone {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-danger-zone {
  margin-top: 2rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(231, 76, 60, 0.03);
}

.danger-zone-title {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.danger-zone-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reset-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  text-align: left;
  transition: all 0.2s;
}

.reset-btn:hover {
  border-color: #e74c3c;
  color: #e74c3c;
  background: rgba(231, 76, 60, 0.05);
}

@media (max-width: 768px) {
  .diagnostics-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .diagnostics-list {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 40vh;
  }
}

/* ---- Phase Bar (Progression chart) ---- */
.phase-bar {
  display: flex;
  gap: 4px;
  padding: 4px 50px 4px 50px;
  margin-bottom: 4px;
}

.phase-segment {
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid;
  font-size: 11px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.phase-segment:hover { opacity: 0.8; }

/* Progression detail panel */
.progression-detail {
  margin: 12px 20px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  animation: fadeIn 0.2s ease;
}
.detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.detail-type { font-weight: 600; font-size: 0.95rem; }
.detail-date { color: var(--text-secondary); font-size: 0.85rem; }
.detail-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
}
.detail-close:hover { color: var(--text-primary); }
.detail-metrics {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.detail-metric {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.detail-label { font-size: 0.7rem; color: var(--text-secondary); text-transform: uppercase; }
.detail-value { font-size: 1rem; color: var(--text-primary); font-weight: 500; }
.detail-sessions { margin-top: 8px; }
.detail-session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  transition: background 0.1s;
}
.detail-session-row:hover { background: rgba(255,255,255,0.02); }
.detail-session-row:last-child { border-bottom: none; }
.detail-session-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.detail-session-day { color: var(--text-secondary); width: 70px; }
.detail-session-type { color: var(--text-primary); width: 80px; }
.detail-session-dist { color: var(--text-primary); }
.detail-session-pace { color: var(--text-secondary); margin-left: auto; font-size: 0.8rem; }
.detail-session-zone { color: #4ecdc4; font-size: 0.75rem; margin-left: 8px; }
.detail-section-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
  margin-bottom: 6px;
}
.detail-planned-row { opacity: 0.9; }
.detail-session-notes {
  padding: 4px 0 6px 18px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
  border-bottom: 1px solid var(--border);
}

/* ---- Coaching Notes ---- */

.notes-subtitle {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.note-content {
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 0.75rem;
}

.note-tags {
  display: flex;
  gap: 4px;
}

.note-tag {
  background: rgba(0, 212, 170, 0.1);
  color: #00d4aa;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 0.7rem;
}

.note-date {
  color: var(--text-secondary);
}

.note-edit-btn, .note-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.2s;
  font-size: 0.8rem;
  padding: 2px 4px;
  margin-left: auto;
}

.note-card:hover .note-edit-btn,
.note-card:hover .note-delete-btn {
  opacity: 0.6;
}

.note-edit-btn:hover, .note-delete-btn:hover {
  opacity: 1 !important;
}

.note-delete-btn:hover {
  color: #e74c3c;
}

.note-edit-textarea {
  width: 100%;
  min-height: 60px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.profile-section h3 {
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

/* ============================================
   Week View
   ============================================ */

.week-navigator {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) 0;
  margin-bottom: var(--space-3);
}

.week-nav-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.week-nav-arrow {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font-size: var(--text-lg);
  transition: var(--transition);
}
.week-nav-arrow:hover { background: var(--surface-2); color: var(--text-primary); }
.week-nav-arrow:disabled { opacity: 0.3; cursor: default; }
.week-nav-arrow:disabled:hover { background: transparent; color: var(--text-muted); }

.week-nav-title { font-size: var(--text-base); font-weight: var(--font-semibold); color: var(--text-primary); }
.week-nav-dates { font-size: var(--text-xs); color: var(--text-muted); }

.phase-badge {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: 2px 8px;
  border-radius: var(--radius-xs);
}
.phase-badge.base { background: rgba(0,212,170,0.15); color: #00d4aa; }
.phase-badge.build { background: rgba(240,180,41,0.15); color: #f0b429; }
.phase-badge.peak { background: rgba(255,107,107,0.15); color: #ff6b6b; }
.phase-badge.taper { background: rgba(136,136,136,0.15); color: #888; }

.week-summary { display: flex; gap: var(--space-5); text-align: center; }
.week-stat-label { font-size: 9px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.week-stat-value { font-size: var(--text-lg); font-weight: var(--font-bold); color: var(--text-primary); }
.week-stat-value span { font-size: var(--text-sm); font-weight: normal; color: var(--text-muted); }

/* ============================================
   Day Rows
   ============================================ */

.week-days { display: flex; flex-direction: column; gap: var(--space-1); }

.day-row {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  align-items: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--surface-2);
}
.day-row:hover { background: var(--surface-3); }
.day-row.rest { background: rgba(255, 255, 255, 0.015); cursor: default; }
.day-row.rest:hover { background: rgba(255, 255, 255, 0.015); }
.day-row.today { border: 1px solid rgba(0, 212, 170, 0.25); }

.day-date { width: 36px; text-align: center; flex-shrink: 0; }
.day-date-abbr { font-size: 9px; color: var(--text-muted); text-transform: uppercase; }
.day-date-num { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--text-primary); }
.day-row.rest .day-date-abbr, .day-row.rest .day-date-num { color: var(--text-muted); opacity: 0.5; }
.day-row.today .day-date-abbr, .day-row.today .day-date-num { color: var(--accent); }

.day-bar { width: 3px; height: 32px; border-radius: 2px; flex-shrink: 0; }
.day-bar.completed { background: var(--accent); }
.day-bar.planned { background: var(--accent-warning); opacity: 0.5; }
.day-bar.long_run { background: #4a9eff; opacity: 0.5; }
.day-bar.rest { background: #333; }

.day-content { flex: 1; min-width: 0; }
.day-session-header { display: flex; align-items: center; gap: var(--space-2); }
.day-session-type { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--text-primary); }
.day-row.rest .day-session-type { color: var(--text-muted); opacity: 0.5; }

.day-badge { font-size: 9px; padding: 1px 6px; border-radius: var(--radius-xs); font-weight: var(--font-medium); }
.day-badge.done { background: rgba(0,212,170,0.15); color: var(--accent); }
.day-badge.planned { background: rgba(240,180,41,0.1); color: var(--accent-warning); }

.day-metrics { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.day-action { flex-shrink: 0; color: var(--text-muted); font-size: var(--text-sm); }

.btn-garmin-row {
  background: var(--accent);
  color: var(--surface-0);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-xs);
  font-size: 9px;
  font-weight: var(--font-semibold);
  transition: var(--transition);
}
.btn-garmin-row:hover { background: var(--accent-hover); }

.day-expand {
  overflow: hidden;
  max-height: 0;
  transition: max-height 200ms ease;
  padding: 0 var(--space-4);
}
.day-expand.open {
  max-height: 300px;
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-2);
  background: var(--surface-0);
  border-radius: var(--radius-sm);
}

.day-expand-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-2);
}
.day-expand-metric { font-size: var(--text-xs); }
.day-expand-metric .label { color: var(--text-muted); }
.day-expand-metric .value { color: var(--text-primary); font-weight: var(--font-semibold); }

/* ============================================
   Week Alerts
   ============================================ */

.week-alert {
  background: rgba(240, 180, 41, 0.08);
  border: 1px solid rgba(240, 180, 41, 0.2);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.week-alert.critical { background: rgba(229, 62, 62, 0.08); border-color: rgba(229, 62, 62, 0.2); }
.week-alert-content { flex: 1; }
.week-alert-title { font-size: var(--text-sm); font-weight: var(--font-semibold); color: var(--accent-warning); }
.week-alert.critical .week-alert-title { color: var(--danger); }
.week-alert-message { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.week-alert-dismiss { color: var(--text-muted); font-size: var(--text-lg); cursor: pointer; padding: var(--space-1); }
.week-alert-dismiss:hover { color: var(--text-primary); }

/* ============================================
   Coach Insight (Week View)
   ============================================ */

.week-coach-insight {
  background: rgba(0, 212, 170, 0.04);
  border: 1px solid rgba(0, 212, 170, 0.1);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.week-coach-insight .insight-icon { font-size: 16px; flex-shrink: 0; margin-top: 2px; }
.week-coach-insight .insight-title { font-size: var(--text-sm); font-weight: var(--font-medium); color: var(--text-primary); }
.week-coach-insight .insight-body { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; line-height: 1.5; }

/* ============================================
   Week Tab Fade Transition
   ============================================ */

#tab-week { transition: opacity 150ms ease; }

/* ============================================
   Activity Expand + Filters
   ============================================ */

.activity-expand {
  overflow: hidden;
  max-height: 0;
  width: 100%;
  transition: max-height 220ms ease, padding 220ms ease;
}

.activity-expand.open {
  max-height: 200px;
  padding: var(--space-3) var(--space-4) var(--space-2);
  border-top: 1px solid var(--border);
  margin-top: var(--space-2);
}

.activity-filters {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.activity-filters select {
  background: var(--surface-1);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.activity-filters select:hover,
.activity-filters select:focus {
  border-color: var(--accent);
  outline: none;
}
