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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
}

h1 { margin-bottom: 16px; }
p { margin-bottom: 12px; }

label {
  display: block;
  font-weight: 600;
  margin: 16px 0 4px;
}

input, select, textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 16px;
  font-family: inherit;
}

textarea { resize: vertical; }

.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  margin-top: 16px;
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
  background: #e5e7eb;
  color: #333;
}

.btn-small {
  padding: 4px 12px;
  font-size: 14px;
  margin-top: 0;
}

.login-page {
  text-align: center;
  margin-top: 60px;
}

.login-hero {
  max-width: 440px;
  margin: 0 auto;
}

.login-tagline {
  font-size: 20px;
  color: #6b7280;
  margin-bottom: 32px;
}

.login-features {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 32px;
}

.login-feature {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 14px 16px;
}

.login-feature strong {
  display: block;
  margin-bottom: 4px;
}

.login-feature span {
  font-size: 14px;
  color: #6b7280;
  line-height: 1.4;
}

.login-cta {
  font-size: 18px;
  padding: 12px 32px;
}

.login-not-allowed {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 24px;
  text-align: left;
}

.login-not-allowed p {
  margin-bottom: 12px;
}

.login-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
  color: #991b1b;
}

.request-access-form {
  display: flex;
  gap: 8px;
}

.request-access-form input {
  flex: 1;
}

.request-status-success {
  margin-top: 12px;
  color: #166534;
  font-weight: 500;
}

.request-status-error {
  margin-top: 12px;
  color: #991b1b;
}

.admin-access-requests {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.admin-access-requests h2 {
  margin-bottom: 12px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 8px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.goals-preview {
  background: white;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.goals-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.goals-content {
  margin-top: 8px;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

.goals-content.collapsed {
  max-height: 0;
  margin-top: 0;
}

.lessons-section {
  margin-top: 24px;
}

.lessons-section h2 {
  margin-bottom: 12px;
  font-size: 18px;
}

.lesson-card {
  background: white;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  margin-bottom: 12px;
}

.lesson-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.lesson-card-header h3 {
  font-size: 16px;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.lesson-meta {
  font-size: 13px;
  color: #6b7280;
}

/* Triple-dot menu */

.lesson-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.lesson-menu-btn {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  color: #9ca3af;
  letter-spacing: 2px;
}

.lesson-menu-btn:hover { color: #374151; }

.lesson-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 10;
  min-width: 120px;
}

.lesson-menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  color: #374151;
}

.lesson-menu-item:hover { background: #f3f4f6; }

/* Disabled listen button for non-ready states */

.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.show-archived-btn {
  margin-top: 16px;
  margin-bottom: 12px;
  min-height: 44px;
  padding: 10px 16px;
  font-size: 14px;
  opacity: 0.6;
}

.show-archived-btn:hover {
  opacity: 1;
}

.lesson-error {
  margin-top: 8px;
  font-size: 13px;
  color: #991b1b;
}

.empty-state {
  text-align: center;
  color: #9ca3af;
  padding: 32px 0;
}

/* Player */

.player-page {
  position: fixed;
  inset: 0;
  background: #1a1a2e;
  color: #e0e0e0;
  display: flex;
  flex-direction: column;
  padding: 0;
}

.player-loading,
.player-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 18px;
}

.player-error a { color: #60a5fa; }

.player-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(0,0,0,0.3);
}

.player-back-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #e0e0e0;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.player-topic {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 48px;
  padding: 20px;
}

.player-chapter-info {
  text-align: center;
}

.player-chapter-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 8px;
}

.player-progress-text {
  font-size: 14px;
  color: #9ca3af;
}

.player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3vw, 24px);
  width: 100%;
  max-width: 500px;
}

.player-toggle-btn {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: none;
  background: #2563eb;
  color: white;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.player-toggle-btn:hover { background: #1d4ed8; }
.player-toggle-btn:active { background: #1e40af; }

.player-skip-btn {
  width: clamp(40px, 12vw, 56px);
  height: clamp(40px, 12vw, 56px);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: #e0e0e0;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.player-skip-btn:hover { background: rgba(255,255,255,0.1); }
.player-skip-btn:disabled {
  opacity: 0.3;
  cursor: default;
}
.player-skip-btn:disabled:hover { background: transparent; }

.player-time-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-time {
  font-size: 16px;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
}

.player-restart-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #9ca3af;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.player-restart-btn:hover { background: rgba(255,255,255,0.1); }

.player-speed-btn {
  min-width: 48px;
  height: 40px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #9ca3af;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  padding: 0 12px;
}

.player-speed-btn:hover { background: rgba(255,255,255,0.1); }

.player-highwater-btn {
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid rgba(96,165,250,0.4);
  background: rgba(96,165,250,0.1);
  color: #60a5fa;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s;
}

.player-highwater-btn:hover { background: rgba(96,165,250,0.25); }

.player-seek-btn {
  width: clamp(40px, 12vw, 56px);
  height: clamp(40px, 12vw, 56px);
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: #e0e0e0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.player-seek-btn:hover { background: rgba(255,255,255,0.1); }

/* Voice Notes */

.hidden { display: none !important; }

.player-note-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.player-note-btn {
  padding: 10px 28px;
  border-radius: 24px;
  border: 1px solid rgba(255,255,255,0.3);
  background: transparent;
  color: #e0e0e0;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}

.player-note-btn:hover { background: rgba(255,255,255,0.1); }

.player-note-btn.recording {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
  animation: pulse-recording 1.5s ease-in-out infinite;
}

.player-recording-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(220,38,38,0.15);
  border-radius: 8px;
  font-size: 14px;
  color: #fca5a5;
}

.recording-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes pulse-recording {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

.player-cancel-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #e0e0e0;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  margin-left: 8px;
}

.player-cancel-btn:hover { background: rgba(255,255,255,0.1); }

.player-note-status {
  font-size: 14px;
  color: #86efac;
  text-align: center;
}

.player-notes-chapter {
  width: 100%;
  max-width: 400px;
}

.player-notes-toggle {
  background: none;
  border: none;
  color: #9ca3af;
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
  width: 100%;
  text-align: left;
}

.player-notes-toggle:hover { color: #e0e0e0; }

.player-notes-list {
  margin-top: 8px;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-item {
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 8px 12px;
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.note-time {
  font-size: 12px;
  color: #60a5fa;
  font-variant-numeric: tabular-nums;
}

.note-text {
  font-size: 14px;
  color: #d1d5db;
  line-height: 1.4;
}

.note-delete-btn {
  background: none;
  border: none;
  color: #6b7280;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
}

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

.note-pending { opacity: 0.7; }

.note-status-label {
  font-size: 11px;
  color: #9ca3af;
  font-style: italic;
}

/* Q&A Dialogue */

.player-action-row {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.player-ask-btn {
  padding: 10px 28px;
  border-radius: 24px;
  border: 1px solid rgba(124,58,237,0.5);
  background: transparent;
  color: #c4b5fd;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}

.player-ask-btn:hover { background: rgba(124,58,237,0.15); }

.player-ask-btn.recording {
  background: #dc2626;
  border-color: #dc2626;
  color: white;
  animation: pulse-recording 1.5s ease-in-out infinite;
}

.player-mark-btn {
  padding: 10px 28px;
  border-radius: 24px;
  border: 1px solid rgba(234,179,8,0.5);
  background: transparent;
  color: #fde68a;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

.player-mark-btn:hover { background: rgba(234,179,8,0.15); }

.player-qa-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.player-qa-status {
  font-size: 16px;
  color: #c4b5fd;
  text-align: center;
}

.player-qa-actions {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.player-qa-action-btn {
  padding: 16px 36px;
  border-radius: 16px;
  border: none;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  background: #2563eb;
  color: white;
}

.player-qa-action-btn:hover { background: #1d4ed8; }

.player-qa-continue-btn {
  background: rgba(124,58,237,0.3);
  border: 1px solid rgba(124,58,237,0.5);
  color: #c4b5fd;
}

.player-qa-continue-btn:hover { background: rgba(124,58,237,0.45); }

/* Onboarding */

.onboarding-box {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  line-height: 1.6;
}

.onboarding-box h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.onboarding-box ol {
  padding-left: 20px;
  margin: 12px 0;
}

.onboarding-box li {
  margin-bottom: 8px;
}

.onboarding-box ul {
  padding-left: 20px;
  margin: 8px 0 0;
  list-style: disc;
}

.onboarding-box ul li {
  margin-bottom: 4px;
}

.onboarding-box code {
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  word-break: break-all;
}

.onboarding-box a {
  color: #2563eb;
}

.onboarding-tip {
  font-size: 14px;
  color: #6b7280;
  margin-top: 12px;
}

.onboarding-close {
  margin-top: 12px;
}

/* Lesson card actions */

.lesson-actions {
  margin-top: 10px;
}

.lesson-actions .btn {
  display: block;
  width: 100%;
  margin-top: 0;
  min-height: 48px;
  padding: 12px 20px;
  font-size: 16px;
  box-sizing: border-box;
}

.lesson-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.lesson-actions-row .btn {
  flex: 1;
  min-height: 48px;
  padding: 12px 20px;
  font-size: 16px;
  margin-top: 0;
}

/* Lesson (non-driving) view */

.lesson-page {
  max-width: 700px;
  margin: 0 auto;
}

.lesson-loading,
.lesson-error {
  text-align: center;
  padding: 60px 0;
  color: #6b7280;
  font-size: 16px;
}

.lesson-error a { color: #2563eb; }

.lesson-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.lesson-header > div { flex: 1; }

.lesson-title {
  font-size: 22px;
  margin-bottom: 2px;
}

.lesson-meta {
  font-size: 13px;
  color: #6b7280;
}

.lesson-back-btn,
.lesson-listen-btn {
  display: inline-block;
  padding: 6px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  color: #333;
  text-decoration: none;
  background: white;
  white-space: nowrap;
}

.lesson-listen-btn {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}

.lesson-back-btn:hover { background: #f3f4f6; }
.lesson-listen-btn:hover { background: #1d4ed8; }

.lesson-body {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.lesson-chapter {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px;
}

.lesson-chapter-title {
  font-size: 18px;
  margin-bottom: 16px;
  color: #111;
}

.lesson-chapter-content {
  font-size: 15px;
  line-height: 1.75;
  color: #374151;
}

.lesson-chapter-content p {
  margin-bottom: 12px;
}

.lesson-chapter-content p:last-child {
  margin-bottom: 0;
}

.lesson-annotations {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lesson-annotation {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
}

.lesson-note {
  background: #eff6ff;
  border-left: 3px solid #60a5fa;
}

.lesson-conversation {
  background: #f5f3ff;
  border-left: 3px solid #a78bfa;
}

.lesson-annotation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.lesson-annotation-type {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lesson-note .lesson-annotation-type { color: #2563eb; }
.lesson-conversation .lesson-annotation-type { color: #7c3aed; }

.lesson-annotation-time {
  font-size: 12px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

.lesson-annotation-body {
  color: #374151;
}

.lesson-msg {
  margin-bottom: 6px;
}

.lesson-msg:last-child { margin-bottom: 0; }

.lesson-msg-role {
  font-weight: 600;
}

.lesson-msg-user .lesson-msg-role { color: #7c3aed; }
.lesson-msg-assistant .lesson-msg-role { color: #059669; }

.onboarding-hint {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #6b7280;
}

/* Completed lesson indicator */

.lesson-completed {
  border-color: #22c55e;
  box-shadow: 0 0 0 1px #22c55e;
}

.completed-badge {
  color: #22c55e;
  font-weight: 700;
  margin-right: 6px;
}

.progress-pct {
  display: inline-block;
  margin-left: 4px;
  font-weight: 600;
  color: #6b7280;
}

/* Shared lesson badge */

.shared-badge {
  display: inline-block;
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Share button */

.lesson-share-btn:hover {
  opacity: 1;
}

/* Toast notification */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Admin Dashboard */

.admin-page header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.admin-page h2 {
  margin: 24px 0 12px;
  font-size: 18px;
}

.admin-total-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 24px;
  text-align: center;
}

.admin-total-label {
  font-size: 14px;
  color: #6b7280;
  margin-bottom: 4px;
}

.admin-total-value {
  font-size: 36px;
  font-weight: 700;
  color: #111;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  font-size: 14px;
}

.admin-table th {
  background: #f9fafb;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  color: #374151;
  border-bottom: 1px solid #e5e7eb;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-topic {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
