/* Final layout layer shared by all roles. */
:root{--content-gap:clamp(12px,2vw,24px)}
html{scrollbar-gutter:stable}body{min-width:0}#app{width:100%;min-width:0}
#app :is(.wrap,.card,.form-group,.form-row,.flex-between,.grid-2,.grid-3,.grid-4,.editor-q-layout,.editor-q-main,.editor-q-sidebar,#teacher-content,#admin-content){min-width:0;box-sizing:border-box}
#app :is(h1,h2,h3,p,label,.alert,.badge){overflow-wrap:break-word}
#app .wrap{margin-left:auto;margin-right:auto;width:100%;max-width:1440px}
#app .grid-2{grid-template-columns:repeat(2,minmax(0,1fr))}#app .grid-3{grid-template-columns:repeat(3,minmax(0,1fr))}#app .grid-4{grid-template-columns:repeat(4,minmax(0,1fr))}
#app .form-row{display:flex;flex-wrap:wrap;gap:var(--content-gap)}#app .form-row>.form-group{flex:1 1 220px}
#app .flex-between{gap:12px;flex-wrap:wrap}
#app :is(input:not([type=checkbox]):not([type=radio]):not([type=color]),select,textarea){max-width:100%;box-sizing:border-box}
#app :is(.table-scroll,.table-responsive){max-width:100%;min-width:0;overflow-x:auto;touch-action:pan-x pan-y;scrollbar-width:auto;scrollbar-color:#5c9da5 #e8f1f3}
.table-responsive:focus-visible,.table-scroll:focus-visible{outline:3px solid #087f83;outline-offset:2px}
#app :is(.table-scroll,.table-responsive) table{width:100%;min-width:560px;border-collapse:collapse}
#app td{overflow-wrap:anywhere}#app th{white-space:nowrap}#app td .btn{margin:2px}
#app :is(.modal-actions,.ed-actions){display:flex;gap:10px;flex-wrap:wrap}
.modal-overlay{overflow-y:auto;overscroll-behavior:contain}.modal{min-width:0;box-sizing:border-box}
#app .school-banner{display:flex;flex-wrap:wrap;align-items:center;gap:10px}
#app .tabs{scrollbar-width:auto;scrollbar-color:#73aab3 #eaf2f4}
#app .card{border-color:#d3e2e7}#app .card h2{line-height:1.35}
@media(min-width:1024px) and (max-width:1279px){#app .wrap{padding:24px}#app .grid-4{grid-template-columns:repeat(2,minmax(0,1fr))}.editor-mode .editor-q-sidebar{flex-basis:170px!important;width:170px!important}}
@media(max-width:1023px){
 #app .wrap{padding:18px 14px 28px!important}
 #app>header{padding:12px 14px!important;gap:12px;min-height:0!important;height:auto!important;align-items:center}
 #app>header>div:first-child{flex:1 1 240px;min-width:0;max-width:100%}
 #app>header h1{font-size:18px!important;line-height:1.35;min-width:0;white-space:normal;letter-spacing:-.3px}
 #app>header .user-info{margin-left:auto!important;justify-content:flex-end!important;max-width:100%;min-width:0}
 #app>header .user-dropdown{left:auto!important;right:0!important;min-width:0!important;width:min(270px,calc(100vw - 64px))!important;max-width:calc(100vw - 64px)!important;max-height:55dvh;overflow-y:auto;background:#fff}
 #app :is(.grid-3,.grid-4){grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:14px}
 #app .card{padding:18px!important;margin-bottom:16px;border-radius:13px}
 #app .card h2{font-size:19px}
 #app .tabs{width:100%;display:flex;flex-wrap:nowrap;overflow-x:auto;padding:5px;gap:5px;margin-bottom:16px}
 #app .tab{flex:0 0 auto;min-height:44px;white-space:nowrap}
 #app .btn-sm{min-height:42px!important}
 .editor-mode .editor-q-layout{flex-direction:column!important;align-items:stretch!important;gap:14px!important}
 .editor-mode .editor-q-sidebar{position:relative!important;top:auto!important;flex:0 0 auto!important;width:100%!important;max-width:100%!important;max-height:none!important;display:block!important;overflow:visible!important;padding:8px!important}
 .editor-mode .editor-q-pinned{position:static!important}.editor-mode .editor-q-side-rest{display:flex;flex-direction:row!important;gap:6px;overflow-x:auto;padding-bottom:8px}
 .editor-mode .editor-q-side-item{flex:0 0 150px;margin:0 0 6px!important;min-height:44px}
 .editor-mode .editor-q-main{width:100%!important;max-width:100%!important;flex:1 1 auto!important}
 .editor-mode .qtp-grid{grid-template-columns:repeat(4,minmax(0,1fr))!important;gap:8px!important}
 .editor-mode .qtp-card{min-height:112px!important;padding:10px 7px!important}
 .editor-mode .rte-toolbar{flex-wrap:wrap!important;overflow:visible!important;gap:3px}
 .editor-mode .rte-toolbar button{min-height:38px;min-width:34px}
 .modal-overlay{padding:12px!important;align-items:flex-start!important}.modal{width:100%!important;max-width:760px!important;margin:auto!important;max-height:calc(100dvh - 24px)!important;padding:18px!important;border-radius:13px}
 .modal-actions{position:relative;display:flex;flex-wrap:wrap;gap:8px}.modal-actions>.btn{flex:1 1 130px;white-space:normal}
 .backup-create-layout{display:flex!important;flex-direction:column!important}.backup-create-settings{width:100%!important;min-width:0!important}
 .class-manager-table{max-height:55dvh}.stats-charts{grid-template-columns:1fr!important}
 #app .test-take-wrap .device-frame-wrap{border-radius:12px!important}
 #app .test-take-wrap .q-text-display{overflow-wrap:break-word}
 #app .test-take-wrap .options-list li{min-width:0;gap:8px}
 #app .test-take-wrap .options-list li .q-text-display{min-width:0}
 #app .test-take-wrap .groups-board{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px}
 #app .test-take-wrap :is(.mi-row,.match-row){min-width:0;max-width:100%}
 #app .test-take-wrap .match-row{display:grid!important;grid-template-columns:minmax(0,1fr) 20px minmax(0,1fr)!important;gap:6px}
 #app .test-take-wrap :is(.match-left-item,.match-right-item){min-width:0!important;width:auto!important;overflow-wrap:anywhere!important;padding:10px!important}
}
@media(max-width:599px){
 #app .wrap{padding:14px 10px 24px!important}
 #app>header{padding:10px!important}#app>header h1{font-size:16px!important}
 #app>header .user-info{width:100%!important;justify-content:flex-end!important}
 #app :is(.grid-2,.grid-3,.grid-4){grid-template-columns:1fr!important;gap:12px}
 #app .card{padding:14px!important}#app .card h2{font-size:18px}
 #app .form-row{flex-direction:column;gap:12px}#app .form-row>.form-group{width:100%;flex:0 0 auto}
 #app .form-group :is(input:not([type=checkbox]):not([type=radio]):not([type=color]),select,textarea){width:100%}
 #app .flex-between{align-items:stretch}#app .flex-between>div{max-width:100%;flex-wrap:wrap}
 #app .flex-between select{width:100%!important}
 #app .catalog-grid{grid-template-columns:1fr!important}
 #app .test-take-meta{flex-wrap:wrap;gap:8px}
 .editor-mode .qtp-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 .editor-mode .qtp-description{font-size:11px!important}
 .editor-mode .editor-question-top{flex-wrap:wrap;gap:8px}
 #app .test-take-wrap .options-list li.order-item{padding:10px 8px;gap:6px}
 #app .test-take-wrap .order-handle{width:22px;flex:0 0 22px}
 #app .test-take-wrap .order-item .btn{padding:6px!important;min-width:32px;min-height:42px}
 #app .test-take-wrap .q-stem-with-img{flex-direction:column!important}
 #app .test-take-wrap .q-attach-thumb{align-self:flex-start}
 #testedu-footer{max-width:100%;gap:24px;font-size:12px}
 .login-page{padding:20px 10px!important;min-height:auto!important}.login-box{padding:20px 16px!important;width:100%!important;max-width:460px!important}.role-switch button{min-width:0;padding:8px 6px;font-size:12px}
}
@media(prefers-reduced-motion:reduce){#app *{scroll-behavior:auto!important;animation-duration:.01ms!important;transition-duration:.01ms!important}}
@media print{#app .table-responsive{overflow:visible}#app .table-responsive table{min-width:0}}

@media(max-width:1023px){
 #app .test-take-wrap .match-board{display:grid!important;grid-template-columns:minmax(0,1fr) 18px minmax(0,1fr)!important;gap:8px!important;align-items:stretch!important}
 #app .test-take-wrap .match-board>*{min-width:0!important;max-width:100%!important;overflow-wrap:anywhere}
 #app .test-take-wrap .match-connector{align-self:center;justify-self:center}
 #app .test-take-wrap .groups-bin{min-width:0!important;max-width:100%!important}
 #app .test-take-wrap .groups-bin-body{min-width:0!important}
 #app .test-take-wrap :is(.groups-chip,.mi-chip,.il-choice){max-width:100%;overflow-wrap:break-word;white-space:normal}
 #app .test-take-wrap .il-layout{padding-right:0!important}
 .sym-panel{max-width:calc(100vw - 52px)!important;right:40px!important;left:auto!important}
 .table-responsive,.table-scroll{background:linear-gradient(90deg,#fff,#fff),linear-gradient(90deg,#087f8320,transparent);background-attachment:local,scroll}
}

@media(max-width:1023px){
 fieldset{min-width:0;max-width:100%;box-sizing:border-box}
 body:has(.modal-overlay)>.test-page-scroll-rail{display:none}
 body:has(.modal-overlay)>.test-mobile-nav{visibility:hidden}
 #app .test-take-wrap .progress-bar{max-width:100%}
 #app .test-take-wrap .order-item .order-num{flex-shrink:0}
}

.groups-reveal-columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px}.groups-reveal-columns>section{min-width:0;padding:12px;background:#f5fafb;border:1px solid #d5e5e8;border-radius:12px}.groups-reveal-columns h3{font-size:16px;margin:0 0 12px}
@media(max-width:767px){.groups-reveal-columns{grid-template-columns:1fr;gap:14px}#app .test-take-wrap .order-h-row{display:flex!important;flex-wrap:wrap!important;justify-content:center;gap:6px!important;max-width:100%!important;width:100%!important;min-width:0!important;overflow:visible!important}#app .test-take-wrap .order-h-tile{flex:0 0 auto!important;min-width:32px!important;width:auto!important;max-width:100%;height:40px!important;padding:0 8px!important;font-size:18px!important}#app .test-take-wrap .order-h-formed{overflow-wrap:anywhere!important;white-space:normal!important;max-width:100%}}

/* Editor: keep the heading and controls on a readable card at every height. */
body.editor-mode{background:var(--bg)!important}
body.editor-mode #app>header{background:linear-gradient(110deg,#087f83,#37b4b4)!important;color:#fff;border-bottom:1px solid #ffffff33}
body.editor-mode #app>header .user-menu-btn{color:var(--text)}
body.editor-mode #app .test-editor-shell{background:#fff!important;border:1px solid var(--border)!important;border-radius:16px!important;box-shadow:var(--shadow)!important;padding:24px!important;margin-top:0!important;overflow:visible!important}
body.editor-mode .test-editor-toolbar{padding-bottom:18px;border-bottom:1px solid var(--border);align-items:center!important;gap:14px!important}
body.editor-mode .test-editor-toolbar h2{font-size:clamp(20px,2vw,26px);line-height:1.35;color:var(--text)}
body.editor-mode .test-editor-toolbar>div{display:flex;flex-wrap:wrap;gap:8px;min-width:0}
body.editor-mode .test-editor-toolbar .btn{min-height:44px;white-space:normal}
body.editor-mode .editor-test-settings{margin-top:14px;border:1px solid var(--border);border-radius:12px;background:#f8fbfc;padding:16px;min-width:0}
body.editor-mode .editor-test-settings>summary{font-weight:700;color:var(--primary-dark);cursor:pointer;min-height:32px;line-height:1.5}
body.editor-mode .editor-test-settings[open]>summary{margin-bottom:16px}
@media(max-width:767px){body.editor-mode #app .test-editor-shell{padding:16px!important;border-radius:12px!important}body.editor-mode .test-editor-toolbar{align-items:flex-start!important}body.editor-mode .test-editor-toolbar>div{width:100%}body.editor-mode .test-editor-toolbar .btn{flex:1 1 150px;font-size:13px;padding:10px}body.editor-mode .editor-test-settings{padding:12px}}

/* Keep wide attached pictures (including registration plates) entirely visible. */
.q-editor-attach-media{min-width:0;max-width:100%}
.q-editor-attach-media.has-image{width:320px;flex:0 1 320px;max-width:100%}
.q-editor-attach-zoom{display:flex;align-items:center;justify-content:center;width:100%;max-width:100%;padding:0!important;border:0!important;background:transparent!important;cursor:zoom-in;min-height:44px}
.q-editor-attach-zoom .q-editor-attach-preview{display:block;width:100%!important;height:auto!important;max-width:100%!important;max-height:180px;object-fit:contain!important;object-position:center;background:#f8fafc;border-radius:10px}
@media(max-width:767px){.q-editor-attach-media.has-image{flex:1 1 100%;width:100%;max-width:360px}.q-editor-attach-zoom .q-editor-attach-preview{max-height:160px}}

/* In-test question image: a complete small picture and a separate magnifier. */
.q-attach-thumb{display:flex!important;align-items:center;justify-content:center;width:160px!important;height:80px!important;max-width:100%;padding:6px 38px 6px 6px!important;box-sizing:border-box;text-align:left}
.q-attach-thumb img{width:100%!important;height:100%!important;min-width:0;object-fit:contain!important;object-position:center;display:block}
.q-attach-thumb .q-zoom-ico{right:6px!important;top:50%!important;transform:translateY(-50%);width:26px;height:26px;pointer-events:none}
