:root {
    --bg: #008080;
    --mobile-toolbar-height: 96px;
    --face: #c0c0c0;
    --face-2: #d4d0c8;
    --face-3: #efefef;
    --shadow: #808080;
    --dark: #404040;
    --light: #ffffff;
    --blue: #000080;
    --blue-2: #0a246a;
    --red: #8a0000;
    --paper: #f7f3e8;
    --text: #111;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    min-height: 100%;
    font-family: Tahoma, Verdana, Arial, sans-serif;
    font-size: 12px;
    color: var(--text);
    background: var(--bg);
}
body { overflow: hidden; overscroll-behavior: none; }
body.workspace-touch-lock { overflow: hidden; overscroll-behavior: none; }

html, body, .app-shell, .sidebar, .workspace, .window-titlebar, .section-toggle, .btn, .status-strip, .layer-list, .source-list-rich, .workspace-stage, .stage-inner, #previewCanvas {
    -webkit-user-select: none;
    user-select: none;
}
input, select, textarea {
    -webkit-user-select: none;
    user-select: none;
}
#previewCanvas.can-pan {
    cursor: grab;
}
#previewCanvas.is-panning {
    cursor: grabbing !important;
}
button, input, select, textarea {
    font: inherit;
}
strong { font-weight: 700; }

.app-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
}

.win-panel {
    background: var(--face);
    border-top: 2px solid var(--light);
    border-left: 2px solid var(--light);
    border-right: 2px solid var(--dark);
    border-bottom: 2px solid var(--dark);
}

.inset-panel {
    box-shadow: inset 1px 1px 0 var(--shadow), inset -1px -1px 0 var(--light);
}

.window-titlebar {
    min-height: 28px;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #fff;
    background: linear-gradient(90deg, var(--blue) 0%, #1f63d5 100%);
    border-bottom: 1px solid #5c5c5c;
}

.title-left,
.toolbar-group,
.title-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.title-dot {
    width: 11px;
    height: 11px;
    display: inline-block;
    background: #efe79a;
    border-top: 1px solid #fff7c9;
    border-left: 1px solid #fff7c9;
    border-right: 1px solid #8d8340;
    border-bottom: 1px solid #8d8340;
}
.title-dot.small {
    width: 9px;
    height: 9px;
}
.title-control-btn,
.title-close {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #000;
    background: var(--face);
    border-top: 1px solid var(--light);
    border-left: 1px solid var(--light);
    border-right: 1px solid var(--dark);
    border-bottom: 1px solid var(--dark);
}
.title-close {
    border-radius: 0;
    padding: 0;
}

.title-control-btn {
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    user-select: none;
    cursor: pointer;
    border-radius: 0;
    padding: 0;
}
.title-control-btn:first-child {
    align-items: flex-end;
    padding-bottom: 2px;
}
.title-control-btn.is-active {
    box-shadow: inset 1px 1px 0 var(--dark), inset -1px -1px 0 var(--light);
    background: #d8d8d8;
}

.sidebar,
.workspace {
    min-height: 0;
}

.sidebar {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.sidebar-scroll {
    min-height: 0;
    overflow: auto;
    padding: 8px;
}

.win-group {
    margin-bottom: 10px;
    padding: 8px;
    background: var(--face);
    border-top: 1px solid var(--light);
    border-left: 1px solid var(--light);
    border-right: 1px solid var(--shadow);
    border-bottom: 1px solid var(--shadow);
}

.section-toggle {
    width: calc(100% + 4px);
    margin: -2px -2px 8px;
    padding: 3px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--face);
    color: #000;
    border-top: 1px solid var(--light);
    border-left: 1px solid var(--light);
    border-right: 1px solid var(--shadow);
    border-bottom: 1px solid var(--shadow);
    font-weight: 700;
}
.section-toggle > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.section-toggle b {
    width: 16px;
    text-align: center;
    font-size: 12px;
    line-height: 1;
}
.section-body.collapsed,
.hidden {
    display: none !important;
}

.icon-inline {
    display: inline-flex;
    width: 12px;
    justify-content: center;
    color: #000;
}

.field-row {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
}
.field-row.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack,
.toolbar-line,
.stack-mobile {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toolbar-line.stack-mobile {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
label span {
    font-weight: 700;
}

.range-control span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.range-value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 1px 6px 0;
    font-size: 11px;
    line-height: 1.2;
    color: #000;
    background: var(--face-3);
    border-top: 1px solid var(--shadow);
    border-left: 1px solid var(--shadow);
    border-right: 1px solid var(--light);
    border-bottom: 1px solid var(--light);
}

.layer-detail-row {
    align-items: end;
}

.layer-detail-row input[readonly] {
    background: #efefef;
}

.layer-detail-note {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 6px 8px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #4b4b4b;
    background: var(--face-3);
    border-top: 2px solid var(--shadow);
    border-left: 2px solid var(--shadow);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    min-height: 24px;
    padding: 2px 5px;
    color: #000;
    background: #fff;
    border-top: 2px solid var(--shadow);
    border-left: 2px solid var(--shadow);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
}

input[type="range"] {
    width: 100%;
    accent-color: var(--blue);
}

.file-drop,
.doc-stats,
.empty-state,
.status-strip,
.help-body {
    padding: 8px;
    background: var(--face-3);
    border-top: 2px solid var(--shadow);
    border-left: 2px solid var(--shadow);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
}

.file-drop {
    position: relative;
    display: block;
}
.file-drop input {
    position: absolute;
    inset: 0;
    opacity: 0;
}
.file-drop small,
.hint {
    display: block;
    color: #333;
    margin-top: 4px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.quick-create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 8px;
}


.quick-create-grid-triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-create-grid-shapes {
    margin-top: 4px;
}

.quick-create-grid-shapes-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.quick-create-btn {
    min-height: 112px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    color: #000;
    background: var(--face);
    border: 0;
    border-top: 2px solid var(--light);
    border-left: 2px solid var(--light);
    border-right: 2px solid var(--dark);
    border-bottom: 2px solid var(--dark);
}

.quick-create-btn:hover,
.icon-tool-btn:hover,
.text-tool-btn:hover {
    background: #d7d3cb;
}

.quick-create-btn:hover {
    color: var(--blue);
}

.quick-create-btn.quick-create-btn-text:hover,
.text-tool-btn:hover {
    color: #8a0000;
}

.quick-create-btn.quick-create-btn-shape:hover {
    color: #0d4f8b;
}

.quick-create-btn.quick-create-btn-shape {
    min-height: 72px;
    padding: 7px 4px 6px;
    gap: 4px;
}

.quick-create-btn:active {
    border-top: 2px solid var(--dark);
    border-left: 2px solid var(--dark);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
    padding: 11px 7px 9px 9px;
}

.quick-create-symbol {
    font-size: 33px;
    line-height: 1;
}

.quick-create-symbol-text {
    font-size: 38px;
    font-weight: 700;
    color: var(--blue);
}

.quick-create-btn.quick-create-btn-text:hover .quick-create-symbol-text {
    color: #8a0000;
}

.quick-create-symbol.quick-create-symbol-shape {
    font-size: 26px;
}

.quick-create-btn.quick-create-btn-shape .quick-create-label {
    font-size: 11px;
    line-height: 1.05;
}

.quick-create-label {
    font-weight: 700;
}

.icon-tool-btn,
.text-tool-btn {
    min-width: 34px;
}

.btn {
    min-height: 24px;
    padding: 3px 9px;
    color: #000;
    background: var(--face);
    border: 0;
    border-top: 2px solid var(--light);
    border-left: 2px solid var(--light);
    border-right: 2px solid var(--dark);
    border-bottom: 2px solid var(--dark);
}
.btn:active,
.btn.active {
    border-top: 2px solid var(--dark);
    border-left: 2px solid var(--dark);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
    padding: 4px 8px 2px 10px;
}
.btn.primary {
    font-weight: 700;
    color: var(--blue);
}
.btn:hover:not(:disabled) {
    background: #d7d3cb;
}
.btn.primary:hover:not(:disabled) {
    color: #aa0000;
}
.btn:focus-visible {
    outline: 1px dotted #000;
    outline-offset: -4px;
}
.btn.danger {
    color: var(--red);
}
.btn:disabled {
    color: #666;
}

.workspace {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 10px;
}
.workspace-toolbar,
.workspace-stage {
    overflow: hidden;
}
.workspace-toolbar {
    padding: 0;
}
.status-strip {
    margin: 8px;
    min-height: 28px;
    display: flex;
    align-items: center;
    font-size: 13px;
}
.workspace-stage {
    padding: 8px;
    touch-action: none;
}
.stage-inner {
    position: relative;
    touch-action: none;
    height: 100%;
    min-height: 0;
    display: grid;
    justify-items: center;
    align-items: start;
    overflow: visible;
    border-top: 2px solid var(--shadow);
    border-left: 2px solid var(--shadow);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
}

.stage-inner,
.modal-canvas-wrap {
    --checker-base: #9b9b9b;
    --checker-light: rgba(255,255,255,0.08);
    --checker-dark: rgba(0,0,0,0.08);
    --checker-size: 16px;
    --checker-offset: 8px;
    background:
        linear-gradient(45deg, var(--checker-light) 25%, transparent 25%, transparent 75%, var(--checker-light) 75%),
        linear-gradient(45deg, var(--checker-dark) 25%, transparent 25%, transparent 75%, var(--checker-dark) 75%),
        var(--checker-base);
    background-size: var(--checker-size) var(--checker-size);
    background-position: 0 0, var(--checker-offset) var(--checker-offset);
}
#previewCanvas {
    position: relative;
    z-index: 1;
    display: block;
    max-width: none;
    max-height: none;
    flex: none;
    background: var(--paper);
    border: 1px solid #666;
    box-shadow: 5px 5px 0 rgba(0,0,0,0.28);
}
.selection-overlay-canvas {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 3;
    pointer-events: none;
    display: block;
    transform-origin: top left;
}

.layer-list,
.source-list-rich {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.layer-list {
    max-height: 360px;
    overflow: auto;
}
.source-list { display: none; }
.source-card,
.layer-item {
    width: 100%;
    text-align: center;
    position: relative;
    display: grid;
    grid-template-columns: 46px minmax(0,1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 6px;
    color: #000;
    background: var(--face);
    border: 0;
    border-top: 2px solid var(--light);
    border-left: 2px solid var(--light);
    border-right: 2px solid var(--shadow);
    border-bottom: 2px solid var(--shadow);
}
.layer-item.active,
.source-card.active {
    background: var(--blue-2);
    color: #fff;
}
.layer-thumb,
.source-thumb {
    width: 42px;
    height: 42px;
    object-fit: contain;
    background: #fff;
    border-top: 2px solid var(--shadow);
    border-left: 2px solid var(--shadow);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
}
.layer-meta,
.source-card-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.layer-meta strong,
.layer-meta span,
.source-card-meta strong,
.source-card-meta span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.layer-item.active .layer-meta strong,
.layer-item.active .layer-meta span {
    color: #fff;
}
.layer-icons {
    display: flex;
    align-items: center;
    gap: 4px;
}
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 20px;
    padding: 0 4px;
    font-size: 10px;
    background: #ece9d8;
    border-top: 1px solid var(--light);
    border-left: 1px solid var(--light);
    border-right: 1px solid var(--dark);
    border-bottom: 1px solid var(--dark);
}
.layer-lock,
.layer-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: #000;
    background: var(--face);
    border-top: 1px solid var(--light);
    border-left: 1px solid var(--light);
    border-right: 1px solid var(--dark);
    border-bottom: 1px solid var(--dark);
    font-size: 12px;
    line-height: 1;
}
.layer-lock.active {
    background: var(--blue-2);
    color: #fff;
}
.layer-item.dragging {
    opacity: 0.45;
}

.modal {
    position: fixed;
    inset: 0;
    padding: 18px;
    display: grid;
    place-items: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 50;
}
.mobile-modal-exit {
    display: none;
}
.modal-exit-btn {
    width: 100%;
    min-height: 42px;
    font-weight: 700;
}

.mobile-modal-footer-actions,
.mobile-only-modal-actions {
    display: none !important;
}

.modal-window {
    width: min(1400px, calc(100vw - 24px));
    height: min(900px, calc(100dvh - 24px));
    max-height: calc(100dvh - 24px);
    display: grid;
    grid-template-rows: auto minmax(0,1fr) auto;
}
.modal-body {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(280px, 320px) minmax(0,1fr);
    gap: 10px;
    padding: 10px;
    overflow: hidden;
}
.modal-sidebar {
    min-height: 0;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.modal-canvas-wrap {
    min-height: 0;
    min-width: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    padding: 10px;
    border-top: 2px solid var(--shadow);
    border-left: 2px solid var(--shadow);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
}
#selectionCanvas {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    display: block;
    background: transparent;
    border: 1px solid #666;
    touch-action: none;
}

.legend {
    margin: -16px 0 8px 4px;
    display: inline-block;
    padding: 0 4px;
    background: var(--face);
    font-weight: 700;
}

.help-fab {
    position: fixed;
    right: 12px;
    bottom: 12px;
    width: 36px;
    height: 36px;
    border-radius: 0;
    z-index: 40;
}
.help-window {
    width: min(760px, calc(100vw - 36px));
    max-height: min(720px, calc(100vh - 36px));
    display: grid;
    grid-template-rows: auto minmax(0,1fr);
}
.help-body {
    overflow: auto;
    padding: 12px;
}

.subdivider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}
.subdivider::before,
.subdivider::after {
    content: "";
    flex: 1;
    height: 2px;
    background: #bdbdbd;
    border-top: 1px solid var(--light);
    border-bottom: 1px solid var(--shadow);
}

@media (max-width: 1180px) {
    .app-shell { grid-template-columns: 300px minmax(0, 1fr); }
    .modal-body { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    body { overflow: auto; }
    .app-shell {
        height: auto;
        grid-template-columns: 1fr;
        width: 100%;
        padding: 8px;
        gap: 8px;
        overflow-x: hidden;
    }
    .sidebar,
    .workspace,
    .sidebar-scroll,
    .workspace-toolbar,
    .workspace-stage,
    .stage-inner,
    .win-group,
    .status-strip {
        min-width: 0;
    }
    .sidebar-scroll,
    .workspace-stage {
        overflow-x: hidden;
    }
    .workspace { min-height: 70vh; }
    .window-titlebar {
        align-items: flex-start;
        flex-wrap: wrap;
    }
    .title-left,
    .toolbar-group,
    .title-buttons,
    .title-controls {
        min-width: 0;
        max-width: 100%;
    }
    .title-left {
        flex: 1 1 100%;
    }
    .title-left strong,
    .modal-source-name,
    .status-strip {
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .title-left strong,
    .modal-source-name {
        white-space: nowrap;
    }
    .toolbar-group {
        width: 100%;
        flex-wrap: wrap;
    }
    .toolbar-group .btn {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
    }
    .field-row.two,
    .field-row.three,
    .field-row.four,
    .toolbar-line.stack-mobile {
        grid-template-columns: 1fr;
    }
    .modal {
        place-items: start center;
        overflow-y: auto;
        padding: 10px;
    }
    .modal-window,
    .text-modal-window,
    .help-window,
    .startup-modal-window {
        width: min(100%, calc(100vw - 20px));
        margin: 0 auto;
    }
    .modal-window,
    .text-modal-window {
        height: calc(100dvh - 20px);
        max-height: calc(100dvh - 20px);
    }
    .help-window,
    .startup-modal-window {
        height: auto;
        max-height: none;
    }
    .modal-titlebar {
        position: sticky;
        top: 0;
        z-index: 7;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 8px;
    }
    .modal-titlebar .title-left {
        flex: 1 1 auto;
        min-width: 0;
    }
    .modal-titlebar .title-close {
        margin-left: auto;
        flex: 0 0 auto;
        align-self: center;
    }
    .title-close {
        min-width: 18px;
        min-height: 18px;
        width: 18px;
        height: 18px;
        font-size: 12px;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
    .mobile-modal-exit {
        display: none !important;
    }
    .modal-body {
        min-height: 0;
        padding: 8px;
        gap: 8px;
        overflow: hidden;
        grid-template-columns: 1fr;
        grid-template-rows: minmax(260px, 42dvh) minmax(0, 1fr);
        align-content: stretch;
    }
    .modal-body > .modal-canvas-wrap {
        order: 1;
    }
    .modal-body > .modal-sidebar {
        order: 2;
    }
    .modal-sidebar {
        min-height: 0;
        max-height: none;
        overflow: auto;
        padding-bottom: 8px;
    }
    .modal-canvas-wrap {
        min-height: 260px;
        overflow: hidden;
        align-items: center;
        justify-items: center;
    }
    .mobile-only-modal-actions {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        position: sticky;
        bottom: 0;
        z-index: 8;
        padding: 8px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        background: var(--face);
        border-top: 2px solid var(--shadow);
        box-shadow: 0 -2px 0 var(--light);
    }
    .mobile-only-modal-actions .btn {
        min-height: 48px;
        font-weight: 700;
    }
    .modal-inline-actions {
        display: none !important;
    }
    .modal-inline-apply-row {
        display: grid !important;
        grid-template-columns: 1fr;
    }
    .modal-inline-apply-row .btn.primary {
        display: none !important;
    }
    #selectionCanvas,
    #textPreviewCanvas,
    #shapePreviewCanvas {
        min-width: 0;
        max-width: 100%;
        max-height: 100%;
    }
    #selectionCanvas {
        width: auto;
        height: auto;
    }
    #textPreviewCanvas,
    #shapePreviewCanvas {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    .startup-modal {
        align-items: start;
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    .startup-modal-window {
        margin-top: 0;
    }
    .startup-modal-body {
        padding: 10px;
    }
    .startup-top-grid {
        grid-template-columns: 1fr;
    }
    .startup-pixel-title {
        font-size: 19px;
        letter-spacing: 1px;
        padding: 8px 10px 7px;
    }
    .startup-support-list {
        grid-template-columns: 1fr;
    }
    .startup-support-item,
    .btn,
    .section-toggle {
        min-width: 0;
    }
    .quick-create-grid {
        grid-template-columns: 1fr;
    }
    .quick-create-btn {
        min-height: 92px;
    }
    .help-fab {
        right: 10px;
        bottom: max(10px, env(safe-area-inset-bottom));
    }
}


.mobile-panel-nav {
    display: none;
}

.mobile-panel-tab {
    min-height: 34px;
    padding: 6px 8px;
    color: #000;
    background: var(--face);
    border: 0;
    border-top: 2px solid var(--light);
    border-left: 2px solid var(--light);
    border-right: 2px solid var(--dark);
    border-bottom: 2px solid var(--dark);
    font-weight: 700;
    text-align: center;
}

.mobile-panel-tab.is-active {
    border-top: 2px solid var(--dark);
    border-left: 2px solid var(--dark);
    border-right: 2px solid var(--light);
    border-bottom: 2px solid var(--light);
    background: #d9d9d9;
    color: var(--blue);
}

@media (max-width: 900px) {
    .sidebar {
        order: 2;
    }
    .workspace {
        order: 1;
        min-height: auto;
        gap: 8px;
    }
    .workspace-toolbar {
        position: sticky;
        top: 0;
        z-index: 25;
    }
    .workspace-stage {
        position: sticky;
        top: var(--mobile-toolbar-height);
        z-index: 20;
        padding: 6px;
        height: clamp(280px, 46dvh, 460px);
        min-height: 280px;
        overflow: hidden;
    }
    .stage-inner {
        overflow: hidden;
    }
    .status-strip {
        margin: 6px;
        min-height: 24px;
        font-size: 12px;
    }
    .toolbar-group {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
        gap: 6px;
        align-items: start;
    }
    .toolbar-group .lang-switch {
        grid-column: 3;
        justify-self: end;
        align-self: start;
        width: max-content;
        display: inline-flex;
        align-items: center;
        justify-content: flex-end;
        gap: 3px;
        margin-left: 0;
        margin-right: 0;
        padding-right: 0;
    }
    .toolbar-group .btn {
        flex: none;
    }
    .sidebar-scroll {
        padding-top: 0;
        overflow: visible;
    }
    .brandbar .title-buttons {
        display: none;
    }
    .mobile-panel-nav {
        position: sticky;
        top: calc(var(--mobile-toolbar-height) + clamp(280px, 46dvh, 460px) + 8px);
        z-index: 18;
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
        margin-top: 0;
        background: var(--face);
    }
    .mobile-panel-section {
        display: none;
        margin-top: 8px;
    }
    .mobile-panel-section.is-mobile-active {
        display: block;
    }
    .mobile-panel-section .section-body.collapsed {
        display: block !important;
    }
    .mobile-panel-section .section-toggle {
        margin-bottom: 0;
    }
    .mobile-panel-section .section-toggle b {
        display: none;
    }
    .mobile-panel-section .section-body {
        padding-top: 8px;
    }
    .quick-create-grid.quick-create-grid-triple {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .quick-create-btn {
        min-height: 74px;
        padding: 8px 6px;
        gap: 4px;
    }
    .quick-create-symbol {
        font-size: 24px;
    }
    .quick-create-symbol-text {
        font-size: 28px;
    }
    .quick-create-symbol.quick-create-symbol-shape {
        font-size: 22px;
    }
    .quick-create-label {
        font-size: 10px;
    }
    .layer-list {
        max-height: none;
    }
}

@media (max-width: 640px) {
    .toolbar-group {
        grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    }
    .toolbar-group .lang-switch {
        grid-column: 3;
        justify-self: end;
    }
    .mobile-panel-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .window-titlebar {
        padding: 5px;
    }
}


.startup-modal {
    background: rgba(0, 0, 0, 0.18);
}

.startup-modal::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.28);
    backdrop-filter: blur(3px) brightness(.78);
    -webkit-backdrop-filter: blur(3px) brightness(.78);
    pointer-events: none;
}

.startup-modal > * {
    position: relative;
    z-index: 1;
}

.startup-modal-window {
    width: min(520px, calc(100vw - 24px));
    height: auto;
    max-height: none;
    grid-template-rows: auto auto;
}

.startup-modal-body {
    display: block;
    padding: 10px;
}

.startup-content-wrap {
    display: grid;
    gap: 8px;
}

.startup-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
}

.startup-pixel-title {
    font-family: "Courier New", monospace;
    font-size: 21px;
    line-height: 1;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #ffff66;
    background: #000080;
    border: 2px solid;
    border-color: #ffffff #404040 #404040 #ffffff;
    box-shadow: inset -1px -1px 0 #000000, inset 1px 1px 0 #c0c0c0;
    padding: 7px 10px 6px;
    text-align: center;
    text-shadow:
        2px 0 0 #000000,
        0 2px 0 #000000,
        2px 2px 0 #000000;
}

.startup-image-frame {
    padding: 6px;
    background: #bfbfbf;
}

.startup-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    border: 1px solid #000000;
    image-rendering: pixelated;
}

.startup-copy-box,
.startup-tools-box,
.startup-support-box {
    margin-bottom: 0;
    background: #c0c0c0;
}

.startup-copy-box,
.startup-tools-box {
    height: 100%;
}

.startup-copy-box p,
.startup-tools-text {
    margin: 4px 0 0;
    line-height: 1.35;
}

.startup-support-text {
    margin: 4px 0 8px;
    line-height: 1.35;
}

.startup-inline-link,
.startup-support-link {
    display: inline;
    width: auto;
    color: #000080;
    text-decoration: underline;
    text-underline-offset: 1px;
    word-break: break-word;
}

.startup-inline-link {
    font-weight: 700;
}

.startup-inline-link:hover,
.startup-support-item:hover .startup-support-link {
    color: #aa0000;
}

.startup-support-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.startup-support-item {
    display: grid;
    gap: 3px;
    padding: 7px 9px;
    background: #d4d0c8;
    border: 2px solid;
    border-color: #ffffff #808080 #808080 #ffffff;
    color: inherit;
    text-decoration: none;
}

.startup-support-item:hover {
    background: #dcd8d0;
}

.startup-support-item:active {
    border-color: #808080 #ffffff #ffffff #808080;
    padding: 8px 8px 6px 10px;
}

.startup-support-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #000080;
}

.startup-actions {
    justify-content: flex-end;
    padding-top: 0;
}

@media (max-width: 560px) {
    .startup-info-grid {
        grid-template-columns: 1fr;
    }

    .startup-support-list {
        grid-template-columns: 1fr;
    }
}

body.startup-modal-open .app-shell {
    filter: none;
}

code {
    font-family: "MS Sans Serif", "Tahoma", monospace;
    background: #d9d9d9;
    border: 2px solid;
    border-color: #fff #808080 #808080 #fff;
    padding: 1px 4px;
}


.text-tool-btn { min-width: 34px; font-weight: 700; }
.layer-type-badge { font-size: 10px; padding: 1px 4px; background: #ece9d8; border-top: 1px solid var(--light); border-left: 1px solid var(--light); border-right: 1px solid var(--dark); border-bottom: 1px solid var(--dark); }
.layer-info-line { display:flex; align-items:center; gap:6px; }
.layer-text-only.hidden, .layer-shape-only.hidden, .layer-image-only.hidden { display:none !important; }
.text-modal-window { width: min(1420px, calc(100vw - 36px)); }
.text-modal-textarea { width: 100%; min-height: 160px; resize: vertical; font: inherit; }
#textPreviewCanvas,
#shapePreviewCanvas { width: min(100%, 1000px); height: auto; max-height: 100%; display:block; background: transparent; border: 1px solid #666; }
input[readonly] { background: #e6e6e6; color: #333; }

#addImageLayerBtn:hover { color: var(--blue); }
#addTextLayerBtn:hover { color: #8a0000; }
.icon-tool-btn { font-size: 15px; line-height: 1; }


.lang-switch {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 2px;
}
.lang-btn {
    min-width: 42px;
    padding: 0 8px;
    text-align: center;
    text-decoration: none;
    color: inherit;
    font-size: 15px;
    line-height: 1;
}
.lang-btn.active {
    box-shadow: inset 1px 1px 0 var(--shadow), inset -1px -1px 0 var(--light);
    background: #d8d8d8;
}
.flag-lang-btn {
    min-width: 34px;
    width: 34px;
    height: 24px;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.flag-icon-img {
    display: block;
    width: 19px;
    height: 13px;
    border: 1px solid #111;
    image-rendering: crisp-edges;
    box-shadow: inset 1px 1px 0 rgba(255,255,255,.28);
    background: #fff;
    pointer-events: none;
}
.startup-titlebar .title-buttons { gap: 3px; }


@media (max-width: 900px) {
    .lang-switch {
        gap: 2px;
        margin-left: 0;
    }
    .flag-lang-btn {
        min-width: 30px;
        width: 30px;
        height: 22px;
        padding: 1px;
    }
    .flag-icon-img {
        width: 18px;
        height: 12px;
    }
}


.window-control-btn {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 0;
    border-top: 1px solid var(--light);
    border-left: 1px solid var(--light);
    border-right: 1px solid var(--dark);
    border-bottom: 1px solid var(--dark);
    background: var(--face);
    color: #000;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #9b9b9b;
}

.window-control-btn[disabled] {
    opacity: 1;
    cursor: default;
    pointer-events: none;
}

.window-control-btn:active:not([disabled]) {
    border-top: 1px solid var(--dark);
    border-left: 1px solid var(--dark);
    border-right: 1px solid var(--light);
    border-bottom: 1px solid var(--light);
    box-shadow: inset 1px 1px 0 #9b9b9b, inset -1px -1px 0 #fff;
    padding: 1px 0 0 1px;
}

.startup-titlebar .title-close { cursor: pointer; }


.legal-link-wrap {
    margin-top: 8px;
    text-align: left;
}
.legal-link {
    padding: 0;
    border: 0;
    background: transparent;
    color: #444;
    font-size: 10px;
    line-height: 1.2;
    text-decoration: underline;
    cursor: pointer;
}
.legal-link:hover {
    color: var(--blue);
}
.legal-window {
    width: min(860px, calc(100vw - 36px));
}
.legal-body a {
    color: var(--blue);
}
.legal-status {
    margin-top: 14px;
}
