/* =====================================================================
   Designer — style sheet v2
   A drafting-table look: cool paper, ink, one blue pencil accent.
   The preview stage is a measured drawing sheet; everything around it
   stays quiet so the device is what you look at.
   ===================================================================== */
@font-face {
    font-family: "Geist";
    src: url("../fonts/Geist-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-display: swap;
}

:root {
    --paper: #e9ecef;
    --paper-2: #dfe3e7;
    --sheet: #ffffff;
    --sheet-2: #f6f7f9;
    --ink: #16191d;
    --ink-2: #464d57;
    --ink-3: #7b838e;
    --line: #dde1e6;
    --line-2: #c8ced5;
    --blue: #1f4fe0;
    --blue-2: #173ec0;
    --blue-soft: #e9eefe;
    --blue-ring: rgba(31, 79, 224, 0.28);
    --danger: #c3312a;
    --danger-soft: #fbeceb;
    --ok: #1d8a4e;

    --r-1: 6px;
    --r-2: 9px;
    --r-3: 14px;

    --shadow-1: 0 1px 2px rgba(22, 25, 29, 0.06);
    --shadow-2: 0 6px 24px rgba(22, 25, 29, 0.08), 0 1px 2px rgba(22, 25, 29, 0.05);
    --shadow-3: 0 24px 60px rgba(22, 25, 29, 0.20);

    --topbar-h: 56px;
    --panel-w: 400px;
    --ease: cubic-bezier(.2, .7, .2, 1);
    font-family: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "tnum" 1;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); }
::selection { background: var(--blue-ring); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button { font: inherit; color: inherit; }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }

/* ---------------------------------------------------------------- topbar */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 20px;
    padding: 0 16px 0 14px;
    background: var(--sheet);
    border-bottom: 1px solid var(--line);
}
.topbar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.topbar-logo img { height: 26px; width: auto; display: block; }
.topbar-logo-mark { width: 24px; height: 24px; border-radius: 7px; background: var(--ink); display: block; position: relative; }
.topbar-logo-mark::after { content: ""; position: absolute; inset: 6px 8px; border: 2px solid #fff; border-radius: 3px; }
.topbar-name { font-weight: 600; font-size: 15px; letter-spacing: -0.02em; }
.topbar-extra { display: flex; gap: 10px; align-items: center; }
.mainnav { display: flex; gap: 2px; margin-left: 8px; }
.nav-link {
    display: inline-flex; align-items: center; gap: 7px;
    height: 34px; padding: 0 12px;
    border-radius: var(--r-2);
    color: var(--ink-2); text-decoration: none; font-weight: 500;
}
.nav-link:hover { background: var(--sheet-2); color: var(--ink); }
.nav-link.is-active { background: var(--blue-soft); color: var(--blue-2); }
.topbar-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.pill-form { margin: 0; display: inline-flex; }

/* ---------------------------------------------------------------- controls */
label, .label { display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2); margin-bottom: 5px; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
    width: 100%;
    height: 34px;
    padding: 0 10px;
    font: inherit; font-size: 13.5px; color: var(--ink);
    background: var(--sheet);
    border: 1px solid var(--line-2);
    border-radius: var(--r-1);
    transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 8px 10px; }
select { padding-right: 28px; appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%237b838e' stroke-width='1.6'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; }
input:hover, select:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-ring); }
input[type="number"] { padding: 0 6px 0 8px; }
input[type="file"] { font-size: 12.5px; color: var(--ink-2); max-width: 100%; }
input[type="file"]::file-selector-button {
    font: inherit; font-weight: 500; margin-right: 10px; padding: 6px 12px;
    border: 1px solid var(--line-2); border-radius: var(--r-1); background: var(--sheet); color: var(--ink); cursor: pointer;
}
input[type="file"]::file-selector-button:hover { border-color: var(--ink-3); }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 3px; background: var(--line-2); border-radius: 3px; }
input[type="range"]::-moz-range-track { height: 3px; background: var(--line-2); border-radius: 3px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; margin-top: -6px; border-radius: 50%; background: var(--sheet); border: 2px solid var(--ink); transition: transform .12s; }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--sheet); border: 2px solid var(--ink); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); border-color: var(--blue); }
input[type="range"]:focus { box-shadow: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--blue-ring); }

input[type="color"] {
    -webkit-appearance: none; appearance: none; padding: 0; width: 34px; height: 30px; flex: none;
    border: 1px solid var(--line-2); border-radius: var(--r-1); background: none; cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 4px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--blue); width: 15px; height: 15px; margin: 0; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px;
    border-radius: var(--r-1);
    border: 1px solid transparent;
    font-weight: 550; font-size: 13.5px; text-decoration: none; white-space: nowrap;
    cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-2); }
.btn-quiet, .btn-ghost { background: var(--sheet); color: var(--ink); border-color: var(--line-2); }
.btn-quiet:hover, .btn-ghost:hover { border-color: var(--ink-3); background: var(--sheet-2); }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: transparent; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #a62820; }
.btn-block, .btn-wide { width: 100%; }
.btn-small { height: 30px; padding: 0 11px; font-size: 13px; }
.btn-tiny { height: 26px; padding: 0 9px; font-size: 12.5px; font-weight: 500; }
.icon-btn {
    display: inline-grid; place-items: center; flex: none;
    width: 34px; height: 34px; padding: 0;
    border-radius: var(--r-1); border: 1px solid transparent; background: transparent;
    color: var(--ink-2); cursor: pointer; font-size: 18px; line-height: 1;
}
.icon-btn:hover { background: var(--sheet-2); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.link-btn { background: none; border: 0; padding: 4px 0; color: var(--blue); font-weight: 500; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 450; color: var(--ink); margin: 8px 0 0; cursor: pointer; }
.check.small { font-size: 12.5px; margin: 0; color: var(--ink-2); }
.inline { display: flex; gap: 6px; align-items: center; }
.inline > select, .inline > input { flex: 1; min-width: 0; }
.field { margin-top: 12px; }
.field:first-child { margin-top: 0; }
.help { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-3); line-height: 1.45; }
.help.is-error, .is-error { color: var(--danger) !important; }
.empty { margin: 4px 0; color: var(--ink-3); font-size: 12.5px; }

/* segmented control */
.seg { display: inline-flex; flex-wrap: nowrap; padding: 2px; gap: 2px; background: var(--paper); border-radius: var(--r-2); max-width: 100%; }
.seg-wrap { flex-wrap: wrap; }
.seg button {
    border: 0; background: transparent; height: 28px; padding: 0 11px; border-radius: 7px;
    font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.seg button:hover { color: var(--ink); }
.seg button.is-on { background: var(--sheet); color: var(--ink); box-shadow: var(--shadow-1); }
.seg-small button { height: 24px; padding: 0 9px; font-size: 12px; }

/* banners */
.banner { padding: 11px 14px; border-radius: var(--r-2); margin-bottom: 18px; font-weight: 500; border: 1px solid; }
.banner-success { background: #eaf6ef; border-color: #bfe3cd; color: #165f37; }
.banner-error { background: var(--danger-soft); border-color: #f0c4c1; color: #8f241e; }
.banner-floating { position: fixed; top: calc(var(--topbar-h) + 12px); left: 50%; transform: translateX(-50%); z-index: 60; box-shadow: var(--shadow-2); }

/* =====================================================================
   EDITOR
   ===================================================================== */
body.is-editor { height: 100vh; overflow: hidden; }
.editor {
    display: grid;
    grid-template-columns: var(--panel-w) 1fr;
    height: calc(100vh - var(--topbar-h));
}

/* ---------- panel ---------- */
.panel {
    display: flex; flex-direction: column; min-height: 0;
    background: var(--sheet);
    border-right: 1px solid var(--line);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 14px 10px 18px; }
.panel-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history { display: flex; gap: 2px; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); }
.tab {
    position: relative; border: 0; background: none; cursor: pointer;
    padding: 10px 8px 11px; font-size: 13px; font-weight: 500; color: var(--ink-3);
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); }
.tab.is-active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }
.panel-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.tab-pane { display: none; padding: 4px 0 40px; }
.tab-pane.is-active { display: block; }

.group { padding: 16px 18px 18px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group-title { font-size: 13.5px; font-weight: 600; margin-bottom: 4px; color: var(--ink); }
.group-title + .seg, .group-title + .rows, .group-title + .field { margin-top: 8px; }
.notice { margin: 14px 18px 0; padding: 10px 12px; border-radius: var(--r-2); background: var(--sheet-2); border: 1px dashed var(--line-2); color: var(--ink-2); font-size: 12.5px; }

.slider-field { display: grid; grid-template-columns: 74px 1fr 84px; align-items: center; gap: 10px; margin-top: 10px; }
.slider-field label { margin: 0; }
.slider-field output { font-size: 12.5px; color: var(--ink-2); text-align: right; }
.num-unit { position: relative; display: block; }
.num-unit input { padding-right: 26px; height: 30px; text-align: right; }
.num-unit span { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); font-size: 11.5px; color: var(--ink-3); pointer-events: none; }

.color-row { display: grid; grid-template-columns: 1fr 34px 96px; align-items: center; gap: 10px; margin-top: 10px; }
.color-row label { margin: 0; font-weight: 450; color: var(--ink); font-size: 13px; }
.color-row:not(:has(input[type=range])) { grid-template-columns: 1fr 34px; }

.swatches { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; margin: 8px 0 6px; }
.swatch { aspect-ratio: 1; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .12); cursor: pointer; padding: 0; box-shadow: inset 0 1px 1px rgba(255,255,255,.4); transition: transform .12s; }
.swatch:hover { transform: scale(1.1); }

/* presets */
.search { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.chip {
    border: 1px solid var(--line-2); background: var(--sheet); border-radius: 99px;
    height: 26px; padding: 0 10px; font-size: 12px; font-weight: 500; color: var(--ink-2); cursor: pointer;
}
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #fff; }
.preset-list { max-height: 268px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-2); background: var(--sheet-2); padding: 3px; }
.preset {
    display: flex; justify-content: space-between; align-items: baseline; gap: 8px; width: 100%;
    border: 0; background: transparent; text-align: left; padding: 7px 9px; border-radius: 6px; cursor: pointer;
}
.preset:hover { background: var(--sheet); }
.preset.is-on { background: var(--blue-soft); }
.preset.is-on .preset-name { color: var(--blue-2); }
.preset-name { font-weight: 500; font-size: 13px; }
.preset-meta { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.preset-list .empty { padding: 10px; }


/* size tiles (true-proportion outlines) */
.size-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.size-tile {
    display: grid; justify-items: center; align-content: start; gap: 2px;
    padding: 8px 4px 7px; border: 1px solid var(--line); border-radius: var(--r-2);
    background: var(--sheet); cursor: pointer; text-align: center; min-height: 104px;
}
.size-tile:hover { border-color: var(--ink-3); }
.size-tile.is-on { border-color: var(--blue); background: var(--blue-soft); box-shadow: 0 0 0 1px var(--blue); }
.size-shape { height: 50px; display: grid; place-items: end center; }
.size-shape rect { fill: var(--paper); stroke: var(--ink-2); stroke-width: 1.2; }
.size-tile.is-on .size-shape rect { fill: #fff; stroke: var(--blue); }
.size-inch { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; margin-top: 3px; }
.size-note { font-size: 10.5px; color: var(--ink-3); line-height: 1.2; }
.size-mm { font-size: 10.5px; color: var(--ink-2); }

/* camera layout gallery */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; max-height: 430px; overflow-y: auto; padding: 2px; margin: 2px -2px 0; }
.tpl-card {
    position: relative; display: flex; flex-direction: column; gap: 4px;
    padding: 6px 6px 8px; border: 1px solid var(--line); border-radius: var(--r-2);
    background: var(--sheet); cursor: pointer; text-align: left;
}
.tpl-card:hover { border-color: var(--ink-3); }
.tpl-card.is-on { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.tpl-card:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.tpl-thumb { display: block; border-radius: 6px; overflow: hidden; background: linear-gradient(#f4f5f7, #e8eaed); aspect-ratio: 1 / 0.82; }
.tpl-thumb svg { display: block; width: 100%; height: 100%; }
.tpl-name { font-size: 11.5px; font-weight: 500; line-height: 1.25; color: var(--ink); }
.tpl-del {
    position: absolute; top: 4px; right: 4px; min-width: 22px; height: 22px; padding: 0 6px;
    border: 0; border-radius: 6px; background: rgba(255,255,255,.92); color: var(--danger); font-size: 13px; cursor: pointer;
    box-shadow: var(--shadow-1);
}

/* rows (buttons / islands / parts) */
.rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.row {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px;
    padding: 8px 34px 8px 8px; position: relative;
    background: var(--sheet-2); border: 1px solid var(--line); border-radius: var(--r-2);
}
.row.is-selected { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-ring); background: var(--sheet); }
.mini { margin: 0; flex: 1 1 58px; min-width: 0; }
.mini-wide { flex: 2 1 120px; }
.mini > span { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 3px; font-weight: 500; }
.mini input, .mini select { height: 28px; font-size: 12.5px; }
.mini input[type=color] { width: 100%; height: 28px; }
.row-remove {
    position: absolute; top: 6px; right: 5px;
    width: 24px; height: 24px; display: grid; place-items: center;
    border: 0; background: transparent; border-radius: 5px; color: var(--ink-3); cursor: pointer;
}
.row-remove:hover { background: var(--danger-soft); color: var(--danger); }
.add-parts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.add-parts .btn { height: 28px; padding: 0 10px; font-size: 12.5px; }
.add-parts .btn::before { content: "+"; font-weight: 400; margin-right: 2px; color: var(--ink-3); }
.save-tpl { margin-top: 10px; }

/* ---------- stage ---------- */
.stage { display: grid; grid-template-rows: auto 1fr auto; min-width: 0; min-height: 0; }
.savebar {
    display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
    padding: 10px 16px 12px;
    background: var(--sheet);
    border-bottom: 1px solid var(--line);
}
.savebar-field { min-width: 150px; }
.savebar-field.grow { flex: 1; min-width: 180px; }
.savebar-field label { font-size: 11.5px; margin-bottom: 4px; color: var(--ink-3); }
.savebar-field .icon-btn { border-color: var(--line-2); }
.savebar-action { display: flex; align-items: center; gap: 10px; }
.save-status { font-size: 12.5px; color: var(--ink-3); max-width: 260px; }

.canvas {
    position: relative; overflow: auto; min-height: 0;
    background-color: #f3f5f7;
    background-image:
        linear-gradient(rgba(31, 79, 224, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 79, 224, 0.07) 1px, transparent 1px),
        linear-gradient(rgba(31, 79, 224, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 79, 224, 0.035) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    background-position: -1px -1px;
}
.canvas[data-bg="white"] { background: #fff; }
.canvas[data-bg="dark"] { background: #1c1f24; }
.canvas[data-bg="checker"] {
    background-color: #fff;
    background-image: linear-gradient(45deg, #e6e8eb 25%, transparent 25%), linear-gradient(-45deg, #e6e8eb 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #e6e8eb 75%), linear-gradient(-45deg, transparent 75%, #e6e8eb 75%);
    background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.canvas-inner { min-width: 100%; min-height: 100%; display: grid; place-items: center; padding: 24px; }
.svg-preview { line-height: 0; }
.svg-preview svg { display: block; overflow: visible; }
.svg-preview [data-cam-item].is-sel { filter: drop-shadow(0 0 1.5px #1f4fe0) drop-shadow(0 0 1.5px #1f4fe0); }
.canvas[data-bg="dark"] .dim text { fill: #9fb6ff; }
.preview-error { color: var(--danger); font-size: 13px; padding: 16px; line-height: 1.4; }

.stage-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 8px 14px 8px 18px; background: var(--sheet); border-top: 1px solid var(--line);
}
.stage-caption { margin: 0; color: var(--ink-2); font-size: 12.5px; }
.stage-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.zoom { display: flex; align-items: center; gap: 2px; }
.zoom .icon-btn { width: 28px; height: 28px; font-size: 16px; }
.zoom-val { border: 0; background: none; width: 52px; height: 28px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; border-radius: 6px; }
.zoom-val:hover { background: var(--sheet-2); }

/* prompt dialog */
.prompt-glass { width: min(380px, 100%); text-align: left; }
.prompt-title { font-size: 16px; margin-bottom: 14px; }
.prompt-error { color: var(--danger); font-size: 12.5px; margin: 10px 0 0; }

@media (max-width: 960px) {
    :root { --panel-w: 340px; }
    .slider-field { grid-template-columns: 64px 1fr 78px; }
}
@media (max-width: 760px) {
    body.is-editor { height: auto; overflow: auto; }
    .editor { grid-template-columns: 1fr; height: auto; }
    .stage { order: -1; grid-template-rows: auto 60vh auto; }
    .panel { border-right: 0; }
    .panel-scroll { overflow: visible; }
    .topbar-name, .nav-link span { display: none; }
}

/* =====================================================================
   LIBRARY (downloads.php)
   ===================================================================== */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 20px 80px; }
.page-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-title { font-size: 24px; letter-spacing: -0.02em; }
.empty-state { color: var(--ink-3); padding: 14px 4px; }

.accordion { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r-3); margin-bottom: 12px; }
.accordion > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px; border-radius: var(--r-3);
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > summary::before {
    content: ""; width: 8px; height: 8px; flex: none; margin: 0 2px;
    border-right: 1.6px solid var(--ink-3); border-bottom: 1.6px solid var(--ink-3);
    transform: rotate(-45deg); transition: transform .2s var(--ease);
}
.accordion[open] > summary::before { transform: rotate(45deg); }
.accordion > summary:hover { background: var(--sheet-2); }
.brand-logo-thumb { width: 26px; height: 26px; object-fit: contain; }
.accordion-title { font-weight: 600; font-size: 15px; }
.accordion-count { color: var(--ink-3); font-size: 12.5px; }
.accordion-body { padding: 4px 16px 16px; }
.series-accordion { background: var(--sheet-2); border-radius: var(--r-2); margin: 10px 0 0; }
.series-accordion > summary { padding: 11px 14px; border-radius: var(--r-2); }
.series-accordion .accordion-title { font-size: 14px; }
.summary-delete-form { margin-left: auto; opacity: 0; transition: opacity .15s; }
.accordion > summary:hover .summary-delete-form, .summary-delete-form:focus-within { opacity: 1; }
.brand-toolbar { display: flex; justify-content: flex-end; padding: 4px 0 6px; }
.zip-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.zip-form select { width: auto; height: 30px; }
.inline-tiny-form { display: inline; margin: 0; }

.model-list { display: flex; flex-direction: column; padding: 0 0 4px; }
.model-list-header, .model-row {
    display: grid;
    grid-template-columns: 18px 44px minmax(0, 1fr) auto 150px;
    align-items: center; gap: 12px;
}
.model-list-header { padding: 6px 10px; font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.model-row { padding: 6px 10px; border-radius: var(--r-2); background: transparent; transition: background .12s; }
.model-row:hover { background: var(--sheet); }
.model-row.dragging { opacity: .5; background: var(--blue-soft); }
.model-row-handle { color: var(--line-2); cursor: grab; font-size: 15px; user-select: none; }
.model-row:hover .model-row-handle { color: var(--ink-3); }
.model-row-icon { width: 44px; height: 44px; display: grid; place-items: center; color: var(--ink-3); }
.model-row-icon img { width: 44px; height: 44px; object-fit: contain; }
.model-row-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-row-actions { display: flex; gap: 2px; flex-wrap: wrap; }
.model-row-actions .btn-ghost { border-color: transparent; background: transparent; }
.model-row-actions .btn-ghost:hover { background: var(--paper); }
.model-row-downloads { justify-self: end; width: 100%; }
.dl-select { height: 30px; font-size: 12.5px; }

@media (max-width: 760px) {
    .model-list-header { display: none; }
    .model-row { grid-template-columns: 16px 40px minmax(0, 1fr); row-gap: 6px; }
    .model-row-actions, .model-row-downloads { grid-column: 3; }
}

/* =====================================================================
   MODALS
   ===================================================================== */
.modal-overlay, .preview-modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    display: grid; place-items: center; padding: 16px;
    background: rgba(22, 25, 29, 0.42);
    backdrop-filter: blur(3px);
}
#confirmModalOverlay { z-index: 300; }
.modal-glass, .preview-modal-glass {
    position: relative; width: min(420px, 100%);
    background: var(--sheet); border-radius: var(--r-3); box-shadow: var(--shadow-3);
    padding: 22px;
}
.modal-text { margin: 0 0 18px; font-size: 14.5px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-x, .preview-modal-close {
    position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; background: transparent;
    border-radius: var(--r-1); cursor: pointer; color: var(--ink-3); font-size: 15px;
}
.modal-x:hover, .preview-modal-close:hover { background: var(--sheet-2); color: var(--ink); }

.settings-glass { width: min(520px, 100%); max-height: 90vh; overflow-y: auto; }
.settings-title { font-size: 18px; margin-bottom: 6px; }
.settings-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.settings-section:last-child { border-bottom: 0; padding-bottom: 0; }
.settings-section h3 { font-size: 14px; margin-bottom: 4px; }
.settings-help { margin: 0 0 12px; color: var(--ink-3); font-size: 12.5px; }
.settings-logo-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.settings-logo-preview { width: 64px; height: 64px; border-radius: var(--r-2); border: 1px dashed var(--line-2); display: grid; place-items: center; background: var(--sheet-2); }
.settings-logo-preview img { max-width: 48px; max-height: 48px; }
.settings-logo-empty { font-size: 11px; color: var(--ink-3); }
.settings-logo-form, .settings-import-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.settings-import-form { margin-top: 10px; }
.settings-remove-logo { margin-top: 8px; }
.settings-backup-row { display: flex; gap: 8px; }
.settings-warn { margin: 8px 0 0; font-size: 12px; color: var(--danger); }

.preview-modal-glass { width: min(560px, 100%); padding: 18px 18px 22px; }
.preview-modal-title { margin: 0 40px 10px 4px; font-weight: 600; font-size: 15px; }
.preview-modal-canvas {
    display: grid; place-items: center; height: min(70vh, 620px);
    background-color: #f3f5f7; border-radius: var(--r-2);
    background-image: linear-gradient(rgba(31, 79, 224, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(31, 79, 224, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}
.preview-modal-canvas svg { max-width: 100%; max-height: 100%; width: auto; height: auto; }

/* =====================================================================
   LANDING + SIGN IN (index.php / login.php)
   ===================================================================== */
.hero-body, .login-body {
    min-height: 100vh; margin: 0;
    background-color: #f3f5f7;
    background-image:
        linear-gradient(rgba(31, 79, 224, 0.07) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 79, 224, 0.07) 1px, transparent 1px),
        linear-gradient(rgba(31, 79, 224, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 79, 224, 0.035) 1px, transparent 1px);
    background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
}
.hero { position: relative; min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); align-items: center; gap: 40px; max-width: 1180px; margin: 0 auto; padding: 48px 32px; overflow: hidden; }
.hero-inner { position: relative; z-index: 2; max-width: 560px; }
.hero-kicker { display: inline-block; font-size: 13px; font-weight: 500; color: var(--blue-2); margin-bottom: 18px; padding: 4px 10px; border: 1px solid var(--blue-ring); border-radius: 99px; background: rgba(255,255,255,.7); }
.hero-title { font-size: clamp(40px, 6vw, 76px); line-height: 0.98; letter-spacing: -0.045em; font-weight: 650; margin: 0 0 22px; color: var(--ink); }
.hero-sub { font-size: 17px; line-height: 1.55; color: var(--ink-2); margin: 0 0 30px; max-width: 46ch; }
.btn-hero { height: 46px; padding: 0 22px; font-size: 15px; border-radius: var(--r-2); }
.hero-glow { display: none; }
.hero-devices { position: relative; height: 560px; }
.hero-device { position: absolute; height: 470px; width: auto; filter: drop-shadow(0 30px 40px rgba(22,25,29,.22)); }
.hero-device-1 { left: 6%; top: 40px; transform: rotate(-7deg); }
.hero-device-2 { right: 4%; top: 70px; transform: rotate(6deg); }
@media (max-width: 860px) {
    .hero { grid-template-columns: 1fr; padding-top: 64px; }
    .hero-devices { height: 360px; }
    .hero-device { height: 300px; }
}

.login-card { width: min(380px, calc(100% - 32px)); margin: 14vh auto 0; background: var(--sheet); border-radius: var(--r-3); box-shadow: var(--shadow-2); padding: 28px; }
.login-title { font-size: 22px; margin: 0 0 6px; }
.login-sub { color: var(--ink-3); margin: 0 0 18px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }

.login-modal-overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(22, 25, 29, .45); backdrop-filter: blur(4px); }
.login-modal-overlay.hidden { display: none; }
.login-modal-glass { position: relative; width: min(360px, 100%); background: var(--sheet); border-radius: var(--r-3); box-shadow: var(--shadow-3); padding: 28px 24px 24px; text-align: center; }
.login-modal-close { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border: 0; background: transparent; border-radius: 6px; cursor: pointer; color: var(--ink-3); }
.login-modal-close:hover { background: var(--sheet-2); color: var(--ink); }
.login-modal-title { font-size: 17px; font-weight: 600; margin: 0 0 16px; }
.login-state form { display: flex; flex-direction: column; gap: 10px; }
.login-state input[type="password"] { height: 42px; font-size: 15px; text-align: center; letter-spacing: 0.1em; }
.login-state input[type="password"]::placeholder { letter-spacing: 0; color: var(--ink-3); }
.login-modal-error { margin: 12px 0 0; color: var(--danger); font-size: 13px; }
.login-modal-error.hidden { display: none; }
.login-state.hidden { display: none; }
.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* sign-in "scan" animation (hero-login.js) */
.radar { position: relative; width: 120px; height: 120px; margin: 4px auto 16px; border-radius: 50%; background: var(--blue-soft); overflow: hidden; color: var(--blue); }
.radar::before { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--blue-ring); }
.radar-ring { position: absolute; border: 1px solid var(--blue-ring); border-radius: 50%; }
.radar-ring.r1 { inset: 15%; } .radar-ring.r2 { inset: 30%; } .radar-ring.r3 { inset: 45%; }
.radar-sweep { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, rgba(31,79,224,.35), transparent 30%); animation: spin 1.4s linear infinite; }
.radar-blip { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); animation: blip 1.4s infinite; }
.radar-blip.b1 { top: 28%; left: 62%; } .radar-blip.b2 { top: 64%; left: 30%; animation-delay: .5s; } .radar-blip.b3 { top: 50%; left: 78%; animation-delay: .9s; }
.radar-icon { position: absolute; inset: 38%; width: 24%; height: 24%; }
.scan-text { font-weight: 500; margin: 0 0 10px; }
.scan-progress { height: 3px; background: var(--line); border-radius: 3px; overflow: hidden; }
.scan-progress span { display: block; height: 100%; width: 0; background: var(--blue); transition: width .2s; }
.scan-hex { font-size: 11px; color: var(--ink-3); margin: 10px 0 0; min-height: 1em; word-break: break-all; }
.scan-ring { width: 84px; height: 84px; margin: 6px auto 14px; border-radius: 50%; display: grid; place-items: center; }
.scan-ring .scan-icon { width: 40px; height: 40px; }
.scan-ring-success { background: #e6f5ec; color: var(--ok); }
.scan-ring-success::after { content: none; }
.scan-ring-success .scan-icon path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw .5s forwards .1s; }
.scan-text-success { color: var(--ok); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blip { 0%, 100% { opacity: 0; transform: scale(.6); } 40% { opacity: 1; transform: scale(1); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
