/* SwingCheck AI — styles.css */

:root {
  --bg: #0f1214;
  --bg2: #1a1e22;
  --bg3: #242a30;
  --surface: #2a3038;
  --green: #00E676;
  --green-dim: #00C853;
  --green-glow: rgba(0, 230, 118, 0.15);
  --green-glow2: rgba(0, 230, 118, 0.08);
  --red: #FF5252;
  --orange: #FFB74D;
  --yellow: #FFD54F;
  --blue: #64B5F6;
  --purple: #CE93D8;
  --text: #E8EAED;
  --text2: #9AA0A6;
  --text3: #5F6368;
  --radius: 12px;
  --radius-sm: 8px;
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ─── Header ─── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--bg3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 32px;
  height: 32px;
  background: var(--green);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header h1 span { color: var(--green); }

/* ─── Header Nav ─── */
.header-nav {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.nav-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  font-family: inherit;
}

.nav-btn:hover { color: var(--text); background: var(--bg3); }
.nav-btn.active { background: var(--green); color: #000; }

/* ─── Screens ─── */
.screen {
  display: none;
  padding: 20px;
  max-width: 800px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

.screen.active { display: block; }

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

/* ─── Upload Screen — Dual Upload ─── */
.upload-area {
  margin-top: 30px;
  text-align: center;
}

.upload-area h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.upload-area p {
  color: var(--text2);
  margin-bottom: 30px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.dual-upload {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.upload-panel {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--bg3);
  transition: border-color 0.2s;
}

.upload-panel.has-video {
  border-color: var(--green);
}

.upload-panel-label {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.upload-zone {
  border: 2px dashed var(--bg3);
  border-radius: var(--radius-sm);
  padding: 30px 12px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg);
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--green);
  background: var(--green-glow2);
}

.upload-zone .icon {
  font-size: 36px;
  margin-bottom: 10px;
}

.upload-zone .label {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-zone .sublabel {
  color: var(--text3);
  font-size: 0.75rem;
}

.upload-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.upload-status {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--green);
  min-height: 20px;
}

.upload-hint {
  margin-top: 16px;
  color: var(--text3);
  font-size: 0.85rem;
}

.upload-hint.slo-mo-tip {
  background: linear-gradient(135deg, #1a3a2a, #1a2a3a);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 1rem;
  color: var(--text1);
  text-align: center;
  animation: tipPulse 2s ease-in-out infinite;
}

@keyframes tipPulse {
  0%, 100% { border-color: var(--accent); box-shadow: 0 0 0 0 rgba(0, 200, 83, 0); }
  50% { border-color: #00e676; box-shadow: 0 0 12px rgba(0, 200, 83, 0.3); }
}

.btn {
  flex: 1;
  padding: 14px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--green);
  color: #000;
}

.btn-primary:hover { background: var(--green-dim); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover { background: var(--bg3); }

.btn-full { width: 100%; }

/* ─── Video Player Screen — Dual ─── */
.dual-video-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.dual-video-container.two-videos {
  grid-template-columns: 1fr 1fr;
}

.video-panel-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 6px;
  text-align: center;
}

.video-container {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  aspect-ratio: 16/9;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-container canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.video-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  background: var(--bg2);
  border-radius: var(--radius);
}

.video-controls button {
  background: var(--surface);
  border: none;
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}

.video-controls button:hover { background: var(--bg3); }

/* Annotation toggle button */
.btn-annotation-toggle {
  background: var(--surface);
  border: 1px solid var(--bg3);
  color: var(--text2);
  padding: 0 12px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-annotation-toggle:hover {
  background: var(--bg3);
  color: var(--text);
}

.btn-annotation-toggle.active {
  background: var(--green-glow);
  border-color: var(--green);
  color: var(--green);
}

.video-controls .time-display {
  color: var(--text2);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: center;
  flex-shrink: 0;
}

.video-controls input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg3);
  border-radius: 2px;
  outline: none;
}

.video-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green);
  cursor: pointer;
}

.pose-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg2);
  font-size: 0.85rem;
  color: var(--text2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.pose-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
}

.pose-status .dot.ready { background: var(--green); }
.pose-status .dot.error { background: var(--red); }

.analyze-section {
  margin-top: 20px;
}

.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

/* ─── Results Screen ─── */
.overall-score {
  text-align: center;
  padding: 30px 20px;
  background: var(--bg2);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.score-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 4px solid var(--green);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  position: relative;
}

.score-circle .number {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--green);
  line-height: 1;
}

.score-circle .label {
  font-size: 0.7rem;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.overall-score h3 {
  font-size: 1rem;
  color: var(--text2);
  font-weight: 400;
}

/* Angle badges */
.angle-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 6px;
  vertical-align: middle;
}

.angle-badge.dtl {
  background: rgba(100, 181, 246, 0.15);
  color: var(--blue);
}

.angle-badge.faceon {
  background: rgba(206, 147, 216, 0.15);
  color: var(--purple);
}

.angle-badge.both {
  background: var(--green-glow);
  color: var(--green);
}

.category-card {
  background: var(--bg2);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.category-header:hover { background: var(--bg3); }

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

.category-score {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.score-good { background: rgba(0, 230, 118, 0.15); color: var(--green); }
.score-ok { background: rgba(255, 183, 77, 0.15); color: var(--orange); }
.score-bad { background: rgba(255, 82, 82, 0.15); color: var(--red); }

.category-header .name {
  font-weight: 600;
  font-size: 0.95rem;
}

.category-header .chevron {
  color: var(--text3);
  transition: transform 0.2s;
  font-size: 1.2rem;
}

.category-card.open .chevron { transform: rotate(180deg); }

.category-body {
  display: none;
  padding: 0 16px 16px;
}

.category-card.open .category-body { display: block; }

/* ─── Annotated Frame Image (in category results) ─── */
.annotated-frame {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg3);
  margin-bottom: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.issue-list, .good-list {
  list-style: none;
  margin-bottom: 12px;
}

.issue-list:last-child, .good-list:last-child { margin-bottom: 0; }

.issue-list li, .good-list li {
  padding: 8px 0;
  font-size: 0.9rem;
  line-height: 1.5;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.issue-list li::before {
  content: '⚠';
  flex-shrink: 0;
}

.good-list li::before {
  content: '✓';
  color: var(--green);
  font-weight: 700;
  flex-shrink: 0;
}

.issue-list li.major::before { content: '🔴'; }
.issue-list li.moderate::before { content: '🟡'; }
.issue-list li.minor::before { content: '🟢'; }

.section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  margin-bottom: 8px;
  font-weight: 600;
}

.summary-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  border-left: 3px solid var(--green);
}

.summary-card h3 {
  font-size: 1rem;
  margin-bottom: 10px;
}

.summary-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text2);
}

.priority-list {
  list-style: none;
  margin-top: 14px;
}

.priority-list li {
  padding: 8px 0;
  font-size: 0.9rem;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.priority-list .num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #000;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ─── Drills Section ─── */
.drills-header {
  margin-bottom: 16px;
}

.drills-header h2 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.drills-header p {
  color: var(--text2);
  font-size: 0.85rem;
}

.drill-card {
  background: var(--bg2);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.drill-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.drill-header:hover { background: var(--bg3); }

.drill-header .left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drill-header .name {
  font-weight: 600;
  font-size: 0.95rem;
}

.drill-header .reason {
  font-size: 0.8rem;
  color: var(--text3);
}

.drill-header .chevron {
  color: var(--text3);
  transition: transform 0.2s;
  font-size: 1.2rem;
}

.drill-card.open .chevron { transform: rotate(180deg); }

.drill-body {
  display: none;
  padding: 0 16px 16px;
}

.drill-card.open .drill-body { display: block; }

.drill-body p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text2);
  margin-bottom: 14px;
}

/* YouTube clickable thumbnail in drill */
.drill-youtube-link {
  display: block;
  text-decoration: none;
}

.drill-youtube-thumb {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  background: var(--bg3);
}

.drill-youtube-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.drill-youtube-link:hover .drill-youtube-thumb img {
  transform: scale(1.03);
  filter: brightness(0.85);
}

.drill-youtube-thumb .play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  /* Offset the play triangle slightly right for optical center */
  padding-left: 3px;
}

.drill-youtube-link:hover .play-button {
  background: rgba(255, 0, 0, 0.8);
  transform: translate(-50%, -50%) scale(1.1);
}

/* Legacy iframe embed (kept for backwards compat, unused) */
.drill-youtube-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%;
  margin-bottom: 8px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.drill-youtube-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
}

.drill-youtube-title {
  font-size: 0.82rem;
  color: var(--text);
  margin-top: 6px;
  font-weight: 500;
  line-height: 1.3;
}

.drill-youtube-channel {
  font-size: 0.75rem;
  color: var(--text3);
  margin-top: 2px;
}

.drill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.drill-tag {
  padding: 4px 10px;
  background: var(--surface);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text2);
}

.drill-tag.green {
  background: var(--green-glow);
  color: var(--green);
}

.drill-steps {
  list-style: none;
  counter-reset: step;
}

.drill-steps li {
  counter-increment: step;
  padding: 6px 0 6px 32px;
  position: relative;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text2);
}

.drill-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drill-tips {
  margin-top: 14px;
  padding: 12px;
  background: var(--green-glow2);
  border-radius: var(--radius-sm);
}

.drill-tips h4 {
  font-size: 0.8rem;
  color: var(--green);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drill-tips ul {
  list-style: none;
}

.drill-tips li {
  padding: 3px 0;
  font-size: 0.85rem;
  color: var(--text2);
}

.drill-tips li::before {
  content: '💡 ';
}

.drill-reps {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--green);
  font-weight: 500;
}

/* ─── Loading ─── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 20, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  flex-direction: column;
  gap: 20px;
}

.loading-overlay.active { display: flex; }

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--bg3);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay .label {
  font-size: 0.95rem;
  color: var(--text2);
}

/* ─── Golf Chat Assistant ─── */

/* Floating chat button */
.chat-floating-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 230, 118, 0.3), 0 2px 6px rgba(0, 0, 0, 0.3);
  z-index: 300;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.25s ease;
  line-height: 1;
}

.chat-floating-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 230, 118, 0.4), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.chat-floating-btn:active {
  transform: scale(0.95);
}

.chat-floating-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
}

/* Chat panel */
.chat-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 70vh;
  max-height: 600px;
  background: var(--bg2);
  border-top: 1px solid var(--bg3);
  border-left: 1px solid var(--bg3);
  z-index: 310;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

.chat-panel.open {
  transform: translateY(0);
}

/* Chat header */
.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--bg3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.chat-panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.chat-close-btn {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1.1rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.chat-close-btn:hover {
  background: var(--surface);
  color: var(--text);
}

/* Chat messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Message bubbles */
.chat-message {
  display: flex;
  max-width: 88%;
}

.chat-message-user {
  align-self: flex-end;
  justify-content: flex-end;
}

.chat-message-assistant {
  align-self: flex-start;
  justify-content: flex-start;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
}

.chat-message-user .chat-bubble {
  background: var(--green);
  color: #000;
  border-bottom-right-radius: 4px;
}

.chat-message-assistant .chat-bubble {
  background: var(--surface);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-bubble strong {
  font-weight: 700;
}

/* Quick action chips */
.chat-chips {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  overflow-x: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--bg3);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chat-chips::-webkit-scrollbar {
  display: none;
}

.chat-chip {
  flex-shrink: 0;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--bg3);
  background: var(--bg);
  color: var(--text2);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.chat-chip:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-glow2);
}

/* Chat input row */
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--bg3);
  background: var(--bg2);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 24px;
  border: 1px solid var(--bg3);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

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

.chat-input:focus {
  border-color: var(--green);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--green);
  color: #000;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}

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

.chat-send-btn:active {
  transform: scale(0.9);
}

/* ─── Utilities ─── */
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-20 { margin-bottom: 20px; }
.text-center { text-align: center; }

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .dual-upload {
    grid-template-columns: 1fr;
  }
  .dual-video-container.two-videos {
    grid-template-columns: 1fr;
  }
  .screen { padding: 14px; }
  .upload-area { margin-top: 20px; }
  .upload-area h2 { font-size: 1.3rem; }
  .upload-zone { padding: 24px 12px; }
  .btn { padding: 12px 16px; font-size: 0.9rem; }

  .drill-youtube-thumb .play-button {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  /* Chat — full width on mobile */
  .chat-floating-btn {
    bottom: 16px;
    right: 16px;
  }
}

/* Desktop: chat panel as side panel */
@media (min-width: 768px) {
  .chat-panel {
    width: 360px;
    height: 520px;
    max-height: 70vh;
    bottom: 88px;
    right: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--bg3);
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
  }

  .chat-panel.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  .chat-panel-header {
    border-radius: var(--radius) var(--radius) 0 0;
  }
}

/* ─── Routine Builder ─── */
.routine-intro {
  text-align: center;
  margin-bottom: 28px;
}

.routine-intro h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.routine-intro p {
  color: var(--text2);
  font-size: 0.92rem;
  line-height: 1.5;
  max-width: 560px;
  margin: 0 auto;
}

.routine-form {
  max-width: 560px;
  margin: 0 auto;
}

.routine-form-group {
  margin-bottom: 20px;
}

.routine-form-row {
  display: flex;
  gap: 16px;
}

.flex-1 { flex: 1; }

.routine-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.routine-label .optional {
  color: var(--text3);
  font-weight: 400;
}

.routine-select, .routine-input, .routine-textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg3);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.routine-select:focus, .routine-input:focus, .routine-textarea:focus {
  border-color: var(--green);
}

.routine-textarea {
  resize: vertical;
  min-height: 56px;
}

/* Day checkboxes */
.routine-days-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.routine-day-check {
  cursor: pointer;
}

.routine-day-check input { display: none; }

.routine-day-check span {
  display: block;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg3);
  background: var(--bg);
  color: var(--text2);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s;
  user-select: none;
}

.routine-day-check input:checked + span {
  background: var(--green-glow);
  border-color: var(--green);
  color: var(--green);
}

.routine-day-check span:hover {
  border-color: var(--green);
}

/* Goal checkboxes */
.routine-goals-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.routine-goal-check {
  cursor: pointer;
}

.routine-goal-check input { display: none; }

.routine-goal-check span {
  display: block;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--bg3);
  background: var(--bg);
  color: var(--text2);
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.15s;
  user-select: none;
}

.routine-goal-check input:checked + span {
  background: var(--green-glow);
  border-color: var(--green);
  color: var(--green);
}

.routine-goal-check span:hover {
  border-color: var(--green);
}

/* Routine loading */
.routine-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
}

.routine-loading .label {
  color: var(--text2);
  font-size: 0.92rem;
}

/* Routine result */
.routine-result-header {
  margin-bottom: 20px;
}

.routine-result-header h2 {
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.routine-summary p {
  color: var(--text2);
  font-size: 0.9rem;
  line-height: 1.5;
}

.routine-weekly-focus {
  display: inline-block;
  padding: 4px 12px;
  background: var(--green-glow);
  color: var(--green);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Calendar day cards */
.routine-calendar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.routine-day-card {
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
  border-left: 3px solid var(--bg3);
}

.routine-day-card.type-practice { border-left-color: var(--green); }
.routine-day-card.type-workout { border-left-color: var(--blue); }
.routine-day-card.type-recovery { border-left-color: var(--purple); }
.routine-day-card.off-day { border-left-color: var(--text3); opacity: 0.6; }

.routine-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.routine-day-header:hover { background: var(--bg3); }

.routine-day-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.routine-day-icon {
  font-size: 1.4rem;
}

.routine-day-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.routine-day-title {
  font-size: 0.8rem;
  color: var(--text2);
  margin-top: 2px;
}

.routine-day-chevron {
  color: var(--text3);
  transition: transform 0.2s;
  font-size: 1.1rem;
}

.routine-day-card.open .routine-day-chevron {
  transform: rotate(180deg);
}

.routine-day-body {
  display: none;
  padding: 0 16px 16px;
}

.routine-day-card.open .routine-day-body {
  display: block;
}

/* Items inside day cards */
.routine-item {
  padding: 10px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1px solid var(--bg3);
}

.routine-item.is-app-drill {
  border-color: rgba(0, 230, 118, 0.25);
}

.routine-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.routine-item-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
}

.routine-item-duration, .routine-item-sets {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text2);
}

.routine-item-desc {
  font-size: 0.82rem;
  color: var(--text3);
  line-height: 1.4;
}

.routine-day-notes {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text2);
  padding: 8px 12px;
  background: var(--green-glow2);
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

.routine-result-actions {
  display: flex;
  gap: 12px;
}

/* ─── Responsive adjustments ─── */
@media (max-width: 600px) {
  .header {
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
  }

  .header-nav {
    width: 100%;
    justify-content: center;
  }

  .nav-btn {
    flex: 1;
    text-align: center;
    font-size: 0.75rem;
    padding: 6px 8px;
  }

  .routine-form-row {
    flex-direction: column;
    gap: 0;
  }
}

/* ─── Auth UI ─── */
.header-auth {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.btn-auth {
  padding: 6px 14px;
  border: 1px solid var(--bg3);
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-auth:hover { color: var(--green); border-color: var(--green); }

.btn-logout { color: var(--text3); }
.btn-logout:hover { color: var(--red); border-color: var(--red); }

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

.user-email {
  font-size: 0.78rem;
  color: var(--text2);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Auth Modal */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 18, 20, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
}

.auth-modal-overlay.active { display: flex; }

.auth-modal {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  position: relative;
}

.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 1.1rem;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.auth-modal-close:hover { background: var(--surface); color: var(--text); }

.auth-modal h2 {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.auth-modal-subtitle {
  color: var(--text3);
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.auth-error {
  color: var(--red);
  font-size: 0.82rem;
  margin-bottom: 12px;
  min-height: 0;
}

.auth-error:empty { display: none; }

.auth-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg3);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}

.auth-input:focus { border-color: var(--green); }

.auth-toggle {
  margin-top: 16px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text3);
}

.auth-toggle-btn {
  background: none;
  border: none;
  color: var(--green);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
}

.auth-toggle-btn:hover { text-decoration: underline; }

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text1);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-social:hover {
  background: var(--bg3);
  border-color: var(--text3);
}

.btn-google svg {
  flex-shrink: 0;
}

.auth-divider {
  display: flex;
  align-items: center;
  margin: 16px 0;
  gap: 12px;
}

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

.auth-divider span {
  color: var(--text3);
  font-size: 0.8rem;
  text-transform: uppercase;
}

/* ─── History ─── */
.history-section {
  max-width: 700px;
  margin: 0 auto;
}

.history-section h2 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.history-subtitle {
  color: var(--text3);
  font-size: 0.88rem;
  margin-bottom: 20px;
}

.history-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
}

.history-tab {
  flex: 1;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.history-tab:hover { color: var(--text); background: var(--bg3); }
.history-tab.active { background: var(--green); color: #000; }

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border: 1px solid var(--bg3);
  transition: border-color 0.15s;
}

.history-item:hover { border-color: var(--green); }

.history-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-item-score {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}

.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.history-item-date {
  font-size: 0.78rem;
  color: var(--text3);
}

.history-item-arrow {
  color: var(--text3);
  font-size: 1rem;
}

.history-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text3);
  font-size: 0.9rem;
}

/* History Detail */
.history-detail {
  max-width: 700px;
  margin: 0 auto;
}

.history-back-btn {
  background: none;
  border: none;
  color: var(--green);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
  font-family: inherit;
  padding: 0;
}

.history-back-btn:hover { text-decoration: underline; }

@media (max-width: 600px) {
  .header-auth { display: none; }
  .header-auth.mobile-show { display: flex; }
  
  .auth-modal { margin: 16px; padding: 24px; }
  
  .user-email { max-width: 100px; }
}

/* Show auth in header on mobile too */
@media (max-width: 600px) {
  .header {
    flex-wrap: wrap;
  }
  .header-auth {
    display: flex;
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }
}

/* Hide file inputs */
.file-input { display: none; }
