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

/* Ensure [hidden] always wins over display rules */
[hidden] { display: none !important; }

:root {
  --brand-dark:    #1a1a2e;
  --brand-mid:     #16213e;
  --brand-accent:  #4F81BD;
  --brand-accent2: #4BACC6;
  --brand-green:   #9BBB59;
  --brand-light:   #e8f0fe;
  --text-primary:  #1a1a2e;
  --text-secondary:#555;
  --text-muted:    #888;
  --border:        #dde3f0;
  --bg:            #f4f6fb;
  --white:         #ffffff;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 2px 16px rgba(26,26,46,.08);
  --shadow-lg:     0 8px 40px rgba(26,26,46,.14);
  --transition:    .2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* Session page: fixed viewport height so flex/grid children are properly constrained */
body.session-page {
  height: 100vh;
  overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  background: var(--brand-dark);
  border-bottom: 3px solid var(--brand-accent);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0,0,0,.3);
}

.header__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header__logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header__eye {
  width: 52px;
  height: 32px;
  flex-shrink: 0;
}

.header__title-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.header__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -.01em;
  line-height: 1.2;
}

.header__subtitle {
  font-size: .78rem;
  color: var(--brand-accent);
  font-weight: 500;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.badge--blue {
  background: rgba(79,129,189,.2);
  color: var(--brand-accent2);
  border: 1px solid rgba(79,129,189,.35);
}

.badge--video {
  background: rgba(142,68,173,.15);
  color: #8e44ad;
  border: 1px solid rgba(142,68,173,.3);
  padding: 2px 8px;
  font-size: .65rem;
  vertical-align: middle;
  margin-left: 6px;
}

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 24px 60px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 100%);
  border-radius: var(--radius);
  padding: 28px 36px;
  border-left: 4px solid var(--brand-accent);
}

.hero__text {
  color: #c8d4e8;
  font-size: 1rem;
  line-height: 1.7;
  max-width: 780px;
}

.hero__text strong { color: var(--white); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  border: 1px solid var(--border);
}

.card__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 24px;
}

/* ── Icons ───────────────────────────────────────────────────────────────── */
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.icon--large { width: 36px; height: 36px; }
.icon--green { color: #27ae60; stroke: #27ae60; }

/* ── Upload grid ─────────────────────────────────────────────────────────── */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

@media (max-width: 640px) {
  .upload-grid { grid-template-columns: 1fr; }
}

/* ── Upload zone ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), background var(--transition);
  overflow: hidden;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--brand-accent);
  background: rgba(79,129,189,.04);
}

.upload-zone.has-file {
  border-color: #27ae60;
  border-style: solid;
  background: rgba(39,174,96,.04);
}

.upload-zone__label {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 28px 20px;
  cursor: pointer;
  text-align: center;
}

.upload-zone__icon {
  width: 48px;
  height: 48px;
  background: var(--brand-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  transition: background var(--transition);
}

.upload-zone__icon svg {
  width: 24px;
  height: 24px;
  stroke: var(--brand-accent);
}

.upload-zone:hover .upload-zone__icon,
.upload-zone.drag-over .upload-zone__icon {
  background: rgba(79,129,189,.18);
}

.upload-zone__tag {
  font-size: .95rem;
  font-weight: 700;
  color: var(--brand-dark);
  letter-spacing: -.01em;
}

.upload-zone__hint {
  font-size: .82rem;
  color: var(--text-secondary);
}

.upload-zone__format {
  font-size: .75rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ── Upload preview (after file selected) ────────────────────────────────── */
.upload-zone__preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: rgba(39,174,96,.06);
  border-top: 1px solid rgba(39,174,96,.2);
}

.upload-zone__preview-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.upload-zone__filename {
  font-size: .88rem;
  font-weight: 600;
  color: var(--brand-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-zone__filesize {
  font-size: .75rem;
  color: var(--text-muted);
}

.btn-remove {
  background: none;
  border: 1px solid #e0e0e0;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: .75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.btn-remove:hover {
  background: #fee;
  border-color: #e74c3c;
  color: #e74c3c;
}

/* ── Progress steps ──────────────────────────────────────────────────────── */
.upload-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 28px;
}

.upload-progress__step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 90px;
  text-align: center;
  transition: color var(--transition);
}

.upload-progress__step.active { color: var(--brand-accent); }
.upload-progress__step.done   { color: #27ae60; }

.upload-progress__dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--white);
  transition: all var(--transition);
  position: relative;
}

.upload-progress__step.active .upload-progress__dot {
  border-color: var(--brand-accent);
  background: var(--brand-accent);
  box-shadow: 0 0 0 4px rgba(79,129,189,.2);
}

.upload-progress__step.done .upload-progress__dot {
  border-color: #27ae60;
  background: #27ae60;
}

.upload-progress__step.done .upload-progress__dot::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: .7rem;
  font-weight: 700;
}

.upload-progress__line {
  flex: 1;
  height: 2px;
  background: var(--border);
  max-width: 80px;
  margin-bottom: 22px;
  transition: background var(--transition);
}

.upload-progress__line.active { background: var(--brand-accent); }
.upload-progress__line.done   { background: #27ae60; }

/* ── Generate row ────────────────────────────────────────────────────────── */
.generate-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.generate-hint {
  font-size: .82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: -.01em;
}

.btn--primary {
  background: var(--brand-accent);
  color: var(--white);
  box-shadow: 0 2px 12px rgba(79,129,189,.35);
}

.btn--primary:hover:not(:disabled) {
  background: #3d6fa8;
  box-shadow: 0 4px 20px rgba(79,129,189,.5);
  transform: translateY(-1px);
}

.btn--primary:disabled {
  background: #b0bec5;
  box-shadow: none;
  cursor: not-allowed;
  opacity: .7;
}

.btn--outline {
  background: transparent;
  color: var(--brand-accent);
  border: 2px solid var(--brand-accent);
}

.btn--outline:hover {
  background: var(--brand-light);
}

.btn--large {
  padding: 14px 32px;
  font-size: 1rem;
  border-radius: var(--radius);
}

/* ── Loading overlay ─────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 48px 56px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  min-width: 320px;
}

.spinner {
  width: 52px;
  height: 52px;
  border: 4px solid var(--brand-light);
  border-top-color: var(--brand-accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 20px;
}

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

.loading-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 6px;
}

.loading-sub {
  font-size: .88rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.loading-bar {
  height: 6px;
  background: var(--brand-light);
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar__fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-accent), var(--brand-accent2));
  border-radius: 3px;
  width: 0%;
  transition: width .4s ease;
}

/* ── Result card ─────────────────────────────────────────────────────────── */
.result-card {
  border-left: 4px solid #27ae60;
  animation: slideIn .4s ease;
}

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

.result-card__header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.result-card__title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.result-card__sub {
  font-size: .88rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.result-actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 28px;
}

/* ── Stats grid ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.stat-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.stat-item__key {
  font-size: .72rem;
  font-weight: 600;
  color: var(--brand-accent);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}

.stat-item__val {
  font-size: .9rem;
  font-weight: 500;
  color: var(--brand-dark);
  word-break: break-word;
}

/* ── Charts info ─────────────────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.chart-info {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  padding-bottom: 52px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: box-shadow var(--transition), border-color var(--transition);
  position: relative;
}

.chart-info:hover {
  box-shadow: var(--shadow);
  border-color: var(--brand-accent);
}

.chart-info__num {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--brand-light);
  line-height: 1;
  min-width: 36px;
  background: var(--brand-dark);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  text-align: center;
  letter-spacing: -.02em;
}

.chart-info__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chart-info__body strong {
  font-size: .9rem;
  color: var(--brand-dark);
}

.chart-info__body span {
  font-size: .75rem;
  color: var(--brand-accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.chart-info__body p {
  font-size: .8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 2px;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  background: var(--brand-dark);
  color: #666a88;
  text-align: center;
  padding: 16px 24px;
  font-size: .78rem;
  border-top: 1px solid rgba(255,255,255,.06);
}

/* ── File Library ────────────────────────────────────────────────────────── */
.file-library__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  margin-bottom: 12px;
}

.file-library__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  font-weight: 700;
  color: var(--brand-dark);
}

.file-library__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.file-library__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), background var(--transition);
}

.file-library__item:hover {
  border-color: var(--brand-accent);
  background: rgba(79,129,189,.04);
}

.file-library__item.active {
  border-color: #27ae60;
  background: rgba(39,174,96,.06);
}

.file-library__item-icon {
  color: var(--brand-accent);
  flex-shrink: 0;
}

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

.file-library__item-name {
  font-size: .88rem;
  font-weight: 600;
  color: var(--brand-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-library__item-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.file-library__actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.btn-select-file {
  padding: 5px 14px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--brand-accent);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-select-file:hover:not(:disabled) {
  background: #3d6fa8;
}

.btn-select-file:disabled {
  background: #27ae60;
  cursor: default;
  opacity: 1;
}

.btn-delete-file {
  padding: 5px 10px;
  font-size: .8rem;
  font-weight: 600;
  background: transparent;
  color: #e74c3c;
  border: 1.5px solid #e74c3c;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-delete-file:hover {
  background: #fee;
}

.btn-upload-video {
  padding: 5px 12px;
  font-size: .8rem;
  font-weight: 600;
  background: transparent;
  color: #8e44ad;
  border: 1.5px solid #8e44ad;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-upload-video:hover {
  background: rgba(142,68,173,.08);
}

.file-library__item--video {
  border-color: rgba(142,68,173,.3);
  background: rgba(142,68,173,.03);
}

.file-library__item--video:hover {
  border-color: #8e44ad;
  background: rgba(142,68,173,.07);
}

.file-library__item-icon--video {
  color: #8e44ad;
}

/* ── Error toast ─────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #e74c3c;
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  max-width: 380px;
  animation: toastIn .3s ease;
}

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

/* ── View Chart Buttons ──────────────────────────────────────────────────── */
.btn-view-chart {
  position: absolute;
  bottom: 16px;
  right: 16px;
  padding: 6px 14px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--brand-accent);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.btn-view-chart:hover:not(:disabled) {
  background: #3d6fa8;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79,129,189,.4);
}

.btn-view-chart:disabled {
  background: #b0bec5;
  cursor: not-allowed;
  opacity: .6;
}

.btn--small {
  padding: 8px 16px;
  font-size: .85rem;
}

/* ── See Video Card ──────────────────────────────────────────────────────── */
.video-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.video-card__hint {
  font-size: .9rem;
  color: var(--text-secondary);
}

/* ── Video Player Page ───────────────────────────────────────────────────── */
.video-wrapper {
  width: 100%;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 4px;
}

.video-wrapper video {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
}

/* ── Chart Viewer Page ───────────────────────────────────────────────────── */
.chart-viewer-main {
  max-width: 1400px;
}

.chart-viewer-card {
  padding: 40px;
}

.chart-viewer-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border);
}

.chart-viewer-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 8px;
}

.chart-viewer-subtitle {
  font-size: .95rem;
  color: var(--text-secondary);
}

.chart-canvas-wrapper {
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-canvas-wrapper canvas {
  max-width: 100%;
  height: auto !important;
}

.chart-table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

.data-table thead {
  background: var(--brand-dark);
  color: var(--white);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

.data-table tbody tr:hover {
  background: var(--bg);
}

.data-table tbody tr.highlight-row {
  background: rgba(79,129,189,.08);
  font-weight: 600;
}

.data-table td {
  padding: 12px 16px;
  color: var(--text-primary);
}

.data-table tfoot {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-secondary);
  font-size: .85rem;
}

.data-table tfoot td {
  padding: 14px 16px;
}

.chart-error {
  text-align: center;
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.chart-error p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 400px;
}

/* ── Playback Controls ───────────────────────────────────────────────────── */
.playback-controls {
  margin-top: 20px;
  padding: 16px 20px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.playback-timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.playback-scrubber {
  flex: 1;
  height: 6px;
  accent-color: var(--brand-accent);
  cursor: pointer;
  border-radius: 3px;
}

.playback-time,
.playback-duration {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 36px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.playback-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.playback-play-btn {
  min-width: 100px;
  gap: 6px;
}

.playback-reset-btn {
  gap: 6px;
}

.playback-speed {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-left: auto;
}

.playback-speed label {
  font-weight: 500;
}

.playback-speed select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 0.85rem;
  background: var(--white);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition);
}

.playback-speed select:focus {
  outline: none;
  border-color: var(--brand-accent);
}

/* Pause icon (two vertical bars) */
.icon-pause rect {
  fill: currentColor;
}

/* ── Session Info Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,.78);
  backdrop-filter: blur(4px);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--white);
  border-radius: var(--radius);
  padding: 40px 44px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  animation: slideIn .3s ease;
}

.modal--wide {
  max-width: 700px;
}

.modal__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 8px;
}

.modal__desc {
  font-size: .88rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
  line-height: 1.6;
}

.modal__field {
  margin-bottom: 22px;
}

.modal__label {
  display: block;
  font-size: .75rem;
  font-weight: 700;
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}

.modal__radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal__radio {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  font-size: .92rem;
  font-weight: 500;
  color: var(--text-primary);
  user-select: none;
}

.modal__radio:hover {
  border-color: var(--brand-accent);
  background: rgba(79,129,189,.04);
}

.modal__radio input[type='radio'] {
  display: none;
}

.modal__radio-box {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color var(--transition);
}

.modal__radio-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-accent);
  opacity: 0;
  transition: opacity var(--transition);
}

.modal__radio input[type='radio']:checked ~ .modal__radio-box {
  border-color: var(--brand-accent);
}

.modal__radio input[type='radio']:checked ~ .modal__radio-box .modal__radio-dot {
  opacity: 1;
}

.modal__radio:has(input[type='radio']:checked) {
  border-color: var(--brand-accent);
  background: rgba(79,129,189,.07);
}

.modal__input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .92rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.modal__input:focus {
  border-color: var(--brand-accent);
  box-shadow: 0 0 0 3px rgba(79,129,189,.14);
}

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

.modal__input.input--error {
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231,76,60,.12);
}

.modal__actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── Error Banner ────────────────────────────────────────────────────────── */

.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: #4a1a1a;
  border-bottom: 2px solid #e74c3c;
  color: #ff8a80;
  font-size: 0.85rem;
  font-weight: 500;
}

.error-banner[hidden] {
  display: none;
}

.error-banner .icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: #e74c3c;
}

.error-banner__close {
  margin-left: auto;
  background: none;
  border: none;
  color: #ff8a80;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 4px;
  opacity: 0.7;
}

.error-banner__close:hover {
  opacity: 1;
}

/* ── Session Viewer Layout ───────────────────────────────────────────────── */

.header-toggle {
  height: 20px;
  background: var(--brand-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
}

.header-toggle__btn {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255,255,255,0.5);
  line-height: 1;
  width: 100%;
  height: 100%;
}

.header-toggle__btn:hover {
  color: rgba(255,255,255,0.9);
}

.header-toggle__arrow {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.header-toggle__btn[aria-expanded="true"] .header-toggle__arrow {
  transform: rotate(180deg);
}

.header-controls-panel {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease;
  background: var(--brand-dark);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.header-controls-panel.is-open {
  max-height: 64px;
}

.header-controls-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
}

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

.session-timer {
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  font-variant-numeric: tabular-nums;
  background: rgba(255,255,255,0.08);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
}

.session-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 20px;
  background: var(--bg);
  overflow: hidden;
  box-sizing: border-box;
  min-height: 0;
}

.session-main > .session-columns {
  display: flex;
  gap: 20px;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* Left column (1/3) */
.session-left {
  flex: 0 0 calc(33.333% - 10px);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
  min-width: 0;
}

/* Right column (2/3) */
.session-right {
  flex: 0 0 calc(66.667% - 10px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Video Container ─────────────────────────────────────────────────────── */

.session-video-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  flex: 0 0 auto;
  height: 340px;
  position: relative;
}

/* ── Review Countdown Overlay ────────────────────────────────────────────── */

.review-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--white);
  z-index: 10;
}

.review-overlay[hidden] {
  display: none;
}

.review-overlay__timer {
  font-size: 3.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--brand-accent);
  letter-spacing: -0.02em;
}

.review-overlay__message {
  font-size: 0.9rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
  text-align: center;
  max-width: 80%;
  margin: 0;
  line-height: 1.5;
}

.review-overlay__skip {
  margin-top: 6px;
  opacity: 0.7;
}

.review-overlay__skip:hover {
  opacity: 1;
}

.session-video-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand-mid) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--white);
}

.session-video-placeholder .icon--large {
  color: rgba(255, 255, 255, 0.3);
  width: 64px;
  height: 64px;
}

.session-video-placeholder p {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
}

.session-video-placeholder span {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

.session-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* ── Notes Container ─────────────────────────────────────────────────────── */

.session-notes-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 300px;
}

.session-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.session-notes-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin: 0;
}

.session-notes-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.session-notes-textarea {
  flex: 1;
  padding: 16px 20px;
  border: none;
  resize: none;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-primary);
  outline: none;
  background: transparent;
}

.session-notes-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* ── Chart Panels ────────────────────────────────────────────────────────── */

.session-chart-panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 380px;
  overflow: hidden;
}

.session-chart-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg);
  scrollbar-width: thin;
  scrollbar-color: var(--brand-accent) var(--border);
}

.session-chart-tabs::-webkit-scrollbar {
  height: 6px;
}

.session-chart-tabs::-webkit-scrollbar-track {
  background: var(--border);
}

.session-chart-tabs::-webkit-scrollbar-thumb {
  background: var(--brand-accent);
  border-radius: 3px;
}

.session-chart-tab {
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
  font-family: inherit;
}

.session-chart-tab:hover {
  background: rgba(79, 129, 189, 0.08);
  border-color: var(--brand-accent);
  color: var(--brand-accent);
}

.session-chart-tab.active {
  background: var(--brand-accent);
  border-color: var(--brand-accent);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(79, 129, 189, 0.3);
}

.session-chart-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  min-height: 280px;
  overflow: auto;
}

.session-chart-canvas {
  width: 100% !important;
  height: 100% !important;
}

.session-chart-table {
  width: 100%;
  height: 100%;
  overflow: auto;
}

.session-chart-table .data-table {
  width: 100%;
  height: auto;
}

.session-chart-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 40px 20px;
}

.session-chart-placeholder .icon--large {
  color: var(--brand-accent);
  opacity: 0.4;
  width: 56px;
  height: 56px;
}

.session-chart-placeholder p {
  font-size: 1rem;
  font-weight: 600;
  color: var(--brand-dark);
  margin: 0;
}

.session-chart-placeholder span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── Session Selection Modal ─────────────────────────────────────────────── */

.session-list-container {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.session-list-loading {
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.session-list-loading .spinner {
  margin: 0;
}

.session-list-loading p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

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

.session-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}

.session-item:last-child {
  border-bottom: none;
}

.session-item:hover {
  background: rgba(79, 129, 189, 0.04);
}

.session-item.selected {
  background: rgba(79, 129, 189, 0.12);
  border-left: 4px solid var(--brand-accent);
}

.session-item__icon {
  width: 40px;
  height: 40px;
  background: var(--brand-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.session-item__icon svg {
  width: 20px;
  height: 20px;
  stroke: var(--brand-accent);
}

.session-item__info {
  flex: 1;
  min-width: 0;
}

.session-item__name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brand-dark);
  margin-bottom: 4px;
}

.session-item__meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.session-item__check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}

.session-item.selected .session-item__check {
  border-color: var(--brand-accent);
  background: var(--brand-accent);
}

.session-item.selected .session-item__check svg {
  stroke: var(--white);
}

/* ── Responsive adjustments ──────────────────────────────────────────────── */

@media (max-width: 1200px) {
  .session-main {
    flex-direction: column;
  }
  
  .session-left,
  .session-right {
    flex: 1 1 auto;
  }
  
  .session-video-container {
    height: 280px;
  }
  
  .session-notes-container {
    min-height: 200px;
  }
}

/* ── Focus Mode (Mode 2) layout ──────────────────────────────────────────── */

.session-main--focus-mode .session-right {
  display: none;
}

.session-main--focus-mode .session-left {
  flex: 1 1 100%;
  flex-direction: row;
  max-width: 100%;
  margin: 0;
}

/* Left sidebar: actions + notes stacked */
.session-main--focus-mode .session-left-panel {
  flex: 0 0 30%;
  order: 0;
  min-height: 0;
  overflow: hidden;
}

/* Video takes all remaining width */
.session-main--focus-mode .session-video-section {
  flex: 1 1 0;
  order: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.session-main--focus-mode .session-video-container {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
}

.session-main--focus-mode .session-notes-container {
  order: 0;
}

/* ── No-notes layout (Mode 1 & 3) ────────────────────────────────────────── */

.session-main--no-notes .session-left-panel {
  flex: 0 0 auto;
}

.session-main--no-notes .session-video-section {
  flex: 1 1 0;
  min-height: 0;
}

.session-main--no-notes .session-video-container {
  height: auto;
  flex: 1 1 0;
  min-height: 0;
}

/* ── Modal mode selector cards ───────────────────────────────────────────── */

.modal__field--mode {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.modal__radio-group--horizontal {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
}

.modal__radio--mode {
  flex: 1 1 calc(50% - 5px);
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
}

.modal__radio--mode .modal__radio-box {
  display: none;
}

.modal__radio-mode-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal__radio-mode-content .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--brand-accent);
  opacity: 0.6;
}

.modal__radio--mode:has(input:checked) .modal__radio-mode-content .icon {
  opacity: 1;
}

.modal__radio-mode-content strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--brand-dark);
}

/* ── Session Video Section ───────────────────────────────────────────────── */

.session-video-section {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* ── Session Left Panel (actions + notes) ────────────────────────────────── */

.session-left-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Session Actions ─────────────────────────────────────────────────────── */

.session-actions-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  flex-shrink: 0;
  margin-top: auto;
}

.session-actions-header {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.session-actions-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--brand-dark);
  margin: 0;
}

.session-actions-body {
  padding: 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Phase Recognition & Help ────────────────────────────────────────────── */

.session-phase-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.session-phase-row {
  display: flex;
  gap: 8px;
}

.phase-btn {
  flex: 1;
  padding: 14px 8px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--brand-dark);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.phase-btn:hover:not(:disabled) {
  border-color: var(--brand-accent);
  color: var(--brand-accent);
}

.phase-btn--active {
  background: var(--brand-accent);
  color: #fff;
  border-color: var(--brand-accent);
  cursor: default;
}

.phase-btn--past {
  background: var(--bg);
  color: var(--text-muted);
  border-color: var(--border);
  opacity: 0.45;
  cursor: default;
}

.phase-btn--help {
  flex: none;
  width: 100%;
}

.phase-btn--used {
  background: var(--bg);
  color: var(--text-muted);
  border-color: var(--border);
  opacity: 0.45;
  cursor: default;
}

/* ── Multi-Chart Panel (Modes 5 & 6) ──────────────────────────────────────── */

.session-multi-chart {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 5fr 2fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.mc-panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1.5px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 0;
}

.mc-panel:hover {
  border-color: var(--brand-accent);
  box-shadow: 0 4px 20px rgba(79, 129, 189, 0.18);
}

.mc-row-bottom {
  grid-column: 1 / -1;
  display: flex;
  gap: 12px;
  min-height: 0;
}

.mc-row-bottom #mc-panel-C {
  flex: 0 0 calc(65% - 6px);
}

.mc-row-bottom #mc-panel-D {
  flex: 1;
}

.mc-panel--fixed {
  cursor: default;
}

.mc-panel--fixed:hover {
  border-color: var(--border);
  box-shadow: var(--shadow);
}

.mc-panel__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  gap: 8px;
  user-select: none;
}

.mc-panel__title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mc-panel__toggle-hint {
  font-size: 0.70rem;
  color: var(--brand-accent);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity var(--transition);
}

.mc-panel:hover .mc-panel__toggle-hint {
  opacity: 1;
}

.mc-panel__content {
  flex: 1;
  min-height: 0;
  padding: 12px;
  display: flex;
  align-items: stretch;
}

.mc-canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.mc-table-wrapper {
  width: 100%;
  overflow: auto;
}

.mc-table-wrapper .data-table {
  font-size: 0.78rem;
}

.mc-table-wrapper .data-table th,
.mc-table-wrapper .data-table td {
  padding: 6px 10px;
}
