        * { margin: 0; padding: 0; box-sizing: border-box; }
        html, body { height: 100%; width: 100%; overflow: hidden; font-family: 'Nunito', sans-serif; background: #1a1a2e; }
        .screen { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; flex-direction: column; }
        .screen.active { display: flex; }

        /* HOME SCREEN */
        .home-screen { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); justify-content: center; align-items: center; padding: 3vmin; }
        .home-content { width: 100%; text-align: center; }
        .home-logo { font-size: 15vmin; margin-bottom: 2vmin; }
        .home-title { font-size: 7vmin; font-weight: 800; color: white; margin-bottom: 1vmin; }
        .home-subtitle { font-size: 2.5vmin; color: rgba(255,255,255,0.8); margin-bottom: 6vmin; }
        .home-menu { display: flex; gap: 3vmin; justify-content: center; flex-wrap: wrap; margin: 0 auto; }
        .menu-card { background: white; border-radius: 2.5vmin; padding: 3.5vmin 4vmin; cursor: pointer; transition: transform 0.2s; text-align: center; box-shadow: 0 1vmin 3vmin rgba(0,0,0,0.2); flex: 0 0 20vmin; }
        .menu-card:hover { transform: translateY(-1vmin) scale(1.02); }
        /* line-height: 1.2 forces a deterministic height for the emoji
           variant (otherwise "normal" gives ~1.36, ~7.7px taller than the
           <img> variant on the PiCom and SymBrowser cards, which pushed
           those titles above the emoji-card titles). 7vmin × 1.2 = 8.4vmin,
           matching the inline height set on the icon images. */
        .menu-card-icon { font-size: 7vmin; line-height: 1.2; margin-bottom: 1.5vmin; display: block; }
        /* Reserve enough vertical space for 2 lines worth of text on every
           card so the title row and description row sit at the same y on
           every card, regardless of how many lines each card's text wraps
           to. align-items: flex-start anchors the FIRST line at the top of
           the reserved box — without this, 1-line text would be centred
           inside the box and visually appear higher than 2-line text whose
           first line sits at the top of the same box.
           justify-content: center keeps short text horizontally centred. */
        .menu-card h3 {
            font-size: 2.5vmin;
            line-height: 1.2;
            color: #333;
            margin-bottom: 0.5vmin;
            min-height: 6vmin;          /* = font-size 2.5vmin × line-height 1.2 × 2 */
            display: flex;
            align-items: flex-start;
            justify-content: center;
            text-align: center;
        }
        .menu-card p {
            font-size: 1.6vmin;
            line-height: 1.3;
            color: #666;
            min-height: 4.2vmin;        /* = font-size 1.6vmin × line-height 1.3 × 2 */
            display: flex;
            align-items: flex-start;
            justify-content: center;
            text-align: center;
            margin: 0;
        }
        .menu-card.create { border-top: 0.8vmin solid #00b894; }
        .menu-card.load { border-top: 0.8vmin solid #0984e3; }
        .menu-card.manage { border-top: 0.8vmin solid #00b894; background: white; }
        .menu-card.picom { border-top: 0.8vmin solid #0984e3; background: white; }
        .menu-card.symbrowser { border-top: 0.8vmin solid #6c5ce7; background: white; }
        .menu-card.symword { border-top: 0.8vmin solid #6c5ce7; background: white; }
        .settings-btn { position: absolute; top: calc(3vmin + env(safe-area-inset-top, 0px)); right: max(3vmin, env(safe-area-inset-right, 0px)); background: rgba(255,255,255,0.2); border: none; color: white; width: 7vmin; height: 7vmin; border-radius: 50%; cursor: pointer; font-size: 4vmin; display: flex; align-items: center; justify-content: center; }
        .settings-btn:hover { background: rgba(255,255,255,0.3); }

        /* SCREEN HEADER */
        .screen-header { height: 8vmin; min-height: 45px; padding: 0 2vmin; display: flex; align-items: center; gap: 1.5vmin; flex-shrink: 0; background: linear-gradient(135deg, #0984e3, #6c5ce7); }
        /* The iOS/Mac app lets the page fill the screen (viewport-fit=cover): keep headers clear of the status bar and
           notch, with the header colour running up behind them. More buttons than fit (editor, portrait) scroll sideways. */
        .screen-header { box-sizing: content-box; padding-top: env(safe-area-inset-top, 0px); padding-left: max(2vmin, env(safe-area-inset-left, 0px)); padding-right: max(2vmin, env(safe-area-inset-right, 0px)); overflow-x: auto; scrollbar-width: none; }
        .screen-header::-webkit-scrollbar { display: none; }
        .screen-header > * { flex-shrink: 0; }
        .home-btn { background: rgba(255,255,255,0.2); border: none; color: white; width: 5vmin; height: 5vmin; min-width: 36px; min-height: 36px; border-radius: 50%; cursor: pointer; font-size: 2.5vmin; display: flex; align-items: center; justify-content: center; }
        .home-btn:hover { background: rgba(255,255,255,0.3); }
        .screen-title { font-size: 2.8vmin; color: white; flex: 1; font-weight: 700; }
        .header-btn { background: rgba(255,255,255,0.2); border: none; color: white; padding: 1vmin 2vmin; border-radius: 1vmin; cursor: pointer; font-size: 1.8vmin; font-weight: 600; font-family: inherit; display: flex; align-items: center; gap: 0.5vmin; }
        .header-btn:hover { background: rgba(255,255,255,0.3); }
        .header-btn.danger { background: #d63031; }
        .header-btn.success { background: #00b894; }

        /* LOAD SCREEN */
        .load-screen .screen-header { background: linear-gradient(135deg, #74b9ff, #0984e3); }
        .screen-title-dark { color: #333; }
        .board-grid-list { flex: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(22vmin, 1fr)); gap: 2vmin; padding: 2vmin; align-content: start; overflow-y: auto; background: #f5f5f5; }
        .board-card { background: white; border-radius: 2vmin; padding: 1.5vmin; cursor: pointer; box-shadow: 0 0.5vmin 2vmin rgba(0,0,0,0.1); display: flex; flex-direction: column; align-items: center; transition: transform 0.2s; }
        .board-card:hover { transform: scale(1.03); }
        .board-card-icon { font-size: 5vmin; margin-bottom: 0.5vmin; }
        .board-card-preview { margin-bottom: 0.5vmin; display: flex; align-items: center; justify-content: center; width: 100%; height: 12vmin; }
        .board-card-preview svg { max-width: 100%; max-height: 100%; height: auto; }
        .board-card h3 { font-size: 2vmin; text-align: center; margin-bottom: 0.3vmin; }
        .board-card p { font-size: 1.4vmin; color: #666; }
        .board-card-btns { display: flex; gap: 0.8vmin; margin-top: auto; padding-top: 1vmin; width: 100%; }
        .board-card-btn { flex: 1; padding: 0.8vmin; border: none; border-radius: 0.8vmin; cursor: pointer; font-size: 1.4vmin; font-weight: 600; font-family: inherit; }
        .board-card-btn.edit { background: #0984e3; color: white; }
        .board-card-btn.run { background: #00b894; color: white; }
        .board-card-btn:hover { opacity: 0.85; }
        .board-card-btn:disabled { opacity: 0.7; cursor: wait; }
        .spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; }
        @keyframes spin { to { transform: rotate(360deg); } }
        @keyframes aispin { to { transform: rotate(360deg); } }
        .empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #f5f5f5; }
        .empty-state-icon { font-size: 12vmin; margin-bottom: 2vmin; opacity: 0.3; }
        .empty-state p { font-size: 2.5vmin; color: #666; }

        /* MANAGE SCREEN */
        .manage-screen .screen-header { background: linear-gradient(135deg, #a29bfe, #6c5ce7); }
        .manage-screen .board-grid-list { grid-template-columns: repeat(auto-fit, minmax(28vmin, 1fr)); }
        .manage-card { background: white; border-radius: 2vmin; padding: 2vmin; box-shadow: 0 0.5vmin 2vmin rgba(0,0,0,0.1); display: flex; flex-direction: column; height: 100%; }
        .manage-card-header { display: flex; align-items: center; gap: 1.5vmin; margin-bottom: 1.5vmin; padding-bottom: 1.5vmin; border-bottom: 1px solid #eee; }
        .manage-card-icon { font-size: 5vmin; }
        .manage-card-preview { flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
        .manage-card-preview svg { max-width: 100%; height: auto; }
        .manage-card-info { flex: 1; }
        .manage-card-info h3 { font-size: 2.2vmin; margin-bottom: 0.3vmin; }
        .manage-card-info p { font-size: 1.6vmin; color: #666; }
        .manage-card-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1vmin; margin-top: auto; }
        .manage-action-btn { padding: 1.2vmin; border: none; border-radius: 1vmin; cursor: pointer; font-size: 1.6vmin; font-weight: 600; font-family: inherit; display: flex; align-items: center; justify-content: center; gap: 0.5vmin; transition: opacity 0.2s; }
        .manage-action-btn:hover { opacity: 0.85; }
        .manage-action-btn.open { background: #00cec9; color: #333; }
        .manage-action-btn.duplicate { background: #74b9ff; color: white; }
        .manage-action-btn.rename { background: #fdcb6e; color: #333; }
        .manage-action-btn.delete { background: #ff7675; color: white; }
        .manage-action-btn.export { background: #00b894; color: white; }
        .manage-action-btn.share { background: #0984e3; color: white; }
        .manage-action-btn.symbols { background: #a29bfe; color: white; }
        .manage-action-btn.print { background: #6c5ce7; color: white; }

        /* SETTINGS SCREEN */
        .settings-screen .screen-header { background: linear-gradient(135deg, #ffeaa7, #fdcb6e); }
        .settings-body { flex: 1; padding: 3vmin; background: #f5f5f5; overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; }
        .settings-card { background: white; border-radius: 2vmin; padding: 3vmin; max-width: 70vmin; width: 100%; box-shadow: 0 0.5vmin 2vmin rgba(0,0,0,0.1); }
        .settings-section { margin-bottom: 3vmin; }
        .settings-section:last-child { margin-bottom: 0; }
        .settings-section h3 { font-size: 2.5vmin; margin-bottom: 1.5vmin; display: flex; align-items: center; gap: 1vmin; }
        .settings-row { display: flex; gap: 1vmin; margin-bottom: 1.5vmin; align-items: center; }
        .settings-row input[type="number"] { width: 8vmin; padding: 1.2vmin; border: 2px solid #ddd; border-radius: 1vmin; font-size: 1.8vmin; text-align: center; }
        .btn { padding: 1.2vmin 2vmin; border: none; border-radius: 1vmin; font-size: 1.8vmin; font-weight: 600; cursor: pointer; font-family: inherit; }
        .btn-secondary { background: #dfe6e9; color: #333; }

        /* EDITOR SCREEN */
        .editor-body { flex: 1; display: flex; overflow: hidden; background: #e8e8e8; }
        
        .resize-handle { width: 6px; background: #ddd; cursor: ew-resize; flex-shrink: 0; transition: background 0.2s; }
        .resize-handle:hover, .resize-handle.dragging { background: #0984e3; }
        
        .editor-sidebar { width: 32vmin; min-width: 220px; max-width: 50%; display: flex; flex-direction: column; background: #fff; border-left: 1px solid #ddd; overflow-y: auto; overflow-x: hidden; flex-shrink: 0; }
        .sidebar-section { border-bottom: 1px solid #eee; }
        .sidebar-header { padding: 1.5vmin 1.8vmin; background: #f8f8f8; font-size: 2vmin; font-weight: 700; display: flex; align-items: center; gap: 1vmin; cursor: pointer; position: sticky; top: 0; z-index: 1; }
        .sidebar-header:hover { background: #f0f0f0; }
        .sidebar-header .expand-icon { margin-left: auto; font-size: 1.5vmin; transition: transform 0.2s; }
        .sidebar-header.collapsed .expand-icon { transform: rotate(-90deg); }
        .sidebar-content { padding: 1.5vmin; }
        .sidebar-content.collapsed { display: none; }
        
        .tabs { display: flex; gap: 0.5vmin; margin-bottom: 1.2vmin; }
        .tab { flex: 1; min-width: 0; padding: 1.1vmin 0.4vmin; background: #f0f0f0; border: none; border-radius: 1vmin; cursor: pointer; font-size: 2.9vmin; font-weight: 600; }
        .tab.active { background: #0984e3; color: white; }
        
        .symbol-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6vmin, 1fr)); grid-auto-rows: 6vmin; gap: 0.6vmin; max-height: 40vmin; overflow-y: auto; border: 1px solid #eee; border-radius: 1vmin; padding: 0.8vmin; background: #fafafa; }
        .symbol-grid.web-results { grid-template-columns: repeat(auto-fill, minmax(10vmin, 1fr)); grid-auto-rows: 10vmin; }
        /* Sensory Symbols tab: a picture with its name under it */
        .symbol-grid.ss-grid { grid-template-columns: repeat(auto-fill, minmax(11vmin, 1fr)); grid-auto-rows: auto; align-items: start; max-height: 48vmin; min-height: 8vmin; }
        .ss-item { display: flex; flex-direction: column; align-items: center; gap: 0.3vmin; padding: 0.5vmin; background: white; border: 2px solid #eee; border-radius: 0.8vmin; cursor: pointer; font-family: inherit; color: #333; min-width: 0; }
        .ss-item:hover, .ss-item:focus-visible { border-color: #0984e3; outline: none; }
        .ss-item[aria-busy="true"] { opacity: 0.5; }
        .ss-item img { width: 100%; aspect-ratio: 1; object-fit: contain; }
        .ss-name { font-size: 1.4vmin; line-height: 1.15; text-align: center; overflow-wrap: anywhere; max-height: 2.4em; overflow: hidden; width: 100%; }
        .ss-status { font-size: 1.2vmin; color: #666; text-align: center; padding: 0.5vmin; min-height: 1.6em; }
        .ss-more { display: block; margin: 0.5vmin auto; }
        .ss-more[hidden] { display: none; }
        .ss-credit { font-size: 1.1vmin; color: #999; text-align: center; margin: 0.5vmin 0 0; }
        .symbol-item { background: white; border: 2px solid #eee; border-radius: 0.8vmin; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0.3vmin; overflow: hidden; }
        .symbol-item:hover { border-color: #0984e3; }
        .symbol-item img { width: 90%; height: 90%; object-fit: contain; }
        .symbol-item .svg-container svg { max-width: 90%; max-height: 90%; width: auto; height: auto; }
        
        .input-row { display: flex; gap: 0.8vmin; margin-bottom: 1.2vmin; }
        .input-row input, .input-row select { flex: 1; padding: 1vmin; border: 1px solid #ddd; border-radius: 0.8vmin; font-size: 1.8vmin; }
        .input-row button { padding: 1vmin 1.5vmin; background: #dfe6e9; border: none; border-radius: 0.8vmin; cursor: pointer; font-size: 1.8vmin; }
        .btn-small { padding: 1vmin 1.5vmin; font-size: 1.8vmin; width: 100%; margin-top: 0.8vmin; }
        .btn-success { background: #00b894; color: white; }
        .btn-primary { background: #0984e3; color: white; }
        .btn-danger { background: #d63031; color: white; }
        .btn:disabled { opacity: 0.5; cursor: not-allowed; }

        /* CELL EDITOR */
        .cell-preview { display: flex; align-items: center; gap: 1.2vmin; background: #f5f5f5; padding: 1vmin; border-radius: 1vmin; margin-bottom: 1.2vmin; min-height: 6vmin; }
        .cell-preview img { width: 5vmin; height: 5vmin; object-fit: contain; }
        .cell-preview span { font-size: 1.8vmin; color: #666; flex: 1; }
        .form-group { margin-bottom: 1vmin; }
        .form-group label { display: block; font-size: 1.5vmin; color: #666; margin-bottom: 0.4vmin; }
        .form-group input, .form-group select { width: 100%; padding: 0.8vmin; border: 1px solid #ddd; border-radius: 0.8vmin; font-size: 1.8vmin; }
        .form-row { display: flex; gap: 0.8vmin; }
        .form-row .form-group { flex: 1; }
        .editor-btns { display: flex; gap: 0.8vmin; margin-top: 1vmin; }
        .editor-btns button { flex: 1; }

        /* BOARD AREA */
        .board-container { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1.5vmin; overflow: auto; background: repeating-conic-gradient(#e0e0e0 0% 25%, #f0f0f0 0% 50%) 50% / 20px 20px; position: relative; }
        .board { background: white; box-shadow: 0 0.5vmin 2vmin rgba(0,0,0,0.15); transform-origin: center; }
        .board-inner { padding: 4mm; }
        .board-grid { display: grid; gap: 1mm; }
        
        .cell { background: white; border: 1px solid #ddd; border-radius: 1.5mm; display: flex; flex-direction: column; cursor: pointer; position: relative; overflow: hidden; }
        .cell:hover { border-color: #0984e3; }
        .cell.selected { border: 3px solid #0984e3; background: #e3f2fd; box-shadow: 0 0 0 3px rgba(9, 132, 227, 0.3), 0 4px 12px rgba(9, 132, 227, 0.25); }
        .cell-content { flex: 1; display: flex; flex-direction: column; padding: 0.5mm; min-height: 0; position: relative; pointer-events: none; }
        .cell-content.label-top { flex-direction: column; }
        .cell-content.label-bottom { flex-direction: column; }
        .cell-content.label-center { justify-content: center; align-items: center; }
        .cell-content.label-center .cell-image-area { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
        .cell-content.label-center .cell-label { position: absolute; top: 50%; left: 0; right: 0; transform: translateY(-50%); z-index: 2; width: 100%; }
        .cell-image-area { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; position: relative; }
        .cell-image-area img.main-img { max-width: 100%; max-height: 100%; object-fit: contain; }
        .cell-image-area img.annotation-img { position: absolute; width: 30%; height: 30%; object-fit: contain; }
        .cell-image-area img.ann-tl { top: 0; left: 0; }
        .cell-image-area img.ann-tr { top: 0; right: 0; }
        .cell-image-area img.ann-bl { bottom: 0; left: 0; }
        .cell-image-area img.ann-br { bottom: 0; right: 0; }
        .cell-label { text-align: center; padding: 0.5mm; line-height: 1.1; word-break: break-word; flex-shrink: 0; max-height: 1.5em; overflow: hidden; text-overflow: ellipsis; }
        .cell .remove { position: absolute; top: 0.5mm; left: 0.5mm; width: 3mm; height: 3mm; background: #d63031; color: white; border: none; border-radius: 50%; font-size: 2mm; cursor: pointer; opacity: 0; display: flex; align-items: center; justify-content: center; z-index: 5; }
        .cell:hover .remove { opacity: 1; }
        .cell .link-indicator { position: absolute; bottom: 0.5mm; right: 0.5mm; font-size: 2.5mm; opacity: 0.7; z-index: 4; filter: drop-shadow(0 0 1px white); }
        .cell:hover .link-indicator { opacity: 1; }
        .cell.has-link { border-radius: 1.5mm 15% 1.5mm 1.5mm !important; }
        .cell-placeholder { font-size: 1.8mm; color: #ccc; }
        .cell.drag-over { background: #e8f5e9 !important; border: 2px dashed #00b894 !important; }
        .cell.drag-over * { pointer-events: none; }

        /* DRAW */
        .draw-area { border: 1px solid #ddd; border-radius: 0.5vmin; overflow: hidden; margin-bottom: 1vmin; }
        .draw-toolbar { display: flex; gap: 0.5vmin; padding: 0.5vmin; background: #f5f5f5; align-items: center; flex-wrap: wrap; }
        .draw-toolbar input[type="color"] { width: 3vmin; height: 3vmin; border: none; cursor: pointer; }
        .draw-toolbar input[type="range"] { width: 5vmin; }
        .draw-canvas { display: block; background: white; cursor: crosshair; width: 100%; height: 10vmin; }
        .modal .draw-tool-btn { padding: 6px 10px; font-size: 18pt !important; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
        .modal .draw-tool-btn svg { width: 28px; height: 28px; }

        /* ZOOM */
        .zoom-bar { position: absolute; bottom: calc(1.5vmin + env(safe-area-inset-bottom, 0px)); left: max(1.5vmin, env(safe-area-inset-left, 0px)); display: flex; align-items: center; gap: 0.5vmin; background: white; padding: 0.5vmin; border-radius: 0.8vmin; box-shadow: 0 0.3vmin 1vmin rgba(0,0,0,0.15); }
        .zoom-bar button { width: 3.5vmin; height: 3.5vmin; border: none; background: #f0f0f0; border-radius: 0.5vmin; cursor: pointer; font-size: 1.8vmin; }
        .zoom-bar button:hover { background: #0984e3; color: white; }
        .zoom-bar span { font-size: 1.5vmin; min-width: 5vmin; text-align: center; }

        /* MODALS */
        .modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: none; align-items: center; justify-content: center; z-index: 100; }
        .modal.active { display: flex; }
        .modal-box { background: white; border-radius: 2vmin; width: 90%; max-width: 45vmin; max-height: 80%; overflow: hidden; }
        .modal-header { padding: 1.5vmin; background: #f8f8f8; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; }
        .modal-header h3 { font-size: 2.2vmin; }
        .modal-close { background: none; border: none; font-size: 2.5vmin; cursor: pointer; color: #666; }
        .modal-body { padding: 1.5vmin; overflow-y: auto; max-height: 50vmin; }
        .modal-footer { padding: 1.5vmin; background: #f8f8f8; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 1vmin; }
        .modal .form-group { margin-bottom: 1.5vmin; }
        .modal .form-group label { font-size: 1.6vmin; margin-bottom: 0.5vmin; }
        .modal .form-group input, .modal .form-group select { padding: 1vmin; font-size: 1.8vmin; }
        .modal .form-row input { width: 8vmin; }
        .modal .btn { padding: 1vmin 2vmin; font-size: 1.8vmin; }

        /* ANNOTATION PICKER */
        .ann-picker { display: flex; gap: 0.5vmin; flex-wrap: wrap; margin-top: 0.5vmin; }
        .ann-picker-item { width: 4vmin; height: 4vmin; border: 2px solid #ddd; border-radius: 0.5vmin; cursor: pointer; display: flex; align-items: center; justify-content: center; background: white; }
        .ann-picker-item:hover { border-color: #0984e3; }
        .ann-picker-item.selected { border-color: #00b894; background: #e8f8f5; }
        .ann-picker-item img { width: 80%; height: 80%; object-fit: contain; }

        @media print {
            body * { visibility: hidden; }
            .board, .board * { visibility: visible; }
            .board { position: absolute; left: 0; top: 0; box-shadow: none !important; transform: none !important; }
            .cell .remove { display: none !important; }
        }
        .brand-logo { position: absolute; bottom: calc(2vmin + env(safe-area-inset-bottom, 0px)); left: max(2vmin, env(safe-area-inset-left, 0px)); width: 8vmin; height: 8vmin; object-fit: contain; filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6)) drop-shadow(0 0 8px rgba(100, 150, 255, 0.4)); }
        .brand-logo-right { position: absolute; bottom: calc(2vmin + env(safe-area-inset-bottom, 0px)); right: max(2vmin, env(safe-area-inset-right, 0px)); width: 8vmin; height: 8vmin; object-fit: contain; filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.6)) drop-shadow(0 0 8px rgba(100, 150, 255, 0.4)); }
        .help-btn { position: absolute; top: calc(3vmin + env(safe-area-inset-top, 0px)); left: max(3vmin, env(safe-area-inset-left, 0px)); background: rgba(255,255,255,0.2); border: none; color: white; width: 7vmin; height: 7vmin; border-radius: 50%; cursor: pointer; font-size: 4vmin; font-weight: 800; display: flex; align-items: center; justify-content: center; }
        .help-btn:hover { background: rgba(255,255,255,0.3); }

        #defLanguage { flex: 1; min-width: 0; padding: 0.8vmin; border: 1px solid #ddd; border-radius: 0.5vmin; font: inherit; background: white; color: inherit; }
        #defLanguage:hover { border-color: #0984e3; }
        .app-version { text-align: center; color: #888; font-size: 1.4vmin; margin: 2vmin 0 1vmin; }

/* Offline web site: the service worker's progress, under the version in Settings (offline.js) */
.offline-status { margin: 4px 0 0; font-size: 1.6vmin; color: #555; }
.offline-status .offline-action { margin-inline-start: 8px; padding: 4px 12px; border: none; border-radius: 8px;
    background: #0a66d6; color: #fff; font: inherit; cursor: pointer; }

/* Offline web site: symbol packs in Settings (packs.js) */
.symbol-packs { margin-top: 1.5vmin; }
.symbol-packs h4 { margin: 0 0 0.5vmin; font-size: 1.8vmin; }
.symbol-packs-note { margin: 0 0 1vmin; font-size: 1.4vmin; color: #666; }
.symbol-pack { display: flex; align-items: center; justify-content: space-between; gap: 1vmin; padding: 0.6vmin 0;
    border-top: 1px solid #eee; font-size: 1.6vmin; }
.symbol-pack .btn { min-width: 14vmin; padding: 0.8vmin 1.4vmin; font-size: 1.5vmin; }

/* ---------------------------------------------------------------------------------------------------------------
   PHONE EDITOR (phone.js). Carers make quick changes on a phone: pick a cell, give it a symbol, a label and spoken
   words. Full board design stays on tablets and computers, which are exactly as they were: everything that applies
   to them is only the "hidden" defaults just below.
   --------------------------------------------------------------------------------------------------------------- */
.phone-more { display: contents; }
.phone-more > * { flex-shrink: 0; }
.phone-more-btn, .sheet-bar, .phone-more-toggle { display: none; }

@media (max-width: 600px) {
    /* Toolbar: one row (home, board name, Undo, Redo, More); the other tools open in a panel under it */
    #editorScreen .screen-header { height: 56px; min-height: 56px; gap: 6px; overflow: visible; position: relative; z-index: 40;
        padding-left: max(8px, env(safe-area-inset-left, 0px)); padding-right: max(8px, env(safe-area-inset-right, 0px)); }
    #editorScreen .screen-header > * { min-width: 0; }
    #editorScreen .home-btn { width: 44px; height: 44px; min-width: 44px; min-height: 44px; font-size: 22px; flex-shrink: 0; }
    #editorScreen .screen-title { font-size: 17px; flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    #editorScreen #obzBoardSelector { display: none; font-size: 15px !important; padding: 8px !important; min-height: 44px; max-width: 32%; margin-left: 0 !important; }
    #editorScreen .screen-header .header-btn { min-height: 44px; font-size: 15px; padding: 0 12px; border-radius: 10px; gap: 6px; white-space: nowrap; flex-shrink: 0; }
    #editorScreen .screen-header .phone-icon { font-size: 0; width: 44px; padding: 0; justify-content: center; }
    #editorScreen .screen-header .phone-icon::before { content: attr(data-icon); font-size: 20px; }
    #editorScreen .phone-more-btn { display: flex; align-items: center; justify-content: center; }
    #editorScreen .phone-more-btn[aria-expanded="true"] { background: rgba(255,255,255,0.4); }

    #editorScreen .phone-more { display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 45;
        flex-wrap: wrap; gap: 8px; padding: 10px max(10px, env(safe-area-inset-right, 0px)) 12px max(10px, env(safe-area-inset-left, 0px));
        background: linear-gradient(135deg, #0773c9, #5b4bd1); box-shadow: 0 8px 18px rgba(0,0,0,0.3); border-radius: 0 0 14px 14px; }
    #editorScreen .phone-more.open { display: flex; }
    #editorScreen .phone-more .header-btn { flex: 1 1 calc(33% - 8px); justify-content: center; }
    #editorScreen .phone-more .header-btn input[type="number"] { width: 64px !important; min-height: 36px; padding: 4px !important; font-size: 16px !important; border-radius: 8px !important; }
    #editorScreen .phone-more .header-btn span { font-size: 15px !important; }

    /* Board: full width at the top (phone.js scales it to fit the width); it scrolls if it is taller than the room */
    #editorScreen .editor-body { position: relative; flex-direction: column; }
    #editorScreen .resize-handle, #editorScreen .zoom-bar { display: none; }
    #editorScreen .board-container { align-items: flex-start; justify-content: flex-start; padding: 4px; scrollbar-width: none;
        padding-left: max(4px, env(safe-area-inset-left, 0px)); padding-right: max(4px, env(safe-area-inset-right, 0px));
        padding-bottom: calc(4px + var(--sheet-h, 0px)); -webkit-overflow-scrolling: touch; }
    #editorScreen .board-container::-webkit-scrollbar { display: none; }
    #editorScreen .board { margin: 0 auto auto; flex-shrink: 0; transform-origin: center top; }
    #editorScreen .cell.selected { box-shadow: 0 0 0 2px rgba(9, 132, 227, 0.4); }

    /* The side panel becomes a bottom sheet, shown while a cell is selected */
    #editorSidebar { position: fixed; left: 0; right: 0; bottom: var(--kb, 0px); width: auto !important; min-width: 0; max-width: none;
        display: none; z-index: 60; border-left: none; border-radius: 16px 16px 0 0; box-shadow: 0 -6px 22px rgba(0,0,0,0.28);
        max-height: calc(var(--vvh, 100vh) * 0.6); overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
        padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
    #editorSidebar.sheet-open { display: flex; animation: sheetUp 0.18s ease-out; }
    #editorSidebar.kb-open { max-height: calc(var(--vvh, 100vh) - 72px - env(safe-area-inset-top, 0px)); }
    @keyframes sheetUp { from { transform: translateY(40%); opacity: 0.4; } to { transform: none; opacity: 1; } }
    #editorSidebar .sidebar-section { flex-shrink: 0; }
    #editorSidebar .sheet-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; z-index: 3;
        flex-shrink: 0; min-height: 52px; padding: 4px 8px 4px 16px; background: #fff; border-bottom: 1px solid #e4e4e4; border-radius: 16px 16px 0 0; }
    #editorSidebar .sheet-title { font-weight: 800; color: #333; }
    #editorSidebar .sheet-done { min-height: 44px; min-width: 44px; padding: 0 16px; border: none; border-radius: 22px; background: #0984e3; color: #fff;
        font-family: inherit; font-weight: 700; cursor: pointer; }

    /* Readable text and big targets inside the sheet (beats the older inline vmin sizes on purpose) */
    #editorSidebar, #editorSidebar * { font-size: 15px !important; }
    #editorSidebar input:not([type="checkbox"]):not([type="color"]):not([type="file"]), #editorSidebar select, #editorSidebar textarea {
        font-size: 16px !important; min-height: 44px; padding: 8px 10px !important; border-radius: 8px !important; }
    #editorSidebar input[type="color"] { height: 44px !important; min-width: 56px; padding: 2px !important; }
    #editorSidebar input[type="checkbox"] { width: 22px; height: 22px; }
    #editorSidebar button, #editorSidebar .btn { min-height: 44px; min-width: 44px; padding: 8px 14px !important; border-radius: 8px; }
    #editorSidebar .tab { font-size: 22px !important; padding: 6px !important; }
    #editorSidebar .sidebar-header { position: static; min-height: 48px; padding: 12px 16px; font-size: 16px !important; }
    #editorSidebar .sidebar-header .expand-icon { font-size: 15px !important; }
    #editorSidebar .sidebar-content { padding: 10px 14px 14px; }
    #editorSidebar .tabs { gap: 6px; margin-bottom: 10px; }
    #editorSidebar .input-row { gap: 6px; margin-bottom: 8px; }
    #editorSidebar .form-group { margin-bottom: 10px; }
    #editorSidebar .form-group label, #editorSidebar #communicatorFields label { margin-bottom: 4px; }
    #editorSidebar .form-row { gap: 8px; }
    #editorSidebar .cell-preview { display: none; }
    #editorSidebar #symbolSearchStatus, #editorSidebar #webSearchStatus, #editorSidebar #annotationSearchStatus { padding: 4px !important; }

    #editorSidebar .symbol-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); grid-auto-rows: 60px; gap: 6px; padding: 6px; max-height: 132px; border-radius: 8px; }
    #editorSidebar .symbol-grid.web-results { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); grid-auto-rows: 84px; min-height: 0 !important; }
    #editorSidebar #annotationGrid { max-height: 132px !important; }
    #editorSidebar .symbol-item { border-radius: 8px; padding: 3px; }
    #editorSidebar .symbol-grid.ss-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); grid-auto-rows: auto; max-height: 300px; }
    #editorSidebar .ss-item { border-radius: 8px; padding: 4px !important; gap: 2px; min-height: 0; }
    #editorSidebar .ss-name { font-size: 13px !important; }
    #editorSidebar .ss-status { font-size: 14px !important; padding: 6px 4px !important; }
    #editorSidebar .ss-credit { font-size: 12px !important; }
    #editorSidebar .ann-picker { gap: 8px; }
    #editorSidebar .ann-picker-item { width: 48px; height: 48px; border-radius: 8px; font-size: 22px !important; }

    /* Communicator: vocalise, audio, commands */
    #editorSidebar #communicatorFields > div { margin-bottom: 14px !important; }
    #editorSidebar #communicatorFields label[title] { min-height: 48px; padding: 6px !important; border-radius: 8px !important; }
    #editorSidebar #communicatorFields label[title] span { font-size: 22px !important; }
    #editorSidebar #recordIcon { width: 20px !important; height: 20px !important; }
    #editorSidebar #playIcon { border-left-width: 18px !important; border-top-width: 11px !important; border-bottom-width: 11px !important; }

    /* The less common cell settings fold away behind one button (phone.js moves them into #phoneCellMore) */
    #editorSidebar .phone-more-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; margin: 4px 0 8px;
        background: #f0f0f0; border: none; color: #333; font-family: inherit; font-weight: 700; cursor: pointer; }
    #editorSidebar .phone-more-toggle::after { content: '▼'; font-size: 12px; transition: transform 0.2s; }
    #editorSidebar .phone-more-toggle.collapsed::after { transform: rotate(-90deg); }
    #editorSidebar #phoneCellMore.collapsed { display: none; }
}

/* ===== CHILDREN (profiles.js) ===== */
/* The chooser takes some room, so the logo and spacing above the menu are a little tighter */
.home-logo { font-size: 12vmin; margin-bottom: 1vmin; }
.home-title { margin-bottom: 0.5vmin; }
.home-subtitle { margin-bottom: 2vmin; }
.child-chooser { position: relative; display: inline-block; margin-bottom: 3vmin; }
.child-chooser-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 18px; border: 2px solid rgba(255,255,255,0.55); border-radius: 999px;
    background: rgba(255,255,255,0.18); color: #fff; font-family: inherit; font-size: clamp(16px, 2.4vmin, 22px); font-weight: 700; cursor: pointer; max-width: min(86vw, 420px); }
.child-chooser-btn:hover, .child-chooser-btn[aria-expanded="true"] { background: rgba(255,255,255,0.3); }
.child-chooser-btn:focus-visible, .cc-item:focus-visible { outline: 3px solid #ffeaa7; outline-offset: 2px; }
.cc-emoji { font-size: 1.5em; line-height: 1; }
.cc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-caret { opacity: 0.85; }
.child-chooser-panel { position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 60; min-width: max(100%, 260px); max-width: 92vw; max-height: 60vh; overflow-y: auto;
    background: #fff; border-radius: 16px; box-shadow: 0 10px 34px rgba(0,0,0,0.35); padding: 8px; text-align: left; }
.child-chooser-panel[hidden] { display: none; }
.cc-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 14px; border: none; border-radius: 10px; background: none; color: #333;
    font-family: inherit; font-size: clamp(16px, 2.2vmin, 20px); font-weight: 600; text-align: left; cursor: pointer; }
.cc-item:hover { background: #f1f0ff; }
.cc-item.on { background: #e8f0fe; }
.cc-item-emoji { font-size: 1.5em; line-height: 1; width: 1.5em; text-align: center; }
.cc-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-tick { color: #0984e3; font-weight: 800; }
.cc-action { color: #4a3fbf; }
.cc-sep { height: 1px; background: #e4e4e4; margin: 6px 4px; }

/* Open Board / Manage Boards grouped by child */
.board-card, .manage-card { position: relative; }
.child-badge { position: absolute; top: 6px; right: 6px; z-index: 1; min-width: 30px; height: 30px; padding: 0 4px; display: flex; align-items: center; justify-content: center;
    border-radius: 15px; background: #fff; box-shadow: 0 1px 5px rgba(0,0,0,0.28); font-size: 18px; line-height: 1; }
.board-group-heading { grid-column: 1 / -1; font-size: clamp(16px, 2.4vmin, 22px); color: #333; margin: 6px 2px 0; padding-bottom: 6px; border-bottom: 2px solid #ddd; }
.board-group-heading:first-child { margin-top: 0; }
.board-group-note { grid-column: 1 / -1; font-size: clamp(14px, 1.9vmin, 18px); color: #666; margin: 0 2px 6px; }
.manage-child { display: flex; align-items: center; gap: 10px; margin: 0 0 1.2vmin; font-size: clamp(14px, 1.8vmin, 18px); font-weight: 600; color: #444; }
.manage-child-select { flex: 1; min-width: 0; min-height: 40px; padding: 6px 10px; border: 1px solid #ccc; border-radius: 8px; background: #fff; font-family: inherit; font-size: inherit; color: #333; }

/* The Children screen */
.profiles-screen .screen-header { background: linear-gradient(135deg, #55efc4, #00b894); }
.profiles-body { flex: 1; overflow-y: auto; background: #f5f5f5; padding: clamp(12px, 2.4vmin, 28px); }
.profiles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: clamp(12px, 2vmin, 24px); align-items: start; }
.profiles-body .empty-state { height: 100%; gap: 14px; }
.profiles-body .empty-state p { font-size: clamp(16px, 2.2vmin, 22px); text-align: center; padding: 0 16px; }
.child-card { background: #fff; border-radius: 18px; padding: clamp(14px, 2vmin, 22px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.child-card-head { display: flex; align-items: center; gap: 14px; }
.child-card-emoji { font-size: clamp(40px, 6vmin, 56px); line-height: 1; }
.child-card-title { min-width: 0; }
.child-card-title h2 { font-size: clamp(20px, 3vmin, 28px); color: #222; overflow-wrap: anywhere; }
.child-card-title p { font-size: clamp(14px, 1.9vmin, 18px); color: #666; }
.child-card-sub { font-size: clamp(14px, 1.8vmin, 17px); color: #888; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.child-devices { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.child-device { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; background: #f7f7fb; border-radius: 12px; }
.child-device-icon { font-size: 24px; }
.child-device-text { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; }
.child-device-text strong { font-size: clamp(15px, 2vmin, 19px); color: #333; overflow-wrap: anywhere; }
.child-device-text small { font-size: clamp(13px, 1.7vmin, 16px); color: #666; }
.child-no-devices { font-size: clamp(14px, 1.8vmin, 17px); color: #888; }
.sbp-link { background: none; border: none; min-height: 40px; padding: 0 6px; font-family: inherit; font-size: clamp(14px, 1.8vmin, 17px); font-weight: 700; color: #0984e3; cursor: pointer; text-decoration: underline; }
.sbp-link.danger { color: #d63031; }
.child-card-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 4px; }

/* Buttons, notes and dialogs for children and backup */
.sbp-btn { min-height: 44px; font-size: clamp(15px, 2vmin, 19px) !important; padding: 8px 14px !important; }
.sbp-btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.sbp-note { font-size: clamp(13px, 1.7vmin, 16px); color: #777; margin: 0 0 10px; line-height: 1.35; }
.sbp-modal { padding: 12px; }
.sbp-box { width: min(94vw, 460px); max-width: none !important; max-height: 92vh !important; display: flex; flex-direction: column; }
.sbp-box .modal-header { padding: 8px 8px 8px 16px; }
.sbp-box .modal-header h3 { font-size: clamp(17px, 2.4vmin, 22px); }
.sbp-box .modal-close { font-size: 28px; min-width: 44px; min-height: 44px; }
.sbp-box .modal-body { max-height: none !important; overflow-y: auto; padding: 16px; }
.sbp-box .modal-footer { flex-wrap: wrap; padding: 12px 16px; }
.sbp-message { font-size: clamp(15px, 2vmin, 18px); color: #333; line-height: 1.4; margin-bottom: 10px; }
.sbp-field { margin-bottom: 14px; flex: 1; min-width: 0; }
.sbp-field-row { display: flex; gap: 12px; }
.sbp-box .sbp-field label { display: block; font-size: 15px; font-weight: 700; color: #555; margin-bottom: 6px; }
.sbp-box .sbp-field input, .sbp-box .sbp-field select { width: 100%; min-height: 44px; padding: 8px 12px; border: 2px solid #ddd; border-radius: 10px; font-family: inherit; font-size: 16px; background: #fff; color: #222; }
.sbp-box .sbp-field input:focus, .sbp-box .sbp-field select:focus { outline: none; border-color: #0984e3; }
.sbp-emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.sbp-emoji { min-height: 48px; font-size: 28px; line-height: 1; border: 3px solid transparent; border-radius: 12px; background: #f2f2f7; cursor: pointer; }
.sbp-emoji:hover { background: #e6e6f2; }
.sbp-emoji.selected { border-color: #0984e3; background: #e8f0fe; }
.sbp-contents { list-style: none; margin: 0 0 12px; padding: 10px 14px; background: #f7f7fb; border-radius: 10px; font-size: 16px; font-weight: 700; color: #333; display: flex; flex-direction: column; gap: 4px; }
.sbp-check { display: flex; align-items: flex-start; gap: 10px; font-size: 16px; color: #333; margin-bottom: 10px; cursor: pointer; }
.sbp-check input { width: 24px; height: 24px; flex-shrink: 0; margin-top: 1px; }

@media (max-width: 600px) {
    .profiles-screen .screen-header { height: 56px; min-height: 56px; gap: 8px; }
    .profiles-screen .screen-title { font-size: 20px; }
    .profiles-screen .header-btn { min-height: 44px; font-size: 15px; padding: 0 12px; border-radius: 10px; white-space: nowrap; }
    .profiles-screen .home-btn { width: 44px; height: 44px; font-size: 20px; }
    .child-chooser { max-width: 100%; }
    .child-card-actions { grid-template-columns: 1fr 1fr; }
    .sbp-field-row { flex-direction: column; gap: 0; }
    .sbp-emoji-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .board-group-heading { font-size: 18px; }
    .manage-child { font-size: 16px; }
    .manage-child-select { min-height: 44px; font-size: 16px; }
}

/* ---- Deploy (deploy-ui.js): devices on a child's card, Connect a device, Deploy… ---- */
#carerNameSettingsSection .sbp-field { margin-bottom: 0; max-width: 420px; }
#carerNameSettingsSection .sbp-field label { display: block; font-size: 1.6vmin; font-weight: 700; color: #555; margin-bottom: 6px; }
#carerNameSettingsSection .sbp-field input { width: 100%; min-height: 44px; padding: 8px 12px; border: 2px solid #ddd; border-radius: 10px; font-family: inherit; font-size: 16px; background: #fff; color: #222; }
.dep-device { align-items: flex-start; }
.dep-device .child-device-text { flex: 1 1 200px; gap: 2px; }
.dep-status { font-weight: 700; }
.dep-status[data-state="ok"] { color: #1a7f45; }
.dep-status[data-state="error"], .dep-status[data-state="lost"] { color: #c0392b; }
.dep-status[data-state="waiting"] { color: #a86400; }
.dep-offline { color: #a86400; }
.dep-caps { color: #666; }
.dep-actions { flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dep-actions .dep-btn { flex: 0 1 auto; }
.dep-actions .sbp-btn { min-height: 44px; }
.dep-connect-btn { align-self: flex-start; }
.dep-box { width: min(94vw, 640px) !important; }
.dep-box [hidden] { display: none !important; }
.dep-connect { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; align-items: center; margin: 4px 0 12px; }
.dep-qr-wrap { flex: 0 0 auto; }
.dep-qr { width: 264px; height: 264px; max-width: 100%; padding: 12px; background: #fff; border: 2px solid #e2e2ea; border-radius: 14px; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.dep-qr canvas, .dep-qr img { width: 240px !important; height: 240px !important; max-width: 100%; display: block; }
.dep-qr img[style*="display: none"] { display: none !important; }
.dep-code-wrap { flex: 1 1 200px; text-align: center; min-width: 0; }
.dep-code-label { font-size: 15px; color: #555; font-weight: 700; margin-bottom: 4px; }
.dep-code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: clamp(30px, 8vw, 44px); font-weight: 800; letter-spacing: 0.08em; color: #222; line-height: 1.2; user-select: all; }
.dep-code-valid { font-size: 15px; color: #777; margin-top: 2px; }
.dep-state { font-size: 16px; font-weight: 700; color: #555; text-align: center; min-height: 24px; }
.dep-state[data-state="connected"] { color: #1a7f45; font-size: 22px; padding: 18px 0; }
.dep-state[data-state="error"] { color: #c0392b; }
.dep-spin { width: 36px; height: 36px; border: 4px solid #ddd; border-top-color: #0984e3; border-radius: 50%; animation: depspin 0.9s linear infinite; }
@keyframes depspin { to { transform: rotate(360deg); } }
.dep-what { display: flex; gap: 0; margin-bottom: 14px; border: 2px solid #0984e3; border-radius: 12px; overflow: hidden; }
.dep-seg { flex: 1; position: relative; cursor: pointer; }
.dep-seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.dep-seg span { display: block; text-align: center; padding: 10px 6px; min-height: 44px; box-sizing: border-box; font-size: 16px; font-weight: 700; color: #0984e3; background: #fff; }
.dep-seg + .dep-seg span { border-left: 2px solid #0984e3; }
.dep-seg input:checked + span { background: #0984e3; color: #fff; }
.dep-seg input:focus-visible + span { outline: 3px solid #f39c12; outline-offset: -3px; }
.dep-seg input:disabled + span { opacity: 0.4; cursor: default; }
.dep-warn { background: #fff4e0; border: 2px solid #f0a020; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; }
.dep-warn p { font-size: 16px; font-weight: 700; color: #5c3a00; margin-bottom: 10px; line-height: 1.35; }
.dep-group { border: 2px solid #e8e8f0; border-radius: 12px; padding: 12px 14px 4px; margin: 0 0 14px; min-width: 0; }
.dep-group legend { font-size: 15px; font-weight: 800; color: #333; padding: 0 6px; }
.dep-field-bool { margin-bottom: 8px; }
.dep-msg { font-size: 16px; font-weight: 700; color: #555; min-height: 22px; line-height: 1.35; }
.dep-msg[data-state="error"] { color: #c0392b; }
@media (min-width: 700px) {
    .dep-deploy-box .dep-group { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; }
    .dep-deploy-box .dep-group legend { grid-column: 1 / -1; float: none; }
    .dep-deploy-box .dep-group .dep-field-bool { grid-column: 1 / -1; }
    .dep-deploy-box { width: min(94vw, 760px) !important; }
}
@media (max-width: 600px) {
    .dep-actions .dep-btn { flex: 1 1 100%; }
    .dep-actions .sbp-link { flex: 0 0 auto; text-align: left; margin-left: -6px; }
    .dep-group { padding: 10px 10px 2px; }
    .dep-qr { width: 100%; }
    .dep-qr canvas, .dep-qr img { width: min(240px, 100%) !important; height: auto !important; aspect-ratio: 1; }
}
.dep-card-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dep-card-actions .dep-connect-btn { flex: 0 1 auto; align-self: auto; }
.child-device .dep-print-btn { flex: 0 0 auto; }
@media (max-width: 600px) {
    .dep-card-actions .dep-connect-btn { flex: 1 1 100%; }
    .child-device .dep-print-btn { flex: 1 1 100%; }
}

/* ---- How a child uses their boards (insight.js) ---- */
.insight-screen .screen-header { background: linear-gradient(135deg, #55efc4, #00b894); }
.insight-screen .screen-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ins-body { flex: 1; overflow-y: auto; overflow-x: hidden; background: #f5f5f5; padding: clamp(12px, 2.4vmin, 28px); }
.ins-wrap { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ins-from { font-size: clamp(14px, 1.8vmin, 17px); color: #666; }
.ins-period { margin-bottom: 0; align-self: flex-start; width: min(100%, 480px); background: #fff; }
.ins-period .dep-seg span { white-space: nowrap; }
.ins-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: clamp(12px, 2vmin, 20px); align-items: start; min-width: 0; }
.ins-card { background: #fff; border-radius: 18px; padding: clamp(14px, 2vmin, 22px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); min-width: 0; }
.ins-wide { grid-column: 1 / -1; }
.ins-card h2 { font-size: clamp(18px, 2.4vmin, 22px); color: #222; margin-bottom: 4px; }
.ins-sub { font-size: clamp(14px, 1.8vmin, 17px); color: #888; text-transform: uppercase; letter-spacing: 0.04em; margin: 14px 0 6px; }
.ins-small { font-size: clamp(13px, 1.7vmin, 16px); color: #666; line-height: 1.35; margin-bottom: 8px; }
.ins-big { font-size: clamp(17px, 2.2vmin, 21px); font-weight: 700; color: #333; line-height: 1.3; margin: 4px 0 8px; }
.ins-note { font-size: clamp(13px, 1.7vmin, 16px); color: #666; line-height: 1.4; padding: 0 2px; }
.ins-save { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-bottom: 8px; }
.ins-plot { height: 150px; display: flex; align-items: flex-end; gap: 8px; border-bottom: 2px solid #e2e2ea; margin-top: 8px; }
.ins-plot.ins-d7 { height: 176px; border-bottom: 0; }
.ins-plot.ins-d30 { gap: 3px; }
.ins-plot.ins-d90 { gap: 1px; }
.ins-day { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; cursor: default; }
.ins-bar { display: block; width: 100%; background: #00b894; border-radius: 4px 4px 0 0; }
.ins-d7 .ins-bar { max-width: 56px; }
.ins-d90 .ins-bar { border-radius: 2px 2px 0 0; }
.ins-day:hover .ins-bar { background: #00a383; }
.ins-day.is-zero .ins-bar { background: transparent; }
.ins-num { font-size: 14px; font-weight: 700; color: #333; height: 20px; line-height: 20px; }
.ins-lbl { font-size: clamp(12px, 1.6vmin, 15px); color: #666; height: 26px; line-height: 26px; border-top: 2px solid #e2e2ea; width: 100%; text-align: center; margin-top: 0; }
.ins-axis { display: flex; justify-content: space-between; font-size: 13px; color: #666; margin-top: 4px; }
.ins-rows { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.ins-row { display: grid; grid-template-columns: minmax(70px, 38%) 1fr auto; align-items: center; gap: 10px; min-height: 30px; }
.ins-name { font-size: clamp(15px, 2vmin, 18px); font-weight: 700; color: #333; overflow-wrap: anywhere; }
.ins-meter { display: block; height: 12px; background: #eef0f4; border-radius: 6px; overflow: hidden; }
.ins-meter span { display: block; height: 100%; background: #0984e3; border-radius: 6px; }
.ins-n { font-size: clamp(14px, 1.8vmin, 17px); font-weight: 700; color: #555; min-width: 2ch; text-align: right; }
.ins-msgs { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.ins-msgs li { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; background: #f7f7fb; border-radius: 10px; }
.ins-msg { font-size: clamp(15px, 2vmin, 18px); font-weight: 700; color: #333; overflow-wrap: anywhere; }
.ins-msgs small { font-size: 13px; color: #777; }
.ins-modelling { background: #f3f0ff; box-shadow: none; border: 2px dashed #b9aef0; }
.ins-modelling .ins-big { color: #4b3a9c; }
.ins-empty { text-align: center; padding: 28px 16px; }
.ins-empty-icon { font-size: 44px; line-height: 1; margin-bottom: 8px; }
.ins-empty p { font-size: clamp(15px, 2vmin, 18px); color: #555; line-height: 1.4; }
.ins-status { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 28px 16px; }
.ins-status p { font-size: clamp(15px, 2vmin, 18px); font-weight: 700; color: #555; line-height: 1.4; }
.ins-status.is-error p { color: #c0392b; }
@media (max-width: 600px) {
    .insight-screen .screen-header { height: 56px; min-height: 56px; gap: 8px; }
    .insight-screen .screen-title { font-size: 18px; }
    .insight-screen .header-btn { min-height: 44px; font-size: 15px; padding: 0 12px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
    .ins-period { align-self: stretch; }
    .ins-period .dep-seg span { padding: 10px 2px; font-size: 15px; }
    .ins-d7 { gap: 4px; }
    .ins-save .sbp-btn { width: 100%; }
}

/* ---- Board templates and the wizard (wizard.js) ---- */
.wiz-start { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; min-height: 44px; padding: 10px 14px !important; margin-bottom: 8px; border: 2px dashed #0984e3 !important; background: #f2f8ff !important; color: #0b4f86 !important; font-weight: 700; }
.wiz-start small { font-size: max(11px, 0.85em); font-weight: 400; color: #4d6b85; }
.wiz-or { font-size: 1.5vmin; color: #777; margin: 0 0 8px; }
.wiz-box { width: min(94vw, 640px) !important; }
.wiz-box .modal-body { flex: 1 1 auto; min-height: 0; }
.wiz-box .modal-header, .wiz-box .modal-footer { flex: none; }
.wiz-steps { font-size: 14px; font-weight: 700; color: #777; margin-bottom: 6px; }
.wiz-title { font-size: clamp(18px, 2.4vmin, 22px); color: #222; margin: 0 0 6px; }
.wiz-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); gap: 10px; }
.wiz-card { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; min-height: 88px; padding: 10px 12px; border: 3px solid #e2e2ea; border-radius: 14px; background: #fff; color: #222; font-family: inherit; cursor: pointer; min-width: 0; }
.wiz-card:hover { background: #f4f7fb; }
.wiz-card.selected { border-color: #0984e3; background: #e8f0fe; }
.wiz-card:focus-visible { outline: 3px solid #f39c12; outline-offset: 2px; }
.wiz-card-name { font-size: 16px; font-weight: 800; line-height: 1.2; overflow-wrap: anywhere; }
.wiz-card-size { font-size: 13px; color: #666; }
.wiz-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.wiz-chip { font-size: 12px; padding: 2px 7px; border-radius: 10px; background: #eef0f4; color: #444; }
.wiz-more { font-size: 12px; color: #888; }
.wiz-hint { font-size: 12px; color: #666; }
.wiz-count { font-size: 16px; font-weight: 700; color: #333; margin: 4px 0 8px; }
.wiz-warn { font-size: 15px; font-weight: 700; color: #7a4a00; background: #fff4e0; border: 2px solid #f0a020; border-radius: 10px; padding: 8px 12px; margin: 0 0 10px; line-height: 1.35; }
.wiz-error { color: #c0392b; font-weight: 700; }
.wiz-advice { background: #fff4e0; border: 2px solid #f0a020; border-radius: 12px; padding: 10px 12px; margin: 0 0 10px; }
.wiz-advice p { font-size: 15px; font-weight: 700; color: #5c3a00; line-height: 1.35; margin: 0 0 8px; }
.wiz-advice p:last-child { margin-bottom: 0; }
.wiz-minigrid { direction: ltr; display: grid; grid-template-columns: repeat(var(--c), minmax(0, 1fr)); gap: 3px; max-width: 420px; margin-top: 6px; }
.wiz-tile { display: flex; align-items: center; justify-content: center; text-align: center; aspect-ratio: 1.15; min-width: 0; overflow: hidden; border: 1px solid #c9cdd6; border-radius: 5px; background: #fff; color: #333; line-height: 1.1; padding: 1px; overflow-wrap: anywhere; }
.wiz-tile.empty { border-style: dashed; background: #f6f7f9; }
.wiz-size-row .sbp-field { max-width: 160px; }
.wiz-progress { margin: 6px 0 10px; }
.wiz-bar { height: 12px; border-radius: 6px; background: #eef0f4; overflow: hidden; }
.wiz-bar span { display: block; height: 100%; width: 0; background: #0984e3; border-radius: 6px; transition: width 0.1s; }
.wiz-progress p { font-size: 15px; font-weight: 700; color: #555; margin: 6px 0 0; }
.wiz-toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 300; max-width: min(92vw, 520px); background: #333; color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 16px; line-height: 1.35; text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
@media (max-width: 600px) {
    #createModal .modal-box { max-width: min(92vw, 420px); }   /* 45vmin is 175px on a phone: too narrow for the template button */
    .wiz-start { font-size: 13px !important; }
    .wiz-or { font-size: 12px; }
    .wiz-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .wiz-card { padding: 8px 10px; min-height: 96px; }
    .wiz-size-row { flex-direction: row; gap: 12px; }
    .wiz-box .modal-footer { flex-wrap: nowrap; }
    .wiz-box .modal-footer .btn { flex: 1 1 0; }
}

/* Keyboard access and persistent saving failures. */
button.menu-card { font: inherit; color: inherit; text-align: center; }
.menu-card:focus-visible, .board-card[role="button"]:focus-visible,
.board-card-preview[role="button"]:focus-visible, .board-set-board-item:focus-visible,
#board [data-cell]:focus-visible { outline: 4px solid #1264c7; outline-offset: 3px; }
#sbSaveStatus { position: fixed; bottom: 12px; left: 12px; right: 12px; z-index: 100002; padding: 12px 16px; border-radius: 8px; background: #fff3cd; color: #482e00; font: 16px/1.4 system-ui, sans-serif; box-shadow: 0 2px 12px #0003; }
#sbSaveStatus.failed { border: 2px solid #a33; background: #fff0f0; color: #700; }
#sbSaveStatus[hidden] { display: none; }

/* Topic suggestions stay in a teacher-owned draft until approval and a committed save. */
.wiz-topic-card { border-style: dashed; }
.topic-modal .modal-footer { flex-wrap: wrap; }
.topic-check { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; font-size: 16px; line-height: 1.45; }
.topic-check input { flex: 0 0 22px; width: 22px; height: 22px; margin-top: 2px; }
.topic-review { direction: ltr; display: grid; grid-template-columns: repeat(var(--topic-cols), minmax(0,1fr)); gap: 10px; margin: 16px 0; }
.topic-cell { min-width: 0; display: flex; flex-direction: column; gap: 7px; padding: 10px; border: 1px solid #aeb5bf; border-radius: 10px; color: #222; }
.topic-cell label { font-size: 13px; font-weight: 700; }
.topic-cell input, .topic-cell select { width: 100%; min-width: 0; padding: 9px 6px; font: inherit; border: 1px solid #9299a4; border-radius: 7px; background: white; color: #222; }
.topic-picture { height: 90px; display: flex; align-items: center; justify-content: center; text-align: center; border: 1px dashed #8d939c; background: #fff9; border-radius: 7px; font-size: 13px; }
.topic-picture img { max-height: 100%; max-width: 100%; object-fit: contain; }
.topic-cell .btn { min-height: 44px; white-space: normal; }
.topic-part-label { margin-top: 4px; }
@media (max-width: 600px) { .topic-review { grid-template-columns: repeat(2,minmax(0,1fr)); } .topic-modal .modal-footer .btn { flex: 1 1 160px; } }
.topic-board-preview { direction: ltr; display: grid; grid-template-columns: repeat(var(--preview-cols),minmax(0,1fr)); gap: 3px; width: 100%; margin: 10px 0 18px; }
.topic-preview-cell { aspect-ratio: 1.15; min-width: 0; overflow: hidden; border: 1px solid #aaa; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px; font-size: 11px; text-align: center; overflow-wrap: anywhere; }
.topic-preview-cell img { max-width: 100%; height: 60%; object-fit: contain; }
.topic-board-preview { max-width: 240px; max-height: 220px; overflow: auto; margin-left: auto; margin-right: auto; }
.wiz-topic-card { display: flex; flex-direction: column; gap: 5px; width: 100%; margin: 10px 0 14px; min-height: 76px; }

#sbRecoveredLabels, #sbLegacyRecovery { margin: .6rem 1rem; padding: .6rem; background: #fff6d6; color: #242221; font-size: 1rem; }
#sbRecoveredLabels summary, #sbLegacyRecovery summary { cursor: pointer; font-weight: bold; }
#sbRecoveredLabels > div { display: flex; align-items: end; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
#sbRecoveredLabels label { flex: 1 1 14rem; }
#sbRecoveredLabels textarea { display: block; width: 100%; margin-top: .2rem; font: inherit; }
#sbRecoveredLabels button, #sbLegacyRecovery button { padding: .5rem; font: inherit; }
