@font-face { font-family: "Lexend"; src: url("../fonts/google/Lexend.ttf") format("truetype"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("../fonts/google/Montserrat.ttf") format("truetype"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato"; src: url("../fonts/google/Lato.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }

:root {
    color-scheme: dark;
    --page: #090c12;
    --surface: #10151e;
    --surface-2: #151b26;
    --surface-3: #1b2330;
    --border: #273142;
    --border-strong: #354156;
    --text: #f4f7fb;
    --muted: #94a0b3;
    --muted-strong: #b9c2d0;
    --primary: #6d6cf5;
    --primary-hover: #7c7bff;
    --primary-soft: rgba(109, 108, 245, .14);
    --success: #38c994;
    --warning: #f4b860;
    --danger: #ef6573;
    --header-height: 72px;
    --footer-height: 128px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; max-width: 100%; overflow-x: hidden; background: var(--page); }
body { max-width: 100%; margin: 0; min-height: 100vh; display: flex; flex-direction: column; overflow-x: hidden; background: var(--page); color: var(--text); font-size: 15px; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .56; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

:focus-visible { outline: 3px solid rgba(124, 123, 255, .52); outline-offset: 2px; }
.skip-link {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 100;
    padding: 10px 14px;
    border-radius: 7px;
    background: #fff;
    color: #111827;
    font-weight: 800;
    text-decoration: none;
    transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--header-height);
    display: grid;
    grid-template-columns: 230px minmax(260px, 1fr) auto;
    align-items: center;
    gap: 20px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(9, 12, 18, .96);
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; color: var(--text); text-decoration: none; }
.brand img { width: 38px; height: 38px; border-radius: 9px; }
.brand span { display: grid; gap: 2px; min-width: 0; }
.brand strong { font-size: 14px; letter-spacing: -.01em; white-space: nowrap; }
.brand small { color: var(--muted); font-size: 11px; white-space: nowrap; }

.project-identity { justify-self: center; display: flex; align-items: center; gap: 10px; min-width: 0; width: min(600px, 100%); }
.project-identity label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }
.project-identity input {
    width: min(340px, 50vw);
    min-height: 38px;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    font-weight: 700;
}
.project-identity input:hover, .project-identity input:focus { border-color: var(--border-strong); background: var(--surface); }
.save-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.save-status i { color: var(--success); font-size: 7px; }
.save-status.saving i { color: var(--warning); }
.save-status.error i { color: var(--danger); }

.header-actions { display: flex; gap: 8px; }
.header-reset {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted-strong);
    font-weight: 750;
    white-space: nowrap;
}
.header-reset:hover:not(:disabled) { border-color: #72505a; background: rgba(239, 101, 115, .08); color: #ffadb5; }
.icon-button {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted-strong);
    text-decoration: none;
}
.icon-button:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.preview-toggle, .preview-close { display: none; }
.preview-scrim { display: none; }

.app-layout {
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
    flex: 1 0 auto;
    display: grid;
    grid-template-columns: 230px minmax(540px, 1fr) minmax(350px, 420px);
}

.sidebar {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height) - var(--footer-height));
    display: flex;
    flex-direction: column;
    padding: 22px 14px 18px;
    border-right: 1px solid var(--border);
    background: #0c1017;
}
.section-nav { display: grid; gap: 5px; }
.nav-item {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted-strong);
    text-align: left;
    font-weight: 700;
}
.nav-item i { width: 18px; color: var(--muted); text-align: center; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: #deddff; }
.nav-item.active i { color: #9594ff; }
.sidebar-summary { margin-top: auto; display: grid; gap: 10px; padding: 16px 13px; border-top: 1px solid var(--border); color: var(--muted); }
.sidebar-summary span { display: flex; justify-content: space-between; gap: 8px; }
.sidebar-summary strong { color: var(--text); }

.workspace { min-width: 0; padding: 34px clamp(22px, 3vw, 48px) 72px; }
.workspace-panel { width: min(980px, 100%); margin: 0 auto; }
.workspace-heading, .section-heading, .generation-intro, .preview-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.workspace-heading { margin-bottom: 26px; }
.workspace-heading h1 { margin: 4px 0 8px; font-size: clamp(28px, 3.2vw, 38px); line-height: 1.1; letter-spacing: -.035em; }
.workspace-heading p, .generation-intro p, .section-heading p { margin: 0; color: var(--muted); line-height: 1.55; }
.eyebrow { margin: 0; color: #9d9cff; font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h2, h3 { letter-spacing: -.02em; }

.button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 9px 15px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text);
    font-weight: 750;
    white-space: nowrap;
}
.button.primary { background: var(--primary); color: #fff; box-shadow: 0 8px 24px rgba(91, 89, 232, .18); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover); }
.button.secondary { border-color: var(--border); background: var(--surface-2); color: var(--muted-strong); }
.button.secondary:hover:not(:disabled) { border-color: var(--border-strong); color: var(--text); }
.button.danger { background: var(--danger); color: #fff; }
.button.danger-quiet { border-color: rgba(239, 101, 115, .25); background: rgba(239, 101, 115, .08); color: #ff9ca5; }
.button.small { min-height: 40px; padding: 8px 12px; font-size: 13px; }
.button.icon-only { width: 40px; min-height: 40px; padding: 0; }

.loading-card, .empty-state, .settings-card, .generation-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}
.loading-card { display: flex; align-items: center; gap: 14px; min-height: 96px; padding: 20px; }
.loading-card div { display: grid; gap: 5px; }
.loading-card span { color: var(--muted); }
.spinner { width: 22px; height: 22px; flex: 0 0 auto; border: 3px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.quick-start { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; }
.quick-start li { min-width: 0; display: flex; align-items: center; gap: 11px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 10px; background: rgba(255,255,255,.012); }
.quick-start li > span { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--primary-soft); color: #bebdff; font-size: 12px; font-weight: 850; }
.quick-start div { min-width: 0; display: grid; gap: 2px; }
.quick-start strong { font-size: 13px; }
.quick-start small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.set-list { width: 100%; display: grid; gap: 10px; max-height: min(720px, 68vh); overflow-y: auto; }
.set-card { width: 100%; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; transition: opacity .16s ease, transform .16s ease, border-color .16s ease; }
.set-card.dirty { border-color: rgba(109, 108, 245, .68); }
.set-card[draggable="true"] .set-card-header { cursor: grab; }
.set-card.dragging { opacity: .38; transform: scale(.988); border-color: var(--primary); }
.set-card.dragging .set-card-header { cursor: grabbing; }
.set-card-header { min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, .012); }
.set-drag-handle { width: 28px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; color: var(--muted); font-size: 17px; cursor: grab; }
.set-card[draggable="true"] .set-drag-handle:hover { background: var(--surface-3); color: var(--text); }
.set-card:not([draggable="true"]) .set-drag-handle { opacity: .34; cursor: default; }
.set-drop-indicator { min-height: 30px; display: grid; place-items: center; border: 2px dashed #8b89ff; border-radius: 9px; background: rgba(109, 108, 245, .13); color: #cfceff; font-size: 12px; font-weight: 800; letter-spacing: .01em; pointer-events: none; }
.set-number { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 7px; background: var(--primary-soft); color: #aaa9ff; font-size: 12px; font-weight: 800; }
.set-name { min-width: 0; flex: 1; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); padding: 7px 8px; font-weight: 800; }
.set-name:hover, .set-name:focus { border-color: var(--border-strong); background: var(--surface-2); }
.set-card-summary { min-width: 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.set-card:not(.collapsed) .set-card-summary { display: none; }
.set-actions { display: flex; align-items: center; gap: 4px; }
.set-actions button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.set-actions button:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.set-actions .preview-set.active { background: var(--primary-soft); color: #c2c1ff; box-shadow: inset 0 0 0 1px rgba(139, 137, 255, .36); }
.set-actions button.delete:hover { color: #ff9ca5; }
.set-card-body { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(150px, 1.25fr) minmax(150px, 1fr) minmax(140px, 1fr) auto; align-items: end; gap: 13px; padding: 16px; }

.field, .choice-field { display: grid; gap: 7px; color: var(--muted-strong); font-size: 13px; font-weight: 700; }
.field span, .choice-field span { display: block; }
.field small, .choice-field small { color: var(--muted); font-weight: 500; line-height: 1.4; }
input[type="text"], input[type="number"], select {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 7px;
    background: #0c1119;
    color: var(--text);
}
select option:disabled { color: #657084; }
input[type="color"] { width: 42px; height: 32px; padding: 2px; border: 1px solid var(--border-strong); border-radius: 6px; background: #0c1119; }
input[type="range"] { width: min(190px, 100%); accent-color: var(--primary); }
.save-set { min-width: 104px; }

.empty-state { display: grid; justify-items: center; gap: 9px; padding: 42px 24px; text-align: center; }
.empty-state > i { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: #9b9aff; font-size: 18px; }
.empty-state h2, .empty-state h3, .empty-state p { margin: 0; }
.empty-state p { max-width: 480px; color: var(--muted); line-height: 1.55; }
.empty-state.compact { padding: 34px 20px; border: 0; background: transparent; }

.generation-card { margin-top: 24px; padding: 22px; }
.generation-intro { align-items: center; }
.generation-intro h2 { margin: 4px 0 7px; }
.generate-button { min-height: 48px; padding-inline: 20px; }
.generation-progress { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border); }
.progress-topline, .progress-meta { display: flex; justify-content: space-between; gap: 18px; }
.progress-topline div { display: grid; gap: 4px; }
.progress-topline span, .progress-meta { color: var(--muted); font-size: 12px; }
#progress-percent { color: #b8b7ff; font-size: 22px; }
progress { width: 100%; height: 10px; margin: 14px 0 10px; border: 0; border-radius: 999px; overflow: hidden; background: var(--surface-3); accent-color: var(--primary); }
progress::-webkit-progress-bar { background: var(--surface-3); }
progress::-webkit-progress-value { border-radius: inherit; background: var(--primary); }
progress::-moz-progress-bar { border-radius: inherit; background: var(--primary); }
.progress-actions { display: flex; gap: 8px; margin-top: 14px; }
.progress-meta span:nth-child(2) { margin-left: auto; }
.generation-complete { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; margin-top: 20px; padding: 18px; border: 1px solid rgba(56, 201, 148, .4); border-radius: 11px; background: rgba(56, 201, 148, .09); }
.generation-complete-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 50%; background: rgba(56, 201, 148, .16); color: var(--success); font-size: 22px; }
.generation-complete div { display: grid; gap: 4px; }
.generation-complete strong { font-size: 17px; }
.generation-complete p { margin: 0; color: var(--muted-strong); font-size: 13px; line-height: 1.5; }
.generation-complete .button { min-width: 170px; }

.settings-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.settings-card { padding: 22px; }
.settings-card h2 { margin: 0 0 18px; font-size: 17px; }
.preset-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 20px 0 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.preset-bar > span { margin-right: 4px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.preset-bar button { min-height: 34px; padding: 7px 11px; border: 1px solid var(--border-strong); border-radius: 7px; background: #0c1119; color: var(--muted-strong); font-size: 12px; font-weight: 750; }
.preset-bar button:hover { border-color: var(--primary); color: var(--text); }
.preset-bar button i { margin-right: 5px; color: #9f9eff; }
.control-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.control-grid.colors label { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted-strong); font-weight: 700; }
.color-control { display: inline-flex; align-items: center; gap: 7px; }
.color-control output { min-width: 56px; color: var(--muted); font-family: "Courier New", monospace; font-size: 10px; text-align: right; }
.toggle-control input { width: 18px; height: 18px; accent-color: var(--primary); }
.control-stack { display: grid; gap: 18px; }
.control-stack > label { display: grid; gap: 8px; color: var(--muted-strong); font-weight: 700; }
.control-stack label span { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.control-stack output { width: 48px; color: var(--muted); font-size: 12px; text-align: right; }
.appearance-selects { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }

.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 0; padding: 0; border: 0; }
.radio-cards legend { margin-bottom: 12px; color: var(--muted-strong); font-weight: 800; }
.radio-cards label { position: relative; }
.radio-cards input { position: absolute; opacity: 0; pointer-events: none; }
.radio-cards label > span { min-height: 145px; display: grid; align-content: start; gap: 8px; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: #0c1119; cursor: pointer; }
.radio-cards i { color: #9f9eff; font-size: 18px; }
.radio-cards small { color: var(--muted); line-height: 1.5; }
.radio-cards input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.radio-cards input:focus-visible + span { outline: 3px solid rgba(124, 123, 255, .52); outline-offset: 2px; }
.radio-cards label.unavailable > span { opacity: .45; cursor: not-allowed; }
.field.full { margin-top: 20px; }
.custom-symbol-editor { margin-top: 20px; padding: 18px; border: 1px solid var(--border); border-radius: 10px; background: #0c1119; }
.custom-symbol-editor .field.full { margin-top: 0; }
.symbol-editor-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 9px; color: var(--muted); font-size: 11px; }
.symbol-validation { min-height: 18px; margin-top: 7px; color: #f2a2a2; font-size: 11px; font-weight: 700; }
.symbol-validation.valid { color: var(--success); }
.symbol-map { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; max-height: 150px; overflow: auto; margin-top: 10px; }
.symbol-map span { padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 11px; }
.symbol-map strong { color: var(--text); }

.export-card { display: grid; gap: 22px; }
.custom-size-fields { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: #0c1119; }
.export-validation { margin: -4px 0 0; color: var(--muted); font-size: 11px; }
.export-validation.error { color: #f2a2a2; font-weight: 700; }
.filename-preview { display: grid; gap: 6px; padding: 13px 14px; border: 1px solid var(--border); border-radius: 8px; background: #0c1119; }
.filename-preview span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.filename-preview strong { overflow-wrap: anywhere; color: var(--muted-strong); font-family: "Courier New", monospace; font-size: 12px; }
.export-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.export-progress { display: grid; gap: 10px; padding: 14px; border: 1px solid rgba(124, 123, 255, .28); border-radius: 8px; background: var(--primary-soft); }
.export-progress > div { display: grid; gap: 4px; }
.export-progress span { color: var(--muted); font-size: 11px; }
.export-progress progress { width: 100%; height: 8px; accent-color: var(--primary); }
.batch-ready { display: flex; align-items: center; gap: 13px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; background: rgba(255,255,255,.015); }
.batch-ready > i { color: #9f9eff; }
.batch-ready div { display: grid; gap: 4px; }
.batch-ready span { color: var(--muted); font-size: 12px; }
.coming-soon { display: flex; align-items: center; gap: 13px; padding: 14px; border: 1px solid rgba(244, 184, 96, .25); border-radius: 8px; background: rgba(244, 184, 96, .06); }
.coming-soon > i { color: var(--warning); }
.coming-soon div { display: grid; gap: 4px; }
.coming-soon span { color: var(--muted); font-size: 12px; }

.preview-panel {
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height) - var(--footer-height));
    overflow: auto;
    padding: 28px 22px;
    border-left: 1px solid var(--border);
    background: #0c1017;
}
.preview-header { align-items: center; }
.preview-header h2 { margin: 4px 0 0; font-size: 20px; }
.preview-header-actions { display: flex; align-items: center; gap: 8px; }
.preview-enlarge { min-height: 38px; padding: 8px 11px; font-size: 11px; white-space: nowrap; }
.preview-set-name { display: grid; grid-template-columns: auto 1fr; gap: 2px 9px; margin: 16px 0 0; padding: 11px 12px; border: 1px solid rgba(109, 108, 245, .28); border-radius: 9px; background: var(--primary-soft); }
.preview-set-name i { grid-row: 1 / span 2; align-self: center; color: #aaa9ff; }
.preview-set-name span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.preview-set-name strong { overflow: hidden; color: var(--text); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.preview-help { margin: 13px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: 20px 0; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--page); }
.segmented button { min-height: 34px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface-3); color: var(--text); }
.preview-content { min-height: 300px; display: grid; align-content: start; gap: 20px; }
.preview-empty { min-height: 310px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 30px; border: 1px dashed var(--border-strong); border-radius: 11px; color: var(--muted); text-align: center; }
.preview-empty i { color: #7776df; font-size: 27px; }
.preview-empty strong { color: var(--muted-strong); }
.preview-empty span { font-size: 12px; line-height: 1.5; }
.preview-board-group { display: grid; gap: 9px; }
.preview-board-group > strong { color: var(--muted-strong); font-size: 12px; }
.sudoku-canvas-wrap {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #e8ebf0 25%, transparent 25%),
        linear-gradient(-45deg, #e8ebf0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e8ebf0 75%),
        linear-gradient(-45deg, transparent 75%, #e8ebf0 75%);
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-size: 16px 16px;
}
.sudoku-canvas { width: 100%; height: 100%; display: block; aspect-ratio: 1; }
.preview-content.both { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.preview-larger-tip { display: flex; align-items: center; gap: 7px; margin: 13px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.preview-larger-tip i { color: #aaa9ff; }
.preview-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 18px; }
.preview-meta span { display: grid; gap: 3px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.preview-meta strong { color: var(--text); font-size: 12px; text-transform: none; letter-spacing: 0; }

.preview-dialog {
    width: min(1240px, calc(100vw - 32px));
    max-width: none;
    height: min(900px, calc(100vh - 32px));
    max-height: none;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 15px;
    background: #0c1017;
    color: var(--text);
    box-shadow: 0 28px 100px rgba(0,0,0,.65);
}
.preview-dialog::backdrop { background: rgba(3, 5, 9, .84); backdrop-filter: blur(4px); }
.preview-dialog-shell { height: 100%; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; }
.preview-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 20px 22px 15px; border-bottom: 1px solid var(--border); background: var(--surface); }
.preview-dialog-header h2 { margin: 4px 0 3px; font-size: clamp(20px, 2.5vw, 28px); }
.preview-dialog-header p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.preview-dialog-tools { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 22px; border-bottom: 1px solid var(--border); background: #0e141d; }
.preview-dialog-modes { width: min(360px, 100%); margin: 0; }
.preview-zoom { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.preview-zoom .icon-button { width: 38px; height: 38px; }
.preview-zoom > label { min-width: 180px; display: grid; grid-template-columns: minmax(100px, 1fr) 44px; align-items: center; gap: 8px; }
.preview-zoom input { width: 100%; accent-color: var(--primary); }
.preview-zoom output { color: var(--muted-strong); font-size: 11px; font-weight: 800; text-align: right; }
.preview-zoom .button { min-height: 38px; padding: 8px 11px; font-size: 11px; white-space: nowrap; }
.preview-dialog-set { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 22px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; }
.preview-dialog-set i { color: #aaa9ff; }
.preview-dialog-set span { font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.preview-dialog-set strong { min-width: 0; overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.preview-large-viewport { min-height: 0; overflow: auto; padding: 28px; overscroll-behavior: contain; background: #080b10; }
.preview-large-stage { width: 760px; max-width: none; margin: 0 auto; transition: width .16s ease; }
.preview-large-stage.measuring { transition: none; }
.preview-large-stage .preview-content { min-height: 0; }
.preview-large-stage .preview-board-group > strong { font-size: 13px; }
.preview-dialog-note { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; padding: 11px 18px; border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 11px; text-align: center; }
.preview-dialog-note i { color: #aaa9ff; }
.preview-dialog.is-fullscreen { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; border: 0; border-radius: 0; }

.confirm-dialog { width: min(430px, calc(100% - 32px)); padding: 0; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--surface-2); color: var(--text); box-shadow: 0 26px 90px rgba(0,0,0,.55); }
.confirm-dialog::backdrop { background: rgba(3, 5, 9, .75); }
.confirm-dialog form { padding: 24px; }
.dialog-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 9px; background: rgba(239, 101, 115, .1); color: var(--danger); }
.confirm-dialog h2 { margin: 18px 0 8px; }
.confirm-dialog p { margin: 0; color: var(--muted); line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }

.project-dialog { width: min(780px, calc(100% - 32px)); max-height: min(760px, calc(100vh - 32px)); padding: 0; overflow: auto; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface-2); color: var(--text); box-shadow: 0 26px 90px rgba(0,0,0,.55); }
.project-dialog::backdrop { background: rgba(3, 5, 9, .78); }
.project-dialog-header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px 16px; background: var(--surface-2); }
.project-dialog-header h2 { margin: 4px 0 0; font-size: 26px; }
.project-dialog-help { margin: 0; padding: 0 24px 18px; color: var(--muted); line-height: 1.55; }
.project-list { display: grid; gap: 9px; padding: 0 24px 22px; }
.project-list-loading { min-height: 88px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.project-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 13px; padding: 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); transition: opacity .16s ease, transform .16s ease, border-color .16s ease; }
.project-card.current { border-color: rgba(109, 108, 245, .65); background: var(--primary-soft); }
.project-card.dragging { opacity: .38; transform: scale(.988); border-color: var(--primary); }
.project-drag-handle { width: 28px; height: 42px; display: grid; place-items: center; border-radius: 7px; color: var(--muted); font-size: 17px; cursor: grab; }
.project-card[draggable="true"] .project-drag-handle:hover { background: var(--surface-3); color: var(--text); }
.project-card:not([draggable="true"]) .project-drag-handle { opacity: .34; cursor: default; }
.project-card.dragging .project-drag-handle { cursor: grabbing; }
.project-card-copy { min-width: 0; display: grid; gap: 5px; }
.project-card-copy strong { overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.project-card-copy span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.project-card-actions { display: flex; align-items: center; gap: 5px; }
.project-card-actions .project-open { min-width: 116px; }
.project-card-actions > button:not(.project-open) { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border: 0; border-radius: 7px; background: transparent; color: var(--muted); }
.project-card-actions > button:not(.project-open):hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.project-card-actions .project-delete:hover:not(:disabled) { color: #ff9ca5; }
.project-drop-indicator { min-height: 30px; display: grid; place-items: center; border: 2px dashed #8b89ff; border-radius: 9px; background: rgba(109, 108, 245, .13); color: #cfceff; font-size: 12px; font-weight: 800; pointer-events: none; }
.project-current-label { color: #c7c6ff !important; font-weight: 750; }
.new-project-panel { position: sticky; bottom: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; padding: 18px 24px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.new-project-panel .field { margin: 0; }

.tour-dialog { width: min(540px, calc(100% - 28px)); padding: 30px; border: 1px solid var(--border-strong); border-radius: 16px; background: var(--surface-2); color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.62); }
.tour-dialog::backdrop { background: rgba(3, 5, 9, .78); backdrop-filter: blur(3px); }
.tour-close { position: absolute; top: 14px; right: 14px; width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 18px; }
.tour-close:hover { background: var(--surface-3); color: var(--text); }
.tour-visual { min-height: 150px; display: grid; place-items: center; margin: -30px -30px 24px; border-radius: 16px 16px 0 0; background: radial-gradient(circle at 50% 25%, rgba(138, 136, 255, .34), transparent 58%), #0d111a; }
.tour-visual span { width: 82px; height: 82px; display: grid; place-items: center; border: 1px solid rgba(169, 168, 255, .42); border-radius: 24px; background: rgba(109, 108, 245, .2); color: #c4c3ff; font-size: 34px; box-shadow: 0 16px 40px rgba(48, 46, 160, .28); }
.tour-progress { margin: 0 0 7px; color: #aaa9ff; font-size: 11px; font-weight: 850; letter-spacing: .08em; text-transform: uppercase; }
.tour-dialog h2 { margin: 0 42px 9px 0; font-size: 27px; }
.tour-dialog > p:not(.tour-progress) { margin: 0; color: var(--muted-strong); font-size: 15px; line-height: 1.65; }
.tour-tip { display: flex; align-items: flex-start; gap: 10px; margin-top: 18px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 9px; background: #0c1119; color: var(--muted); font-size: 12px; line-height: 1.5; }
.tour-tip i { margin-top: 2px; color: var(--warning); }
.tour-dots { display: flex; justify-content: center; gap: 7px; margin: 22px 0; }
.tour-dots span { width: 8px; height: 8px; border-radius: 999px; background: var(--border-strong); transition: width .18s ease, background .18s ease; }
.tour-dots span.active { width: 24px; background: var(--primary); }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tour-actions > div { display: flex; gap: 8px; }

.app-footer { min-height: var(--footer-height); display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 7px; padding: 18px 24px; border-top: 1px solid var(--border); background: #0c1017; color: var(--muted); font-size: 13px; text-align: center; }
.app-footer-main { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 9px 24px; }
.app-footer strong { color: var(--muted-strong); }
.app-footer a { display: inline-flex; align-items: center; gap: 7px; color: #bdbcff; text-decoration: none; }
.app-footer a:hover { color: #fff; text-decoration: underline; }
.app-footer p { margin: 0; line-height: 1.45; }
.app-footer-legal { max-width: 840px; color: #788598; font-size: 11px; }
.app-version { display: inline-flex; align-items: center; gap: 7px; color: var(--muted-strong); }

.custom-font-panel { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-top: 16px; padding: 13px; border: 1px solid var(--border); border-radius: 9px; background: #0c1119; }
.custom-font-panel > i { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: #bdbcff; }
.custom-font-copy { display: grid; gap: 3px; min-width: 0; }
.custom-font-copy strong { color: var(--text); font-size: 13px; }
.custom-font-copy span, .custom-font-status { color: var(--muted); font-size: 11px; line-height: 1.45; }
.custom-font-status { grid-column: 2 / -1; margin: -3px 0 0; }
.custom-font-status.ready { color: var(--success); }
.custom-font-status.error { color: var(--danger); }
.custom-font-panel input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.custom-font-panel .button { white-space: nowrap; }
.google-font-launcher { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; margin-top: 20px; padding: 16px; border: 1px solid #354156; border-radius: 12px; background: linear-gradient(135deg, rgba(109,108,245,.10), rgba(255,255,255,.015) 55%), #0c1119; }
.google-font-launcher-icon { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(149,148,255,.22); border-radius: 11px; background: var(--primary-soft); color: #bdbcff; font-size: 17px; }
.google-font-launcher-copy { min-width: 0; display: grid; gap: 4px; }
.google-font-launcher-copy > strong { font-size: 14px; color: var(--text); }
.google-font-launcher-copy > span { max-width: 510px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.google-font-current { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--muted-strong) !important; font-weight: 700; }
.google-font-current i { color: #8d98aa; }
.google-font-current.selected i { color: var(--success); }

.font-dialog { width: min(960px, calc(100% - 32px)); height: min(780px, calc(100vh - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow: hidden; border: 1px solid var(--border-strong); border-radius: 16px; background: #101620; color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.62); }
.font-dialog[open] { display: flex; flex-direction: column; }
.font-dialog::backdrop { background: rgba(3,5,9,.82); backdrop-filter: blur(4px); }
.font-dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; flex: 0 0 auto; padding: 24px 26px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(135deg, rgba(109,108,245,.10), transparent 60%), var(--surface-2); }
.font-dialog-header h2 { margin: 4px 0 7px; font-size: 26px; }
.font-dialog-header p:last-child { max-width: 660px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.font-dialog-tools { display: grid; gap: 14px; flex: 0 0 auto; padding: 18px 26px 15px; }
.font-search { min-height: 52px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 0 10px 0 16px; border: 1px solid var(--border-strong); border-radius: 11px; background: #090e15; color: var(--muted); transition: border-color .15s ease, box-shadow .15s ease; }
.font-search:focus-within { border-color: #7776f6; box-shadow: 0 0 0 3px rgba(109,108,245,.15); }
.font-search > i { font-size: 15px; }
.font-search input { min-width: 0; width: 100%; height: 48px; padding: 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 15px; }
.font-search input::placeholder { color: #778397; }
.font-search input::-webkit-search-cancel-button { display: none; }
.font-search button { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 7px; background: var(--surface-3); color: var(--muted); }
.font-search button:hover { color: var(--text); }
.font-filter-list { display: flex; gap: 7px; overflow-x: auto; padding: 1px 1px 3px; scrollbar-width: thin; }
.font-filter-list button { min-height: 36px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--muted-strong); font-size: 12px; font-weight: 750; white-space: nowrap; }
.font-filter-list button:hover { border-color: var(--border-strong); color: var(--text); }
.font-filter-list button.active { border-color: rgba(149,148,255,.45); background: var(--primary-soft); color: #deddff; }
.font-library-options { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.font-view-list { min-width: 0; }
.font-layout-switch { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 9px; background: #090e15; }
.font-layout-switch button { min-height: 30px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 10px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 750; }
.font-layout-switch button:hover { color: var(--text); }
.font-layout-switch button.active { background: var(--surface-3); color: #deddff; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.font-subset-field { display: grid; gap: 5px; flex: 0 0 190px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.font-subset-field select { width: 100%; min-height: 38px; padding: 7px 30px 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: #0b1018; color: var(--muted-strong); font-size: 12px; text-transform: none; }
.font-results-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex: 0 0 auto; padding: 0 26px 12px; }
.font-results-heading p, .font-results-heading small { margin: 0; color: var(--muted); font-size: 12px; }
.font-results-heading p { color: var(--muted-strong); font-weight: 700; }
.font-results-heading p.error { color: var(--danger); }
.font-preview-text-field { min-width: min(360px, 52%); display: grid; grid-template-columns: auto minmax(160px, 1fr); align-items: center; gap: 9px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.font-preview-text-field input { min-width: 0; width: 100%; height: 36px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; outline: 0; background: #090e15; color: var(--text); font-size: 12px; text-transform: none; }
.font-preview-text-field input:focus { border-color: #7776f6; box-shadow: 0 0 0 3px rgba(109,108,245,.14); }
.font-result-grid { min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; flex: 1 1 auto; align-content: start; overflow-y: auto; padding: 0 26px 22px; }
.font-result-grid.layout-row { grid-template-columns: 1fr; }
.font-result-card { position: relative; min-width: 0; min-height: 194px; display: flex; flex-direction: column; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 11px; background: #0c1119; color: var(--text); text-align: left; transition: border-color .15s ease, background .15s ease, transform .15s ease; }
.font-result-card:hover { border-color: #5f60a2; background: #121827; transform: translateY(-1px); }
.font-result-grid[aria-busy="true"] .font-result-card { pointer-events: none; opacity: .62; }
.font-result-card.selected { border-color: rgba(56,201,148,.52); background: rgba(56,201,148,.065); }
.font-card-top { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.font-card-heading { min-width: 0; display: grid; gap: 4px; }
.font-card-top strong { overflow: hidden; color: #f7f8fc; font-size: 20px; font-weight: 500; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.font-card-top span { color: #788598; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 9px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.font-card-buttons { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.font-favorite { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: #657184; }
.font-favorite:hover, .font-favorite.active { border-color: rgba(244,184,96,.4); color: var(--warning); background: rgba(244,184,96,.08); }
.font-google-link { width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 8px; background: transparent; color: #7f8a9c; text-decoration: none; }
.font-google-link:hover { border-color: rgba(149,148,255,.45); background: var(--primary-soft); color: #c5c4ff; }
.font-card-preview { min-width: 0; min-height: 48px; overflow: hidden; display: flex; align-items: center; color: #f7f8fc; line-height: 1.25; text-overflow: ellipsis; }
.font-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: #7f8a9c; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 10px; }
.font-card-meta a { color: #9d9cff; text-decoration: none; }
.font-card-meta a:hover { text-decoration: underline; }
.font-card-action { width: 100%; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; margin-top: auto; border: 1px solid rgba(149,148,255,.24); border-radius: 8px; background: var(--primary-soft); color: #c5c4ff; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-size: 11px; font-weight: 800; }
.font-card-action:hover { border-color: rgba(149,148,255,.5); background: rgba(109,108,245,.2); }
.font-result-card.selected .font-card-action { color: var(--success); }
.font-result-grid.layout-row .font-result-card { min-height: 110px; display: grid; grid-template-columns: minmax(190px, .85fr) minmax(260px, 1.35fr) minmax(145px, .55fr); grid-template-rows: auto auto; align-items: center; gap: 8px 20px; }
.font-result-grid.layout-row .font-card-top { grid-column: 1; grid-row: 1 / 3; }
.font-result-grid.layout-row .font-card-preview { grid-column: 2; grid-row: 1 / 3; }
.font-result-grid.layout-row .font-card-meta { grid-column: 3; grid-row: 1; }
.font-result-grid.layout-row .font-card-action { grid-column: 3; grid-row: 2; margin-top: 0; }
.font-empty-state { grid-column: 1 / -1; min-height: 220px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 28px; color: var(--muted); text-align: center; }
.font-empty-state i { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); color: #8d98aa; font-size: 18px; }
.font-empty-state strong { color: var(--text); }
.font-dialog-footer { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 0; padding: 0 26px 16px; }
.font-dialog-footer .button { min-width: 120px; min-height: 38px; }
.font-dialog-footer > span { min-width: 110px; color: var(--muted); font-size: 11px; font-weight: 750; text-align: center; }
.font-upload-panel { flex: 0 0 auto; border-top: 1px solid var(--border); background: #0c1119; }
.font-upload-panel summary { min-height: 54px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 26px; color: var(--muted-strong); cursor: pointer; list-style: none; }
.font-upload-panel summary::-webkit-details-marker { display: none; }
.font-upload-panel summary > span { display: inline-flex; align-items: center; gap: 9px; }
.font-upload-panel summary i { color: #aaa9ff; }
.font-upload-panel summary small { color: var(--muted); }
.font-dropzone { display: grid; place-items: center; gap: 7px; margin: 0 26px 12px; padding: 18px; border: 1px dashed #46536a; border-radius: 11px; background: rgba(255,255,255,.015); color: var(--muted); text-align: center; transition: border-color .15s ease, background .15s ease; }
.font-dropzone.drag-over { border-color: #8f8eff; background: var(--primary-soft); }
.font-dropzone > i { color: #aaa9ff; font-size: 22px; }
.font-dropzone strong { color: var(--text); }
.font-dropzone span, .font-dropzone small { font-size: 11px; }
.font-dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.font-upload-panel .custom-font-status { margin: 0 26px 14px; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 60; display: grid; gap: 9px; width: min(370px, calc(100% - 32px)); }
.toast-region[popover] { inset: auto 22px 22px auto; margin: 0; padding: 0; overflow: visible; border: 0; background: transparent; color: inherit; }
.toast-region[popover]::backdrop { display: none; }
.toast { display: flex; align-items: flex-start; gap: 11px; padding: 13px 14px; border: 1px solid var(--border-strong); border-radius: 9px; background: #171e2a; box-shadow: 0 16px 46px rgba(0,0,0,.38); }
.toast i { margin-top: 2px; color: var(--success); }
.toast.error i { color: var(--danger); }
.toast div { display: grid; gap: 3px; }
.toast span { color: var(--muted); font-size: 12px; line-height: 1.45; }

@media (max-width: 1360px) {
    .app-layout { grid-template-columns: 210px minmax(520px, 1fr); }
    .preview-panel { position: fixed; inset: var(--header-height) 0 0 auto; z-index: 45; width: min(430px, 92vw); height: calc(100vh - var(--header-height)); transform: translateX(102%); transition: transform .2s ease; box-shadow: -22px 0 60px rgba(0,0,0,.45); }
    body.preview-open .preview-panel { transform: translateX(0); }
    body.preview-open { overflow: hidden; }
    .preview-scrim { position: fixed; inset: var(--header-height) 0 0; z-index: 40; border: 0; background: rgba(3, 5, 9, .72); cursor: default; }
    body.preview-open .preview-scrim { display: block; }
    .preview-toggle, .preview-close { display: inline-grid; }
    .set-card-body { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
    .save-set { grid-column: 3; grid-row: 1 / span 2; align-self: stretch; }
}

@media (max-width: 820px) {
    :root { --header-height: 64px; }
    .app-header { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; padding: 0 12px; }
    .brand strong { font-size: 13px; }
    .brand small, .project-identity label, .save-status { display: none; }
    .brand img { width: 34px; height: 34px; }
    .header-reset { width: 44px; padding: 0; }
    .header-reset span { display: none; }
    .project-identity input { width: 100%; text-align: center; }
    .app-layout { display: block; }
    .sidebar { position: sticky; top: var(--header-height); z-index: 20; width: 100%; height: auto; padding: 7px 8px; border-right: 0; border-bottom: 1px solid var(--border); }
    .section-nav { grid-template-columns: repeat(4, 1fr); gap: 4px; }
    .nav-item { min-height: 52px; flex-direction: column; justify-content: center; gap: 4px; padding: 6px 3px; font-size: 10px; line-height: 1.1; text-align: center; }
    .nav-item i { height: 17px; }
    .nav-item span { display: block; }
    .sidebar-summary { display: none; }
    .workspace { padding: 26px 16px 60px; }
    .workspace-heading { align-items: center; }
    .settings-grid { grid-template-columns: 1fr; }
    .radio-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .radio-cards label > span { min-height: auto; }
    .control-grid { grid-template-columns: 1fr; }
    .appearance-selects { grid-template-columns: 1fr; }
    .custom-size-fields { grid-template-columns: 1fr; }
    .preview-panel { width: min(430px, 100vw); }
    .preview-dialog { width: calc(100vw - 16px); height: calc(100vh - 16px); }
    .preview-dialog-tools { align-items: stretch; flex-direction: column; }
    .preview-dialog-modes { width: 100%; }
    .preview-zoom { justify-content: center; flex-wrap: wrap; }
    .preview-zoom > label { flex: 1 1 180px; }
    .quick-start { grid-template-columns: 1fr; }
    .quick-start li { padding: 10px 12px; }
}

@media (max-width: 620px) {
    .brand span { display: none; }
    .workspace-heading, .generation-intro { align-items: stretch; flex-direction: column; }
    .workspace-heading .button, .generate-button { width: 100%; }
    .set-card-header { flex-wrap: wrap; }
    .set-name { order: 1; width: calc(100% - 46px); flex: none; }
    .set-card-summary { order: 2; width: 100%; }
    .set-actions { order: 3; width: 100%; justify-content: flex-end; padding-top: 7px; border-top: 1px solid var(--border); }
    .set-card-body { grid-template-columns: 1fr; }
    .save-set { grid-column: auto; grid-row: auto; min-height: 44px; }
    .progress-topline, .progress-meta { align-items: flex-start; flex-direction: column; }
    .generation-complete { grid-template-columns: auto minmax(0, 1fr); }
    .generation-complete .button { grid-column: 1 / -1; width: 100%; }
    .preview-content.both { grid-template-columns: 1fr; }
    .preview-header { align-items: flex-start; }
    .preview-header-actions { align-items: flex-end; flex-direction: column-reverse; }
    .preview-dialog-header { padding: 16px 14px 12px; }
    .preview-dialog-tools { padding: 10px 12px; }
    .preview-zoom .button { flex: 1 1 auto; }
    .preview-dialog-set { padding: 9px 14px; }
    .preview-large-viewport { padding: 16px; }
    .preview-dialog-note { padding: 9px 12px; }
    .radio-cards { grid-template-columns: 1fr; }
    .symbol-editor-meta { align-items: flex-start; flex-direction: column; }
    .export-actions .button, .progress-actions .button { width: 100%; }
    .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
    .dialog-actions .button { width: 100%; }
    .project-dialog { width: calc(100% - 20px); max-height: calc(100vh - 20px); }
    .project-dialog-header { padding: 18px 16px 14px; }
    .project-dialog-help, .project-list { padding-left: 16px; padding-right: 16px; }
    .project-card { grid-template-columns: auto minmax(0, 1fr); }
    .project-card-actions { grid-column: 1 / -1; width: 100%; }
    .project-card-actions .project-open { flex: 1; }
    .new-project-panel { grid-template-columns: 1fr; padding: 16px; }
    .new-project-panel .button { width: 100%; }
    .tour-dialog { padding: 24px 18px 18px; }
    .tour-visual { min-height: 126px; margin: -24px -18px 20px; }
    .tour-actions { align-items: stretch; flex-direction: column-reverse; }
    .tour-actions > div { display: grid; grid-template-columns: 1fr 1.4fr; }
    .tour-actions > .button { width: 100%; }
    .toast-region { right: 12px; bottom: 12px; width: calc(100% - 24px); }
    .custom-font-panel { grid-template-columns: auto minmax(0, 1fr); }
    .custom-font-panel .button { grid-column: 1 / -1; width: 100%; }
    .custom-font-status { grid-column: 1 / -1; }
    .google-font-launcher { grid-template-columns: auto minmax(0, 1fr); }
    .google-font-launcher .button { grid-column: 1 / -1; width: 100%; }
    .font-dialog { width: calc(100% - 20px); height: calc(100vh - 20px); max-height: calc(100vh - 20px); }
    .font-dialog-header { padding: 18px 16px 15px; }
    .font-dialog-header h2 { font-size: 22px; }
    .font-dialog-tools { padding: 14px 16px 12px; }
    .font-library-options { align-items: stretch; flex-direction: column; }
    .font-subset-field { flex-basis: auto; }
    .font-results-heading { align-items: stretch; flex-direction: column; padding: 0 16px 10px; }
    .font-preview-text-field { min-width: 0; width: 100%; grid-template-columns: 1fr; gap: 5px; }
    .font-result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 16px 18px; }
    .font-result-grid.layout-row .font-result-card { min-height: 170px; display: flex; }
    .font-dialog-footer { padding: 0 16px 16px; }
    .font-dialog-footer .button { min-width: 0; flex: 1; }
    .font-dialog-footer > span { min-width: 80px; }
    .font-upload-panel summary { padding-inline: 16px; }
    .font-dropzone { margin-inline: 16px; }
    .font-upload-panel .custom-font-status { margin-inline: 16px; }
}

@media (max-width: 420px) {
    .app-header { grid-template-columns: 38px minmax(0, 1fr) auto; }
    .project-identity input { padding-inline: 6px; font-size: 12px; }
    .workspace { padding-inline: 12px; }
    .nav-item { min-height: 58px; font-size: 10.5px; }
    .font-result-grid { grid-template-columns: 1fr; }
    .font-result-card { min-height: 190px; }
    .font-result-grid.layout-row .font-result-card { min-height: 190px; }
    .font-dialog-footer { gap: 7px; }
    .font-dialog-footer .button { padding-inline: 8px; font-size: 11px; }
    .font-upload-panel summary small { display: none; }
}

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

@media (forced-colors: active) {
    :focus-visible { outline: 3px solid Highlight; }
    .nav-item.active, .set-actions .preview-set.active, .radio-cards input:checked + span { border: 2px solid Highlight; }
    .spinner { border-top-color: Highlight; }
}
