/* ═══════════════════════════════════════════════════════════════
   APPEARANCE MODAL — Themes + Color Customization
   ═══════════════════════════════════════════════════════════════ */

.appearance-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    z-index: 100000;
    display: flex; align-items: center; justify-content: center;
    animation: appear-in 0.2s ease;
}
.appearance-overlay.hidden { display: none; }
@keyframes appear-in { from { opacity: 0; } to { opacity: 1; } }

.appearance-modal {
    background: var(--pc-sidebar, var(--bg-surface, #12121a));
    color: var(--pc-sidebar-text, var(--text-primary));
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 680px;
    max-width: 95vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 64px rgba(0,0,0,0.5);
    animation: appear-card 0.2s ease;
}
@keyframes appear-card { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ── Header ── */
.appearance-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.appearance-header h2 {
    margin: 0; font-size: 18px; font-weight: 700;
    display: flex; align-items: center; gap: 8px;
}
.appearance-close {
    width: 32px; height: 32px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--pc-controls-text, var(--text-muted));
    font-size: 16px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.appearance-close:hover { background: var(--danger-dim); border-color: var(--danger); color: var(--danger); }

/* ── Scrollable body ── */
.appearance-body {
    flex: 1; overflow-y: auto;
    padding: 20px 24px 24px;
}

/* ── Themes Section ── */
.themes-section {
    margin-bottom: 24px;
}
.themes-section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.themes-section-header h3 {
    margin: 0; font-size: 14px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
    opacity: 0.6;
}
.theme-save-btn {
    padding: 5px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--pc-controls-text, var(--text-secondary));
    font-size: 12px; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
}
.theme-save-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent-active-text, var(--accent));
    color: var(--accent-active-text, var(--accent));
}

.themes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.theme-card {
    position: relative;
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
}
.theme-card:hover {
    border-color: var(--accent-active-text, var(--accent));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.theme-card.active {
    border-color: var(--accent-active-text, var(--accent));
    box-shadow: 0 0 0 1px var(--accent-active-text, var(--accent));
}

/* Theme preview: mini mockup of canvas + toolbar + sidebar */
.theme-preview {
    height: 56px;
    border-radius: 6px;
    display: flex;
    overflow: hidden;
    margin-bottom: 6px;
}
.theme-preview-sidebar {
    width: 16px;
    flex-shrink: 0;
}
.theme-preview-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.theme-preview-toolbar {
    height: 10px;
    display: flex; align-items: center;
    padding: 0 3px; gap: 2px;
}
.theme-preview-dot {
    width: 4px; height: 4px;
    border-radius: 50%;
}
.theme-preview-canvas {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    gap: 3px; padding: 2px;
}
.theme-preview-node {
    width: 16px; height: 10px;
    border-radius: 3px;
}

.theme-name {
    font-size: 11px; font-weight: 600;
    text-align: center;
    color: inherit;
    opacity: 0.8;
}
.theme-card.active .theme-name { opacity: 1; }

/* Custom theme delete button */
.theme-delete {
    position: absolute; top: 4px; right: 4px;
    width: 18px; height: 18px;
    background: rgba(0,0,0,0.5); border: none;
    border-radius: 50%; color: #fff;
    font-size: 10px; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.theme-card:hover .theme-delete { display: flex; }
.theme-delete:hover { background: var(--danger); }

/* ── Tabs ── */
.appearance-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}
.appearance-tab {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: inherit;
    opacity: 0.5;
    font-size: 12px; font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.appearance-tab:hover { opacity: 0.8; }
.appearance-tab.active {
    opacity: 1;
    border-bottom-color: var(--accent-active-text, var(--accent));
    color: var(--accent-active-text, var(--accent));
}

/* ── Tab panels ── */
.appearance-panel { display: none; }
.appearance-panel.active { display: block; }

.appearance-panel h4 {
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.04em;
    opacity: 0.5; margin: 0 0 10px;
}

.appearance-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0;
}
.appearance-row label {
    font-size: 13px;
    opacity: 0.8;
}
.appearance-row input[type="color"] {
    width: 36px; height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px;
    cursor: pointer;
    background: transparent;
}
.appearance-row select {
    padding: 5px 8px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--pc-controls-text-hover, var(--text-primary));
    font-size: 12px;
}
.appearance-row input[type="range"] {
    width: 120px;
    accent-color: var(--accent);
}
.appearance-row span {
    font-size: 11px; opacity: 0.5;
    min-width: 36px; text-align: right;
    font-family: 'JetBrains Mono', monospace;
}

.appearance-hint {
    font-size: 11px;
    opacity: 0.4;
    margin-bottom: 12px;
    line-height: 1.4;
}

.appearance-toggle {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 0;
}
.appearance-toggle label {
    font-size: 13px; opacity: 0.8; cursor: pointer;
}
.appearance-toggle input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--accent);
}

.appearance-reset-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--pc-controls-text, var(--text-secondary));
    font-size: 12px; cursor: pointer;
    transition: all 0.15s;
    margin-top: 8px;
}
.appearance-reset-btn:hover {
    background: var(--accent-dim);
    border-color: var(--accent-active-text, var(--accent));
    color: var(--accent-active-text, var(--accent));
}

/* ── Slot grid (reused from settings) ── */
.appearance-slot-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.appearance-slot {
    display: flex; flex-direction: column;
    align-items: center; gap: 4px;
}
.appearance-slot input[type="color"] {
    width: 44px; height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2px;
    cursor: pointer;
    background: transparent;
}
.appearance-slot select {
    width: 100%;
    padding: 3px 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--pc-controls-text-hover, var(--text-primary));
    font-size: 10px;
    text-align: center;
}
.appearance-slot select option:disabled {
    color: rgba(128,128,128,0.5);
}

/* ── Save theme dialog ── */
.theme-save-dialog {
    display: flex; gap: 8px; align-items: center;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
}
.theme-save-dialog.hidden { display: none; }
.theme-save-dialog input {
    flex: 1;
    padding: 5px 8px;
    background: var(--pc-sidebar, var(--bg-surface));
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--pc-sidebar-text, var(--text-primary));
    font-size: 12px;
}
.theme-save-dialog input:focus { outline: none; border-color: var(--accent); }
.theme-save-dialog button {
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px; font-weight: 500;
    cursor: pointer; border: none;
}
.theme-save-confirm { background: var(--accent); color: var(--accent-text, #fff); }
.theme-save-cancel { background: transparent; color: inherit; opacity: 0.6; }
.theme-save-cancel:hover { opacity: 1; }

/* ═══════════════════════════════════════════════════════════════
   LIVE PREVIEW — Mini app mockup
   ═══════════════════════════════════════════════════════════════ */

.live-preview-section {
    margin-bottom: 24px;
}

.live-preview {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    font-family: 'Outfit', sans-serif;
    font-size: 9px;
    line-height: 1.3;
}

/* Tab bar */
.lp-tabbar {
    display: flex; align-items: center;
    height: 22px; padding: 0 6px;
    gap: 2px;
    border-bottom: 1px solid rgba(128,128,128,0.15);
}
.lp-tab {
    padding: 2px 8px;
    font-size: 8px;
    opacity: 0.5;
    border-bottom: 1.5px solid transparent;
    white-space: nowrap;
}
.lp-tab-active {
    opacity: 1;
    font-weight: 600;
}
.lp-tab-add {
    font-size: 10px;
    opacity: 0.4;
    padding: 0 4px;
}
.lp-tabbar-right {
    margin-left: auto;
    display: flex; gap: 4px;
}
.lp-btn-ghost {
    font-size: 7px;
    opacity: 0.5;
    padding: 1px 4px;
}

/* Toolbar */
.lp-toolbar {
    display: flex; align-items: center;
    height: 24px; padding: 0 6px;
    gap: 3px;
    border-bottom: 1px solid rgba(128,128,128,0.15);
}
.lp-tool-btn, .lp-tool-select {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 7px;
    border: 1px solid transparent;
    white-space: nowrap;
}
.lp-tool-active {
    font-weight: 600;
}
.lp-tool-divider {
    width: 1px; height: 14px;
    margin: 0 2px;
}
.lp-zoom {
    display: flex; align-items: center;
    border-radius: 3px;
    padding: 1px 4px;
    gap: 3px;
    font-size: 7px;
    border: 1px solid transparent;
}
.lp-zoom-btn { opacity: 0.6; font-size: 8px; font-weight: 700; }
.lp-zoom-pct { font-size: 7px; font-weight: 600; }
.lp-search {
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 7px;
    border: 1px solid transparent;
    min-width: 50px;
}
.lp-settings-btn {
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 8px;
    border: 1px solid transparent;
}

/* Main area */
.lp-main {
    display: flex;
    height: 128px;
}

/* Sidebar */
.lp-sidebar {
    width: 28px; flex-shrink: 0;
    display: flex; flex-direction: column;
    align-items: center;
    padding: 6px 2px;
    gap: 4px;
    border-right: 1px solid rgba(128,128,128,0.15);
}
.lp-sidebar-label {
    font-size: 7px; font-weight: 600;
    padding: 2px 0;
}

/* Canvas */
.lp-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
}
.lp-svg {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
}
.lp-line { fill: none; }

/* Nodes */
.lp-node {
    border-radius: 5px;
    padding: 4px 7px;
    border: 1.5px solid;
    position: absolute;
    z-index: 1;
    min-width: 42px;
}
.lp-node-core {
    min-width: 56px;
}
.lp-node-title {
    font-size: 7px; font-weight: 600;
    white-space: nowrap;
}
.lp-node-desc {
    font-size: 5.5px;
}
.lp-node-tag {
    font-size: 5.5px;
    padding: 0.5px 3px;
    border-radius: 6px;
    display: inline-block;
    margin-top: 1px;
    font-weight: 600;
}
.lp-node-add {
    font-size: 6px;
    margin-top: 2px;
    padding: 0.5px 3px;
    border: 1px dashed;
    border-radius: 3px;
    text-align: center;
    opacity: 0.6;
}

/* Glow ring */
.lp-glow-ring {
    position: absolute;
    top: 4px; left: 50%;
    transform: translateX(-50%);
    width: 62px; height: 30px;
    border-radius: 6px;
    border: 1px solid transparent;
    pointer-events: none;
    z-index: 0;
}

/* Settings panel */
.lp-settings {
    width: 65px; flex-shrink: 0;
    padding: 6px;
    border-left: 1px solid rgba(128,128,128,0.15);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lp-settings-title {
    font-size: 8px; font-weight: 700;
    margin-bottom: 2px;
}
.lp-settings-label {
    font-size: 6px;
}
.lp-settings-control {
    height: 8px;
    border-radius: 3px;
    border: 1px solid;
}
.lp-settings-btn-full {
    font-size: 6px;
    padding: 2px 4px;
    border-radius: 3px;
    text-align: center;
    border: 1px solid;
    margin-top: auto;
}

/* Mini toggle in preview settings */
.lp-settings-toggle-mini {
    display: flex; align-items: center;
    margin: 2px 0;
}
.lp-toggle-track {
    width: 18px; height: 10px;
    border-radius: 5px;
    position: relative;
    transition: background 0.2s;
}
.lp-toggle-thumb {
    position: absolute; top: 1.5px; left: 9px;
    width: 7px; height: 7px;
    background: #fff; border-radius: 50%;
}

/* Theme rename button */
.theme-rename {
    position: absolute; top: 4px; right: 22px;
    width: 18px; height: 18px;
    background: rgba(0,0,0,0.5); border: none;
    border-radius: 50%; color: #fff;
    font-size: 10px; cursor: pointer;
    display: none; align-items: center; justify-content: center;
    transition: background 0.15s;
}
.theme-card:hover .theme-rename { display: flex; }
.theme-rename:hover { background: var(--accent); }

/* Split theme preview for paired themes */
.theme-preview-split {
    display: flex;
    overflow: hidden;
}
.theme-split-half {
    flex: 1;
    display: flex;
}
.theme-split-half .theme-preview-canvas {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px;
    height: 100%;
}

/* Mode badges */
.theme-mode-badges {
    position: absolute;
    top: 4px; left: 4px;
    font-size: 8px;
    opacity: 0.5;
    letter-spacing: 1px;
}

/* Create counterpart button */
.theme-create-pair {
    position: absolute; bottom: 22px; right: 4px;
    padding: 2px 5px;
    background: rgba(0,0,0,0.5); border: none;
    border-radius: 4px; color: #fff;
    font-size: 9px; cursor: pointer;
    display: none; align-items: center;
    transition: background 0.15s;
}
.theme-card:hover .theme-create-pair { display: flex; }
.theme-create-pair:hover { background: var(--accent); }