@font-face {
    font-family: 'Classy';
    src: url('https://vkfonts.storage.googleapis.com/classy.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}

:root {
    --bg-deep:        #07070e;
    --bg-surface:     #0d0d1a;
    --bg-card:        #111122;
    --bg-input:       #090914;
    --border:         #252540;
    --border-active:  #7744cc;
    --text-primary:   #e6e2ff;
    --text-secondary: #9080bb;
    --text-muted:     #504070;
    --accent:         #8844ee;
    --accent-soft:    rgba(136,68,238,0.15);
    --accent-glow:    rgba(136,68,238,0.35);
    --danger:         #ff4466;
    --danger-soft:    rgba(255,68,102,0.1);
    --radius-sm:      8px;
    --radius-md:      14px;
    --radius-lg:      20px;
    --T:              0.22s cubic-bezier(0.4,0,0.2,1);
    --font-classy:    'Classy','Georgia','Times New Roman',serif;
    --font-mono:      'JetBrains Mono','Fira Code','Cascadia Code','Consolas',monospace;
    --font-sans:      'Inter','Segoe UI',system-ui,-apple-system,sans-serif;

    /* ── install.css variable aliases ── */
    --glass-bg:  rgba(17,17,34,0.88);
    --glass-bd:  #252540;
    --nm-deep:   0 8px 32px rgba(0,0,0,0.6);
    --nm-btn:    0 2px 8px rgba(0,0,0,0.4);
    --acc-d:     rgba(136,68,238,0.18);
    --acc:       #8844ee;
    --txt:       #e6e2ff;
    --txt2:      #9080bb;
    --bd2:       #252540;
    --s2:        #111122;
    --red:       #ff4466;
    --t:         0.22s cubic-bezier(0.4,0,0.2,1);
}

*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html { font-size:16px; -webkit-font-smoothing:antialiased; }

body {
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex; flex-direction: column;
    overflow-x: hidden; line-height: 1.6;
}

::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:var(--border-active); }

/* ── TOPBAR ── */
.topbar {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    padding: 0 24px; height: 58px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    box-shadow: 0 1px 28px rgba(0,0,0,0.6);
}

.topbar-nav {
    display: flex; align-items: center; gap: 4px;
    background: var(--bg-deep); border-radius: 30px; padding: 4px;
    border: 1px solid var(--border);
}

.topbar-item {
    font-family: var(--font-classy);
    font-size: 0.9rem; letter-spacing: 0.03em;
    padding: 8px 20px; border-radius: 26px;
    border: none; background: transparent;
    color: var(--text-secondary);
    cursor: pointer; transition: all var(--T);
    white-space: nowrap; outline: none; user-select: none;
}

.topbar-item:hover { color: var(--text-primary); background: var(--accent-soft); }

.topbar-item.active {
    background: var(--bg-card);
    color: var(--accent);
    box-shadow: 0 2px 12px rgba(0,0,0,0.4), 0 0 0 1px var(--border-active);
}

/* ── INSTALL BUTTON (topbar right slot) ── */
.topbar-right {
    position: absolute; right: 24px;
    display: flex; align-items: center;
}

#installBtn {
    font-family: var(--font-classy);
    font-size: 0.8rem; letter-spacing: 0.04em;
    padding: 7px 16px; border-radius: 22px;
    border: 1px solid var(--border-active);
    background: var(--accent-soft); color: var(--accent);
    cursor: pointer; transition: all var(--T);
    white-space: nowrap; user-select: none; outline: none;
    display: flex; align-items: center; gap: 6px;
}

#installBtn:hover {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 14px var(--accent-glow);
}

/* .mi used in install.js iOS banner */
.mi {
    font-family: 'Material Symbols Rounded', sans-serif;
    font-size: 20px; line-height: 1;
    font-weight: 300; font-style: normal;
    display: inline-block; vertical-align: middle;
}
.mi-sm { font-size: 16px; }

/* ── MAIN ── */
.main-content {
    flex: 1; display: flex; flex-direction: column;
    padding: 24px 24px 0;
    max-width: 1100px; width: 100%;
    margin: 0 auto; gap: 18px;
}

.panel { display: none; flex: 1; flex-direction: column; animation: fadeIn 0.28s ease; }
.panel.active { display: flex; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── BTN BASE ── */
.btn {
    font-family: var(--font-classy);
    font-size: 0.82rem; letter-spacing: 0.04em;
    padding: 8px 18px; border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--bg-deep); color: var(--text-secondary);
    cursor: pointer; transition: all var(--T);
    white-space: nowrap; user-select: none; outline: none;
}

.btn:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
    background: var(--bg-card);
    box-shadow: 0 2px 12px rgba(136,68,238,0.12);
}

.btn.btn-accent {
    background: var(--accent);
    color: #fff; border-color: var(--accent);
    font-weight: 600;
    box-shadow: 0 2px 14px var(--accent-soft);
}

.btn.btn-accent:hover {
    background: #9955ff;
    border-color: #9955ff;
    box-shadow: 0 4px 22px var(--accent-glow);
}

.btn:disabled { opacity: 0.35; pointer-events: none; }

/* ── EDITOR ── */
.editor-wrapper {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--radius-lg); border: 1px solid var(--border);
    overflow: hidden; box-shadow: 0 8px 40px rgba(0,0,0,0.4);
    transition: border-color var(--T), box-shadow var(--T);
}

.editor-wrapper:focus-within {
    border-color: var(--border-active);
    box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 2px var(--accent-soft);
}

.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 20px; border-bottom: 1px solid var(--border);
    background: var(--bg-surface); gap: 12px;
}

.header-label {
    font-family: var(--font-classy);
    font-size: 0.78rem; letter-spacing: 0.08em;
    color: var(--text-muted); text-transform: uppercase;
}

.btn-group { display: flex; gap: 8px; align-items: center; }

.editor-textarea {
    flex: 1; width: 100%;
    min-height: 420px; padding: 20px 24px;
    background: var(--bg-input); color: #ccc6ff;
    font-family: var(--font-mono); font-size: 0.88rem;
    line-height: 1.75; border: none; outline: none;
    resize: vertical; tab-size: 2;
}

.editor-textarea::placeholder { color: var(--text-muted); opacity: 0.65; font-style: italic; }

.editor-footer {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 20px; border-top: 1px solid var(--border);
    background: var(--bg-surface);
    font-size: 0.7rem; color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ── PREVIEW ── */
.preview-wrapper {
    flex: 1; display: flex; flex-direction: column;
    background: var(--bg-card);
    border-radius: var(--radius-lg); border: 1px solid var(--border);
    overflow: hidden; box-shadow: 0 8px 40px rgba(0,0,0,0.4);
    min-height: 500px;
}

.preview-container {
    flex: 1; position: relative; overflow: hidden;
    background: #090914;
    cursor: grab; user-select: none; -webkit-user-select: none;
    min-height: 440px;
}

.preview-container.panning { cursor: grabbing; }

.preview-stage {
    position: absolute; top: 0; left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.preview-stage svg { display: block; overflow: visible; }

.preview-stage svg text,
.preview-stage svg tspan {
    font-family: var(--font-classy) !important;
}

.preview-empty {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-family: var(--font-classy); font-size: 1rem;
    text-align: center; opacity: 0.5; pointer-events: none;
    line-height: 1.8;
}

.preview-error {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    color: var(--danger);
    font-family: var(--font-mono); font-size: 0.82rem;
    padding: 22px 28px; text-align: center; line-height: 1.8;
    background: var(--danger-soft);
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,68,102,0.2);
    max-width: 520px;
}

.zoom-controls {
    position: absolute; bottom: 14px; right: 14px;
    display: flex; gap: 6px; z-index: 10;
}

.zoom-btn {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-secondary); font-size: 1.1rem; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all var(--T); user-select: none;
}

.zoom-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ── SETTINGS ── */
.settings-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg); border: 1px solid var(--border);
    padding: 28px 32px; box-shadow: 0 8px 40px rgba(0,0,0,0.4);
    display: flex; flex-direction: column; gap: 0;
    max-width: 660px; margin: 0 auto; width: 100%;
}

/* All text in settings uses Classy */
.settings-wrapper,
.settings-wrapper label,
.settings-wrapper .btn {
    font-family: var(--font-classy);
}

.settings-section {
    font-family: var(--font-classy);
    font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--text-muted);
    margin-top: 22px; margin-bottom: 14px;
    padding-bottom: 7px; border-bottom: 1px solid var(--border);
}
.settings-section:first-child { margin-top: 0; }

.settings-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px;
}

.setting-item { display: flex; flex-direction: column; gap: 5px; }

.setting-item label {
    font-family: var(--font-classy);
    font-size: 0.82rem; letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.color-row { display: flex; align-items: center; gap: 8px; }

.setting-color {
    width: 38px; height: 32px; padding: 2px 3px;
    border-radius: 6px; border: 1px solid var(--border);
    background: var(--bg-input); cursor: pointer; flex-shrink: 0;
}

.color-hex {
    flex: 1; padding: 5px 10px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    background: var(--bg-input); color: var(--text-primary);
    font-family: var(--font-mono); font-size: 0.8rem;
    outline: none; transition: border-color var(--T);
}

.color-hex:focus { border-color: var(--border-active); }

.setting-input {
    padding: 7px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-input);
    color: var(--text-primary); font-family: var(--font-mono); font-size: 0.84rem;
    outline: none; transition: border-color var(--T); width: 100%;
}

.setting-input:focus { border-color: var(--border-active); }

.settings-actions {
    display: flex; gap: 10px; margin-top: 22px; justify-content: flex-end;
}

/* ── BOTTOM BAR (brand) ── */
.bottombar {
    display: flex; align-items: center; justify-content: center;
    padding: 20px 24px;
    gap: 10px;
    border-top: 1px solid var(--border);
    margin-top: 24px;
}

.brand-logo {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    display: block;
}

.brand-name {
    font-family: var(--font-classy);
    font-size: 1.3rem; letter-spacing: 0.04em;
    color: var(--accent);
    user-select: none;
}

/* ── RESPONSIVE ── */
@media (max-width:640px) {
    .topbar { padding: 0 12px; height: 50px; }
    .topbar-item { padding: 6px 12px; font-size: 0.78rem; }
    .main-content { padding: 12px 10px 0; }
    .editor-textarea { min-height: 280px; font-size: 0.8rem; padding: 14px 16px; }
    .settings-grid { grid-template-columns: 1fr; }
    .settings-wrapper { padding: 18px 16px; }
    .preview-container { min-height: 360px; }
}
