/* lw-send-app — mobile-first. Brand tokens are injected per-clinic from env in base.html. */
:root {
  --amber: #FFBF00;
  --ink: #1A1A1A;
  --bg: #f7f7f8;
  --card: #fff;
  --line: #e4e4e7;
  --muted: #6b7280;
  --danger: #b00020;
  --ok: #0f7b3f;
  --radius: 10px;
  --tap: 48px; /* minimum comfortable tap target */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  /* iPad home-screen install: keep content clear of the notch/home indicator */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ---- header ---- */
header {
  background: var(--ink);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}
header .dot { width: 12px; height: 12px; background: var(--amber); border-radius: 3px; flex: none; }
header b { font-size: 16px; font-weight: 700; }
header a { color: #b9b9bd; margin-left: auto; font-size: 14px; text-decoration: none; padding: 6px; }
header a:hover { color: #fff; }

/* ---- layout: ONE column, every size ----------------------------------------
   Not a mobile compromise. The two-column grid gave the programme a ~240px column, which wrapped
   every exercise name onto two lines and stacked its dosage selects; and below 800px it collapsed
   to one column anyway, so two layouts were maintained to get one of them right. A single centred
   column is one thing to build, one to test and one to break. activaition-ops#277 */
main { max-width: 720px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
main.narrow { max-width: 420px; }
/* clear of the fixed action bar, plus the home indicator on an installed iPad */
body:has(.bar) { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 12px; }
h2 .count { color: var(--ink); background: var(--amber); border-radius: 20px; padding: 1px 8px; margin-left: 6px; letter-spacing: 0; }
label { display: block; font-weight: 600; margin: 0 0 6px; }

/* ---- controls: 16px font stops iOS zooming on focus ---- */
select, textarea, input[type=password], input[type=search], input[type=text] {
  width: 100%; padding: 12px; border: 1px solid #c9c9cf; border-radius: 8px;
  font: inherit; font-size: 16px; background: #fff; color: var(--ink); min-height: var(--tap);
}
select:focus-visible, textarea:focus-visible, input:focus-visible, button:focus-visible {
  outline: 3px solid var(--amber); outline-offset: 1px;
}
textarea { min-height: 96px; resize: vertical; }
input[type=search] { margin-bottom: 8px; }

/* ---- video picker ---- */
/* No nested scroller on a phone. A scrolling list inside a scrolling page is painful on iOS at the
   best of times, and capping it left a window a few rows high once the keyboard was up. The page
   scrolls instead; the filter shortens the list anyway. Capped only where there is room for it. */
.list { border: 1px solid var(--line); border-radius: 8px; padding: 4px; -webkit-overflow-scrolling: touch; }
@media (min-width: 800px) { .list { max-height: 420px; overflow-y: auto; } }
.group-head { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 14px 10px 6px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.group:first-child .group-head { padding-top: 6px; }
.group[hidden], .vid[hidden] { display: none; }

.vid { display: flex; gap: 8px; align-items: center; border-radius: 8px; min-height: var(--tap); }
.vid + .vid { border-top: 1px solid #f1f1f3; }
.vid:hover { background: #fafafa; }
.vid-main { display: flex; gap: 12px; align-items: flex-start; flex: 1 1 auto; padding: 12px 10px;
  cursor: pointer; font-weight: 400; margin: 0; min-width: 0; }
.vid input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--amber); }
.vid-title { display: block; }
.vid .kind { font-size: 11px; color: #9ca3af; text-transform: uppercase; letter-spacing: .05em; }

/* Preview is a peek, not the main event — small, quiet, out of the way of the tap target. */
.play { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px; font-weight: 700; padding: 0; margin-right: 8px;
  width: 34px; height: 34px; min-height: 34px; flex: none; }
.play:hover { background: #f1f1f3; color: var(--ink); }
.player { padding: 0 10px 12px; }
.player video { width: 100%; max-height: 40vh; border-radius: 8px; background: #000; display: block; }

/* ---- buttons ---- */
button, .btn {
  background: var(--amber); color: var(--ink); border: 0; border-radius: 8px;
  padding: 14px 22px; font: inherit; font-weight: 700; font-size: 16px;
  cursor: pointer; min-height: var(--tap); display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
}
button:active { transform: translateY(1px); }
button[disabled] { background: #e8e8ea; color: #9ca3af; cursor: not-allowed; }
.secondary { background: #ececef; font-weight: 600; }
/* Send is the consequential action — let it dominate the row. */
.actions .secondary { flex: 0 1 auto; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.actions button, .actions .btn { flex: 1 1 auto; }

.note { font-size: 13px; color: var(--muted); margin-top: 10px; }
.note.err { color: var(--danger); }
.banner { background: #fff8e0; border: 1px solid var(--amber); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 16px 16px 0; }
.banner.err { background: #fdecef; border-color: #f3b6c0; color: var(--danger); }

/* ---- preview ---- */
.rendered { border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin: 12px 0; background: #fff; overflow-x: auto; }
.rendered pre { white-space: pre-wrap; word-break: break-word; font: inherit; margin: 0; }
.meta { font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.meta b { color: var(--ink); }
.result-ok h2, .result-ok .big { color: var(--ok); }
.result-err h2, .result-err .big { color: var(--danger); }
.big { font-size: 20px; font-weight: 700; margin: 0 0 8px; }

.htmx-request .spinner { display: inline; }
.spinner { display: none; font-weight: 600; color: var(--muted); font-size: 14px; }

/* --- browse list: every row identical, which is the point ------------------ */
.vid { display: flex; align-items: center; gap: 8px; }
.vid-main { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
/* Wrap, never ellipsis: "Wall assisted side on SL Soleus wall reaches into a curtsey squat"
   truncated mid-name is useless when you are choosing between two of them. */
.vid-title { overflow-wrap: anywhere; }

/* --- the programme: dosage lives here, for the two or three actually chosen --- */
.tray:empty { display: none; }
.picked { border-top: 1px solid var(--line, #e6e6e6); padding: 10px 0; }
.picked[hidden] { display: none; }          /* `hidden` loses to `display:flex` without this */
.picked-name { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.dose { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dose[hidden] { display: none; }
.dose select { width: auto; flex: 0 1 auto; min-height: 38px; padding: 6px 8px;
               font-size: 15px; margin: 0; }
.dose .times { color: #666; font-size: 14px; }
.dose .remove { margin-left: auto; background: none; border: 0; color: #a00;
                font-size: 13px; padding: 6px 4px; min-height: 38px; width: auto; }
.who { margin-left: auto; font-size: 14px; opacity: .75; }


/* ---- the one action, fixed where it can always be reached ------------------ */
.bar[hidden] { display: none; }
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .95); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.bar button[type=submit] { flex: 1 1 auto; max-width: 688px; margin: 0 auto; }
.bar .count { background: var(--ink); color: #fff; border-radius: 20px; padding: 1px 9px;
              margin-left: 8px; font-size: 14px; }

/* ---- preview modal --------------------------------------------------------- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center;
         justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .45); }
/* A flex column, not one scrolling box. The whole card used to scroll together, so at three or
   more exercises Send went off the bottom of a phone — losing the one button the modal exists for.
   The message scrolls; the actions do not move. activaition-ops#280 */
.modal-card {
  position: relative; width: 100%; max-width: 640px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border-radius: var(--radius); box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.modal-card .card { border: 0; border-radius: var(--radius); display: flex; flex-direction: column;
                    min-height: 0; overflow: hidden; }
.modal-card .rendered { overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-card .actions { flex: none; border-top: 1px solid var(--line); padding-top: 12px;
                       margin-top: 12px; background: var(--card); }
body.modal-open { overflow: hidden; }

/* Nothing chosen yet: the field reads as an instruction rather than as an answer. */
select.unset { color: var(--muted); border-color: #c9c9cf; }
.chosen { margin: 8px 0 0; font-weight: 600; font-size: 15px; }
.chosen[hidden] { display: none; }

/* ---- patient picker: search over a results list ---------------------------- */
.plist { border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; overflow: hidden; }
.plist[hidden] { display: none; }
.prow { display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
        width: 100%; text-align: left; background: #fff; border: 0;
        border-bottom: 1px solid var(--line); padding: 10px 12px; min-height: var(--tap);
        font: inherit; color: var(--ink); cursor: pointer; }
.prow:last-child { border-bottom: 0; }
.prow:hover, .prow:focus-visible { background: #fbf6e6; }
.prow[hidden] { display: none; }
.prow-name { font-weight: 600; }
.prow-email { font-size: 13px; color: var(--muted); }
.chosen { margin: 10px 0 0; font-weight: 600; font-size: 15px; }
.chosen[hidden] { display: none; }
.chosen.warn { color: var(--danger); }
button.link { background: none; border: 0; padding: 0 2px; width: auto; min-height: 0;
              font: inherit; font-weight: 500; font-size: 14px; color: #1a5fb4;
              text-decoration: underline; cursor: pointer; }
