/* ─── Study Session Page ─────────────────────────────────── */
.session-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Distraction overlay */
.distraction-fullscreen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(220, 38, 38, 0.12);
  pointer-events: none;
  z-index: 10;
  animation: pulse 1.5s ease-in-out infinite;
}

/* Navbar */
.session-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.session-nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  background: none;
  border: none;
  text-decoration: none;
}
.session-nav-icon { width: 24px; height: 24px; border-radius: 6px; }
.session-nav-center { flex: 1; display: flex; justify-content: center; }
.session-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  background: #f5f1ec;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}
.session-status-pill.focused { background: #dcfce7; color: var(--good); border-color: #bbf7d0; }
.session-status-pill.distracted { background: #fee2e2; color: var(--bad); border-color: #fecaca; animation: subtlePulse 0.8s ease-in-out infinite; }
@keyframes subtlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}
.session-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1.5s ease-in-out infinite;
}
.session-nav-right { display: flex; align-items: center; gap: 12px; }
.session-nav-timer { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text); letter-spacing: -0.5px; }
.btn-session-exit {
  padding: 7px 16px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
}
.btn-session-exit:hover { border-color: var(--text-light); color: var(--text); }

/* Body */
.session-body {
  flex: 1;
  display: flex;
  gap: 24px;
  padding: 28px 32px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* Camera */
.session-camera-wrap { flex: 1; display: flex; flex-direction: column; gap: 16px; }
.session-camera-frame {
  position: relative;
  background: #1c1917;
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 4/3;
  max-height: 520px;
  border: 2px solid var(--border);
  transition: border-color 0.3s;
}
.session-camera-frame.distracted { border-color: var(--bad); box-shadow: 0 0 0 3px rgba(220,38,38,0.2); }
.session-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }

.session-cam-off {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #78716c;
}
.session-cam-off span { font-size: 40px; }
.session-cam-off p { font-size: 14px; }

.session-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #78716c;
  background: #1c1917;
}
.session-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.session-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-full);
}
.session-badge.focused { background: #dcfce7; color: var(--good); border: 1px solid #bbf7d0; }
.session-badge.distracted { background: #fee2e2; color: var(--bad); border: 1px solid #fecaca; }
.session-badge.standby { background: rgba(255,255,255,0.9); color: var(--text-muted); }

.session-error { font-size: 13px; color: var(--bad); text-align: center; }

/* Controls */
.main-controls { display: flex; gap: 12px; }
.btn-cam-main, .btn-study-main {
  flex: 1;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}
.btn-cam-main.active { background: var(--bg-dark); color: var(--bg); }
.btn-cam-main.active:hover { background: #292524; }
.btn-study-main.active { background: var(--primary); color: #fff; box-shadow: 0 4px 16px rgba(232,93,4,0.3); }
.btn-study-main.active:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-study-main.inactive { background: #f0ebe4; color: var(--text-light); cursor: not-allowed; }

.controls-hint { font-size: 13px; color: var(--text-light); text-align: center; }

/* Calibration shortcut link (between controls and hint) */
.calib-shortcut { text-align: center; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-calib-shortcut {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-light);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 6px 16px;
  text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
  background: transparent;
}
.btn-calib-shortcut:hover { color: var(--text); border-color: var(--text-light); }

/* Debug toggle button */
.btn-debug-toggle {
  background: none; border: none;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-light); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
  font-family: inherit; padding: 0;
  transition: color 0.2s;
}
.btn-debug-toggle:hover { color: var(--text-muted); }

/* Debug panel */
.debug-panel {
  margin-top: 10px;
  background: #1c1917;
  border: 1px solid #3f3833;
  border-radius: 10px;
  padding: 14px 16px;
  color: #e7e5e4;
  font-family: 'Courier New', monospace;
  font-size: 12px;
}

.debug-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
  font-size: 12px; font-weight: 700; color: #a8a29e;
  letter-spacing: 0.3px;
}

.debug-close-btn {
  background: #3f3833; border: none; color: #a8a29e;
  font-size: 11px; padding: 3px 10px;
  border-radius: 4px; cursor: pointer; font-family: inherit;
}
.debug-close-btn:hover { background: #57534e; }

.debug-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 12px; margin-bottom: 12px;
}

.debug-item-label {
  font-size: 9.5px; color: #78716c;
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.debug-item-val {
  font-size: 22px; font-weight: 900;
  line-height: 1; margin-bottom: 3px;
  letter-spacing: -0.5px;
  transition: color 0.15s;
}
.debug-item-sub {
  font-size: 10px; color: #57534e;
}

.debug-active-thresh {
  font-size: 10.5px; color: #a8a29e;
  background: #292524; border-radius: 6px;
  padding: 7px 10px; margin-bottom: 8px;
  line-height: 1.5;
}

.debug-storage-row {
  font-size: 10px; color: #57534e;
  border-top: 1px solid #3f3833;
  padding-top: 8px;
  word-break: break-all; line-height: 1.6;
}
.debug-storage-row span { color: #a8a29e; }

/* Sidebar */
.session-sidebar { width: 280px; display: flex; flex-direction: column; gap: 14px; flex-shrink: 0; }
.ssc-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--text-light); margin-bottom: 10px; }

/* Music Card */
.music-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.music-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.music-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #e8f0fe;
  color: #3b5bdb;
}
.music-badge-green {
  background: #e6f4ea;
  color: #2d6a4f;
}
.music-track-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.music-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #3b5bdb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.music-track-name { font-size: 13px; font-weight: 700; color: var(--text); }
.music-track-artist { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.music-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}
.music-btn {
  flex: 1;
  padding: 7px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.music-btn:hover { background: var(--border); }
.music-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.music-volume-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-muted);
}
.music-vol-label { white-space: nowrap; }
.music-vol-pct { white-space: nowrap; font-weight: 600; min-width: 28px; text-align: right; }
.music-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
.music-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
}
.ambient-rows { display: flex; flex-direction: column; gap: 10px; }
.ambient-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ambient-icon { font-size: 15px; flex-shrink: 0; width: 20px; text-align: center; }
.ambient-label { width: 58px; flex-shrink: 0; font-size: 12px; color: var(--text); }
.ambient-pct { min-width: 28px; text-align: right; font-size: 12px; font-weight: 600; color: var(--text-muted); }

/* Timer Card */
.session-timer-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  text-align: center;
}
.timer-display {
  font-size: 40px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  color: var(--text);
  line-height: 1;
  margin-bottom: 8px;
}
.timer-display.running { color: var(--primary); }
.timer-sub { font-size: 12px; color: var(--text-light); line-height: 1.5; }

/* Session Stat Card */
.session-stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.ssc-rows { display: flex; flex-direction: column; gap: 10px; }
.ssc-row { display: flex; align-items: center; justify-content: space-between; }
.ssc-row-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.ssc-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.ssc-dot.green { background: var(--good); }
.ssc-dot.red { background: var(--bad); }
.ssc-dot.orange { background: var(--primary); }
.ssc-row-val { font-size: 14px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.ssc-row-val.good { color: var(--good); }
.ssc-row-val.ok { color: var(--ok); }
.ssc-row-val.bad { color: var(--bad); }
.ssc-bar-wrap { height: 5px; background: #f0ebe4; border-radius: var(--radius-full); overflow: hidden; }
.ssc-bar-fill { height: 100%; border-radius: var(--radius-full); transition: width 0.5s ease; }
.ssc-bar-fill.good { background: var(--good); }
.ssc-bar-fill.ok { background: var(--ok); }
.ssc-bar-fill.bad { background: var(--bad); }

/* ── Calibration Overlay ──────────────────────────────────── */
.calib-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.72);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fadeIn 0.25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.calib-modal {
  background: var(--bg-white);
  border-radius: 24px;
  padding: 40px 36px 32px;
  text-align: center;
  max-width: 400px;
  width: calc(100% - 48px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.4);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(24px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.calib-icon { font-size: 44px; margin-bottom: 14px; line-height: 1; }
.calib-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 10px;
}
.calib-desc {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0 0 28px;
}
.calib-desc strong { color: var(--text); }

/* SVG ring countdown */
.calib-countdown-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 24px;
}
.calib-ring { width: 120px; height: 120px; transform: rotate(-90deg); }
.calib-ring-bg {
  fill: none;
  stroke: #f0ebe4;
  stroke-width: 8;
}
.calib-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.25s linear;
}
.calib-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Tip checklist */
.calib-tips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  background: #faf8f6;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.calib-tip-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
  transition: color 0.3s;
}
.calib-tip-item.done { color: var(--good); font-weight: 600; }
.calib-tip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.3s;
}
.calib-tip-item.done .calib-tip-dot { background: var(--good); }

.calib-status {
  font-size: 12px;
  color: var(--text-light);
  margin: 0 0 20px;
  min-height: 18px;
}
.calib-skip-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 9px 22px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}
.calib-skip-btn:hover { border-color: var(--text-light); color: var(--text); }

@media (max-width: 860px) {
  .session-body { flex-direction: column; padding: 16px; }
  .session-sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .session-sidebar > * { flex: 1; min-width: 240px; }
}
@media (max-width: 560px) {
  .session-nav { padding: 0 12px; }
  .main-controls { flex-direction: column; }
}

