/*
 * mobile.css -- the phone layout for every page, loaded LAST so it overrides
 * the page-specific sheets. Goal: feel like an installed app (compact,
 * one-thumb, nothing sideways) rather than a shrunken website.
 * Everything under @media is small-screen only; the camera tool rail and the
 * theme-aware dialog fix apply at every width.
 */

/* ---------- camera tool rail (Instagram-style) ---------- */

.cam-tools {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 4px;
  border-radius: 999px;
  background: rgba(3, 20, 18, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(4px);
}
.cam-tools button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.14);
  color: var(--on-video-ink);
  cursor: pointer;
  padding: 0;
}
.cam-tools button:disabled { opacity: 0.35; cursor: not-allowed; }
.cam-tools button[aria-expanded="true"] { background: var(--accent); color: var(--accent-ink); }
.zoom-label { font-size: 10.5px; font-weight: 700; color: var(--on-video-ink); font-variant-numeric: tabular-nums; }
.rec-btn { border: 2px solid #fff !important; background: transparent !important; }
.rec-dot { width: 18px; height: 18px; border-radius: 50%; background: #e5484d; transition: all 0.15s; }
.rec-btn.is-recording .rec-dot { width: 14px; height: 14px; border-radius: 4px; }
.rec-badge {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 4;
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: rgba(229, 72, 77, 0.92); color: #fff; font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.rec-live { width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: rec-blink 1s ease-in-out infinite; }
@keyframes rec-blink { 50% { opacity: 0.25; } }

/* video effects panel */
.fx-panel {
  display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; border-radius: 14px;
  border: 1px solid var(--border); background: rgba(var(--surface-rgb), 0.5);
}
.fx-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.fx-chips::-webkit-scrollbar { display: none; }
.fx-chip {
  flex: none; min-height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: transparent; color: var(--ink-soft); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.fx-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.fx-sliders { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.fx-slider { display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 600; color: var(--ink-soft); min-width: 0; }
.fx-slider input { width: 100%; min-width: 0; accent-color: var(--accent); }
.fx-toggles { display: flex; flex-direction: column; gap: 6px; }
.fx-toggles .check-row input { width: 20px; height: 20px; }
.fx-toggles .check-text b { font-size: 13.5px; }
.fx-panel .field-hint { margin: 0; font-size: 11.5px; color: var(--muted); }

/* recording result */
.rec-result { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 14px; border: 1px solid var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.rec-result video { width: 100%; max-height: 50dvh; border-radius: 10px; background: #000; }
.rec-result .button-row button { min-height: 42px; font-size: 14px; }

/* dialogs follow the theme (they were a fixed dark gradient, which made the
   theme-coloured text unreadable in the light theme) */
.dialog, .dialog-wide { background: var(--surface); }

/* form controls never overflow their column, at any width */
.plan-field { min-width: 0; }
.plan-form input[type="text"], .plan-form input[type="date"], .plan-form input[type="email"],
.plan-form input[type="tel"], .plan-form input[type="number"], .plan-form input[type="password"],
.plan-form select { width: 100%; min-width: 0; max-width: 100%; }

@media (max-width: 720px) {

  /* ----- page chrome ----- */
  body { font-size: 15px; line-height: 1.4; }
  .page { padding: 10px 12px 20px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }

  .app-header { gap: 8px; margin-bottom: 10px; align-items: center; }
  .brand { gap: 8px; align-items: center; }
  .brand-logo { width: 34px; height: 24px; margin-top: 0; }
  .brand-text h1 { font-size: 18px; line-height: 1.2; }
  .brand-text h1 span { display: block; font-size: 13px; font-weight: 600; margin-top: 1px; }
  .tagline { display: none; }
  .disclaimer { display: none; }

  .header-actions { gap: 6px; width: 100%; flex-wrap: wrap; align-items: center; }
  .header-actions .pill-btn { min-height: 36px; padding: 6px 12px; font-size: 13px; gap: 6px; }
  .header-actions .icon-btn { width: 36px; height: 36px; }
  .who-am-i { font-size: 12px; }
  /* index.html: header actions collapse to icon-only buttons */
  .app-header .header-actions .pill-btn[aria-label] { width: 36px; padding: 0; justify-content: center; }
  .app-header .header-actions .pill-btn[aria-label] .btn-label { display: none; }

  /* ----- steps: a slim progress strip ----- */
  .steps { margin: 0 0 10px; gap: 6px; }
  .steps li { padding: 6px 8px; border-radius: 12px; gap: 6px; }
  .step-num { width: 22px; height: 22px; font-size: 12px; }
  .step-text b { font-size: 12.5px; }

  /* ----- panels ----- */
  .app-layout { gap: 10px; }
  .panel { padding: 12px; border-radius: 16px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); }
  .app-layout > .panel + .panel { margin-top: 0; }
  body > .page > .panel + .panel, .page > .panel + .panel { margin-top: 10px; }
  .panel-title, .demo-panel-title { font-size: 17px; margin: 0 0 8px; }
  .panel-head { gap: 10px; margin-bottom: 10px; align-items: center; flex-wrap: wrap; }
  .head-icon { width: 34px; height: 34px; border-radius: 11px; font-size: 18px; }
  .head-text { flex: 1 1 0; min-width: 0; }
  .head-text h2, .panel-head h2 { font-size: 16px; }
  .head-text p { font-size: 12.5px; line-height: 1.3; }
  .panel-head > .pill-btn, .panel-head > .schedule-tabs, .panel-head > .header-actions { flex: 0 0 auto; }
  .panel-head > .schedule-tabs, .panel-head > .header-actions { width: 100%; }
  .status-pill { padding: 5px 10px; font-size: 12px; gap: 6px; }

  /* ----- buttons / inputs ----- */
  .pill-btn { min-height: 38px; padding: 6px 14px; }
  .button-row { gap: 8px; }
  .button-row button, .button-row .pill-btn { min-height: 44px; border-radius: 12px; font-size: 15px; }
  .secondary-btn { font-size: 14px !important; }
  .plan-form { gap: 12px; }
  .field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .field-row .plan-field { flex: initial; }
  .field-row .plan-field:has(select, input[type="text"], input[type="email"], input[type="tel"], input[type="password"]) { grid-column: 1 / -1; }
  .plan-label { font-size: 11.5px; }
  .plan-form input[type="text"], .plan-form input[type="date"], .plan-form input[type="email"],
  .plan-form input[type="tel"], .plan-form input[type="number"], .plan-form input[type="password"],
  .plan-form select { height: 42px; padding: 0 12px; font-size: 16px; border-radius: 11px; }
  .schedule-tabs { gap: 6px; }
  .schedule-tab { padding: 7px 12px; font-size: 13px; min-height: 36px; }
  .weekday-picker { gap: 6px; }
  .weekday-btn { width: calc((100% - 36px) / 7); min-width: 38px; min-height: 38px; }
  .template-cards { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .template-card { padding: 10px 12px; }
  .assignment-row, .coach-log-row, .booking-result { padding: 10px 12px; }

  /* ----- index: choose panel ----- */
  .choose-panel { gap: 10px; }
  .select-wrap select { height: 46px; font-size: 15.5px; padding: 0 38px 0 46px; }
  .select-icon { left: 13px; width: 22px; height: 22px; }
  .instructions { font-size: 14px; }
  .tips-card { padding: 10px 12px; }
  .tips-title { font-size: 14px; margin-bottom: 4px; }
  .tips-list { font-size: 13px; }
  .check-text b { font-size: 14px; }
  .check-text small { font-size: 12px; }
  .assignment-banner { padding: 10px 12px; font-size: 13px; margin-bottom: 8px; }

  /* the pinned Start / End bar follows the theme and is slimmer */
  body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .choose-panel .action-bar {
    padding: 8px max(12px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: rgba(var(--surface-rgb), 0.97);
    border-top: 1px solid var(--border-strong);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.12);
  }
  .choose-panel .action-bar button { min-height: 46px; font-size: 15px; }

  /* ----- index: session / camera ----- */
  .session-panel { gap: 10px; }
  .session-panel .head-icon { display: none; }
  .coach-banner { padding: 9px 12px; font-size: 15px; border-radius: 12px; }
  .camera-stack { border-radius: 14px; }
  .camera-stack.mode-body { width: min(100%, calc(62dvh * 3 / 4)); }
  .tracking-badge { top: 8px; left: 8px; padding: 4px 9px; font-size: 12px; border-radius: 9px; }
  .framing-chips { top: 38px; left: 8px; right: auto; align-items: flex-start; max-width: calc(100% - 68px); gap: 5px; }
  .chip { font-size: 12px; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 10px; }
  .chip-icon { width: 22px; height: 22px; border-radius: 7px; }
  .chip-icon .icon { width: 14px; height: 14px; }
  .rep-overlay { padding: 24px 10px 8px; gap: 6px; }
  .rep-badge { font-size: 15px; padding: 5px 10px; border-radius: 10px; }
  .angle-chip { font-size: 14px; padding: 5px 10px; border-radius: 10px; }
  .rep-progress-track { height: 9px; }
  .rep-percent { font-size: 14px; min-width: 38px; }
  .compensation-banner { padding: 8px 12px; font-size: 14px; }
  .camera-placeholder { padding: 14px 56px 14px 14px; font-size: 13px; }
  .camera-placeholder strong { font-size: 16px; }
  .cam-tools { right: 6px; gap: 5px; }
  .cam-tools button { width: 36px; height: 36px; }

  /* ask the coach */
  .ask-coach-panel { padding: 10px 12px; gap: 8px; }
  .ask-coach-head .field-hint { font-size: 11.5px; line-height: 1.3; }
  .ask-coach-form { gap: 6px; }
  .ask-coach-form input[type="text"] { height: 42px; padding: 0 12px; font-size: 16px; min-width: 0; }
  .ask-coach-form .pill-btn, .ask-coach-form .icon-btn { height: 42px; min-height: 42px; }

  /* live feedback + demo */
  .feedback-panel .panel-head { margin-bottom: 8px; }
  .feedback-tiles { gap: 6px; }
  .tile { padding: 8px; gap: 2px; border-radius: 12px; }
  .tile-icon { width: 26px; height: 26px; margin-bottom: 2px; }
  .tile-icon .icon { width: 15px; height: 15px; }
  .tile-label { font-size: 11.5px; }
  .tile-value { font-size: 14px; }
  .demo-figures { gap: 6px; }
  .demo-figure figcaption { font-size: 12px; }
  .demo-disclaimer { font-size: 11.5px; margin-top: 8px; }

  /* summary */
  .summary-body { gap: 10px; }
  .vital-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .vital-tile { padding: 8px; gap: 3px; border-radius: 12px; }
  .vital-top { flex-direction: column; align-items: flex-start; gap: 4px; }
  .vital-icon { width: 26px; height: 26px; border-radius: 8px; }
  .vital-label { font-size: 11px; }
  .vital-value { font-size: 20px; }
  .vital-value small { font-size: 12px; }
  .vital-status { font-size: 11px; }
  .sim-tag { display: none; }
  .summary-empty { padding: 12px; font-size: 13.5px; }
  .summary-foot { font-size: 11.5px; margin-top: 8px; }
  .panel-head > #detail-btn { flex: 1 1 100%; justify-content: center; }

  /* ----- tables become stacked cards (no sideways scrolling) ----- */
  .table-scroll { overflow: visible; border: 0; }
  table.roster, .history-table, .report-table { min-width: 0; width: 100%; display: block; border: 0; }
  table.roster thead, .history-table thead, .report-table thead { display: none; }
  table.roster tbody, .history-table tbody, .report-table tbody { display: flex; flex-direction: column; gap: 8px; }
  table.roster tr, .history-table tr, .report-table tr {
    display: block; padding: 8px 12px; border: 1px solid var(--border); border-radius: 12px;
    background: rgba(var(--surface-rgb), 0.4);
  }
  table.roster td, .history-table td, .report-table td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right;
    padding: 4px 0; border: 0; font-size: 13.5px; min-width: 0; overflow-wrap: anywhere;
  }
  table.roster td::before, .history-table td::before, .report-table td::before {
    content: attr(data-label); flex: none; text-align: left; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
  }
  table.roster td:first-child, .history-table td:first-child, .report-table td:first-child {
    justify-content: flex-start; text-align: left; font-weight: 700; color: var(--ink); padding-bottom: 6px; font-size: 14.5px;
  }
  table.roster td:first-child::before, .history-table td:first-child::before, .report-table td:first-child::before { display: none; }
  .report-table-wrap { overflow: visible; border: 0; }
  .bar-track { width: 70px; }
  .roster-empty, .plan-empty { padding: 20px 12px; }

  /* ----- today: one compact card per exercise ----- */
  .exercise-card {
    display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 8px 12px; padding: 12px; margin-bottom: 8px;
    background: var(--surface); align-items: center;
  }
  .exercise-thumb { width: 52px; height: 52px; border-radius: 11px; }
  .exercise-info .e-name { font-size: 15px; line-height: 1.25; }
  .exercise-action { grid-column: 1 / -1; }
  .exercise-action .pill-btn, .exercise-action .status-badge { width: 100%; justify-content: center; min-height: 42px; }
  .today-empty { padding: 28px 12px; }

  /* ----- plan / clinician extras ----- */
  .progress-summary { gap: 8px; margin-bottom: 12px; }
  .phase-card { padding: 12px; gap: 10px; }
  .phase-marker { width: 18px; }
  .overview-body { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-tile .v { font-size: 22px; }
  .scope-note { padding: 10px 12px; font-size: 12.5px; }
  .activity-day { width: 12px; height: 12px; }

  /* ----- login / assessment ----- */
  .login-page { max-width: none; }
  .login-panel { gap: 12px; }
  .role-tab { padding: 9px 8px; }
  .prwe-item { margin-bottom: 12px; }

  /* ----- dialogs: compact bottom sheets ----- */
  .dialog-head { padding: 12px 14px 4px; }
  .dialog-head h2 { font-size: 17px; }
  .icon-btn { width: 36px; height: 36px; }
  .dialog-body { padding: 2px 14px 16px; font-size: 14px; max-height: calc(86dvh - 64px); }
  .dialog-body h3 { margin: 14px 0 4px; font-size: 14.5px; }
  .readouts { gap: 20px; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}

@media (max-width: 360px) {
  .brand-text h1 { font-size: 16px; }
  .vital-tiles { grid-template-columns: minmax(0, 1fr); }
}
