:root{font-family:"Segoe UI",Roboto,Arial,sans-serif;color:#1e3140;background:#f2f6f8;font-size:18px;--green:#10756e;--soft:#e2f2ed;--line:#cddfe0}*{box-sizing:border-box}body{margin:0}button,input,select,textarea{font:inherit}button,.button{border:1px solid var(--line);border-radius:14px;background:white;color:#193a42;padding:15px 22px;cursor:pointer;font-weight:600;min-height:52px;text-decoration:none}button:hover{background:var(--soft)}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #70bcb0;outline-offset:3px}button.primary,.button.primary{background:var(--green);color:white;border-color:var(--green)}button.danger{background:#b32629;color:white;border:0}button:disabled{opacity:.5;cursor:wait}.subtle{background:transparent}header{display:flex;align-items:center;justify-content:space-between;gap:22px;padding:18px 4px}.brand{width:210px;height:82px;object-fit:contain;object-position:left}nav{display:flex;gap:10px;flex-wrap:wrap;justify-content:flex-end}.app-shell{max-width:1600px;margin:auto;padding:12px 28px 8px}.patient-bar{display:flex;align-items:center;gap:18px;padding:18px 22px;background:var(--soft);border-radius:18px;min-height:82px}#patient-label{font-size:1.1rem;font-weight:700;flex:1}.badge{font-size:.76rem;color:var(--green);border:1px solid #b7d8cf;border-radius:30px;padding:7px 11px}main{display:grid;grid-template-columns:minmax(190px,29%) 1fr;gap:25px;margin-top:20px;min-height:calc(100dvh - 235px)}.portrait-panel{display:flex;flex-direction:column;gap:18px;align-items:stretch;padding:5px}.portrait{position:relative;width:100%;aspect-ratio:1.02;overflow:hidden;border-radius:24px;box-shadow:0 12px 32px #16394a12;animation:breath 7s ease-in-out infinite;transform-origin:center 80%}.portrait>img{width:100%;height:100%;object-fit:cover;object-position:center 28%;position:absolute;inset:0}.portrait>.overlay{opacity:0}.portrait-caption{text-align:center;line-height:1.6;color:#64818b;font-size:.9rem}.thought{position:absolute;right:10px;top:15px;background:#fff;border:3px solid #28415b;border-radius:45%;padding:10px 24px;font-size:28px;color:var(--green);box-shadow:0 5px 18px #14374620}.thought:after{content:"";position:absolute;width:12px;height:12px;bottom:-16px;left:18px;background:white;border:2px solid #28415b;border-radius:50%}.thought span{animation:dots 1.3s infinite}.thought span:nth-child(2){animation-delay:.2s}.thought span:nth-child(3){animation-delay:.4s}.workspace{background:white;border-radius:24px;padding:28px 32px;display:flex;flex-direction:column;min-width:0;box-shadow:0 6px 28px #1d455708}.eyebrow{font-size:.8rem;font-weight:750;letter-spacing:.08em;color:var(--green);text-transform:uppercase}h1{font-size:clamp(1.5rem,2.6vw,2.35rem);line-height:1.2;margin:12px 0}#help{color:#607e89;line-height:1.5;margin:0 0 16px;white-space:pre-line}.content{flex:1;min-height:180px;max-height:64dvh;overflow:auto;padding:4px 6px 12px 0}.actions{display:flex;gap:12px;flex-wrap:wrap;padding-top:16px}.state{color:#61818a;min-height:24px;padding-top:12px;font-size:.9rem}.state.error,.error{color:#af2429}.answer{padding:18px;background:#f0f8f5;border-radius:16px;margin-top:18px}.answer div{font-size:1.3rem;line-height:1.5;margin-top:8px;white-space:pre-line}.choice-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.option{display:flex;gap:14px;align-items:flex-start;padding:10px 6px;line-height:1.45}.option input{width:24px;height:24px;margin:3px 0;accent-color:var(--green);flex-shrink:0}.yesno{display:flex;gap:25px;flex-wrap:wrap;margin:12px 0}.yesno .option{font-size:1.4rem;font-weight:600}label.field{display:block;font-weight:650;margin:18px 0 8px}.field-wrap{margin-bottom:20px}input:not([type=checkbox],[type=radio],[type=range]),select,textarea{width:100%;padding:14px 16px;background:#f1f6f7;border:0;border-radius:12px;color:inherit}textarea{min-height:100px;resize:vertical}input[type=range]{width:100%;accent-color:var(--green);margin-top:22px}.kinds{display:grid;gap:18px}.kind{display:flex;align-items:center;text-align:left;gap:22px;padding:25px}.kind .number{display:grid;place-items:center;border-radius:16px;background:var(--soft);color:var(--green);width:54px;height:54px;font-size:1.5rem;flex-shrink:0}.kind small{display:block;color:#60818b;font-weight:400;margin-top:7px}.table-wrap{overflow:auto}table{width:100%;border-collapse:collapse;font-size:.96rem;table-layout:fixed}th,td{padding:13px 15px;text-align:left;vertical-align:top;border-bottom:1px solid var(--line);white-space:pre-line;overflow-wrap:anywhere}th:first-child,td:first-child{width:30%;background:#f0f8f5;font-weight:650}th{color:var(--green)}.report-extra{white-space:pre-line;line-height:1.6;font-size:.88rem;margin-top:25px}.microphone{margin:20px auto;width:96px;height:96px;display:grid;place-items:center;background:#e6f4ec;color:#1a934e;border-radius:50%;font-size:48px}.microphone.off{background:#faeeee;color:#b32629}footer{display:flex;justify-content:space-between;gap:20px;font-size:.76rem;color:#65838d;padding:15px 4px}footer a{color:var(--green)}dialog{border:0;border-radius:24px;box-shadow:0 30px 100px #102c4266;padding:0;width:min(1050px,94vw);max-height:94dvh;color:inherit}dialog::backdrop{background:#17334177;backdrop-filter:blur(4px)}.modal-head{display:flex;align-items:center;justify-content:space-between;padding:25px 28px 12px}.modal-head h2{margin:0;font-size:1.65rem}.modal-body{padding:10px 28px 26px;overflow:auto;max-height:74dvh}.modal-actions{display:flex;gap:12px;justify-content:flex-end;padding:15px 28px 25px;flex-wrap:wrap}.tabs{display:flex;gap:10px;flex-wrap:wrap;padding:12px 28px}.tabs button{min-width:150px;min-height:58px;border-radius:14px}.tabs button.selected{background:var(--green);color:white}.two-fields{display:grid;grid-template-columns:1fr 1fr;gap:18px}.hint{color:#67838b;font-size:.88rem;line-height:1.6}.archive-item{display:flex;justify-content:space-between;gap:12px;margin:10px 0;padding:15px;border-bottom:1px solid var(--line)}.toast{position:fixed;bottom:28px;left:50%;transform:translateX(-50%);background:#153e3a;color:white;padding:16px 25px;border-radius:16px;box-shadow:0 7px 30px #173e3e33;max-width:90vw;z-index:10}details{margin:16px 0}summary{font-weight:650;cursor:pointer;color:var(--green)}pre{white-space:pre-wrap;font:inherit;font-size:.88rem}#actions:empty{padding:0}[hidden]{display:none!important}@keyframes breath{0%,100%{transform:translateY(0) rotate(-.6deg) scale(1)}50%{transform:translateY(-4px) rotate(.6deg) scale(1.013)}}@keyframes dots{50%{opacity:.25}}@media(max-width:850px){.app-shell{padding:8px 14px}header{gap:10px}.brand{width:155px;height:64px}nav{gap:5px}nav button{padding:12px;font-size:.84rem}main{grid-template-columns:155px 1fr;gap:14px}.workspace{padding:22px}.portrait-caption{font-size:.75rem}.patient-bar{padding:13px;gap:10px}.badge{display:none}.choice-grid{grid-template-columns:1fr}.content{max-height:62dvh}}@media(max-width:580px){header{flex-wrap:wrap}nav{justify-content:flex-start}.brand{height:55px}main{display:block}.portrait-panel{float:right;width:100px;margin:12px 12px 0 10px;position:relative;z-index:1}.portrait-caption{display:none}.portrait-panel #abort{display:none}.workspace{min-height:70dvh}.patient-bar{font-size:.85rem;flex-wrap:wrap}h1{padding-right:78px}.two-fields{grid-template-columns:1fr}.content{max-height:65dvh}.tabs button{flex:1;min-width:120px;font-size:.86rem}dialog{width:97vw}.modal-body{max-height:67dvh}th:first-child,td:first-child{width:37%}}@media print{body{background:white}.app-shell{padding:0}header,.patient-bar,.portrait-panel,#category,#question,#help,#state,#actions,footer,.answer,dialog,.toast{display:none!important}main{display:block;margin:0;min-height:0}.workspace{box-shadow:none;padding:0}.content{max-height:none;overflow:visible}.table-wrap{overflow:visible}table{font-size:10pt}tr{break-inside:avoid}}

footer{flex-wrap:wrap}#network-status{color:#10756e}

/* Tablet canvas: fixed usable viewport, footer and actions never fall below it. */
@media screen and (min-width:600px){
 html,body{height:100%;overflow:hidden}
 .app-shell{height:100dvh;display:flex;flex-direction:column;padding:4px 18px;overflow:hidden}
 header{padding:4px 2px;gap:12px;flex-shrink:0}.brand{width:150px;height:52px}
 nav{gap:7px}nav button{padding:9px 14px;min-height:44px;font-size:.9rem}
 .patient-bar{min-height:54px;padding:8px 16px;gap:12px;border-radius:14px;flex-shrink:0}
 .patient-bar button{padding:8px 14px;min-height:42px}#patient-label{font-size:1rem}
 main{flex:1;min-height:0;margin-top:10px;grid-template-columns:minmax(145px,24%) minmax(0,1fr);gap:18px;overflow:hidden}
 .portrait-panel{min-height:0;gap:12px}.portrait{max-height:45dvh;flex-shrink:1}.portrait-caption{line-height:1.4}
 .workspace{min-height:0;padding:16px 22px;overflow:hidden}.eyebrow{font-size:.72rem}
 h1{font-size:clamp(1.4rem,2.1vw,1.85rem);margin:7px 0;flex-shrink:0}
 #help{margin:0 0 8px;line-height:1.4;font-size:.94rem;max-height:28dvh;overflow:auto;flex-shrink:0}
 #help:empty{display:none}.content{flex:1;min-height:0;max-height:none;overflow:auto;padding:2px 3px 4px 0}
 .actions{padding-top:8px;gap:8px;flex-shrink:0}.actions button{padding:10px 16px;min-height:46px}
 .state{padding-top:5px;min-height:0;flex-shrink:0}.state:empty{display:none}
 .answer{padding:10px 15px;margin-top:8px;flex-shrink:0;max-height:26dvh;overflow:auto}.answer div{font-size:1.2rem;margin-top:4px;line-height:1.4}
 .choice-grid{gap:4px 14px}.option{padding:7px 4px;gap:10px;line-height:1.3}.yesno{margin:8px 0;gap:18px}.yesno .option{font-size:1.4rem}
 .field-wrap{margin-bottom:10px}label.field{margin:8px 0 5px}input:not([type=checkbox],[type=radio],[type=range]),select,textarea{padding:11px 13px}
 .kinds{gap:10px}.kind{padding:15px 18px;gap:16px}.kind small{margin-top:4px}.kind .number{width:42px;height:42px}
 .microphone{margin:10px auto;width:76px;height:76px;font-size:40px}
 footer{padding:7px 2px;font-size:.7rem;gap:8px;flex-shrink:0}
 dialog{max-height:96dvh}#modal-content{display:flex;flex-direction:column;max-height:96dvh;overflow:hidden}
 .modal-head{padding:14px 22px 7px;flex-shrink:0}.modal-head h2{font-size:1.4rem}.modal-head button{min-height:40px;padding:5px 12px}
 .modal-body{padding:5px 22px 14px;max-height:none;min-height:0;overflow:auto}
 .modal-actions{padding:9px 22px 14px;gap:8px;flex-shrink:0}.modal-actions button{min-height:44px;padding:9px 15px}
 .tabs{padding:7px 22px;gap:8px;flex-shrink:0}.tabs button{min-height:44px;min-width:0;padding:10px 15px;font-size:.92rem}
 .settings-dialog{width:min(1100px,96vw)}.settings-dialog .hint{font-size:.83rem;line-height:1.4;margin:8px 0}
 .settings-panel>.two-fields{gap:4px 18px}.settings-panel>button{padding:10px 14px;min-height:44px;margin:4px}
 .settings-panel>.field-wrap{margin-bottom:6px}th,td{padding:9px 12px}
}
.page-hidden{display:none!important}
.content-pages{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:6px 0 0;flex-shrink:0;font-size:.85rem}
.content-pages button{min-height:42px;padding:8px 12px;font-size:.9rem}.content-pages button:disabled{cursor:default}
.assessment-finished #question{font-size:clamp(28px,3.3vw,46px);line-height:1.35;margin:auto 0;text-align:center}
.assessment-finished .workspace{justify-content:center}.assessment-finished #content{flex:0;min-height:0;text-align:center}
.assessment-finished #category{text-align:center}.completion-check{font-size:72px;color:#10756e;padding:14px}
.assessment-finished #abort,.assessment-finished #help,.assessment-finished #state{display:none}
.assessment-finished #content,.assessment-finished .content-pages{display:none!important}
@media print{.page-hidden{display:revert!important}.content-pages{display:none!important}}
.voice-feedback{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:8px;min-height:165px}
.voice-feedback .microphone{margin:0;width:82px;height:82px;flex-shrink:0}
.voice-feedback svg{width:62px;height:62px}
.voice-state{font-size:clamp(24px,2.5vw,32px);font-weight:750;line-height:1.3;text-align:center;color:#b32629;margin:0;white-space:pre-line}
.voice-feedback.listening .voice-state{color:#168244}
.speech-active #state{display:none}

/* Short input dialogs stay above the on-screen keyboard. Only the body scrolls. */
dialog.input-top{position:fixed;inset:12px auto auto 50%;transform:translateX(-50%);margin:0;width:min(1120px,96vw);max-height:calc(100dvh - 24px)}
dialog.input-top #modal-content{display:flex;flex-direction:column;max-height:calc(100dvh - 24px)}
dialog.input-top .modal-head{padding:14px 24px 4px;flex-shrink:0}
dialog.input-top .modal-head h2{font-size:1.4rem}
dialog.input-top .modal-body{padding:0 24px 6px;max-height:none;min-height:0;overflow:auto}
dialog.input-top .modal-actions{padding:8px 24px 14px;flex-shrink:0}
dialog.input-top .field-wrap{margin-bottom:4px}
dialog.input-top label.field{margin:8px 0 5px}
dialog.input-top input,dialog.input-top select{padding:10px 12px}
dialog.patient-dialog .patient-fields{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 22px}
dialog.unlock-dialog{width:min(760px,96vw)}
@media(max-height:420px){dialog.input-top{top:4px;max-height:calc(100dvh - 8px)}dialog.input-top #modal-content{max-height:calc(100dvh - 8px)}dialog.input-top .modal-head{padding-top:8px}dialog.input-top .modal-actions{padding-bottom:8px}}

/* Keep patient fields and their focus outline inside the scrolling form. */
.patient-fields{min-width:0;width:100%;padding:6px 8px 8px;grid-template-columns:repeat(2,minmax(0,1fr))}
.patient-fields>.field-wrap{min-width:0}
.patient-fields input,.patient-fields select{min-width:0;max-width:100%}
@media(max-width:580px){.workspace .patient-fields{grid-template-columns:minmax(0,1fr)}}

/* Reserve space for focus outlines throughout the questionnaire, including numeric and text answers. */
.workspace .content{padding:8px}
.workspace .content .field-wrap{min-width:0}
.workspace .content input,.workspace .content select,.workspace .content textarea{min-width:0;max-width:100%}
.workspace .content .two-fields{grid-template-columns:repeat(2,minmax(0,1fr))}
.workspace .content .patient-fields{padding:0}
@media(max-width:580px){.workspace .content .two-fields{grid-template-columns:minmax(0,1fr)}}

/* One stable canvas replaces full-frame blink/mouth overlays after assets are decoded. */
.portrait{isolation:isolate}
.portrait>.avatar-canvas{position:absolute;inset:0;display:block;width:100%;height:100%;backface-visibility:hidden}
.portrait[data-avatar-ready="true"]>img{visibility:hidden}
.portrait>.thought{z-index:1}

/* Keep the portrait frame still; only eyes and lips are animated. */
.portrait{animation:none;transform:none}

/* Phone layout follows EVA: compact portrait, one column, generous touch targets. */
@media screen and (max-width:850px){
 html,body{height:auto;min-height:100%;overflow:auto}
 .app-shell{height:auto;min-height:100dvh;display:flex;flex-direction:column;overflow:visible;padding:8px max(12px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(12px,env(safe-area-inset-left))}
 header{padding:0 2px;gap:8px;flex-wrap:wrap}.brand{height:52px;width:144px}
 nav{width:100%;justify-content:flex-start;gap:6px}nav button,nav .button{font-size:14px;min-height:44px;padding:9px 12px}
 .patient-bar{min-height:0;padding:10px 12px;border-radius:12px}#patient-label{font-size:15px;line-height:1.35;overflow-wrap:anywhere;min-width:0}
 main{display:flex;flex-direction:column;flex:1;min-height:0;overflow:visible;gap:10px;margin-top:10px}
 .portrait-panel{float:none;width:auto;margin:0;padding:0;flex-direction:row;align-items:center;justify-content:center;gap:14px;flex-shrink:0;z-index:auto}
 .portrait{width:96px;max-height:none;aspect-ratio:1;flex:none;border-radius:18px}
 .portrait-caption{display:block;font-size:14px;line-height:1.4;max-width:180px;text-align:left}
 .portrait-panel #abort:not([hidden]){display:block;font-size:14px;padding:9px;min-height:44px}
 .thought{font-size:18px;padding:4px 9px;top:6px;right:3px;border-width:2px}
 .workspace{min-height:0;padding:16px;border-radius:18px;overflow:visible;flex:1}
 .eyebrow{font-size:11px}h1{padding:0;font-size:25px;line-height:1.25;margin:7px 0 10px;overflow-wrap:anywhere}
 #help{font-size:16px;line-height:1.45;max-height:none;overflow:visible;margin:0 0 10px}#help:empty{display:none}
 .workspace .content{flex:0 1 auto;min-height:0;max-height:none;overflow:visible;padding:6px}
 .workspace .content .two-fields,.workspace .content .patient-fields{grid-template-columns:minmax(0,1fr);gap:6px}
 .field-wrap{margin-bottom:10px;min-width:0}label.field{font-size:16px;margin:8px 0 6px}
 input:not([type=checkbox],[type=radio],[type=range]),select,textarea{font-size:16px;min-height:48px;padding:12px;scroll-margin-block:20px}
 .choice-grid{grid-template-columns:minmax(0,1fr);gap:3px}.option{font-size:16px;gap:12px;line-height:1.45;padding:10px 3px;min-height:44px}
 .option input{width:26px;height:26px;margin:0;flex-shrink:0}.option span{min-width:0;overflow-wrap:anywhere}
 .yesno{gap:4px 14px;margin:8px 0}.yesno .option{font-size:20px}
 .kinds{gap:12px}.kind{padding:16px 12px;gap:12px;width:100%;font-size:17px;min-width:0}.kind>div{min-width:0}.kind strong,.kind small{overflow-wrap:anywhere}.kind small{font-size:15px;line-height:1.4}.kind .number{width:36px;height:36px;font-size:20px;border-radius:12px}
 .actions{padding-top:10px;gap:8px}.actions button{width:100%;min-width:0;min-height:48px;padding:12px 14px;font-size:16px;touch-action:manipulation;overflow-wrap:anywhere}
 .answer{padding:12px;margin-top:12px;max-height:none;overflow:visible}.answer div{font-size:18px;line-height:1.45;overflow-wrap:anywhere}
 .voice-feedback{min-height:0;flex-direction:row;justify-content:flex-start;gap:12px;padding:10px 0}.voice-feedback .microphone{width:54px;height:54px}.voice-feedback svg{width:40px;height:40px}.voice-state{font-size:19px;text-align:left;line-height:1.35;overflow-wrap:anywhere}
 .state{font-size:14px;line-height:1.4;overflow-wrap:anywhere}.state:empty{display:none}
 th,td{font-size:15px;padding:10px 8px}th:first-child,td:first-child{width:36%}.table-wrap{overflow:visible}
 footer{font-size:11px;line-height:1.4;gap:4px;padding:12px 2px;overflow-wrap:anywhere}
 dialog{width:calc(100vw - 16px);max-width:none;max-height:calc(100dvh - 16px);border-radius:16px}
 #modal-content{display:flex;flex-direction:column;max-height:calc(100dvh - 16px);overflow:hidden}
 .modal-head{padding:14px 16px 8px;gap:10px;flex-shrink:0}.modal-head h2{font-size:22px;overflow-wrap:anywhere}.modal-head button{padding:6px 12px;min-height:44px}
 .modal-body{padding:6px 16px 12px;min-height:0;max-height:none;overflow:auto}.modal-actions{padding:10px 16px 14px;gap:8px;flex-shrink:0}.modal-actions button{min-height:48px;flex:1;font-size:16px;padding:10px}
 .tabs{padding:6px 16px;gap:6px}.tabs button{min-width:0;min-height:44px;padding:8px 10px;font-size:14px;flex:1}
 .speech-active{height:100dvh;min-height:0;overflow:hidden}
 .speech-active .app-shell{height:100dvh;min-height:0;overflow:hidden}
 .speech-active header,.speech-active footer,.speech-active #category,.speech-active #help{display:none}
 .speech-active main{min-height:0;overflow:hidden;gap:8px;margin-top:8px}
 .speech-active .portrait{width:72px}.speech-active .portrait-caption{font-size:13px}
 .speech-active .workspace{min-height:0;overflow:hidden;padding:12px}
 .speech-active #question{flex-shrink:1;max-height:28dvh;overflow:auto;font-size:22px;margin:0 0 8px}
 .speech-active .content{flex:0 0 auto;padding:0}
 .speech-active .answer{flex:1 1 0;min-height:48px;overflow:auto;margin-top:6px}
 .speech-active .actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));flex-shrink:0;padding-top:8px}
 .speech-active .actions button{font-size:15px;padding:10px 6px}
 .assessment-finished #question{font-size:27px;padding:0}
}
@media screen and (max-width:850px) and (max-height:500px){
 .speech-active .patient-bar,.speech-active .portrait-caption{display:none}
 .speech-active main{display:grid;grid-template-columns:72px minmax(0,1fr);margin-top:0;gap:10px}
 .speech-active .portrait-panel{align-self:start;padding-top:8px}
 .speech-active .workspace{height:100%;padding:10px}.speech-active #question{max-height:25dvh;font-size:20px}
 .speech-active .voice-feedback{padding:4px 0}.speech-active .microphone{width:44px;height:44px}.speech-active .voice-state{font-size:17px}
}

@media screen and (max-width:850px){.speech-active #question{line-height:1.35;min-height:1.6em;padding-bottom:3px;scrollbar-width:thin}.speech-active .actions{margin-top:auto}.portrait-panel{flex-wrap:wrap}.portrait-panel #abort:not([hidden]){flex-basis:100%}}
