/* medrow.css — the When / How long pick list (medrow.js) and the phone card layout of the medicine rows.
   Dr Shah, 28-Nov-2026: "The frequency & duration should be selected from the intuitive dropdown."
   U15: every rule with text names its colour and background together. UX-M1: 44 px taps, 8 px apart at <= 1024 px. UX-01: no sideways scroll. */
.mrpop { position: absolute; z-index: 60; box-sizing: border-box; max-width: calc(100vw - 16px); max-height: 320px; overflow-y: auto; padding: 4px;
  background: #fff; color: var(--ink, #1b2733); border: 1px solid var(--line, #d3dce5); border-radius: 10px; box-shadow: 0 8px 24px #0f2a3a2e; }
.mrpop[hidden], .mrback[hidden] { display: none !important; }
.mrpop .mrhead { display: none; }
.mrpop .mrlist { list-style: none; margin: 0; padding: 0; }
.mrpop [role=option] { display: flex; align-items: center; gap: 4px 10px; min-height: 44px; box-sizing: border-box; padding: 6px 12px; border-radius: 6px; cursor: pointer;
  font-size: 15px; background: #fff; color: var(--ink, #1b2733); }
.mrpop [role=option] b { font-weight: 700; white-space: nowrap; }
.mrpop [role=option] small { font-size: 12.5px; color: var(--muted, #5d6b7a); background: transparent; }
.mrpop [role=option]:hover, .mrpop [role=option].act { background: var(--accent-2, #e3f1f6); color: var(--accent-d, #0b5870); }
.mrpop [role=option][aria-selected=true] { background: #eef6f9; color: var(--accent-d, #0b5870); box-shadow: inset 3px 0 0 var(--accent, #0f6e8c); }
.mrpop [role=option].mrusual small { color: var(--accent-d, #0b5870); background: transparent; font-weight: 600; }
.mrpop .mrnone { margin: 6px 10px; font-size: 13px; color: var(--muted, #5d6b7a); background: #fff; }
/* phone: a bottom sheet over a backdrop */
.mrback { position: fixed; inset: 0; z-index: 59; background: #0f2a3a59; }
.mrpop.mrsheet { position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-width: none; width: 100%; max-height: 62vh; padding: 0 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-radius: 14px 14px 0 0; border-bottom: 0; }
.mrpop.mrsheet .mrhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 1; padding: 10px 0 8px;
  background: #fff; color: var(--ink, #1b2733); font-size: 16px; }
.mrpop.mrsheet .mrown { min-height: 44px; padding: 6px 14px; background: #fff; color: var(--accent-d, #0b5870); border: 1px solid var(--accent, #0f6e8c); border-radius: 22px; font-size: 15px; }
.mrpop.mrsheet .mrlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mrpop.mrsheet [role=option] { flex-direction: column; align-items: flex-start; justify-content: center; gap: 0; border: 1px solid var(--line, #d3dce5); font-size: 16px; }
.mrpop.mrsheet [role=option] small { white-space: normal; line-height: 1.25; }
.mrpop.mrsheet [role=option].mrusual { grid-column: 1 / -1; }
@media (max-width: 1024px) { .mrpop .mrlist { display: grid; gap: 8px; } }

/* the medicine rows on a phone: one card per medicine — line 1 form + medicine + ✕, line 2 strength · when · how long, line 3 instructions */
@media (max-width: 600px) {
  .sec[data-sec=meds] table.items, .sec[data-sec=meds] table.items tbody { display: block; width: 100%; table-layout: auto; }
  .sec[data-sec=meds] table.items thead { display: none; }
  #items tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1.15fr)) repeat(4, minmax(0, 1fr)) 44px; column-gap: 8px; row-gap: 8px; align-items: start; padding: 10px 0;
    border-bottom: 1px solid var(--line2, #e6ecf1); background: transparent; color: var(--ink, #1b2733); }
  #items td { display: block; width: auto; min-width: 0; padding: 0; border: 0; }
  #items tr > td:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
  #items tr > td:nth-child(2) { grid-column: 3 / 7; grid-row: 1; }
  #items tr > td:nth-child(7) { grid-column: 7; grid-row: 1; }
  #items tr > td:nth-child(3) { grid-column: 1 / 3; grid-row: 2; }
  #items tr > td:nth-child(4) { grid-column: 3 / 5; grid-row: 2; }
  #items tr > td:nth-child(6) { grid-column: 5 / 8; grid-row: 2; }
  #items tr > td:nth-child(5) { grid-column: 1 / 8; grid-row: 3; }
  #items td:nth-child(n+3):not(:nth-child(7))::before { display: block; margin: 0 0 2px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; text-transform: uppercase;
    color: var(--muted, #5d6b7a); background: transparent; }
  #items td:nth-child(3)::before { content: 'Strength'; } #items td:nth-child(4)::before { content: 'When'; }
  #items td:nth-child(5)::before { content: 'Instructions'; } #items td:nth-child(6)::before { content: 'How long'; }
  /* UX-21 at 360 px: columns 1-2 (form, strength) a little wider and 4 px side padding, so "Cap." and "500 mg" fit their boxes */
  #items select, #items input { width: 100%; box-sizing: border-box; min-height: 44px; font-size: 16px; padding-left: 4px; padding-right: 4px; }
  #items button.x { width: 44px; min-width: 44px; min-height: 44px; padding: 0; background: #fff; color: var(--err, #b3261e); }
}
