/* ─── Oswald (variable) ─────────────────────────────────────────────── */
@font-face {
    font-family: 'Oswald';
    src: url('/assets/fonts/Oswald-Variable.ttf') format('truetype');
    font-weight: 200 700;
    font-style: normal;
}

/* ─── Avenir ────────────────────────────────────────────────────────── */
@font-face {
    font-family: 'Avenir';
    src: url('/assets/fonts/Avenir-Book.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}
@font-face {
    font-family: 'Avenir';
    src: url('/assets/fonts/Avenir-Roman.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'Avenir';
    src: url('/assets/fonts/Avenir-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}
@font-face {
    font-family: 'Avenir';
    src: url('/assets/fonts/Avenir-Heavy.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

/* ─── Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #eef0f6;
    --surface:   #ffffff;
    --surface2:  #f3f4f8;
    --border:    #dde0ed;
    --accent:    #4f6ef7;
    --accent-h:  #3a58e8;
    --header:    #006ab3;
    --danger:    #d93a3a;
    --text:      #1c1e2e;
    --text-muted:#6b6f8a;
    --radius:    8px;
    --panel-w:   248px;
    --topbar-h:  56px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    font-size: 16px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.4;
    height: 100vh;
    overflow: hidden;
}

/* ─── Utilities ────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Buttons ──────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
    white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #e8eaf2; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.active   { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn-primary  { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 4px rgba(79,110,247,0.25); }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); border-color: var(--accent-h); }

.btn-outline  { background: transparent; }
.btn-outline:hover:not(:disabled) { background: var(--surface2); }

.btn-danger   { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: rgba(224,80,80,0.15); }

.btn-sm       { padding: 4px 10px; font-size: 14px; }
.btn-block    { width: 100%; }

.btn-group { display: flex; gap: 4px; }

/* ─── Top bar ──────────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--surface);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    z-index: 100;
}
.ratio-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
}

.custom-size-inputs {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
}
.custom-size-inputs input[type="number"] {
    width: 58px;
    text-align: center;
    padding: 3px 5px;
    font-size: 14px;
}
.custom-size-inputs span {
    color: var(--text-muted);
    font-size: 14px;
}
.custom-unit {
    font-size: 13px;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}
.zoom-control #zoom-level {
    min-width: 38px;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    user-select: none;
}

.topbar-brand {
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.01em;
    color: var(--text);
    flex: 0 0 var(--panel-w);
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
}
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right  { flex: 0 0 var(--panel-w); display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.topbar-logout { margin-left: 10px; padding-left: 14px; border-left: 1px solid var(--border); }

/* ─── Editor layout ────────────────────────────────────────────────── */
.editor-page { background: var(--bg); }

.editor-layout {
    display: flex;
    height: calc(100vh - var(--topbar-h));
    margin-top: var(--topbar-h);
}

/* ─── Panels ───────────────────────────────────────────────────────── */
.panel {
    width: var(--panel-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}
.panel-right {
    border-right: none;
    border-left: 1px solid var(--border);
}

.panel-section {
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
}

.panel-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
    border-radius: 4px;
}

/* Upload / action buttons sitting directly inside a panel-section (below header) */
.panel-section > .btn,
.panel-section > label.btn { margin-bottom: 8px; }

/* Panel section headers — blue background for visibility */
.panel-left .panel-section-header,
.panel-right .panel-section-header {
    background: var(--header);
    color: #ffffff;
    margin: -14px -16px 10px -16px;
    padding: 10px 16px;
    border-radius: 4px 4px 0 0;
}
.panel-left .panel-section.collapsible.collapsed,
.panel-right .panel-section.collapsible.collapsed {
    padding-bottom: 0;
}

/* Collapsible sections */
.panel-section.collapsible > .panel-section-header {
    cursor: pointer;
    user-select: none;
}
.panel-section.collapsible > .panel-section-header::after {
    content: '▶';
    font-size: 11px;
    opacity: 0.75;
    margin-left: auto;
    display: inline-block;
    transition: transform 0.15s ease;
    transform: rotate(90deg); /* points down when expanded */
}
.panel-section.collapsible.collapsed > .panel-section-header::after {
    transform: rotate(0deg); /* points right when collapsed */
}
.panel-section.collapsible.collapsed > .panel-section-header {
    margin-bottom: 0;
    border-radius: 4px;
}
.panel-section.collapsible.collapsed > :not(.panel-section-header) {
    display: none;
}

.empty-state {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 14px 0;
}

/* ─── Shared grid item structure ────────────────────────────────────── */
.media-grid,
.logo-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.media-item,
.logo-item {
    border-radius: 4px;
    border: 2px solid transparent;
    background: var(--surface2);
    overflow: hidden;
    transition: border-color 0.15s;
    display: flex;
    flex-direction: column;
}
.media-item:hover  { border-color: var(--border); }
.media-item.active { border-color: var(--accent); }
.logo-item:hover   { border-color: var(--border); }
.logo-item.active  { border-color: var(--accent); }

/* Thumbnail area — square, image fills it */
.item-thumb {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
}
.media-item .item-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.logo-item .item-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
}
.logo-item .item-thumb img {
    max-width: 100%; max-height: 100%;
    object-fit: contain;
    pointer-events: none;
}
.logo-item .item-thumb svg {
    max-width: 100%; max-height: 100%;
    display: block;
}

/* Name label below thumbnail */
.item-name {
    font-size: 13px;
    padding: 4px 6px 5px;
    color: var(--text-muted);
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    cursor: text;
    border-top: 1px solid var(--border);
    transition: color 0.1s;
}
.item-name:hover { color: var(--text); }

.item-name-input {
    width: 100%;
    font-size: 12px;
    padding: 3px 5px;
    background: var(--surface);
    border: none;
    border-top: 1px solid var(--accent);
    color: var(--text);
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

/* Delete button (media only) */
.media-delete {
    position: absolute;
    top: 2px; right: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.item-thumb:hover .media-delete { display: flex; }

/* Move button below image name */
.item-actions {
    padding: 0 4px 4px;
    display: flex;
    gap: 4px;
}
.btn-xs {
    font-size: 11px;
    padding: 1px 6px;
    line-height: 1.6;
}

/* ─── Folder items ───────────────────────────────────────────────────── */
.media-folder-item .folder-thumb,
.logo-folder-item .folder-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface2);
    cursor: pointer;
}
.folder-icon {
    font-size: 30px;
    pointer-events: none;
    user-select: none;
}
.folder-count {
    display: inline-block;
    margin-left: 4px;
    font-size: 10px;
    color: var(--text-muted, #888);
}

/* ─── Media section chrome ───────────────────────────────────────────── */
.media-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}
/* Text buttons in action toolbars share available width equally */
.media-actions .btn:not(.btn-icon) { flex: 1; }

/* Breadcrumb */
.media-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    min-height: 22px;
    margin-bottom: 6px;
    font-size: 12px;
}
.bc-item {
    background: none;
    border: none;
    padding: 1px 4px;
    border-radius: 3px;
    color: var(--accent);
    cursor: pointer;
    font-size: 12px;
}
.bc-item:hover { text-decoration: underline; }
.bc-current {
    color: var(--text);
    cursor: default;
    font-weight: 500;
}
.bc-current:hover { text-decoration: none; }
.bc-sep {
    color: var(--text-muted, #aaa);
    padding: 0 1px;
    pointer-events: none;
}

/* ─── Pagination ─────────────────────────────────────────────────────── */
.media-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 3px;
    padding: 6px 0 2px;
}
.pg-btn { min-width: 28px; }
.pg-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.pg-ellipsis {
    padding: 0 2px;
    color: var(--text-muted, #aaa);
    font-size: 13px;
    line-height: 26px;
}

/* ─── Move-image modal ───────────────────────────────────────────────── */
.move-folder-list {
    max-height: 260px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 12px;
}
.move-folder-option {
    padding: 7px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.move-folder-option:last-child { border-bottom: none; }
.move-folder-option:hover { background: var(--surface2); }
.move-folder-option.selected {
    background: var(--accent);
    color: #fff;
}

/* ─── Template list ─────────────────────────────────────────────────── */
.template-list { display: flex; flex-direction: column; gap: 4px; }

.template-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 6px;
    background: var(--surface2);
    min-width: 0;
}
.template-name {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    display: flex;
    align-items: center;
    gap: 4px;
}
/* inner text span — carries the ellipsis truncation */
.item-name-text,
.folder-name-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
}
.template-actions {
    display: flex;
    gap: 2px;
    align-items: center;
    flex-shrink: 0;
    /* Collapsed by default — takes no space, so name gets the full row */
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-width 0.18s ease, opacity 0.15s;
}
.template-item:hover .template-actions,
.template-item:focus-within .template-actions,
.template-item-active .template-actions {
    max-width: 130px; /* 4 × 26px buttons + gaps */
    opacity: 1;
}
.template-item-active { outline: 2px solid var(--accent); outline-offset: -1px; }

/* Icon action buttons inside item rows */
.btn-icon {
    width: 26px;
    height: 26px;
    padding: 0;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    line-height: 1;
    border-radius: 4px;
}

/* Folder items — always show their single delete button */
.template-folder-item .template-name { font-weight: 400; }
.template-folder-item .template-actions {
    max-width: 30px;
    overflow: visible;
    opacity: 1;
}
.folder-icon-sm { flex-shrink: 0; font-size: 14px; }

/* Breadcrumb bar with folder-create button pinned to the right */
.project-breadcrumb-bar {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 4px;
}
.bc-crumbs {
    flex: 1;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
    min-width: 0;
}

/* ─── Tooltips — bubble rendered by tooltip.js (position:fixed, viewport-aware) ── */
.tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-transform: none;
    letter-spacing: normal;
    cursor: default;
    flex-shrink: 0;
    margin-left: 5px;
    vertical-align: middle;
}
.tip:hover { background: rgba(255,255,255,0.4); }
/* Tips inside property labels (not on blue headers) */
label .tip, .prop-row .tip {
    background: var(--surface2);
    color: var(--text-muted);
}
label .tip:hover, .prop-row .tip:hover { background: var(--accent); color: #fff; }

/* ─── Canvas area ───────────────────────────────────────────────────── */
.canvas-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg);
    overflow: hidden;
    gap: 0;
}

/* Scrollable zone that contains only the canvas — page strip, toolbar and
   layers panel live outside it so they are always visible. */
#canvas-scroll-zone {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 28px 20px;
}

.canvas-wrapper {
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #d0d0d0 25%, transparent 25%),
        linear-gradient(-45deg, #d0d0d0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #d0d0d0 75%),
        linear-gradient(-45deg, transparent 75%, #d0d0d0 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

/* ─── Page strip ────────────────────────────────────────────────────── */
#page-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--surface1);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
#page-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
    flex-wrap: wrap;
}
.page-tab {
    min-width: 30px;
    padding: 2px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
    line-height: 1.6;
}
.page-tab:hover { background: var(--surface3, var(--surface2)); }
.page-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.page-strip-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Drag-and-drop states */
.page-tab.dragging  { opacity: 0.4; }
.page-tab.drag-over {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

/* Page count badge on project list items */
.page-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    margin-left: 6px;
    border-radius: 9px;
    background: var(--surface3, var(--surface2));
    color: var(--text-muted, var(--text));
    font-size: 11px;
    font-weight: 600;
    vertical-align: middle;
}


/* Bottom bar: toolbar + layers, always visible below the scroll zone */
.canvas-bottom-bar {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 20px 12px;
    flex-shrink: 0;
    background: var(--bg);
    border-top: 1px solid var(--border);
}

.canvas-toolbar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    background: var(--surface);
    border-radius: 10px;
    padding: 6px 14px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}
/* ─── Layers panel ──────────────────────────────────────────────────── */
.layers-panel {
    width: 540px;
    max-width: 100%;
    background: var(--surface);
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -1px 6px rgba(0,0,0,0.06);
    overflow: hidden;
    flex-shrink: 0;
}
.layers-header {
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
.layers-list {
    max-height: 180px;
    overflow-y: auto;
}
.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    min-height: 34px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
    user-select: none;
}
.layer-item:last-child { border-bottom: none; }
.layer-item:hover:not(.layer-hidden) { background: var(--surface2); }
.layer-item.layer-active { background: rgba(79,110,247,0.08); }
.layer-item.layer-hidden { opacity: 0.4; }
.layer-icon {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 0;
    flex-shrink: 0;
    width: 26px;
    text-align: center;
}
.layer-name {
    flex: 1;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.layer-name-input {
    flex: 1;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--accent);
    border-radius: 4px;
    padding: 1px 5px;
    outline: none;
    background: var(--surface);
    color: var(--text);
    min-width: 0;
}
.layer-actions { display: flex; gap: 2px; flex-shrink: 0; }
.layer-btn { padding: 2px 7px; font-size: 13px; }
.layer-btn-delete { color: var(--danger); }
.layer-btn-spacer { visibility: hidden; pointer-events: none; }
.layer-btn-eye     { color: var(--text); }
.layer-btn-eye-off { color: var(--text-muted); }

/* Drag-and-drop */
.layer-item[draggable="true"] { cursor: grab; }
.layer-item.layer-dragging    { opacity: 0.35; }
.layer-item.layer-drop-above  { box-shadow: inset 0 2px 0 0 var(--accent); }
.layer-item.layer-drop-below  { box-shadow: inset 0 -2px 0 0 var(--accent); }

.toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--border);
    margin: 0 2px;
}

/* ─── Property panel ────────────────────────────────────────────────── */
.props-empty {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    padding: 20px 0 10px;
    line-height: 1.6;
}

.props-group { display: flex; flex-direction: column; gap: 8px; }
.prop-hint { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

.prop-subgroup {
    border-top: 2px solid var(--accent);
    padding-top: 10px;
    margin-top: 8px;
}
.props-group > .prop-subgroup:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}
.prop-subgroup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text);
    margin-bottom: 10px;
}
.prop-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.prop-row label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}
.prop-row-split {
    flex-direction: row;
    gap: 8px;
}
.prop-row-split > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 15px;
    font-weight: normal;
    padding: 6px 10px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,110,247,0.15);
}

input[type="color"] {
    width: 100%;
    height: 32px;
    padding: 2px 3px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface2);
    cursor: pointer;
}

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

/* Label + compact number input on one line, above a full-width slider */
.slider-row-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2px;
}
.slider-row-label label { margin-bottom: 0; }
.slider-row-label input[type="number"] {
    width: 64px;
    text-align: right;
}

input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; }
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 15px; color: var(--text-muted); cursor: pointer; }

/* ─── Color swap group ───────────────────────────────────────────────── */
.color-swap-btn {
    padding: 0 6px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--text-muted);
    border-color: var(--border);
    background: var(--surface2);
    flex-shrink: 0;
}
.color-swap-btn:hover:not(:disabled) {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--surface);
}

/* ─── Color field (swatch + hex input) ──────────────────────────────── */
.color-field {
    display: flex;
    align-items: center;
    gap: 4px;
}
.color-field input[type="color"] {
    width: 32px;
    flex-shrink: 0;
}
.color-field .color-hex {
    flex: 1;
    width: 0;
    font-family: 'Courier New', monospace;
    text-transform: uppercase;
    min-width: 0;
}

/* ─── Modal ─────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
}
.modal h3 { font-size: 18px; font-weight: 600; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-group { display: flex; flex-direction: column; gap: 4px; }

/* ─── Login page ────────────────────────────────────────────────────── */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 40px 36px;
    width: 360px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}
.login-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.login-logo-img {
    width: 72px;
    height: 72px;
    object-fit: contain;
}
.login-error {
    color: var(--danger);
    font-size: 14px;
    text-align: center;
    margin-top: -8px;
}

/* ─── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface2); }
::-webkit-scrollbar-thumb { background: #c8cce0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Mobile overlay + toggle buttons (hidden on desktop) ───────────── */
.mobile-panel-btn { display: none; }
.panel-close-btn  { display: none; }
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 149;
}
.mobile-overlay.active { display: block; }

/* ─── Mobile layout (≤900px) ────────────────────────────────────────── */
@media (max-width: 900px) {
    /* Topbar: shrink brand, show toggle buttons */
    .topbar { gap: 6px; padding: 0 10px; }
    .topbar-brand { flex: 0 0 auto; font-size: 16px; }
    .topbar-center { flex: 1; min-width: 0; overflow-x: auto; }
    .topbar-right  { flex: 0 0 auto; }
    .mobile-panel-btn { display: inline-flex; }

    /* Panels become slide-in drawers */
    .panel {
        position: fixed;
        top: 0;
        height: 100vh;
        z-index: 150;
        transition: transform 0.25s ease;
        width: min(300px, 85vw);
    }
    .panel-left  { left: 0;  transform: translateX(-100%); }
    .panel-right {
        right: 0;
        transform: translateX(100%);
        border-right: none;
        border-left: 1px solid var(--border);
    }
    .panel-left.panel-open  { transform: translateX(0); }
    .panel-right.panel-open { transform: translateX(0); }

    /* Close button inside each panel */
    .panel-close-btn {
        display: flex;
        justify-content: flex-end;
        width: 100%;
        padding: 8px 10px 4px;
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 20px;
        line-height: 1;
        cursor: pointer;
        flex-shrink: 0;
    }
    .panel-close-btn:hover { color: var(--text); }

    /* Canvas scroll zone: tighter padding on mobile */
    #canvas-scroll-zone { padding: 12px 8px; }

    /* Scale container constrains the canvas-wrapper to its visual size */
    #canvas-scale-container { overflow: hidden; flex-shrink: 0; }

    /* Toolbar wraps gracefully on small screens */
    .canvas-toolbar { flex-wrap: wrap; padding: 5px 10px; }
    .btn-sm { padding: 3px 8px; font-size: 14px; }
}
