/* ECHO patient tablet. Claymorphism, calm light medical palette. */

.p-app { min-height: 100dvh; display: flex; flex-direction: column; }

/* Top bar: solid navy chrome (see base.css), room code prominent, actions grouped right */
.p-top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 22px;
  padding-top: calc(12px + var(--safe-t));
}
.p-top-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.p-top-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.p-top-brand .brand-name {
  margin: 0; font-weight: 800; font-size: 17px; line-height: 1.15; color: var(--chrome-ink);
}
.p-room {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600; color: var(--chrome-ink-soft);
}
.p-room b {
  font-family: "Google Sans", ui-monospace, monospace;
  font-size: 14.5px; font-weight: 800; letter-spacing: .08em; color: var(--chrome);
  background: rgba(255, 253, 248, .92);
  border: none;
  border-radius: 8px; padding: 1px 8px 2px;
  box-shadow: 0 2px 6px rgba(18, 33, 49, .25);
}
.p-status { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.p-act { font-weight: 700; }
.p-top .btn.p-act--quiet { color: var(--chrome-ink-soft); }
@media (max-width: 700px) {
  .p-top { gap: 8px 10px; padding: 10px 16px; padding-top: calc(10px + var(--safe-t)); }
  #capsChips { width: 100%; }
}
@media (max-width: 480px) {
  .p-top { padding: 10px 14px; padding-top: calc(10px + var(--safe-t)); gap: 8px; }
  .p-top-brand { gap: 9px; }
  .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
  .brand-mark .ic { width: 96%; height: 96%; }
  .brand-name { font-size: 17px; }
  .p-room { font-size: 11.5px; }
  .p-room b { font-size: 13px; }
  .p-status { width: 100%; justify-content: flex-start; gap: 6px; margin-top: 2px; }
  .p-status .btn-sm { padding: 6px 10px; font-size: 13px; }
}

/* Wizard gate */
.gate { max-width: 470px; margin: 0 auto; padding: 40px 20px 60px; width: 100%; }
@media (max-width: 480px) {
  .gate { padding: calc(18px + var(--safe-t)) 16px calc(40px + var(--safe-b)); }
}
/* Short landscape viewports (phones/tablets rotated on a pillow or arm mount):
   the logo column dominates vertical space, so compress it and let the gate
   center scroll reach the CTA without a two-finger hunt. */
@media (max-height: 500px) and (orientation: landscape) {
  .gate { padding: 2px 20px 8px; }
  .role-nav { margin-bottom: 3px !important; padding: 0; gap: 4px; }
  .role-nav .badge { padding: 2px 8px !important; font-size: 10.5px !important; }
  .role-nav .badge svg, .role-nav .badge span[data-ic] { display: none; }
  .gate-logo { margin: 0; gap: 2px; }
  .gate-logo .brand-mark { display: none; }
  .gate-logo h1 { font-size: 16px; margin: 0; }
  .gate-logo .tag { display: none; }
  .gate-card { gap: 6px !important; padding: 8px 14px 10px !important; }
  .gate-card label { margin-bottom: 2px !important; font-size: 11px !important; }
  .gate-card input { padding: 6px 10px !important; font-size: 14px !important; border-radius: 8px !important; }
  .gate-card .hint { display: none !important; }
  .gate-cta { padding: 8px !important; font-size: 14px !important; margin-top: 0 !important; }
}
.gate-logo .brand-mark { width: 76px; height: 76px; border-radius: 24px; box-shadow: var(--clay-shadow), inset 1px 2px 3px rgba(255,255,255,.85), inset -2px -3px 5px rgba(37,77,112,.12); }
.gate-logo .brand-mark .ic { width: 96%; height: 96%; }
.gate-logo h1 { font-family: var(--font-display); font-size: clamp(27px, 7vw, 35px); font-weight: 700; line-height: 1.08; margin: 6px 0 0; letter-spacing: -.015em; }
.gate-logo .tag { color: var(--teal-ink); margin: 0; font-size: clamp(13.5px, 3.8vw, 15.5px); font-style: italic; font-weight: 500; line-height: 1.45; font-family: var(--font-display); }

.gate-card { display: grid; gap: 16px; padding: 26px 24px 24px; }
.gate-card label { font-size: 13.5px; color: var(--text-soft); font-weight: 700; display: block; margin-bottom: 7px; }
.gate-card input {
  width: 100%; background: var(--surface-2);
  border: 1px solid rgba(255,255,255,.7);
  border-radius: 14px; padding: 13px 16px; font-size: 17px; font-weight: 600;
  box-shadow: var(--clay-pressed);
  color: var(--text);
}
.gate-card input::placeholder { color: var(--text-faint); font-weight: 500; }
.gate-card .hint { color: var(--text-soft); font-size: 13.5px; margin: 0; line-height: 1.5; }
.gate-err { color: #a63a3a; background: var(--alert-soft); border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 600; }
.gate-cta { padding: 16px; font-size: 17.5px; margin-top: 4px; }

/* Home: greeting + calm grouped sections */
.p-main { flex: 1; padding: 20px 22px calc(90px + var(--safe-b)); display: flex; flex-direction: column; gap: 26px; width: 100%; max-width: 1080px; margin: 0 auto; }
@media (max-width: 500px) {
  .p-main { padding: 14px 16px calc(84px + var(--safe-b)); gap: 20px; }
}
.p-greet { display: flex; flex-direction: column; gap: 2px; }
.p-greet-name {
  margin: 0; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(25px, 4vw, 33px); line-height: 1.12; letter-spacing: -.015em;
  color: var(--text);
}
.p-greet-sub { margin: 0; color: var(--text-soft); font-size: clamp(14px, 2.6vw, 15.5px); font-weight: 500; line-height: 1.45; }

.p-section { display: flex; flex-direction: column; gap: 12px; }
.p-section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 0 4px; }
.p-section-head h2 {
  margin: 0; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(17px, 2.8vw, 20px); line-height: 1.25; letter-spacing: -.005em;
  color: var(--text); display: flex; align-items: center; gap: 10px;
}
.p-section-head p { margin: 0; color: var(--text-faint); font-size: clamp(12.5px, 2.4vw, 14px); font-weight: 500; line-height: 1.45; }
.p-section-flag { width: 10px; height: 10px; border-radius: 3px; flex: none; align-self: center; }
.p-section-flag--red { background: var(--alert); box-shadow: inset 1px 1px 2px rgba(120, 38, 38, .4), 0 0 0 4px rgba(212, 84, 84, .12); }
.p-section-flag--teal { background: var(--clay-deep); box-shadow: inset 1px 1px 2px rgba(29, 63, 92, .35), 0 0 0 4px rgba(168, 213, 204, .28); }

.tiles { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (min-width: 980px) { .tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 500px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 132px; padding: 18px 10px 14px; border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow:
    5px 6px 14px rgba(37, 77, 112, .10),
    -4px -4px 10px rgba(255, 255, 255, .8),
    inset 1px 1px 2px rgba(255, 255, 255, .8),
    inset -1px -2px 3px rgba(37, 77, 112, .06);
  font-size: clamp(15px, 1.9vw, 17.5px); font-weight: 650; letter-spacing: -.003em;
  text-align: center; line-height: 1.27; color: var(--ink-on-fill);
  transition: transform .16s ease, box-shadow .18s ease;
  animation: tilein .4s cubic-bezier(.2, .9, .3, 1.05) backwards;
  animation-delay: var(--i, 0ms);
  min-width: 0;
  overflow: hidden;
}
.tile .tile-lbl {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
  text-wrap: balance;
}
@media (max-width: 500px) {
  .tile { min-height: 114px; padding: 12px 6px 10px; border-radius: var(--radius-md); gap: 6px; }
  .tile .tile-ic { width: 34px; height: 34px; }
  .tile .tile-lbl { font-size: 15.5px; }
  .tile--red {
    grid-column: 1 / -1;
    min-height: 84px !important;
    flex-direction: row !important;
    gap: 16px !important;
    padding: 12px 18px !important;
  }
  .tile--red .tile-ic { width: 38px !important; height: 38px !important; }
  .tile--red .tile-lbl { font-size: 18px !important; text-align: left !important; }
}
@keyframes tilein {
  from { opacity: 0; transform: translateY(16px) scale(.94); }
  to { opacity: 1; transform: none; }
}

/* hover lift (pointer devices only) */
@media (hover: hover) {
  .tile:hover { transform: translateY(-4px); box-shadow: var(--clay-raised); }
}

/* tap pulse ring */
.tile.tapped::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  animation: ringout .55s ease-out forwards; pointer-events: none;
}
@keyframes ringout {
  from { box-shadow: 0 0 0 0 rgba(37, 77, 112, .45); }
  to { box-shadow: 0 0 0 22px rgba(37, 77, 112, 0); }
}
.tile--red.tapped::after {
  animation-name: ringout-red;
}
@keyframes ringout-red {
  from { box-shadow: 0 0 0 0 rgba(212, 84, 84, .5); }
  to { box-shadow: 0 0 0 22px rgba(212, 84, 84, 0); }
}
.tile .tile-ic {
  width: 52px; height: 52px; flex: none;
  border-radius: 16px;
  background: linear-gradient(160deg, #f0faf7, #e1f2ed);
  border: 1px solid rgba(255, 255, 255, .9);
  box-shadow: inset 1px 1px 2px rgba(255,255,255,.9), inset -1px -2px 3px rgba(37, 77, 112, .08), 2px 3px 6px rgba(37, 77, 112, .08);
  display: flex; align-items: center; justify-content: center;
  color: #3f7f76;
}
.tile .tile-ic svg { width: 27px; height: 27px; }

/* Urgent tiles: calm mint fill; icon well blends into the fill */
.tile--urgent .tile-ic,
.tile--red .tile-ic { background: transparent; border-color: transparent; box-shadow: none; }
.tile--urgent {
  background: linear-gradient(145deg, #35658e, #254d70);
  color: #fff;
  border-color: rgba(255,255,255,.35);
  box-shadow:
    8px 10px 20px rgba(37, 77, 112, .28),
    -6px -6px 14px rgba(255,255,255,.4),
    inset 1px 2px 3px rgba(255,255,255,.4),
    inset -2px -3px 5px rgba(29,63,92,.3);
}
.tile--urgent .tile-ic { color: rgba(255,255,255,.92); }
.tile-flag {
  position: absolute; top: 9px; right: 9px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: rgba(255,255,255,.85);
  background: rgba(29, 63, 92, .28);
  padding: 3px 7px; border-radius: 999px;
}
.tile:active { transform: translateY(3px) scale(.98); box-shadow: var(--clay-pressed); }

.tile--red {
  background: linear-gradient(145deg, #dd6161, #bd4848);
  color: #fff;
  border-color: rgba(255,255,255,.35);
  box-shadow:
    8px 10px 20px rgba(184, 68, 68, .34),
    -6px -6px 14px rgba(255,255,255,.4),
    inset 1px 2px 3px rgba(255,255,255,.35),
    inset -2px -3px 5px rgba(120,38,38,.32);
}
.tile--red .tile-ic { color: rgba(255,255,255,.95); }
.tile--red .tile-lbl { font-size: clamp(17px, 2.4vw, 20px); font-weight: 700; letter-spacing: .015em; }
.tile--red.et-phone-home { animation: claypulse 1.6s ease-in-out infinite; }
@keyframes claypulse {
  0%, 100% { box-shadow: 8px 10px 20px rgba(184,68,68,.34), -6px -6px 14px rgba(255,255,255,.4), inset 1px 2px 3px rgba(255,255,255,.35), inset -2px -3px 5px rgba(120,38,38,.32); }
  50% { box-shadow: 8px 10px 20px rgba(184,68,68,.55), -6px -6px 14px rgba(255,255,255,.4), 0 0 0 10px rgba(212,84,84,.14), inset 1px 2px 3px rgba(255,255,255,.35), inset -2px -3px 5px rgba(120,38,38,.32); }
}

.tile--custom .rm {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px;
  border-radius: 50%; background: var(--surface-2); color: var(--text-soft);
  box-shadow: var(--clay-sm); display: flex; align-items: center; justify-content: center;
}
.tile--custom .rm .ic { width: 14px; height: 14px; }

.tile--add {
  background: var(--surface-2); color: var(--text-faint);
  border: 2px dashed var(--line-strong); box-shadow: none;
}
.tile--add .tile-ic { width: 32px; height: 32px; }

/* Panel routing */
.p-panel { flex: 1; padding: 8px 18px calc(90px + var(--safe-b)); width: 100%; max-width: 860px; margin: 0 auto; animation: panelin .3s cubic-bezier(.2, .9, .3, 1.08); }
@keyframes panelin {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
.panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-head h2 {
  margin: 0; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(24px, 3.6vw, 32px); display: flex; align-items: center; gap: 12px;
  line-height: 1.1; letter-spacing: -.015em;
}
.panel-head h2 .ic { width: 30px; height: 30px; color: var(--accent-deep); }
.back { padding: 10px 18px; font-size: 15px; gap: 8px; }

/* Yes/No */
.yn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 14px; }
.yn-ques { font-family: var(--font-display); font-size: clamp(20px, 3vw, 27px); font-weight: 600; margin: 4px 0 6px; line-height: 1.35; }
.yn-big { min-height: 108px; font-size: clamp(20px, 3.4vw, 27px); font-weight: 700; letter-spacing: -.01em; gap: 12px; }
@media (max-width: 480px) {
  .yn-grid { grid-template-columns: 1fr; gap: 10px; }
  .yn-big { min-height: 76px; font-size: 19px; }
}

/* Speak / confirm bar */
.confirm-bar { margin-top: 18px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* Whiteboard: the Write tile draws instead of typing. */
.wb-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.wb-tool {
  border: 0;
  border-radius: 14px;
  padding: 11px 18px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--surface-2, #eef1f6);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .7) inset, 0 4px 10px rgba(23, 35, 58, .06);
  cursor: pointer;
}
.wb-tool.on { color: var(--accent-deep, #2b4a86); background: var(--accent-soft, #dfe9ff); }
.wb-tool:active { transform: translateY(1px); }
.wb-canvas {
  display: block;
  width: 100%;
  height: min(48vh, 420px);
  min-height: 220px;
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--line, #e2e7f0);
  box-shadow: 0 8px 22px rgba(23, 35, 58, .08) inset;
  touch-action: none;
  cursor: crosshair;
}
.wb-canvas.is-drawing { cursor: default; }
.speak-btn { padding: 14px 24px; font-size: 17px; }
@media (max-width: 480px) {
  .confirm-bar .btn { flex: 1 1 auto; width: 100%; }
}

/* "How urgent is it?" severity picker */
.sev-list { display: grid; gap: 12px; margin-top: 16px; }
.sev-opt {
  display: flex; align-items: center; gap: 16px; width: 100%;
  min-height: 64px; padding: 15px 18px;
  border-radius: var(--radius-lg, 18px);
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.65);
  box-shadow: var(--clay-sm);
  font: inherit; font-weight: 700; font-size: 16.5px; line-height: 1.35;
  color: var(--text); text-align: left; word-break: break-word;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.sev-opt:active { transform: translateY(2px) scale(.985); box-shadow: var(--clay-pressed, var(--clay-sm)); }
.sev-dot { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 -2px 0 rgba(0,0,0,.16), 0 0 0 2px rgba(255,255,255,.85); }
.sev-low .sev-dot { background: var(--ok); }
.sev-med .sev-dot { background: var(--warn); }
.sev-high { color: #a63a3a; border-color: rgba(199, 87, 87, .3); }
.sev-high .sev-dot { background: var(--alert); }
@media (max-width: 480px) {
  .sev-opt { min-height: 56px; font-size: 16px; padding: 13px 15px; }
}


/* Write and alphabet */
.alph-out {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,.7); border-radius: var(--radius-md);
  box-shadow: var(--clay-pressed);
  padding: 16px 18px; font-size: clamp(18px, 3.2vw, 27px); font-weight: 700; min-height: 66px;
  word-break: break-word; margin-top: 16px; color: var(--text);
}
.alph-out:empty::before { content: attr(data-placeholder); color: var(--text-faint); font-weight: 500; font-size: 16px; }
.alph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 8px; margin-top: 16px; }
.alph-grid button {
  height: 52px; border-radius: 14px; background: var(--surface);
  border: 1px solid rgba(255,255,255,.65); box-shadow: var(--clay-sm);
  font-size: 19px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  color: var(--text); min-width: 0; overflow: hidden;
}
.alph-grid button:active { transform: translateY(2px); box-shadow: var(--clay-pressed); }
@media (hover: hover) {
  .alph-grid button:hover { transform: translateY(-2px); box-shadow: var(--clay-raised); }
  .alph-grid button:active { transform: translateY(1px); transition-duration: .06s; }
}
.alph-grid button.del { color: #a6701f; background: var(--warn-soft); }
.alph-grid button.space { grid-column: span 3; font-size: 15px; gap: 6px; }
.alph-grid button.send { grid-column: span 2; background: linear-gradient(145deg, #35658e, #254d70); color: #fff; border-color: rgba(255,255,255,.35); gap: 6px; }
.alph-quick { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
@media (max-width: 480px) {
  .alph-grid { grid-template-columns: repeat(6, 1fr); gap: 5px; }
  .alph-grid button { height: 46px; font-size: 17px; border-radius: 10px; }
  .alph-grid button.space { grid-column: span 3; font-size: 13px; }
  .alph-grid button.send { grid-column: span 2; font-size: 13px; }
  .alph-grid button.del { grid-column: span 1; }
}

/* Blink stage */
.blink-stage {
  padding: 22px; border-radius: var(--radius-xl); background: var(--surface);
  border: 1px solid rgba(255,255,255,.65); box-shadow: var(--clay-shadow);
  margin-top: 8px;
}
.blink-lesson { font-family: var(--font-display); font-size: clamp(17px, 3vw, 24px); font-weight: 600; margin-bottom: 14px; line-height: 1.4; }

/* Camera assist (eye-blink mode) */
.blink-cam-stage {
  padding: 22px; border-radius: var(--radius-xl); background: var(--surface);
  border: 1px solid rgba(255,255,255,.65); box-shadow: var(--clay-shadow);
  margin-top: 16px;
}
.blink-cam-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.blink-cam-head h3 {
  margin: 0; font-family: var(--font-display); font-size: clamp(18px, 3vw, 23px); font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.blink-cam-head h3 .ic { width: 22px; height: 22px; color: var(--accent-deep); }
.blink-cam-note { color: var(--text-soft); font-size: 13.5px; line-height: 1.55; margin: 8px 0 12px; }
.blink-cam-frame {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  background: #10181d; box-shadow: var(--clay-pressed), 0 0 0 4px rgba(37,77,112,.12);
  aspect-ratio: 4 / 3; max-width: 520px;
}
.blink-cam-frame video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scaleX(-1); /* mirrored, like a mirror — patients orient instantly */
}
.blink-cam-live {
  position: absolute; top: 10px; left: 10px;
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(13, 20, 25, .55); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .12em;
  padding: 5px 10px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.blink-cam-live .dot { width: 8px; height: 8px; }
.blink-cam-off { position: absolute; bottom: 10px; right: 10px; }
.blink-cam-readout {
  position: absolute; bottom: 10px; left: 10px; right: auto;
  display: flex; align-items: center; gap: 8px;
  background: rgba(13, 20, 25, .55); color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 5px 10px; border-radius: 999px;
  backdrop-filter: blur(4px);
  max-width: calc(100% - 90px);
}
.blink-cam-readout meter { width: 64px; height: 8px; }
.blink-cam-frame.blink-pulse {
  box-shadow: 0 0 0 6px #35658e, var(--clay-shadow);
  transition: box-shadow .12s ease;
}
/* Eye alignment guide. MUST mirror the detector's sampling boxes in
   blink-detector usage (patient.js BLINK_EYE_BOXES):
   left x 20% w 26%, right x 54% w 26%, y 22% h 26% — so what the patient
   aligns their eyes with is exactly the region the tracker reads. */
.blink-eye-guide {
  position: absolute; inset: 0; pointer-events: none;
}
.blink-eye-guide .eye-box {
  position: absolute; top: 22%; height: 26%; width: 26%;
  border: 2px dashed rgba(255,255,255,.55);
  border-radius: 12px; background: rgba(255,255,255,.05);
  box-shadow: inset 0 0 10px rgba(0,0,0,.25);
}
.blink-eye-guide .eye-box.left { left: 20%; }
.blink-eye-guide .eye-box.right { left: 54%; }
.blink-eye-guide .guide-label {
  position: absolute; bottom: 8%; left: 0; right: 0; text-align: center;
  color: rgba(255,255,255,.8); font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-shadow: 0 1px 3px rgba(0,0,0,.9);
}
.btn-pulse {
  animation: btnPulseAnim .5s ease-in-out infinite alternate;
}
@keyframes btnPulseAnim {
  from { transform: scale(1); box-shadow: var(--clay-sm); }
  to { transform: scale(1.05); box-shadow: 0 0 0 4px var(--mint), var(--clay-shadow); }
}
.blink-cam-ctrls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.blink-help { color: var(--text-soft); margin: 10px 2px 0; font-size: 14px; line-height: 1.5; }
.blink-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
@media (max-width: 480px) {
  .blink-actions .btn { flex: 1 1 100%; width: 100%; }
  .blink-cam-frame { max-width: 100%; }
}
.blink-ref { font-size: 13px; color: var(--text-faint); margin-top: 14px; line-height: 1.5; }

/* Capabilities */
.cap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 14px; }
.cap {
  padding: 14px 10px; border-radius: var(--radius-md); background: var(--surface);
  border: 1px solid rgba(255,255,255,.65); box-shadow: var(--clay-sm);
  font-weight: 700; font-size: 14px; text-align: center; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  min-width: 0; word-break: break-word;
}
.cap .ic { width: 24px; height: 24px; color: var(--text-soft); }
.cap small { font-weight: 600; font-size: 11.5px; color: var(--text-faint); letter-spacing: .02em; }
.cap.on {
  background: linear-gradient(145deg, #35658e, #254d70); color: #fff;
  border-color: rgba(255,255,255,.35);
  box-shadow: 6px 8px 14px rgba(37,77,112,.3), -4px -4px 10px rgba(255,255,255,.5);
}
.cap.on .ic { color: rgba(255,255,255,.95); }
.cap.on small { color: rgba(255,255,255,.85); }
@media (max-width: 480px) {
  .cap-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .cap { padding: 12px 6px; font-size: 13px; }
}

/* Flash overlay for emergencies */
.flash-ov { position: fixed; inset: 0; z-index: 80; pointer-events: none; }
.flash-ov.red { background: rgba(212, 84, 84, .5); }
.flash-ov.white { background: rgba(255, 255, 255, .85); }

/* Emergency active alert banner — parked just below the top bar so it never
   covers or clips the toolbar buttons. JS nudges `top` to the real header
   height when the bar wraps taller (mobile, chips row). */
.emg-banner {
  position: fixed; top: calc(78px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  width: min(94vw, 560px); z-index: 100;
  background: linear-gradient(145deg, #df5b5b, #b73939);
  color: #fff; border-radius: 18px; padding: 14px 18px;
  box-shadow: 0 10px 30px rgba(183, 57, 57, 0.4), inset 1px 1px 2px rgba(255,255,255,0.4);
  border: 1px solid rgba(255,255,255,0.3);
  animation: bannerSlide .35s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes bannerSlide {
  from { opacity: 0; transform: translate(-50%, -20px) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
.emg-banner-inner { display: grid; gap: 8px; text-align: center; }
.emg-banner-badge {
  font-size: 13px; font-weight: 800; letter-spacing: 0.08em;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-transform: uppercase;
}
.emg-banner-badge .ic { width: 20px; height: 20px; flex-shrink: 0; }
.emg-banner-msg { font-size: 13.5px; opacity: 0.95; line-height: 1.4; }
.emg-banner-acts { display: flex; justify-content: center; margin-top: 4px; }
.emg-cancel-btn {
  background: rgba(255,255,255,0.2) !important;
  color: #fff !important; border: 1px solid rgba(255,255,255,0.4) !important;
  font-weight: 700 !important; border-radius: 12px !important;
  padding: 9px 16px !important; min-height: 44px; cursor: pointer;
}
.emg-cancel-btn:hover { background: rgba(255,255,255,0.3) !important; }
@media (max-width: 480px) {
  .emg-banner { padding: 12px 14px; border-radius: 16px; }
  .emg-banner-badge { font-size: 12px; }
  .emg-banner-msg { font-size: 13px; }
  .emg-cancel-btn { width: 100%; text-align: center; }
}

/* Custom tile dialog */
.custom-tile-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.custom-tile-chip {
  padding: 8px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--line); cursor: pointer;
  box-shadow: var(--clay-sm); color: var(--text);
  transition: transform .12s ease;
}
@media (pointer: coarse) {
  .custom-tile-chip { min-height: 44px; }
}
.custom-tile-chip:hover { transform: translateY(-2px); border-color: var(--accent); }

/* Touch-first screens skip continuous polish effects and keep taps cheap. */
@media (hover: none) {
  .p-top {
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .tile {
    animation: none;
    box-shadow: 0 2px 6px rgba(37, 77, 112, .12);
    transition: transform .08s ease;
  }
  .tile:active { transform: scale(.985); }
  .tile.tapped::after { content: none; }
}

/* ================================================================
   Eye-blink YES/NO screen (bns-*)
   Claymorphic, tablet-first: very large question and answer text,
   big touch fallbacks, compact camera dock, visible privacy chip.
   ================================================================ */
.bns { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.bns-safety {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.bns-safety-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bns-emg { background: linear-gradient(145deg, #df5b5b, #b73939); color: #fff; border-color: rgba(255,255,255,.35); }
.bns-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid rgba(255,255,255,.7);
  box-shadow: var(--clay-sm); border-radius: 999px; padding: 8px 14px;
  font-size: 13px; color: var(--text-soft); min-height: 40px;
}
.bns-chip b { color: var(--text); font-size: 13px; }
.bns-chip small { color: var(--text-faint); font-size: 11.5px; font-weight: 700; letter-spacing: .03em; }
.bns-chip-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--text-faint); flex: none;
}
.bns-chip.on .bns-chip-dot { background: #3f9c72; box-shadow: 0 0 0 4px rgba(63,156,114,.18); animation: bnsLive 1.8s ease-in-out infinite; }
.bns-chip.warn .bns-chip-dot { background: #c9892b; box-shadow: 0 0 0 4px rgba(201,137,43,.18); }
.bns-chip.off .bns-chip-dot { background: #b8afa2; }
@keyframes bnsLive { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.bns-banner {
  border-radius: 14px; padding: 11px 15px; font-size: 14px; font-weight: 700;
  background: var(--surface-2); color: var(--text-soft);
  border: 1px solid rgba(255,255,255,.7); box-shadow: var(--clay-sm);
}
.bns-banner.warn { background: #fdf3df; color: #7d5a1c; }
.bns-banner.good { background: var(--accent-soft); color: var(--teal-ink); }
.bns-banner.red { background: var(--alert-soft); color: #8e3232; }

.bns-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 272px;
  gap: 16px; align-items: start;
}
.bns-main {
  background: var(--surface); border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius-xl); box-shadow: var(--clay-shadow);
  padding: clamp(18px, 3vw, 30px); min-height: 420px;
}
.bns-side { display: grid; gap: 12px; position: sticky; top: 12px; }
.bns-kicker {
  margin: 0 0 8px; font-size: 12px; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-faint);
}
.bns-title {
  margin: 0 0 14px; font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 42px); line-height: 1.12; font-weight: 700;
}
.bns-title .yes, .bns-legend .yes { color: var(--teal-ink); }
.bns-title .no, .bns-legend .no { color: #a63a3a; }
.bns-lead { color: var(--text-soft); font-size: clamp(15px, 2vw, 18px); line-height: 1.6; margin: 0 0 8px; max-width: 62ch; }
.bns-legend { display: flex; gap: 12px; flex-wrap: wrap; margin: 18px 0; }
.bns-legend-item {
  display: flex; align-items: baseline; gap: 8px;
  background: var(--surface-2); border-radius: 18px; padding: 14px 20px;
  box-shadow: var(--clay-pressed); min-width: 170px;
}
.bns-legend-item b { font-size: 34px; line-height: 1; color: var(--text); }
.bns-legend-item span { color: var(--text-soft); font-weight: 700; font-size: 15px; }
.bns-legend-item strong { margin-left: auto; font-size: 19px; letter-spacing: .04em; }
.bns-privacy {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--accent-soft); border-radius: 18px; padding: 14px 16px;
  margin: 16px 0; color: var(--teal-ink);
}
.bns-privacy .ic { width: 26px; height: 26px; flex: none; margin-top: 1px; }
.bns-privacy p { margin: 0; font-size: 13.5px; line-height: 1.55; }
.bns-eyemode { border: 0; padding: 0; margin: 18px 0 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.bns-eyemode legend { font-size: 13px; font-weight: 800; color: var(--text-soft); margin-bottom: 8px; padding: 0; width: 100%; }
.bns-eye {
  padding: 11px 16px; min-height: 48px; border-radius: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid rgba(255,255,255,.7);
  box-shadow: var(--clay-sm); font-weight: 700; font-size: 14px; color: var(--text);
}
.bns-eye.on { background: linear-gradient(145deg, #35658e, #254d70); color: #fff; border-color: rgba(255,255,255,.35); }
.bns-hint { margin: 8px 0 0; font-size: 13px; color: var(--text-faint); line-height: 1.5; }
.bns-startrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.bns-primary { min-height: 58px; padding: 14px 22px; font-size: 17px; white-space: normal; }
.bns-ref { margin: 16px 0 0; font-size: 12.5px; color: var(--text-faint); line-height: 1.5; }

/* Calibration */
.bns-calib-stage { display: grid; gap: 18px; justify-items: center; padding: 10px 0 4px; }
.bns-dot {
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--surface-2); box-shadow: inset 3px 3px 8px rgba(37,77,112,.16), inset -3px -3px 8px rgba(255,255,255,.9);
  transition: background .12s ease, box-shadow .12s ease, transform .12s ease;
}
.bns-dot.on {
  background: radial-gradient(circle at 35% 35%, #7fd0c0, #2f6f66);
  box-shadow: 0 0 0 10px rgba(63,156,114,.16), 0 0 30px rgba(63,156,114,.55);
  transform: scale(1.12);
}
.bns-calib-bar { width: min(460px, 90%); height: 12px; border-radius: 999px; background: var(--surface-2); box-shadow: var(--clay-pressed); overflow: hidden; }
.bns-calib-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #5fa79b, #35658e); transition: width .12s linear; }
.bns-calib-count { margin: 12px 0; font-size: 15px; font-weight: 700; color: var(--text-soft); text-align: center; }
.bns-calib-stage .bns-dot { margin-top: 8px; }

/* Question and answer */
.bns-question-wrap { margin-bottom: 14px; }
.bns-question {
  margin: 0; font-family: var(--font-display); font-weight: 700;
  font-size: clamp(30px, 6vw, 64px); line-height: 1.08; letter-spacing: -.01em;
  color: var(--text); max-width: 18ch;
}
.bns-waiting {
  background: var(--surface-2); border-radius: 18px; padding: 16px 18px;
  box-shadow: var(--clay-pressed); color: var(--text-soft); margin: 0 0 14px;
}
.bns-waiting b { display: block; font-size: clamp(17px, 3vw, 22px); color: var(--text); margin-bottom: 6px; }
.bns-waiting p { margin: 0; font-size: 14px; line-height: 1.55; }

/* The camera and the blink cue must be visible at the same time: on stacked
   (≤940px) layouts the camera dock is moved into this stage so it sits beside
   the cue (and the result) instead of below the whole page. */
.bns-livestage { display: grid; gap: 12px; }
.bns-livestage.has-cam { grid-template-columns: minmax(0, 38%) minmax(0, 1fr); align-items: start; }
.bns-livestage.has-cam > .bns-camcard { grid-column: 1; margin: 0; }
.bns-livestage.has-cam > .bns-live,
.bns-livestage.has-cam > .bns-result { grid-column: 2; margin: 0; padding-top: 0; }
.bns-livestage.has-cam.cam-solo { grid-template-columns: minmax(0, 1fr); }
.bns-livestage.has-cam.cam-solo > .bns-camcard { grid-column: 1 / -1; max-width: 320px; }

.bns-live { margin: 18px 0; }

/* Patient-facing readiness line: says whether the camera is watching before
   the blink cue starts, and what still works when it is not. */
.bns-ready {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  border-radius: 14px; padding: 10px 14px; margin: 0 0 10px;
  background: var(--surface-2); box-shadow: var(--clay-pressed);
  color: var(--text-soft); font-size: 15px; line-height: 1.35;
}
.bns-ready b { color: var(--text); font-size: 15px; }
.bns-ready-sub { font-size: 13px; color: var(--text-faint); }
.bns-ready-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-faint); flex: none; }
.bns-ready.on { background: var(--accent-soft); color: var(--teal-ink); }
.bns-ready.on b, .bns-ready.on .bns-ready-sub { color: var(--teal-ink); }
.bns-ready.on .bns-ready-sub { opacity: .82; }
.bns-ready.on .bns-ready-dot { background: #3f9c72; box-shadow: 0 0 0 4px rgba(63,156,114,.18); animation: bnsLive 1.8s ease-in-out infinite; }
.bns-ready.warn { background: #fdf3df; color: #7d5a1c; }
.bns-ready.warn b { color: #7d5a1c; }
.bns-ready.warn .bns-ready-sub { color: #8a6a2b; }
.bns-ready.warn .bns-ready-dot { background: #c9892b; box-shadow: 0 0 0 4px rgba(201,137,43,.16); }
.bns-ready.touch .bns-ready-dot { background: #35658e; }
@media (prefers-reduced-motion: reduce) {
  .bns-ready.on .bns-ready-dot { animation: none; }
}

.bns-cue {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  border-radius: 22px; padding: 18px; min-height: 104px;
  background: var(--surface-2); box-shadow: var(--clay-pressed);
  color: var(--text-soft); font-size: clamp(17px, 3vw, 24px); font-weight: 800; text-align: center;
  transition: background .2s ease, color .2s ease;
}
.bns-cue.on { background: linear-gradient(145deg, #eaf7f4, #d8efe9); color: var(--teal-ink); }
.bns-cue.pulse { animation: bnsPulse .32s ease; }
@keyframes bnsPulse { 0% { transform: scale(1); } 45% { transform: scale(1.03); } 100% { transform: scale(1); } }
.bns-cue-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--clay-deep); flex: none; }
.bns-cue.on .bns-cue-dot { animation: bnsLive 1s ease-in-out infinite; }
.bns-timebar { height: 10px; border-radius: 999px; background: var(--surface-2); box-shadow: var(--clay-pressed); overflow: hidden; margin-top: 10px; }
.bns-timebar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #35658e, #5fa79b); border-radius: inherit; transition: width .12s linear; }
.bns-count { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-top: 12px; color: var(--text-soft); }
.bns-count b { font-family: var(--font-display); font-size: clamp(44px, 8vw, 78px); line-height: 1; color: var(--text); }
.bns-count span { font-size: 15px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }

.bns-result { padding: 18px 0 8px; text-align: center; }
.bns-answer {
  font-family: var(--font-display); font-weight: 800; line-height: 1;
  font-size: clamp(72px, 16vw, 168px); letter-spacing: .02em;
}
.bns-answer.yes { color: var(--teal-ink); text-shadow: 0 8px 0 rgba(47,111,102,.10); }
.bns-answer.no { color: #a63a3a; text-shadow: 0 8px 0 rgba(166,58,58,.10); }
.bns-answer.unclear { color: #a6701f; font-size: clamp(38px, 8vw, 72px); }
.bns-confidence { margin: 8px 0 0; color: var(--text-soft); font-weight: 700; font-size: 15px; }
.bns-confirm-prompt {
  margin-top: 14px; padding: 13px 16px; border-radius: 16px;
  background: var(--accent-soft); color: var(--teal-ink);
  font-size: clamp(15px, 2.4vw, 19px); font-weight: 800; line-height: 1.4;
}

.bns-touch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0 8px; }
.bns-touch-btn {
  min-height: 92px; border-radius: 22px; border: 1px solid rgba(255,255,255,.35);
  font: inherit; font-size: clamp(28px, 5vw, 44px); font-weight: 800; letter-spacing: .04em;
  cursor: pointer; color: #fff; box-shadow: var(--clay-shadow);
}
.bns-touch-btn.yes { background: linear-gradient(145deg, #4d9a8c, #2f6f66); }
.bns-touch-btn.no { background: linear-gradient(145deg, #dd6161, #b73939); }
.bns-touch-btn:active { transform: translateY(2px); box-shadow: var(--clay-pressed); }
.bns-touch-note { margin: 0 0 12px; color: var(--text-faint); font-size: 12.5px; line-height: 1.5; text-align: center; }

.bns-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.bns-actions .btn { min-height: 46px; }

.bns-pause {
  background: #fdf3df; border: 1px solid rgba(201,137,43,.35);
  border-radius: 18px; padding: 14px 16px; margin: 12px 0; color: #7d5a1c;
}
.bns-pause b { display: block; font-size: 15px; margin-bottom: 4px; }
.bns-pause p { margin: 0 0 10px; font-size: 14px; line-height: 1.5; }

.bns-done-answer {
  font-family: var(--font-display); font-size: clamp(60px, 13vw, 128px);
  font-weight: 800; line-height: 1; margin: 10px 0 6px;
}
.bns-done-answer.yes { color: var(--teal-ink); }
.bns-done-answer.no { color: #a63a3a; }
.bns-done-meta { color: var(--text-soft); font-size: 14px; margin: 0 0 8px; }

/* Camera dock */
.bns-camcard {
  position: relative; border-radius: 20px; overflow: hidden;
  background: #10181d; box-shadow: var(--clay-shadow), 0 0 0 4px rgba(37,77,112,.10);
  aspect-ratio: 4 / 3;
}
.bns-camcard video { width: 100%; height: 100%; object-fit: cover; display: block; transform: scaleX(-1); }
.bns-camtop {
  position: absolute; top: 8px; left: 8px; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(13,20,25,.62); color: #fff; border-radius: 999px;
  padding: 4px 9px; font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
  backdrop-filter: blur(4px);
}
.bns-live-dot { width: 7px; height: 7px; border-radius: 50%; background: #ff6b6b; animation: bnsLive 1.2s ease-in-out infinite; }
.bns-live-dot.off { background: #9aa7ad; animation: none; }
.bns-camcover {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(13,20,25,.72); color: #fff; font-size: 13px; font-weight: 700; text-align: center;
}
.bns-resume { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); }

.bns-testcard {
  background: var(--surface); border: 1px solid rgba(255,255,255,.7);
  border-radius: 18px; box-shadow: var(--clay-sm); padding: 13px 14px;
}
.bns-testcard b { font-size: 13.5px; }
.bns-testrow { display: flex; gap: 6px; flex-wrap: wrap; margin: 9px 0 7px; }
.bns-testrow .btn { flex: 1 1 70px; }
.bns-testcard small { color: var(--text-faint); font-size: 11.5px; line-height: 1.5; display: block; }
/* When the dock is relocated into the main column on narrow viewports, it
   becomes full-width; the side-column sizing must not shrink it there. */
.bns-main .bns-camcard { aspect-ratio: 4 / 3; max-width: 100%; }
.bns-debug-toggle { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--text-faint); padding: 2px 4px; }
.bns-debug-toggle input { width: 17px; height: 17px; accent-color: var(--accent-deep); }
.bns-debug {
  background: #14202a; color: #d8e8f2; border-radius: 14px; padding: 11px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px; line-height: 1.55; display: grid; gap: 2px;
  max-height: 42vh; overflow: auto;
}
.bns-debug div { display: flex; justify-content: space-between; gap: 10px; }
.bns-debug span { color: #8fb3c9; }
.bns-debug b { color: #fff; font-weight: 700; text-align: right; }

@media (max-width: 940px) {
  .bns-layout { grid-template-columns: minmax(0, 1fr); }
  .bns-side { position: static; grid-template-columns: 220px minmax(0, 1fr); align-items: start; }
  .bns-camcard { grid-row: span 2; }
  .bns-debug { grid-column: 1 / -1; }
  .bns-main { min-height: 0; }
}
@media (max-width: 620px) {
  .bns-side { grid-template-columns: minmax(0, 1fr); }
  .bns-camcard { max-width: 260px; }
  .bns-safety-actions { width: 100%; }
  .bns-safety-actions .btn { flex: 1; }
  .bns-touch-btn { min-height: 80px; }
  .bns-question { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .bns-chip.on .bns-chip-dot, .bns-live-dot, .bns-cue.on .bns-cue-dot { animation: none; }
}

/* ================================================================
   Nurse question card (patient home, above the tiles)
   ================================================================ */
.nq-card {
  background: var(--surface); border: 1px solid rgba(255,255,255,.7);
  border-radius: var(--radius-lg); box-shadow: var(--clay-raised);
  border-left: 6px solid var(--accent);
  padding: 16px 18px; margin: 0 0 18px;
  animation: toastin .28s cubic-bezier(.2, .9, .3, 1.2);
}
.nq-kicker {
  margin: 0 0 6px; font-size: 12px; font-weight: 800;
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint);
}
.nq-text { margin: 0 0 14px; font-family: var(--font-display); font-size: clamp(20px, 4.5vw, 30px); line-height: 1.2; font-weight: 700; }
.nq-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.nq-actions .btn { min-height: 52px; }
.nq-actions .nq-answer { flex: 1 1 220px; }
