/* Roomside — shared styles. Palette and type are fixed in docs/design/TONE.md. */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:opsz,wght@8..60,600;8..60,700&display=swap');

:root {
  --linen: #F6F7F5; --paper: #FFFFFF; --ink: #172334; --slate: #4F5B69; --mist: #D8DDE2;
  --pine: #1E5B52; --pine-dk: #164740; --pine-bg: #E8F0EE; --brass: #8A6A2F; --signal: #B42318; --signal-bg: #FBECEA;
  --serif: "Source Serif 4", "Iowan Old Style", "Hiragino Mincho ProN", "Noto Serif JP", "Noto Serif", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans", "Noto Sans JP", "Noto Sans SC", "Noto Sans KR", "Noto Sans Thai", "Noto Sans Arabic", Roboto, sans-serif;
  --r-ctl: 10px; --r-paper: 6px;
  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--linen); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.6; font-weight: 400; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.25; margin: 0 0 var(--s1); letter-spacing: .005em; }
h1 { font-size: 28px; } h2 { font-size: 21px; } h3 { font-size: 17px; font-family: var(--sans); }
p { margin: 0 0 var(--s2); }
a { color: var(--pine); text-underline-offset: 3px; }
small, .note { font-size: 13px; color: var(--slate); }
.num, .tab { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: var(--r-ctl); border: 1px solid var(--pine); background: var(--pine); color: #fff; font: 600 16px/1.2 var(--sans); cursor: pointer; text-decoration: none; transition: background .15s; }
.btn:hover { background: var(--pine-dk); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--paper); color: var(--pine); }
.btn.ghost:hover { background: var(--pine-bg); }
.btn.quiet { background: transparent; border-color: var(--mist); color: var(--ink); }
.btn.danger { background: var(--signal); border-color: var(--signal); }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 15px; }
.btn svg { width: 20px; height: 20px; }
input, select, textarea { font: 16px/1.4 var(--sans); color: var(--ink); background: var(--paper); border: 1px solid #A9B2BC; border-radius: var(--r-ctl); padding: 11px 13px; width: 100%; min-height: 48px; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--pine); outline: 2px solid var(--pine-bg); }
label { display: block; font-size: 15px; font-weight: 600; margin: 0 0 6px; }
.field { margin-bottom: var(--s2); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--mist); font-weight: 400; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 2px 0 0; flex: none; accent-color: var(--pine); }
.check b { display: block; font-weight: 600; }
.check span { font-size: 15px; color: var(--slate); }

/* surfaces */
.paper { background: var(--paper); border: 1px solid var(--mist); border-radius: var(--r-paper); padding: var(--s3); }
.rule { border: 0; border-top: 1px solid var(--mist); margin: var(--s3) 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--pine-bg); color: var(--pine-dk); white-space: nowrap; }
.badge.warn { background: var(--signal-bg); color: var(--signal); }
.badge.mute { background: #EEF0F2; color: var(--slate); }
.badge.brass { background: #F4EEE3; color: #6B5122; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.kv { width: 100%; border-collapse: collapse; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 10px 8px; border-bottom: 1px solid var(--mist); font-size: 15px; }
.kv th { color: var(--slate); font-weight: 400; width: 34%; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-weight: 600; color: var(--slate); font-size: 13px; padding: 8px; border-bottom: 1px solid var(--ink); white-space: nowrap; }
.table td { padding: 10px 8px; border-bottom: 1px solid var(--mist); vertical-align: top; }
.table td.r, .table th.r { text-align: right; font-variant-numeric: tabular-nums; }
.alert { border-left: 4px solid var(--signal); background: var(--signal-bg); padding: 14px 16px; border-radius: 4px; color: #6E140D; }
.ok-box { border-left: 4px solid var(--pine); background: var(--pine-bg); padding: 14px 16px; border-radius: 4px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--mist); border-top-color: var(--pine); border-radius: 50%; animation: spin 1s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.muted { color: var(--slate); }
.row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: var(--s2); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 8px; font-size: 15px; z-index: 99; max-width: 90vw; }

/* ---------- patient (mobile first) ---------- */
.pt { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; background: var(--linen); }
.pt-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--mist); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.pt-brand { font-family: var(--serif); font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.pt-brand small { display: block; font-family: var(--sans); font-weight: 400; font-size: 13px; color: var(--slate); letter-spacing: 0; }
.pt-lang { min-height: 40px; width: auto; padding: 6px 30px 6px 10px; font-size: 15px; border-color: var(--mist); }
.pt-main { flex: 1; padding: 20px 20px 28px; }
.pt-steps { display: flex; gap: 4px; padding: 10px 20px 0; }
.pt-steps i { flex: 1; height: 3px; border-radius: 2px; background: var(--mist); }
.pt-steps i.on { background: var(--pine); }
.pt-steplabel { padding: 6px 20px 0; font-size: 13px; color: var(--slate); }
.pt h1 { font-size: 26px; }
.pt .lead { font-size: 17px; color: var(--slate); }
.pt-foot { padding: 16px 20px 24px; font-size: 13px; color: var(--slate); border-top: 1px solid var(--mist); }
.pt-foot a { color: var(--slate); margin-right: 12px; }
.sos { display: flex; gap: 10px; align-items: center; font-size: 14px; color: var(--signal); font-weight: 600; margin-top: var(--s2); }
.sos a { color: var(--signal); }

/* chat */
.chat { display: flex; flex-direction: column; gap: 12px; margin-bottom: var(--s2); }
.msg { max-width: 88%; padding: 12px 14px; border-radius: 14px; font-size: 16px; line-height: 1.55; white-space: pre-wrap; word-wrap: break-word; }
.msg.ai { background: var(--paper); border: 1px solid var(--mist); border-top-left-radius: 4px; align-self: flex-start; }
.msg.me { background: var(--pine); color: #fff; border-top-right-radius: 4px; align-self: flex-end; }
.msg.sys { align-self: center; font-size: 13px; color: var(--slate); background: none; padding: 0; }
.msg .who { display: block; font-size: 13px; font-weight: 600; color: var(--slate); margin-bottom: 2px; }
.typing span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--slate); margin-right: 4px; animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { position: sticky; bottom: 0; background: var(--linen); padding: 10px 0 4px; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 48px; height: 48px; max-height: 140px; resize: none; }
.mic { flex: none; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--pine); background: var(--paper); color: var(--pine); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.mic.rec { background: var(--signal); border-color: var(--signal); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(180, 35, 24, .15); } }
.send { flex: none; width: 48px; height: 48px; border-radius: 50%; background: var(--pine); color: #fff; border: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

/* emergency */
.emg { background: var(--signal); color: #fff; margin: -20px -20px 20px; padding: 28px 20px; }
.emg h1 { color: #fff; font-size: 30px; }
.emg .btn { background: #fff; color: var(--signal); border-color: #fff; font-size: 20px; min-height: 60px; }
.phrase { background: var(--paper); border: 1px solid var(--mist); border-radius: var(--r-paper); padding: 14px 16px; margin-top: 12px; }
.phrase .ja { font-size: 20px; font-weight: 700; }
.phrase .ro { font-size: 15px; color: var(--slate); }
.phrase.big .ja { font-size: 24px; line-height: 1.45; word-break: auto-phrase; }
.phrase .tr { font-size: 15px; color: var(--ink); margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--mist); }
p, li { text-wrap: pretty; }

/* key tag (queue) */
.keytag { position: relative; background: var(--paper); border: 1px solid var(--mist); border-radius: 18px 18px 60px 60px; padding: 34px 24px 40px; text-align: center; max-width: 300px; margin: 8px auto 24px; }
.keytag::before { content: ""; position: absolute; top: 12px; left: 50%; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; border: 2px solid var(--brass); background: var(--linen); }
.keytag .lbl { font-size: 13px; color: var(--slate); letter-spacing: .06em; text-transform: uppercase; margin-top: 10px; }
.keytag .no { font-family: var(--serif); font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.keytag .pos { display: flex; justify-content: center; gap: 28px; margin-top: 14px; border-top: 1px solid var(--mist); padding-top: 14px; }
.keytag .pos b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.keytag .pos span { font-size: 13px; color: var(--slate); }

/* call */
.call { position: relative; background: #0F1924; border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 56dvh; width: 100%; }
.call video, .call canvas.remote { width: 100%; height: 100%; object-fit: cover; display: block; }
.call .self { position: absolute; right: 10px; top: 10px; width: 28%; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; border: 2px solid rgba(255, 255, 255, .7); background: #26323F; }
.call .self video, .call .self canvas { width: 100%; height: 100%; object-fit: cover; }
.call .who { position: absolute; left: 12px; top: 12px; color: #fff; font-size: 14px; background: rgba(0, 0, 0, .35); padding: 3px 10px; border-radius: 999px; }
.call .cc { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 14px 16px; background: linear-gradient(transparent, rgba(0, 0, 0, .78) 30%); color: #fff; }
.call .cc .t { font-size: 19px; line-height: 1.45; font-weight: 600; }
.call .cc .o { font-size: 14px; opacity: .8; margin-top: 4px; }
.call .waiting { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #E3E8EC; gap: 12px; text-align: center; padding: 20px; }
.captions { max-height: 30dvh; overflow: auto; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.cap { background: var(--paper); border: 1px solid var(--mist); border-radius: 10px; padding: 10px 12px; }
.cap .t { font-size: 16px; }
.cap .o { font-size: 13px; color: var(--slate); margin-top: 2px; }
.cap.doc { border-left: 3px solid var(--pine); }
.cap.pat { border-left: 3px solid var(--brass); }
.talk { margin-top: 12px; display: flex; gap: 8px; }

/* docs & pharmacies */
.doclist a { display: flex; justify-content: space-between; align-items: center; min-height: 56px; padding: 10px 14px; border: 1px solid var(--mist); border-radius: var(--r-paper); background: var(--paper); text-decoration: none; color: var(--ink); margin-bottom: 8px; }
.doclist a span { font-size: 13px; color: var(--slate); }
.ph { display: block; width: 100%; text-align: left; background: var(--paper); border: 1px solid var(--mist); border-radius: var(--r-paper); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; font: inherit; color: inherit; }
.ph:hover { border-color: var(--pine); }
.ph .n { font-weight: 600; }
.ph .m { font-size: 14px; color: var(--slate); }

/* ---------- staff (desktop) ---------- */
.staff { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; font-size: 16px; }
.bar { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s3); height: 60px; background: var(--paper); border-bottom: 1px solid var(--mist); position: sticky; top: 0; z-index: 10; }
.bar .brand { font-family: var(--serif); font-weight: 700; font-size: 19px; }
.bar .brand small { font-family: var(--sans); font-weight: 400; font-size: 13px; color: var(--slate); margin-left: 8px; }
.bar nav { display: flex; gap: 4px; }
.bar nav a, .bar nav button { padding: 8px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font: 15px var(--sans); border: 0; background: none; cursor: pointer; min-height: 40px; }
.bar nav a.on, .bar nav button.on { background: var(--pine-bg); color: var(--pine-dk); font-weight: 600; }
.bar .sp { flex: 1; }
.duty { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--mist); border-radius: 999px; padding: 4px 6px 4px 14px; font-size: 15px; }
.duty button { min-height: 36px; }
.wrap { max-width: 1240px; margin: 0 auto; padding: var(--s3); width: 100%; }
.cols { display: grid; grid-template-columns: 340px 1fr; gap: 0; min-height: calc(100vh - 60px); }
.queue { border-right: 1px solid var(--mist); background: var(--paper); overflow: auto; max-height: calc(100vh - 60px); position: sticky; top: 60px; }
.queue h2 { font-size: 17px; font-family: var(--sans); padding: 16px 18px 8px; margin: 0; display: flex; justify-content: space-between; }
.qi { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--mist); padding: 14px 18px; cursor: pointer; font: inherit; color: inherit; }
.qi:hover { background: var(--linen); }
.qi.on { background: var(--pine-bg); box-shadow: inset 3px 0 0 var(--pine); }
.qi .top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--slate); }
.qi .one { font-size: 15px; margin-top: 4px; }
.pane { padding: var(--s3) var(--s4); overflow: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.stat { background: var(--paper); border: 1px solid var(--mist); border-radius: var(--r-paper); padding: 16px 18px; }
.stat .k { font-size: 13px; color: var(--slate); }
.stat .v { font-family: var(--serif); font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; margin-top: 4px; }
.stat .s { font-size: 13px; color: var(--slate); }
.sec { margin-bottom: var(--s4); }
.sec > h2 { font-size: 19px; margin-bottom: 12px; }
.sum dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; margin: 0; font-size: 15px; }
.sum dt { color: var(--slate); }
.sum dd { margin: 0; }
.dcall { display: grid; grid-template-columns: 1.1fr 1fr; gap: var(--s3); align-items: start; }
.dcall .call { aspect-ratio: 4 / 3; max-height: none; }
.rx-row { display: grid; grid-template-columns: 2fr 1fr 1.4fr 90px 40px; gap: 8px; margin-bottom: 8px; }
.rx-row input { min-height: 44px; padding: 8px 10px; font-size: 15px; }
.issues div { font-size: 15px; padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; }
.issues .block { background: var(--signal-bg); color: #6E140D; border-left: 3px solid var(--signal); }
.issues .warn { background: #F4EEE3; color: #5A4419; border-left: 3px solid var(--brass); }
.phr { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.phr button { font: 14px var(--sans); border: 1px solid var(--mist); background: var(--paper); border-radius: 999px; padding: 8px 12px; cursor: pointer; color: var(--ink); min-height: 40px; text-align: left; }
.phr button:hover { border-color: var(--pine); }
.empty { text-align: center; color: var(--slate); padding: 60px 20px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; border-bottom: 1px solid var(--mist); }
.bars i { flex: 1; background: var(--pine); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.bars-x { display: flex; justify-content: space-between; font-size: 13px; color: var(--slate); margin-top: 4px; }

/* login / docs pages */
.center { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card { width: 100%; max-width: 420px; }
.doc { background: var(--linen); }
.doc-head { padding: 16px 24px; border-bottom: 1px solid var(--mist); background: var(--paper); }
.brand-sm { font-family: var(--serif); font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.legal { max-width: 760px; margin: 0 auto; padding: 32px 20px 60px; }
.legal h2 { font-size: 19px; margin-top: 28px; }
.legal li { margin-bottom: 6px; }
.legal .warn { color: var(--signal); font-weight: 600; }
.foot { border-top: 1px solid var(--mist); padding: 20px 24px 32px; font-size: 13px; color: var(--slate); }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }
.foot a { color: var(--slate); }

@media (max-width: 900px) {
  .cols { grid-template-columns: 1fr; } .queue { position: static; max-height: none; border-right: 0; }
  .grid2, .grid3, .grid4, .dcall { grid-template-columns: 1fr; } .pane { padding: 20px; }
  .bar { overflow-x: auto; }
}

.meter { height: 8px; background: var(--mist); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; }

/* Japanese/CJK: break at phrase boundaries, not mid-word. */
:lang(ja) body, :lang(ja) p, :lang(ja) li, :lang(ja) h1, :lang(ja) h2, :lang(ja) h3, :lang(ja) td, :lang(ja) span, :lang(ja) a { word-break: auto-phrase; line-break: strict; }
.alert.sos { display: block; margin-top: 18px; font-size: 16px; font-weight: 600; color: #6E140D; }
.alert.sos .btn { width: 100%; justify-content: center; }
.alert.sos .btn { min-height: 48px; color: #fff; }
.pt-lang { min-height: 44px; }

/* Doctor screen inside the demo tour (about 940px wide): narrow queue, one column for chart + documents. */
.tour-mode .cols { grid-template-columns: 220px 1fr; }
.tour-mode .grid2 { grid-template-columns: 1fr; }
.tour-mode .toast { left: auto; right: 16px; transform: none; bottom: auto; top: 16px; }
