/* Touch-first Card Studio shell. Desktop styles are unchanged unless layout=mobile. */
.m-header,.m-card-nav,.m-selection,.m-dock,.m-actions,.m-scrim,.m-only{display:none}
:root[data-layout="mobile"] body,:root[data-layout="mobile"] .app{height:100dvh}
:root[data-layout="mobile"] .app{overflow:hidden}
:root[data-layout="mobile"] .top,:root[data-layout="mobile"] .work-tools,:root[data-layout="mobile"] .status,:root[data-layout="mobile"] #cardControl{display:none!important}
:root[data-layout="mobile"] .main{display:flex;flex:1;min-width:0;min-height:0}
:root[data-layout="mobile"] .viewport{flex:1;min-width:0;min-height:0}
:root[data-layout="mobile"] .canvas-outer{padding:24px 18px;touch-action:none;overscroll-behavior:contain}
:root[data-layout="mobile"] .stage{touch-action:none}
:root[data-layout="mobile"] .m-header{display:block;flex:none;background:#14253b;color:#f7f9ff;z-index:5}
:root[data-layout="mobile"] .m-appbar{display:flex;align-items:center;gap:7px;padding:6px 10px;min-height:50px}
:root[data-layout="mobile"] .m-appbar strong{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px}
:root[data-layout="mobile"] .m-appbar button{border:1px solid #4b6380;border-radius:8px;min-height:40px;padding:8px 10px;color:#f7f9ff;background:#263c57;font-size:13px}
:root[data-layout="mobile"] .m-mode{display:grid;grid-template-columns:1fr 1fr;gap:5px;padding:0 10px 8px}
:root[data-layout="mobile"] .m-mode button{min-height:38px;padding:8px;border:0;border-radius:7px;color:#b7c7de;background:#23364f;font-weight:700;font-size:13px}
:root[data-layout="mobile"] .m-mode button.active{background:#edf4ff;color:#2259a2}
:root[data-layout="mobile"] .m-card-nav{display:flex;justify-content:space-between;align-items:center;gap:10px;background:#f9fbfd;border-top:1px solid #dce5f1;padding:5px 12px;min-height:47px}
:root[data-layout="mobile"] .m-card-nav[hidden]{display:none}
:root[data-layout="mobile"] .m-card-nav button{border:0;background:transparent;color:#2c527f;font-weight:650;font-size:14px;padding:6px 15px;min-height:38px}
:root[data-layout="mobile"] .m-card-nav button:first-child,:root[data-layout="mobile"] .m-card-nav button:last-child{font-size:26px}
:root[data-layout="mobile"] .m-selection{display:flex;flex:none;align-items:center;justify-content:space-between;gap:8px;padding:8px 13px;border-top:1px solid #d9e4ee;background:#f9fbfd}
:root[data-layout="mobile"] .m-selection[hidden]{display:none}
:root[data-layout="mobile"] .m-selection strong{display:block;font-size:13px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
:root[data-layout="mobile"] .m-selection small{display:block;color:#718198;font-size:10px;margin-top:3px}
:root[data-layout="mobile"] .m-selection button{font-size:13px;font-weight:650;color:#235fb3;background:#eaf2ff;border:1px solid #bdd5fa;border-radius:8px;padding:9px;min-height:40px}
:root[data-layout="mobile"] .m-dock{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));align-items:stretch;flex:none;background:white;border-top:1px solid #d9e1ec;padding:4px 4px max(6px,env(safe-area-inset-bottom));z-index:5}
:root[data-layout="mobile"] .m-dock button{border:0;background:transparent;color:#425773;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;font-size:10px;min-width:0;min-height:55px;border-radius:9px}
:root[data-layout="mobile"] .m-dock button span{font-size:22px;line-height:24px}
:root[data-layout="mobile"] .m-dock button.active{background:#e8f1ff;color:#1759ae}
:root[data-layout="mobile"] .side-left,:root[data-layout="mobile"] .side-right{position:fixed;display:none;z-index:71;left:0;right:0;top:auto;bottom:0;width:100%;height:min(75dvh,760px);min-height:0;max-height:calc(100dvh - 42px);padding:0;background:white;border:0;border-radius:16px 16px 0 0;box-shadow:0 -9px 35px #10203040;overflow:hidden}
:root[data-layout="mobile"][data-mobile-panel="layers"] .side-left,:root[data-layout="mobile"][data-mobile-panel="cards"] .side-left,:root[data-layout="mobile"][data-mobile-panel="images"] .side-left,:root[data-layout="mobile"][data-mobile-panel="properties"] .side-right{display:flex;flex-direction:column}
:root[data-layout="mobile"] .m-only{display:flex}
:root[data-layout="mobile"] .m-sheet-head{display:flex;flex:none;justify-content:space-between;align-items:center;padding:14px 18px;border-bottom:1px solid #dce3ee;background:white;min-height:53px}
:root[data-layout="mobile"] .m-sheet-head strong{font-size:15px}
:root[data-layout="mobile"] .m-sheet-head button,:root[data-layout="mobile"] .m-close{font-size:18px;background:transparent;border:0;min-width:40px;min-height:36px;color:#415671}
:root[data-layout="mobile"] .side-left .sidebar-stack{display:flex;flex:1;min-height:0;padding:0}
:root[data-layout="mobile"] .sidebar-panel{display:none;flex:1;border:0;box-shadow:none;border-radius:0;min-height:0}
:root[data-layout="mobile"][data-mobile-panel="layers"] .sidebar-layers,:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards,:root[data-layout="mobile"][data-mobile-panel="images"] .sidebar-sets{display:flex}
:root[data-layout="mobile"] .side-right .side-head{flex:none;padding:9px 16px;border-bottom:1px solid #e4e9f2;justify-content:space-between;min-height:53px}
:root[data-layout="mobile"] .side-right .inspect{overflow-y:auto;overscroll-behavior:contain;flex:1;padding:12px 17px max(22px,env(safe-area-inset-bottom))}
:root[data-layout="mobile"] .field input,:root[data-layout="mobile"] .field select,:root[data-layout="mobile"] .field textarea{min-height:43px;font-size:16px}
:root[data-layout="mobile"] .toggle-line{min-height:40px;font-size:14px}
:root[data-layout="mobile"] .sidebar-panel .side-head{min-height:55px}
:root[data-layout="mobile"] .layer-row,:root[data-layout="mobile"] .card-row{min-height:52px}
:root[data-layout="mobile"] .m-scrim{position:fixed;display:none;inset:0;z-index:60;background:#0d213a81;border:0;cursor:default}
:root[data-layout="mobile"]:not([data-mobile-panel="none"]) .m-scrim{display:block}
:root[data-layout="mobile"] .m-actions{position:fixed;z-index:71;left:0;right:0;bottom:0;display:none;flex-direction:column;border-radius:16px 16px 0 0;background:#fff;max-height:80dvh;overflow:auto;box-shadow:0 -9px 35px #10203040}
:root[data-layout="mobile"][data-mobile-panel="add"] .m-actions,:root[data-layout="mobile"][data-mobile-panel="file"] .m-actions,:root[data-layout="mobile"][data-mobile-panel="export"] .m-actions{display:flex}
:root[data-layout="mobile"] .m-action-list{display:flex;flex-direction:column;padding:9px 15px max(18px,env(safe-area-inset-bottom));overflow:auto}
:root[data-layout="mobile"] .m-action-list button{background:white;border:0;border-bottom:1px solid #e4eaf2;text-align:left;min-height:52px;color:#263e5d;font-size:15px;padding:13px 8px}
:root[data-layout="mobile"] .element.selected .resize-handle{width:23px;height:23px;border-radius:8px;border-width:3px}
:root[data-layout="mobile"] .element.selected .resize-nw{left:-12px;top:-12px}
:root[data-layout="mobile"] .element.selected .resize-ne{right:-12px;top:-12px}
:root[data-layout="mobile"] .element.selected .resize-sw{left:-12px;bottom:-12px}
:root[data-layout="mobile"] .element.selected .resize-se{right:-12px;bottom:-12px}
:root[data-layout="mobile"] .element.selected .resize-n{left:50%;top:-12px}
:root[data-layout="mobile"] .element.selected .resize-s{left:50%;bottom:-12px}
:root[data-layout="mobile"] .element.selected .resize-w{left:-12px;top:50%}
:root[data-layout="mobile"] .element.selected .resize-e{right:-12px;top:50%}
:root[data-layout="mobile"] .dialog-backdrop{padding:12px}
:root[data-layout="mobile"] .dialog{max-height:90dvh;overflow-y:auto}
:root[data-layout="mobile"] .image-manager-backdrop{padding:8px}
:root[data-layout="mobile"] .image-manager{max-height:95dvh}
@media(min-width:800px){:root[data-layout="mobile"] .side-left,:root[data-layout="mobile"] .side-right,:root[data-layout="mobile"] .m-actions{left:auto;right:0;width:min(460px,68vw);height:100dvh;max-height:100dvh;border-radius:0}}

/* Direct content replacement, separate from the advanced property inspector. */
:root[data-layout="mobile"][data-mobile-panel="quick"] .m-actions{display:flex}
:root[data-layout="mobile"] .m-quick-label{display:flex;flex-direction:column;gap:10px;font-size:13px;font-weight:700;color:#435b78;padding:8px 0}
:root[data-layout="mobile"] .m-quick-label textarea{width:100%;min-height:130px;resize:vertical;font:16px/1.45 system-ui,sans-serif;border:1px solid #cbd8e7;border-radius:9px;padding:12px;color:#223a54}
:root[data-layout="mobile"] .m-action-list .m-quick-primary{margin:6px 0;background:#2c6fd5;color:white;border:0;border-radius:9px;text-align:center;font-weight:700}
:root[data-layout="mobile"] .m-quick-hint{color:#607186;font-size:13px;line-height:1.5;padding:12px}
:root[data-layout="mobile"] .m-quick-set{font-size:13px;color:#435b78;margin:15px 0 7px}
:root[data-layout="mobile"] .m-art-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;padding:0 0 12px}
:root[data-layout="mobile"] .m-action-list .m-art-option{display:flex;flex-direction:column;align-items:center;gap:5px;text-align:center;min-height:120px;border:1px solid #dce5ef;border-radius:9px;padding:7px;overflow:hidden}
:root[data-layout="mobile"] .m-art-option img{height:84px;max-width:100%;object-fit:contain}
:root[data-layout="mobile"] .m-art-option span{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px}

/* Shared card gallery previews, larger when the mobile Cards sheet is open. */
.mini-art{position:relative;overflow:hidden}
.mini-art img{width:100%;height:100%;object-fit:contain;display:block}
.mini-art .thumb-number{position:absolute;bottom:0;right:0;padding:1px 2px;background:#163250ce;color:white;font-size:9px;line-height:1.1;border-top-left-radius:3px}
:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards .card-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:12px}
:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards .card-row{display:flex;flex-direction:column;align-items:stretch;gap:7px;padding:9px;border:1px solid #dbe4ee;min-width:0;position:relative}
:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards .card-row.active{border-color:#4385e9;box-shadow:0 0 0 1px #4385e9}
:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards .mini-art{width:100%;height:160px;max-height:30dvh;background:#e8edf3;border:0;display:grid;place-items:center}
:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards .mini-art img{height:100%;width:100%;object-fit:contain}
:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards .card-row .name{width:100%;white-space:normal;overflow-wrap:anywhere;font-size:13px}
:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards .card-row .sub{font-size:11px}
:root[data-layout="mobile"][data-mobile-panel="cards"] .sidebar-cards .card-row .small-btn{position:absolute;top:8px;right:8px;background:#fffffff0;border:1px solid #d5e0ec;min-width:35px;min-height:35px}
:root[data-layout="mobile"] .m-appbar [data-action="undo"],:root[data-layout="mobile"] .m-appbar [data-action="redo"]{min-width:39px;padding:6px;font-size:22px;line-height:1}

/* Precision movement for touch use. */
:root[data-layout="mobile"][data-mobile-panel="nudge"] .m-actions{display:flex}
:root[data-layout="mobile"] .m-selection #mobileNudgeButton{margin-left:auto}
:root[data-layout="mobile"] .m-nudge-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px;max-width:380px;margin:12px auto 2px;width:100%}
:root[data-layout="mobile"] .m-nudge-grid span{min-height:48px}
:root[data-layout="mobile"] .m-action-list .m-nudge-grid button{display:grid;place-items:center;text-align:center;min-height:52px;padding:6px;border:1px solid #d4e1ef;border-radius:10px;background:#f1f6fd;color:#235590;font-size:24px;font-weight:700}
:root[data-layout="mobile"] .m-action-list .m-nudge-grid [data-mobile="nudge-step"]{font-size:12px;background:#e4efff}

:root[data-layout="mobile"] .recovery-panel{width:min(100%,480px);padding:20px}
:root[data-layout="mobile"] .recovery-actions{display:grid;grid-template-columns:1fr}
:root[data-layout="mobile"] .recovery-actions button{width:100%;min-height:48px}
:root[data-layout="mobile"] .m-autosave-status{color:#a4bddb;font-size:12px;padding:8px 10px;display:block}
