/* app.css — M6 셸·컴포넌트·화면 스타일 (토큰은 css/tokens.css 참조, 값 하드코딩 금지) */

/* ── 셸 레이아웃 ─────────────────────────────── */
#shell-header { position: sticky; top: 0; z-index: 40; }
#app { min-height: 60vh; padding-bottom: calc(var(--wo-touch-orb) + 40px); }
#shell-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; }
body[data-shell="off"] #shell-header, body[data-shell="off"] #shell-nav { display: none; }
button { font: var(--wo-type-body); color: inherit; }

/* ── C-01 AppBar + StatusCluster ────────────── */
.vw-appbar {
  display: flex; align-items: center; gap: var(--wo-sp-1);
  min-height: 56px; padding: 0 var(--wo-pad-screen);
  background: var(--wo-surface); border-bottom: 1px solid var(--wo-border);
}
.vw-appbar__logo { font: var(--wo-type-section); color: var(--wo-primary); white-space: nowrap; }
.vw-appbar__chip {
  font: var(--wo-type-label); color: var(--wo-text-sub);
  background: var(--wo-surface-alt); border-radius: var(--wo-r-chip);
  padding: 4px 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  min-width: 0; flex-shrink: 20; /* 좁은 폭에서 칩이 '먼저' 줄어 상태 클러스터(48px 타깃)를 보존 */
}
.vw-appbar__spacer { flex: 1; }
/* 클러스터는 좁은 폭(360)에서만 압축되어 오버플로우를 흡수(390+에선 각 48px 유지). */
.vw-cluster { display: flex; align-items: center; gap: 2px; min-width: 0; flex-shrink: 1; }
.vw-cluster__item {
  position: relative; width: var(--wo-touch-min); height: var(--wo-touch-min);
  min-width: 0; flex-shrink: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: none; border: 0; padding: 0; cursor: pointer;
}
.vw-cluster__item svg { width: 20px; height: 20px; }
.vw-cluster__dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 2px; }
.vw-cluster__item[data-state="on"] .vw-cluster__dot { background: var(--wo-conn-on); }
.vw-cluster__item[data-state="degraded"] .vw-cluster__dot,
.vw-cluster__item[data-state="unknown"] .vw-cluster__dot { background: var(--wo-conn-degraded); }
.vw-cluster__item[data-state="off"] .vw-cluster__dot { background: var(--wo-conn-off); }
.vw-cluster__item[data-state="off"] svg { opacity: .4; }
.vw-iconbtn {
  position: relative; width: var(--wo-touch-min); height: var(--wo-touch-min);
  flex-shrink: 0; /* 알림센터·전체메뉴는 압축 없이 48px 고정(주요 액션) */
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; cursor: pointer; color: var(--wo-text);
}
.vw-iconbtn svg { width: 24px; height: 24px; }
.vw-badge-dot {
  position: absolute; top: 8px; right: 8px; min-width: 16px; height: 16px;
  border-radius: var(--wo-r-chip); background: var(--wo-error); color: #fff;
  font: var(--wo-type-caption); line-height: 16px; padding: 0 4px; text-align: center;
}
.vw-popover {
  position: absolute; top: 54px; right: var(--wo-pad-screen); z-index: 60;
  background: var(--wo-surface); border: 1px solid var(--wo-border);
  border-radius: var(--wo-r-btn); box-shadow: var(--wo-shadow-3);
  padding: var(--wo-sp-3); min-width: 220px; font: var(--wo-type-label);
}
.vw-popover div { display: flex; justify-content: space-between; padding: 6px 4px; }

/* ── C-02 PatientContextHeader ──────────────── */
.vw-pth {
  background: var(--wo-surface); border-bottom: 1px solid var(--wo-border);
  border-top: 4px solid var(--wo-task-strip, var(--wo-primary));
  padding: var(--wo-sp-2) var(--wo-pad-screen);
}
.vw-pth__row { display: flex; align-items: center; gap: var(--wo-sp-2); }
.vw-pth__name { font: var(--wo-type-section); }
.vw-pth__meta { font: var(--wo-type-caption); color: var(--wo-text-sub); }
.vw-pth__unbind {
  margin-left: auto; width: var(--wo-touch-min); height: var(--wo-touch-min);
  background: none; border: 0; color: var(--wo-text-sub); font: var(--wo-type-section); cursor: pointer;
}
.vw-riskbadge {
  display: inline-flex; align-items: center; gap: 3px;
  font: var(--wo-type-caption); font-weight: 700; color: #fff;
  border-radius: var(--wo-r-chip); padding: 2px 8px; border: 0; cursor: pointer;
}

/* ── 하단 바 + C-04 VoiceOrb ────────────────── */
.vw-bottombar {
  display: flex; align-items: center; justify-content: space-around;
  background: var(--wo-surface); border-top: 1px solid var(--wo-border);
  padding: var(--wo-sp-2) var(--wo-sp-4) calc(var(--wo-sp-2) + env(safe-area-inset-bottom));
}
.vw-bottombar__btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 72px; min-height: var(--wo-touch-primary);
  background: none; border: 0; color: var(--wo-text-sub);
  font: var(--wo-type-label); cursor: pointer;
}
.vw-bottombar__btn svg { width: 26px; height: 26px; }
.vw-orb {
  width: var(--wo-touch-orb); height: var(--wo-touch-orb); border-radius: 50%;
  border: 0; background: var(--wo-orb-gradient); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--wo-shadow-1); cursor: pointer; position: relative;
  margin-top: -28px; touch-action: none;
}
.vw-orb svg { width: 32px; height: 32px; }
.vw-orb[data-state="listening"]::before, .vw-orb[data-state="listening"]::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--wo-accent); animation: vw-orb-wave 1.4s ease-out infinite;
}
.vw-orb[data-state="listening"]::after { animation-delay: .7s; }
@keyframes vw-orb-wave {
  0% { transform: scale(1); opacity: .9; }
  100% { transform: scale(1.9); opacity: 0; }
}
.vw-orb[data-state="processing"] svg { animation: vw-spin 1s linear infinite; }
@keyframes vw-spin { to { transform: rotate(360deg); } }
.vw-orb[data-state="disabled"] {
  background: var(--wo-text-disabled); cursor: not-allowed;
}
.vw-orb[data-state="disabled"]::before {
  content: ""; position: absolute; width: 3px; height: 76%;
  background: var(--wo-surface); transform: rotate(45deg); border: 0; animation: none;
}

/* ── S-04 라디얼 퀵메뉴 ─────────────────────── */
.vw-radial { position: fixed; inset: 0; z-index: 80; }
.vw-radial__dim { position: absolute; inset: 0; background: rgba(0,0,0,.6); border: 0; width: 100%; }
.vw-radial__item {
  position: absolute; width: 64px; height: 64px; border-radius: 50%;
  border: 0; background: var(--wo-surface); color: var(--wo-text);
  box-shadow: var(--wo-shadow-3); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font: var(--wo-type-caption); font-weight: 700;
  transform: translate(-50%, 50%) scale(.3); opacity: 0;
  transition: transform var(--wo-motion-radial), opacity var(--wo-motion-radial);
}
.vw-radial__item svg { width: 22px; height: 22px; }
.vw-radial--open .vw-radial__item { opacity: 1; }

/* ── C-14 Toast / TopBanner ─────────────────── */
#banner-root { position: fixed; top: 0; left: 0; right: 0; z-index: 90; pointer-events: none; }
.vw-banner {
  pointer-events: auto; display: flex; align-items: center; gap: var(--wo-sp-2);
  padding: var(--wo-sp-2) var(--wo-pad-screen); font: var(--wo-type-label); color: #fff;
}
.vw-banner--offline { background: var(--wo-conn-off); }
.vw-banner--info { background: var(--wo-info); }
.vw-banner--warn { background: var(--wo-warning); color: var(--wo-text); }
.vw-toast-wrap {
  position: fixed; bottom: calc(var(--wo-touch-orb) + 56px); left: 50%; transform: translateX(-50%);
  z-index: 95; display: flex; flex-direction: column; gap: var(--wo-sp-2); align-items: center;
  width: max-content; max-width: 92vw;
}
.vw-toast {
  background: var(--wo-text); color: var(--wo-bg); border-radius: var(--wo-r-btn);
  padding: 10px 16px; font: var(--wo-type-label); box-shadow: var(--wo-shadow-3);
  animation: vw-toast-in var(--wo-motion-std);
  max-width: 92vw;
}
.vw-toast--error { background: var(--wo-error); color: #fff; }
.vw-toast--success { background: var(--wo-success); color: #fff; }
@keyframes vw-toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── 공통 폼·버튼·카드 ──────────────────────── */
.vw-screen { padding: var(--wo-sp-4) var(--wo-pad-screen); max-width: 560px; margin: 0 auto; }
.vw-card {
  background: var(--wo-surface); border: 1px solid var(--wo-border);
  border-radius: var(--wo-r-card); padding: var(--wo-pad-card); margin-bottom: var(--wo-gap-card);
  box-shadow: var(--wo-shadow-1);
}
.vw-field { margin-bottom: var(--wo-sp-3); }
.vw-field label { display: block; font: var(--wo-type-label); color: var(--wo-text-sub); margin-bottom: 4px; }
.vw-input {
  width: 100%; height: var(--wo-touch-min); border: 1px solid var(--wo-border);
  border-radius: var(--wo-r-btn); background: var(--wo-surface); color: var(--wo-text);
  font: var(--wo-type-body); padding: 0 var(--wo-sp-3);
}
.vw-input:focus { outline: 3px solid var(--wo-primary); outline-offset: 0; border-color: var(--wo-primary); }
.vw-btn {
  display: flex; align-items: center; justify-content: center; gap: var(--wo-sp-2);
  width: 100%; min-height: var(--wo-touch-primary);
  border: 0; border-radius: var(--wo-r-btn); cursor: pointer;
  font: var(--wo-type-section); background: var(--wo-primary); color: #fff;
}
.vw-btn:disabled { background: var(--wo-text-disabled); cursor: not-allowed; }
.vw-btn--secondary { background: var(--wo-surface-alt); color: var(--wo-text); border: 1px solid var(--wo-border); }
.vw-btn__reason { font: var(--wo-type-caption); font-weight: 400; opacity: .9; }
.vw-shake { animation: vw-shake .3s; }
@keyframes vw-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.vw-error-text { color: var(--wo-error); font: var(--wo-type-label); margin-top: var(--wo-sp-2); min-height: 18px; }

/* ── S-01 로그인 ────────────────────────────── */
.vw-login { padding-top: 9vh; }
.vw-logo { text-align: center; margin-bottom: var(--wo-sp-6); }
.vw-logo__mark {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto var(--wo-sp-3);
  background: var(--wo-orb-gradient); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font: var(--wo-type-display);
}
.vw-logo__word { font: var(--wo-type-title); }
.vw-logo__word b { color: var(--wo-primary); }
.vw-divider {
  display: flex; align-items: center; gap: var(--wo-sp-3); margin: var(--wo-sp-4) 0;
  color: var(--wo-text-sub); font: var(--wo-type-caption);
}
.vw-divider::before, .vw-divider::after { content: ""; flex: 1; height: 1px; background: var(--wo-border); }
.vw-tiles { display: flex; gap: var(--wo-gap-card); }
.vw-tile {
  flex: 1; min-height: 96px; border: 1px solid var(--wo-border); border-radius: var(--wo-r-card);
  background: var(--wo-surface); color: var(--wo-text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--wo-sp-2);
  font: var(--wo-type-label); position: relative;
}
.vw-tile svg { width: 30px; height: 30px; color: var(--wo-primary); }
.vw-tile__sim {
  position: absolute; top: 8px; right: 8px; font: var(--wo-type-caption);
  background: var(--wo-warning); color: var(--wo-text); border-radius: var(--wo-r-chip); padding: 1px 8px;
}
.vw-login__foot {
  margin-top: var(--wo-sp-6); text-align: center; font: var(--wo-type-caption); color: var(--wo-text-sub);
  display: flex; align-items: center; justify-content: center; gap: var(--wo-sp-2);
}
.vw-server-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.vw-check { display: flex; align-items: center; gap: var(--wo-sp-2); font: var(--wo-type-label); min-height: var(--wo-touch-min); }
.vw-check input { width: 20px; height: 20px; accent-color: var(--wo-primary); }

/* ── S-02 2차 인증 ──────────────────────────── */
.vw-pin-dots { display: flex; justify-content: center; gap: var(--wo-sp-4); margin: var(--wo-sp-5) 0; }
.vw-pin-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--wo-border); }
.vw-pin-dot--filled { background: var(--wo-primary); }
.vw-pin-dots--error .vw-pin-dot--filled { background: var(--wo-error); }
.vw-numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--wo-sp-3); max-width: 320px; margin: 0 auto; }
.vw-numpad button {
  height: var(--wo-touch-key); border: 1px solid var(--wo-border); border-radius: var(--wo-r-card);
  background: var(--wo-surface); color: var(--wo-text); font: var(--wo-type-title); cursor: pointer;
}
.vw-numpad button:active { background: var(--wo-surface-alt); }

/* ── S-03 홈 ────────────────────────────────── */
.vw-noticebanner {
  display: flex; gap: var(--wo-sp-2); align-items: center;
  background: color-mix(in srgb, var(--wo-info) 12%, var(--wo-surface));
  border: 1px solid var(--wo-info); border-radius: var(--wo-r-btn);
  padding: var(--wo-sp-2) var(--wo-sp-3); margin-bottom: var(--wo-gap-card);
  font: var(--wo-type-label);
}
.vw-noticebanner button { margin-left: auto; background: none; border: 0; color: var(--wo-text-sub); min-width: var(--wo-touch-min); min-height: var(--wo-touch-min); cursor: pointer; }
.vw-dutybar { margin-bottom: var(--wo-gap-card); }
.vw-dutybar__track { height: 6px; border-radius: 3px; background: var(--wo-surface-alt); overflow: hidden; }
.vw-dutybar__fill { height: 100%; background: var(--wo-primary); }
.vw-dutybar__meta { display: flex; justify-content: space-between; font: var(--wo-type-caption); color: var(--wo-text-sub); margin-top: 4px; }

/* C-03 TaskCard */
.vw-task {
  display: flex; align-items: stretch; gap: var(--wo-sp-3);
  background: var(--wo-surface); border: 1px solid var(--wo-border); border-radius: var(--wo-r-card);
  margin-bottom: var(--wo-gap-card); box-shadow: var(--wo-shadow-1);
  overflow: hidden; cursor: pointer; width: 100%; text-align: left; padding: 0;
}
.vw-task__strip { width: 6px; flex: none; background: var(--wo-task-strip, var(--wo-border)); }
.vw-task__body { flex: 1; padding: var(--wo-sp-3) 0; min-width: 0; }
.vw-task__title { font: var(--wo-type-section); display: flex; gap: var(--wo-sp-2); align-items: center; }
.vw-task__kind { font: var(--wo-type-caption); font-weight: 700; color: var(--wo-task-strip, var(--wo-text-sub)); }
.vw-task__meta { font: var(--wo-type-caption); color: var(--wo-text-sub); margin-top: 2px; }
.vw-task__time { font: var(--wo-type-label); font-weight: 700; }
.vw-task__time--late { color: var(--wo-error); }
.vw-task__right { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; padding: var(--wo-sp-3); }
.vw-task__state { font: var(--wo-type-caption); font-weight: 700; border-radius: var(--wo-r-chip); padding: 2px 8px; background: var(--wo-surface-alt); color: var(--wo-text-sub); }
.vw-task__state--late { background: var(--wo-error); color: #fff; }
.vw-task__state--active { background: color-mix(in srgb, var(--wo-primary) 15%, transparent); color: var(--wo-primary); }
.vw-task__state--active::before { content: "●"; animation: vw-pulse 1.2s infinite; margin-right: 3px; }
@keyframes vw-pulse { 50% { opacity: .3; } }
.vw-task--done { opacity: .6; }
.vw-task__menu { background: none; border: 0; color: var(--wo-text-sub); font: var(--wo-type-section); min-width: var(--wo-touch-min); min-height: var(--wo-touch-min); cursor: pointer; }
.vw-empty { text-align: center; color: var(--wo-text-sub); padding: var(--wo-sp-6) 0; }
.vw-empty__art { font-size: 44px; margin-bottom: var(--wo-sp-3); }
.vw-section-toggle {
  width: 100%; background: none; border: 0; color: var(--wo-text-sub); font: var(--wo-type-label);
  min-height: var(--wo-touch-min); cursor: pointer; text-align: left;
}

/* ── S-05 마스터 스캔 ───────────────────────── */
.vw-scan { position: fixed; inset: 0; z-index: 70; background: #000; display: flex; flex-direction: column; }
.vw-scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.vw-scan__hint {
  position: relative; margin: calc(var(--wo-sp-6) + env(safe-area-inset-top)) auto 0;
  background: rgba(0,0,0,.65); color: #fff; border-radius: var(--wo-r-chip);
  padding: var(--wo-sp-2) var(--wo-sp-4); font: var(--wo-type-label); max-width: 88%; text-align: center;
}
.vw-scan__frame {
  position: relative; margin: auto; width: min(72vw, 320px); aspect-ratio: 1.6;
  border: 3px solid rgba(255,255,255,.85); border-radius: var(--wo-r-card);
  transition: border-color var(--wo-motion-flash);
}
.vw-scan__frame--ok { border-color: var(--wo-success); box-shadow: 0 0 0 6px color-mix(in srgb, var(--wo-success) 40%, transparent); }
.vw-scan__frame--bad { border-color: var(--wo-error); box-shadow: 0 0 0 6px color-mix(in srgb, var(--wo-error) 40%, transparent); }
.vw-scan__chip {
  position: absolute; left: 50%; bottom: -44px; transform: translateX(-50%); white-space: nowrap;
  background: var(--wo-success); color: #fff; border-radius: var(--wo-r-chip);
  padding: 4px 12px; font: var(--wo-type-label);
}
.vw-scan__counter {
  position: absolute; top: -40px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.65); color: #fff; border-radius: var(--wo-r-chip); padding: 2px 12px; font: var(--wo-type-label);
}
.vw-scan__bottom {
  position: relative; display: flex; gap: var(--wo-sp-3); align-items: center; justify-content: center;
  padding: var(--wo-sp-4) var(--wo-pad-screen) calc(var(--wo-sp-5) + env(safe-area-inset-bottom));
}
.vw-scan__bottom .vw-btn { width: auto; min-width: 96px; padding: 0 var(--wo-sp-4); background: rgba(255,255,255,.14); color: #fff; }
.vw-scan__sim { position: relative; display: flex; flex-wrap: wrap; gap: var(--wo-sp-2); justify-content: center; padding: 0 var(--wo-pad-screen) var(--wo-sp-3); }
.vw-scan__sim button {
  background: rgba(255,255,255,.14); color: #fff; border: 1px dashed rgba(255,255,255,.5);
  border-radius: var(--wo-r-chip); padding: 8px 12px; font: var(--wo-type-caption); cursor: pointer; min-height: var(--wo-touch-min);
}

/* ── 시트(하단 모달) ────────────────────────── */
.vw-sheet-wrap { position: fixed; inset: 0; z-index: 85; }
.vw-sheet-wrap__dim { position: absolute; inset: 0; background: rgba(0,0,0,.5); border: 0; width: 100%; }
.vw-sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--wo-surface); border-radius: var(--wo-r-sheet) var(--wo-r-sheet) 0 0;
  padding: var(--wo-sp-4) var(--wo-pad-screen) calc(var(--wo-sp-5) + env(safe-area-inset-bottom));
  box-shadow: var(--wo-shadow-3); max-height: 80vh; overflow-y: auto;
  animation: vw-sheet-in var(--wo-motion-std);
}
@keyframes vw-sheet-in { from { transform: translateY(30%); opacity: .5; } }
.vw-sheet h3 { font: var(--wo-type-section); margin: 0 0 var(--wo-sp-3); }
.vw-nfc-wave {
  width: 96px; height: 96px; margin: var(--wo-sp-4) auto; border-radius: 50%;
  background: var(--wo-orb-gradient); position: relative; display: flex; align-items: center; justify-content: center; color: #fff;
}
.vw-nfc-wave::before, .vw-nfc-wave::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--wo-accent); animation: vw-orb-wave 1.6s ease-out infinite;
}
.vw-nfc-wave::after { animation-delay: .8s; }

/* ── S-23 설정 ──────────────────────────────── */
.vw-set-group { margin-bottom: var(--wo-sp-4); }
.vw-set-group h3 { font: var(--wo-type-label); color: var(--wo-text-sub); margin: 0 0 var(--wo-sp-2); }
.vw-set-row {
  display: flex; align-items: center; gap: var(--wo-sp-3); min-height: var(--wo-touch-primary);
  background: var(--wo-surface); border: 1px solid var(--wo-border);
  padding: var(--wo-sp-2) var(--wo-sp-3); margin-top: -1px; font: var(--wo-type-body);
}
.vw-set-group .vw-set-row:first-of-type { border-radius: var(--wo-r-btn) var(--wo-r-btn) 0 0; }
.vw-set-group .vw-set-row:last-of-type { border-radius: 0 0 var(--wo-r-btn) var(--wo-r-btn); }
.vw-set-group .vw-set-row:only-of-type { border-radius: var(--wo-r-btn); }
.vw-set-row > span:first-child { flex: 1; }
.vw-set-row select {
  min-height: var(--wo-touch-min); border: 1px solid var(--wo-border); border-radius: var(--wo-r-btn);
  background: var(--wo-surface); color: var(--wo-text); font: var(--wo-type-label); padding: 0 var(--wo-sp-2);
}
.vw-switch { position: relative; width: 52px; height: 32px; flex: none; }
.vw-switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.vw-switch i {
  position: absolute; inset: 0; background: var(--wo-border); border-radius: var(--wo-r-chip);
  transition: background var(--wo-motion-std); pointer-events: none;
}
.vw-switch i::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px;
  background: var(--wo-surface); border-radius: 50%; transition: transform var(--wo-motion-std);
}
.vw-switch input:checked + i { background: var(--wo-primary); }
.vw-switch input:checked + i::after { transform: translateX(20px); }

/* ── 큰 글씨 모드 (전 단계 +2px) ────────────── */
html.vw-large-text { font-size: 17px; }
html.vw-large-text body { font-size: 17px; }

/* ── 접근성 ─────────────────────────────────── */
:focus-visible { outline: 3px solid var(--wo-primary); outline-offset: 2px; }
.vw-sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
