/* ─── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #root, #app { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0d0d0f;
    color: #e2e8f0;
    font-size: 14px;
    line-height: 1.5;
}

/* ─── Layout ──────────────────────────────────────────────────────────────── */
.app-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}
.app-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.app-main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    width: 196px;
    flex-shrink: 0;
    background: #0f0f17;
    display: flex;
    flex-direction: column;
    padding: 16px 10px;
    gap: 4px;
    transition: width 0.2s ease;
    overflow: hidden;
}
.sidebar-collapsed {
    width: 52px;
    padding: 16px 6px;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    width: 100%;
    transition: all 0.15s;
    white-space: nowrap;
}
.sidebar-collapsed .sidebar-item {
    justify-content: center;
    padding: 10px 0;
}
.sidebar-item:hover { background: #1a1a2e; color: #94a3b8; }
.sidebar-item.active { background: #7c3aed22; color: #a78bfa; }
.sidebar-item.active svg { color: #7c3aed; }
.sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #334155;
    cursor: pointer;
    font-size: 12px;
    width: 100%;
    white-space: nowrap;
    transition: all 0.15s;
}
.sidebar-toggle:hover { background: #1a1a2e; color: #64748b; }
.sidebar-collapsed .sidebar-toggle {
    justify-content: center;
    padding: 8px 0;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: #13131a;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
    z-index: 10;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #a78bfa;
}
.header-title {
    font-size: 16px;
    font-weight: 600;
    color: #f1f5f9;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-file-info {
    color: #64748b;
    font-size: 13px;
    padding: 0 8px;
}

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
    background: #7c3aed;
    color: #fff;
    border-color: #7c3aed;
}
.btn-primary:hover:not(:disabled) { background: #6d28d9; }
.btn-outline {
    background: transparent;
    color: #cbd5e1;
    border-color: #334155;
}
.btn-outline:hover:not(:disabled) { background: #1e293b; border-color: #475569; }
.btn-ghost { background: transparent; color: #64748b; border-color: transparent; }
.btn-ghost:hover:not(:disabled) { color: #e2e8f0; background: #1e1e2e; }
.btn-ghost.active { color: #a78bfa; border-color: #7c3aed; background: #7c3aed22; }
.btn-danger { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ─── Landing / Upload ────────────────────────────────────────────────────── */
.landing-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}
.upload-container { max-width: 600px; width: 100%; }
.upload-zone {
    border: 2px dashed #334155;
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #13131a;
}
.upload-zone:hover, .upload-zone.dragging {
    border-color: #7c3aed;
    background: #1a1a2e;
}
.upload-icon { color: #475569; margin-bottom: 16px; display: block; margin-left: auto; margin-right: auto; }
.upload-zone h2 { font-size: 20px; font-weight: 600; color: #f1f5f9; margin-bottom: 8px; }
.upload-zone p { color: #64748b; }
.reopen-last-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 18px;
    margin-top: 16px;
    background: #7c3aed1a;
    border: 1px solid #7c3aed55;
    border-radius: 10px;
    color: #a78bfa;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    text-align: left;
}
.reopen-last-btn:hover { background: #7c3aed33; border-color: #7c3aed99; }
.reopen-filename {
    margin-left: auto;
    font-size: 12px;
    color: #64748b;
    font-weight: 400;
    font-family: monospace;
}
.sample-files { margin-top: 32px; }
.sample-files h3 { display: flex; align-items: center; gap: 8px; color: #94a3b8; margin-bottom: 12px; }
.sample-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.sample-btn {
    padding: 6px 14px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.sample-btn:hover { border-color: #7c3aed; color: #a78bfa; }

/* ─── Viewer Layout ───────────────────────────────────────────────────────── */
.viewer-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.viewer-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── Rive Control Panel (2nd left sidebar) ───────────────────────────────── */
.rive-ctrl-panel {
    width: 290px;
    flex-shrink: 0;
    background: #0f0f17;
    border-right: 1px solid #1e1e2e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.2s ease;
    position: relative;
}
.rive-ctrl-panel.collapsed {
    width: 36px;
}
.rive-ctrl-panel.collapsed .rive-ctrl-header {
    justify-content: center;
    padding: 0;
}
.rive-ctrl-header {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    height: 36px;
    border-bottom: 1px solid #1e1e2e;
    padding: 0 4px 0 12px;
    gap: 6px;
}
.rive-ctrl-panel-title {
    flex: 1;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #475569;
}
.rive-ctrl-collapse-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #475569;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}
.rive-ctrl-collapse-btn:hover { color: #a78bfa; background: #1a1a2e; }
.rive-ctrl-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}
.rive-ctrl-section {
    border-bottom: 1px solid #1a1a28;
}
.rive-ctrl-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: none;
    color: #475569;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: left;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}
.rive-ctrl-section-header:hover { color: #94a3b8; background: #14141f; }
.rive-ctrl-section-header .sm-input-count { margin-left: auto; }
.rive-ctrl-subsection { border-top: 1px solid #1a1a28; }



/* ─── Tabs ────────────────────────────────────────────────────────────────── */
.tab-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}
.tab-nav {
    display: flex;
    gap: 2px;
    padding: 8px 16px 0;
    background: #13131a;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    border-radius: 4px 4px 0 0;
}
.tab-btn:hover { color: #cbd5e1; }
.tab-btn.active { color: #a78bfa; border-bottom-color: #7c3aed; }
.tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* ─── Overview Tab ────────────────────────────────────────────────────────── */
.overview-tab { display: flex; flex-direction: column; gap: 24px; }
.overview-section { }
.section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 12px;
}
.info-grid { display: flex; flex-direction: column; gap: 1px; background: #1e293b; border-radius: 8px; overflow: hidden; }
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    background: #13131a;
}
.info-label { color: #64748b; font-size: 13px; }
.info-value { color: #e2e8f0; font-size: 13px; }
.mono { font-family: 'SF Mono', 'Fira Mono', monospace; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.stat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: #13131a;
    border: 1px solid #1e293b;
    border-radius: 8px;
}
.stat-icon { color: #7c3aed; }
.stat-value { font-size: 22px; font-weight: 700; color: #f1f5f9; }
.stat-label { font-size: 12px; color: #64748b; }
.stat-sub { font-size: 11px; color: #475569; }
.mod-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.mod-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #1a1a2e;
    border: 1px solid #7c3aed33;
    border-radius: 6px;
}
.mod-name { color: #e2e8f0; }
.mod-size { color: #64748b; font-size: 12px; }

/* ─── Assets Tab ──────────────────────────────────────────────────────────── */
.assets-tab { display: flex; flex-direction: column; gap: 16px; }
.assets-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}
.filter-group { display: flex; gap: 4px; }
.filter-btn {
    padding: 5px 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.filter-btn:hover { border-color: #475569; color: #94a3b8; }
.filter-btn.active { border-color: #7c3aed; color: #a78bfa; background: #7c3aed22; }
.assets-search {
    position: relative;
    display: flex;
    align-items: center;
}
.assets-search-icon {
    position: absolute;
    left: 8px;
    color: #475569;
    pointer-events: none;
}
.assets-search-input {
    padding: 5px 10px 5px 28px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #0d0d0f;
    color: #e2e8f0;
    font-size: 12px;
    width: 160px;
    outline: none;
    transition: border-color 0.15s;
}
.assets-search-input::placeholder { color: #475569; }
.assets-search-input:focus { border-color: #7c3aed; }
.assets-count { font-size: 12px; color: #64748b; }
.asset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.asset-card {
    background: #13131a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}
.asset-card:hover { border-color: #7c3aed; transform: translateY(-1px); }
.asset-card:hover .asset-edit-hint { opacity: 1; }
.asset-modified { border-color: #7c3aed55; background: #1a1a2e; }
.asset-thumb {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0d0d0f;
    position: relative;
    overflow: hidden;
}
.asset-img { width: 100%; height: 100%; object-fit: contain; }
.asset-icon-placeholder { color: #334155; }
.asset-modified-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #7c3aed;
    color: #fff;
    border-radius: 50%;
    padding: 2px;
    display: flex;
}
.asset-info { padding: 10px 12px; }
.asset-name {
    font-size: 13px;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.asset-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: #64748b; font-size: 11px; }
.asset-type-badge {
    padding: 1px 6px;
    background: #1e293b;
    border-radius: 4px;
    font-size: 10px;
}
.asset-format { color: #7c3aed; }
.asset-dims { font-size: 11px; color: #475569; margin-top: 2px; }
.asset-bounds { display: flex; align-items: center; gap: 4px; font-size: 10px; color: #475569; margin-top: 2px; font-family: monospace; }
.asset-bounds-label { color: #7c3aed; font-weight: 600; letter-spacing: 0.03em; }
.asset-bounds-sep { color: #334155; }
.asset-edit-hint {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: #7c3aed;
    color: #fff;
    font-size: 12px;
    padding: 6px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

/* ─── Structure Tab ───────────────────────────────────────────────────────── */
.structure-tab { font-size: 13px; }
.tree-node { }
.tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.1s;
    cursor: default;
}
.tree-row.clickable { cursor: pointer; }
.tree-row:hover { background: #1e293b; }
.tree-chevron, .tree-spacer { width: 14px; flex-shrink: 0; }
.tree-spacer { display: inline-block; }
.tree-icon { color: #64748b; flex-shrink: 0; }
.tree-label { color: #e2e8f0; }
.tree-props { color: #64748b; font-size: 12px; margin-left: 8px; overflow: hidden; text-overflow: ellipsis; }

/* ─── Search Tab ──────────────────────────────────────────────────────────── */
.search-tab { display: flex; flex-direction: column; gap: 16px; }
.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #13131a;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 0 14px;
}
.search-icon { color: #64748b; flex-shrink: 0; }
.search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 14px;
    padding: 10px 0;
    outline: none;
}
.search-results { display: flex; flex-direction: column; gap: 8px; }
.results-count { font-size: 12px; color: #64748b; }
.result-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #13131a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.result-item:hover { border-color: #7c3aed; background: #1a1a2e; }
.result-icon { color: #7c3aed; flex-shrink: 0; }
.result-name { font-weight: 500; color: #e2e8f0; }
.result-meta { font-size: 12px; color: #64748b; }
.search-hint { text-align: center; padding: 60px; color: #334155; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 60px; color: #334155; text-align: center; }

/* ─── Preview Panel ───────────────────────────────────────────────────────── */
.preview-panel {
    height: 100%;
    width: 420px;
    flex-shrink: 0;
    background: #13131a;
    border-left: 1px solid #1e1e2e;
    display: flex;
    flex-direction: column;
}
.preview-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.preview-title { font-size: 13px; font-weight: 600; color: #94a3b8; }
.preview-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}
.preview-badge.modified { background: #7c3aed33; color: #a78bfa; }
.preview-badge.loading { background: #1e293b; color: #64748b; }
.preview-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0d0d0f;
}
.preview-canvas {
    display: block;
    width: 100%;
    height: 100%;
}
.preview-error {
    position: absolute;
    text-align: center;
    color: #ef4444;
    font-size: 13px;
}
.preview-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-top: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.preview-fit-label {
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}
.preview-fit-select {
    flex: 1;
    padding: 4px 6px;
    background: #0d0d0f;
    border: 1px solid #334155;
    border-radius: 5px;
    color: #e2e8f0;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.preview-fit-select:focus   { outline: none; border-color: #7c3aed; }
.preview-fit-select:disabled { opacity: 0.4; cursor: not-allowed; }
.preview-zoom-slider {
    flex: 1;
    accent-color: #7c3aed;
    cursor: pointer;
    min-width: 0;
}
.preview-zoom-slider:disabled { opacity: 0.4; cursor: not-allowed; }


/* ─── State Machine Controls ──────────────────────────────────────────────── */

/* SM panel sits below the playback controls */
.sm-panel {
    flex-shrink: 0;
    max-height: 260px;
    overflow-y: auto;
    border-top: 1px solid #1e1e2e;
    background: #0f0f17;
}
.sm-empty-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #334155;
    margin-left: 2px;
}
.sm-section { border-top: 1px solid #1a1a28; }
.sm-section:first-of-type { border-top: none; }
.sm-section-active { background: #0f0f1a; }
.sm-section-header {
    display: flex;
    align-items: center;
}
.sm-section-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    padding: 6px 14px;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-align: left;
    transition: background 0.1s;
}
.sm-section-toggle:hover { background: #1a1a2e; }
.sm-activate-btn {
    flex-shrink: 0;
    margin-right: 10px;
    padding: 2px 8px;
    font-size: 10px;
    border-radius: 4px;
    border: 1px solid #334155;
    background: transparent;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
}
.sm-activate-btn:hover { border-color: #7c3aed; color: #a78bfa; }
.sm-activate-btn.active { border-color: #7c3aed; color: #a78bfa; background: #7c3aed22; cursor: default; }
.sm-section-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sm-input-count {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #1e293b;
    color: #475569;
}
.sm-inputs {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px 14px 8px;
}
.sm-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}
.sm-input-disabled { opacity: 0.35; pointer-events: none; }
.sm-input-name {
    flex: 1;
    font-size: 12px;
    color: #cbd5e1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.sm-type-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
    letter-spacing: 0.03em;
}
.sm-type-bool    { background: #0f4c75; color: #60c8f5; }
.sm-type-num     { background: #1a3a1a; color: #4ade80; }
.sm-type-trigger { background: #3a1a3a; color: #c084fc; }
.sm-type-str     { background: #2a1e0a; color: #fb923c; }
.sm-type-color   { background: #1a1a3a; color: #818cf8; }

/* Boolean toggle switch */
.sm-toggle {
    position: relative;
    flex-shrink: 0;
    width: 32px;
    height: 18px;
    border-radius: 9px;
    border: none;
    background: #2d3748;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s;
}
.sm-toggle.on { background: #7c3aed; }
.sm-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
    pointer-events: none;
}
.sm-toggle.on .sm-toggle-thumb { transform: translateX(14px); }

/* Number input */
.sm-number-input {
    width: 72px;
    padding: 4px 6px;
    background: #0d0d0f;
    border: 1px solid #334155;
    border-radius: 5px;
    color: #e2e8f0;
    font-size: 12px;
    text-align: right;
    flex-shrink: 0;
    transition: border-color 0.15s;
}
.sm-number-input:focus { outline: none; border-color: #7c3aed; }

/* String text input */
.sm-text-input {
    flex: 1;
    min-width: 0;
    padding: 4px 6px;
    background: #0d0d0f;
    border: 1px solid #334155;
    border-radius: 5px;
    color: #e2e8f0;
    font-size: 12px;
    transition: border-color 0.15s;
}
.sm-text-input:focus { outline: none; border-color: #7c3aed; }

/* Color swatch + picker */
.sm-color-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}
.sm-color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid #334155;
    flex-shrink: 0;
}
.sm-color-hex {
    font-size: 11px;
    color: #94a3b8;
    font-family: monospace;
}
.sm-color-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    border: none;
    padding: 0;
}

/* Trigger fire button */
.sm-fire-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 9px;
    background: #7c3aed22;
    border: 1px solid #7c3aed55;
    border-radius: 5px;
    color: #a78bfa;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    flex-shrink: 0;
    transition: all 0.15s;
}
.sm-fire-btn:hover { background: #7c3aed44; border-color: #7c3aed; }
.sm-fire-btn:active { background: #7c3aed66; transform: scale(0.96); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    backdrop-filter: blur(4px);
}
.modal-panel {
    background: #13131a;
    border: 1px solid #1e293b;
    border-radius: 12px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #1e293b;
    flex-shrink: 0;
}
.modal-title-row { display: flex; align-items: center; gap: 8px; }
.modal-title { font-size: 16px; font-weight: 600; color: #f1f5f9; }
.modal-close-btn {
    background: transparent;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    padding: 6px;
    display: flex;
    transition: all 0.15s;
}
.modal-close-btn:hover { border-color: #ef4444; color: #ef4444; }
.badge-modified {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: #7c3aed33;
    color: #a78bfa;
}
.modal-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.modal-left {
    width: 340px;
    flex-shrink: 0;
    border-right: 1px solid #1e293b;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.modal-right {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.modal-section { display: flex; flex-direction: column; gap: 10px; }
.section-heading {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}
.section-desc { font-size: 13px; color: #64748b; }
.modal-preview-img-wrap { position: relative; }
.modal-preview-label { font-size: 11px; color: #64748b; margin-bottom: 4px; }
.modal-preview-img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 6px;
    background: #0d0d0f;
    display: block;
}
.preview-pair { display: flex; gap: 12px; }
.preview-pair .modal-preview-img-wrap { flex: 1; }
.replacement-preview { display: flex; flex-direction: column; gap: 10px; }
.muted { color: #475569; font-size: 13px; }

/* ─── AI Section ──────────────────────────────────────────────────────────── */
.ai-mode-tabs { display: flex; gap: 4px; }
.ai-tab {
    flex: 1;
    padding: 7px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
    text-align: center;
}
.ai-tab.active { border-color: #7c3aed; color: #a78bfa; background: #7c3aed22; }
.ai-strength-row { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #94a3b8; }
.strength-slider { width: 100%; accent-color: #7c3aed; }
.ai-prompt {
    width: 100%;
    min-height: 160px;
    background: #0d0d0f;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 13px;
    padding: 10px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s;
}
.ai-prompt:focus { outline: none; border-color: #7c3aed; }
.ai-img2img-layout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.ai-img2img-controls {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.ai-source-panel {
    width: 110px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ai-source-panel-label {
    font-size: 11px;
    color: #64748b;
    text-align: center;
}
.ai-source-panel-img {
    width: 100%;
    border-radius: 6px;
    border: 1px solid #1e293b;
    background: #060608;
    object-fit: contain;
    display: block;
}
.ai-source-clear-btn {
    font-size: 10px;
    color: #7c3aed;
    background: none;
    border: 1px solid #7c3aed44;
    border-radius: 4px;
    cursor: pointer;
    padding: 3px 6px;
    text-align: center;
    transition: all 0.15s;
}
.ai-source-clear-btn:hover { background: #7c3aed22; }
.ai-source-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: #a78bfa;
    background: #7c3aed22;
    border: 1px solid #7c3aed44;
    border-radius: 6px;
    padding: 6px 10px;
}
.ai-source-clear {
    margin-left: auto;
    background: none;
    border: none;
    color: #a78bfa;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
}
.ai-source-clear:hover { color: #ef4444; }
.ai-composite-hint { font-size: 11px; color: #7c3aed; margin: 4px 0 0; text-align: center; }
.ai-face-measure-note { background: #1e1e2e; border: 1px solid #7c3aed44; border-radius: 6px; padding: 8px 10px; margin: 6px 0 0; }
.ai-face-measure-label { font-size: 10px; color: #7c3aed; font-weight: 600; letter-spacing: 0.04em; display: block; margin-bottom: 4px; }
.ai-face-measure-text { font-size: 11px; color: #94a3b8; margin: 0; line-height: 1.5; word-break: break-word; }
.ai-error {
    background: #ef444422;
    border: 1px solid #ef444444;
    border-radius: 6px;
    padding: 10px 14px;
    color: #ef4444;
    font-size: 13px;
}
.ai-result { display: flex; flex-direction: column; gap: 10px; }
.ai-result-actions { display: flex; gap: 8px; }
.ai-result-actions .btn { flex: 1; justify-content: center; }

/* ─── Loading ─────────────────────────────────────────────────────────────── */
.loading-overlay {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: #64748b;
}
.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #1e293b;
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.error-banner {
    background: #ef444422;
    border: 1px solid #ef444444;
    border-radius: 8px;
    padding: 12px 16px;
    color: #ef4444;
    margin-bottom: 16px;
    width: 100%;
    max-width: 600px;
}

/* ─── Animations ──────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ─── Generate View (two-column) ─────────────────────────────────────────── */
.generate-view {
    flex: 1;
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.gen-settings-panel {
    width: 360px;
    flex-shrink: 0;
    border-right: 1px solid #1e1e2e;
    overflow-y: auto;
    padding: 20px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.gen-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #f1f5f9;
    padding-bottom: 4px;
    color: #a78bfa;
}
.gen-result-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #0a0a0f;
    overflow: hidden;
}
.gen-result-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.gen-result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #334155;
    text-align: center;
    user-select: none;
}
.gen-result-full {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}
.gen-result-img-bg {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 24px;
    background: repeating-conic-gradient(#13131a 0% 25%, #0d0d0f 0% 50%) 0 0 / 20px 20px;
}
.gen-result-img-full {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    display: block;
}
.gen-result-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid #1e1e2e;
    background: #13131a;
    flex-shrink: 0;
    gap: 12px;
}
.gen-result-actions-row { display: flex; gap: 8px; }

.gen-section { display: flex; flex-direction: column; gap: 8px; }
.gen-section-grow { flex: 1; }
.gen-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}
.required-star { color: #7c3aed; font-size: 14px; }

/* Backend selector */
.gen-backends { display: flex; gap: 8px; flex-wrap: wrap; }
.gen-backend-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    user-select: none;
}
.gen-backend-btn.active {
    border-color: #7c3aed;
    color: #a78bfa;
    background: #7c3aed1a;
}
.gen-backend-btn.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    position: relative;
}
.backend-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #22c55e;
    flex-shrink: 0;
}
.unsupported-badge {
    margin-left: 4px;
    padding: 1px 6px;
    background: #1e293b;
    border-radius: 4px;
    font-size: 11px;
    color: #475569;
}

/* Mode tabs */
.gen-mode-tabs { display: flex; gap: 4px; }
.gen-mode-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid #334155;
    border-radius: 7px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
    text-align: center;
}
.gen-mode-btn:hover { border-color: #475569; color: #94a3b8; }
.gen-mode-btn.active {
    border-color: #7c3aed;
    color: #a78bfa;
    background: #7c3aed1a;
}

/* Dimensions */
.gen-dims {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.gen-dim-field {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #94a3b8;
}
.gen-dim-input {
    width: 72px;
    padding: 6px 8px;
    background: #0d0d0f;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 13px;
    text-align: center;
    transition: border-color 0.15s;
}
.gen-dim-input:focus { outline: none; border-color: #7c3aed; }
.gen-dim-sep { color: #475569; font-size: 16px; }
.gen-dim-presets { display: flex; gap: 4px; margin-left: 4px; flex-wrap: wrap; }
.gen-preset-btn {
    padding: 4px 8px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 5px;
    color: #64748b;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.gen-preset-btn:hover { border-color: #7c3aed; color: #a78bfa; }

/* Source image */
.source-drop-zone {
    border: 2px dashed #334155;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    color: #64748b;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.15s;
}
.source-drop-zone:hover, .source-drop-zone.dragging {
    border-color: #7c3aed;
    color: #a78bfa;
    background: #7c3aed0d;
}
.source-image-preview {
    position: relative;
    display: flex;
    flex-direction: column;
    max-width: 200px;
}
.source-img {
    width: 100%;
    max-height: 150px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0d0d0f;
    display: block;
}
.source-clear-btn {
    position: absolute;
    top: -8px; right: -8px;
    background: #ef4444;
    border: none;
    border-radius: 50%;
    width: 22px; height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: background 0.15s;
}
.source-clear-btn:hover { background: #dc2626; }
.source-img-name {
    display: block;
    font-size: 11px;
    color: #64748b;
    margin-top: 4px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 200px;
}
.source-normalize-btn {
    margin-top: 6px;
    width: 100%;
    justify-content: center;
    font-size: 11px;
}

/* Strength */
.gen-strength-val { color: #a78bfa; font-weight: 600; text-transform: none; letter-spacing: 0; }
.gen-strength-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #475569;
}
.gen-slider { flex: 1; accent-color: #7c3aed; cursor: pointer; }

/* Prompt */
.gen-prompt {
    width: 100%;
    background: #0d0d0f;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    line-height: 1.6;
    padding: 10px 12px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s;
    min-height: 90px;
}
.gen-prompt:focus { outline: none; border-color: #7c3aed; }
.gen-prompt-hint { font-size: 11px; color: #334155; text-align: right; }

/* Generate button */
.btn-generate {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
    border-radius: 8px;
}

/* Error */
.gen-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #ef444422;
    border: 1px solid #ef444444;
    border-radius: 8px;
    padding: 12px 14px;
    color: #f87171;
    font-size: 13px;
}

/* Result */
.gen-result {
    display: flex;
    flex-direction: column;
    gap: 12px;
    border-top: 1px solid #1e293b;
    padding-top: 20px;
}
.gen-result-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.gen-result-label { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.gen-result-meta { font-size: 11px; color: #475569; }
.gen-result-img-wrap {
    background: #0d0d0f;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}
.gen-result-img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}
.gen-result-actions { display: flex; gap: 8px; }
.gen-result-actions .btn { flex: 1; justify-content: center; }

/* No file prompt — full viewer landing */
.no-file-prompt {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* ─── History Grid (GenerateTab right panel idle state) ──────────────────── */
.hist-grid-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.hist-grid-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #64748b;
    padding: 10px 14px 8px;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.hist-clear-btn {
    margin-left: auto;
    background: transparent;
    border: none;
    color: #475569;
    font-size: 11px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.15s;
}
.hist-clear-btn:hover { color: #ef4444; }
.hist-grid-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #64748b;
    font-size: 13px;
}
.hist-grid-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-content: flex-start;
}
.hist-grid-scroll::-webkit-scrollbar { width: 4px; }
.hist-thumb {
    position: relative;
    width: 100px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #1e293b;
    cursor: pointer;
    transition: border-color 0.15s;
    background: #0d0d0f;
    display: flex;
    flex-direction: column;
}
.hist-thumb:hover { border-color: #7c3aed; }
.hist-thumb-img-wrap {
    flex: 1;
    min-height: 140px;
    background: #0d0d0f;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hist-thumb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}
.hist-thumb-size {
    font-size: 10px;
    font-family: monospace;
    color: #475569;
    text-align: center;
    padding: 3px 4px;
    background: #0a0a12;
    border-top: 1px solid #1a1a28;
    white-space: nowrap;
}
.hist-thumb-del {
    position: absolute;
    top: 3px; right: 3px;
    background: rgba(0,0,0,0.7);
    border: none;
    border-radius: 4px;
    color: #94a3b8;
    cursor: pointer;
    padding: 3px;
    display: flex;
    opacity: 0;
    transition: opacity 0.15s;
}
.hist-thumb:hover .hist-thumb-del { opacity: 1; }
.hist-thumb-del:hover { color: #ef4444; }

/* ─── Image Editor ────────────────────────────────────────────────────────── */
.img-editor {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.img-editor-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid #1e1e2e;
    background: #13131a;
    flex-shrink: 0;
}
.img-editor-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.img-editor-back {
    display: flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #94a3b8;
    cursor: pointer;
    font-size: 13px;
    padding: 5px 10px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.img-editor-back:hover { border-color: #475569; color: #e2e8f0; }
.img-editor-prompt {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
    word-break: break-word;
}
.img-editor-time { font-size: 11px; color: #334155; flex-shrink: 0; }
.img-editor-actions { display: flex; gap: 6px; flex-shrink: 0; margin-left: auto; }
.img-editor-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.img-editor-canvas-wrap {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 24px;
    background: #0a0a10;
}
.img-editor-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border-radius: 2px;
    /* checkerboard inside valid area only */
    background: repeating-conic-gradient(#13131a 0% 25%, #0d0d0f 0% 50%) 0 0 / 20px 20px;
    /* clear border showing exact export boundary */
    box-shadow: 0 0 0 1px rgba(255,255,255,0.08), 0 8px 32px rgba(0,0,0,0.6);
}
.img-editor-canvas--draggable { cursor: grab; }
.img-editor-canvas--dragging  { cursor: grabbing; }
.img-editor-controls {
    width: 220px;
    flex-shrink: 0;
    border-left: 1px solid #1e1e2e;
    background: #13131a;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.img-ctrl-section { display: flex; flex-direction: column; gap: 8px; }
.img-ctrl-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
}
.img-ctrl-dims {
    display: flex;
    align-items: center;
    gap: 6px;
}
.img-ctrl-dim-input {
    flex: 1;
    padding: 5px 7px;
    background: #0d0d0f;
    border: 1px solid #334155;
    border-radius: 5px;
    color: #e2e8f0;
    font-size: 12px;
    text-align: center;
    min-width: 0;
}
.img-ctrl-dim-input:focus { outline: none; border-color: #7c3aed; }
.img-ctrl-lock {
    padding: 5px;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 5px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    transition: all 0.15s;
    flex-shrink: 0;
}
.img-ctrl-lock.active { border-color: #7c3aed; color: #a78bfa; }
.img-ctrl-hint { font-size: 11px; color: #334155; }
.img-ctrl-transforms {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.img-ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    background: transparent;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.15s;
}
.img-ctrl-btn:hover { border-color: #475569; color: #94a3b8; }
.img-ctrl-btn.active { border-color: #7c3aed; color: #a78bfa; background: #7c3aed1a; }
.img-ctrl-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.img-ctrl-slider-label { width: 44px; color: #94a3b8; flex-shrink: 0; font-size: 11px; }
.img-ctrl-slider { flex: 1; accent-color: #7c3aed; cursor: pointer; }
.img-ctrl-slider-val { width: 28px; text-align: right; color: #64748b; font-size: 11px; }

/* ─── Modal right-column tabs ─────────────────────────────────────────────── */
.modal-right-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
    flex-shrink: 0;
}
.modal-right-tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid #334155;
    border-radius: 6px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.modal-right-tab:hover { border-color: #475569; color: #94a3b8; }
.modal-right-tab.active { border-color: #7c3aed; color: #a78bfa; background: #7c3aed1a; }

/* ─── History Modal Grid ──────────────────────────────────────────────────── */
.hist-modal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.hist-modal-thumb {
    border-radius: 6px;
    border: 1px solid #1e293b;
    cursor: pointer;
    background: #0d0d0f;
    transition: border-color 0.15s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.hist-modal-thumb:hover { border-color: #7c3aed; }
.hist-modal-thumb:hover .hist-modal-thumb-del { opacity: 1; }
.hist-modal-thumb-del {
    position: absolute; top: 4px; right: 4px;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    background: #0d0d0fcc; border: none; border-radius: 4px;
    color: #94a3b8; cursor: pointer; opacity: 0; transition: opacity .15s, color .15s;
}
.hist-modal-thumb-del:hover { color: #ef4444; }
.hist-modal-thumb-img-wrap {
    position: relative;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #060608;
}
.hist-modal-thumb-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.hist-modal-thumb-info {
    padding: 6px 8px;
    border-top: 1px solid #1e293b;
}
.hist-modal-thumb-prompt {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.4;
    word-break: break-word;
}
.hist-modal-thumb-dims {
    font-size: 10px;
    color: #475569;
    margin-top: 3px;
}

/* ─── Global Generate Tab ─────────────────────────────────────────────────── */
.global-generate-tab {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.gg-phase {
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
}

.gg-center-phase {
    align-items: center;
    justify-content: center;
    text-align: center;
    flex: 1;
    min-height: 200px;
}

.gg-phase-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.gg-phase-icon { color: #7c3aed; flex-shrink: 0; margin-top: 2px; }

.gg-phase-title {
    font-size: 16px;
    font-weight: 600;
    color: #e2e8f0;
}

.gg-phase-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-top: 3px;
}

/* Input Phase */
.gg-form { display: flex; flex-direction: column; gap: 12px; }

.gg-category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.gg-category-tab {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid #1e1e2e;
    border-radius: 20px;
    color: #475569;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
}
.gg-category-tab:hover {
    border-color: #7c3aed;
    color: #a78bfa;
}
.gg-category-tab-active {
    background: #3b1f6e;
    border-color: #7c3aed;
    color: #c4b5fd;
}
.gg-presets {
    display: flex;
    flex-direction: column;
    gap: 5px;
    max-height: 220px;
    overflow-y: auto;
}
.gg-preset-chip {
    text-align: left;
    padding: 7px 12px;
    background: #0d0d0f;
    border: 1px solid #1e1e2e;
    border-radius: 8px;
    color: #64748b;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}
.gg-preset-chip:hover {
    border-color: #7c3aed;
    color: #a78bfa;
}
.gg-preset-chip-active {
    border-color: #7c3aed;
    color: #c4b5fd;
    background: #1e1040;
}

.gg-desc-input {
    width: 100%;
    background: #0d0d0f;
    border: 1px solid #334155;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 14px;
    line-height: 1.6;
    padding: 12px 14px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.gg-desc-input:focus { outline: none; border-color: #7c3aed; }
.gg-desc-input::placeholder { color: #334155; }

/* Upload divider & zone */
.gg-upload-divider {
    text-align: center;
    color: #475569;
    font-size: 12px;
    margin: 4px 0;
    user-select: none;
}
.gg-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    border: 1px dashed #334155;
    border-radius: 8px;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: #0d0d0f;
}
.gg-upload-zone:hover, .gg-upload-zone-dragging {
    border-color: #7c3aed;
    background: #13131a;
    color: #a78bfa;
}
.gg-upload-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #334155;
    border-radius: 8px;
    background: #13131a;
}
.gg-upload-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}
.gg-upload-preview-actions {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.gg-upload-filename {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gg-upload-btns {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Spinner */
@keyframes gg-spin { to { transform: rotate(360deg); } }
.gg-spinner { animation: gg-spin 0.9s linear infinite; color: #7c3aed; }
.gg-spinner-sm { color: #a78bfa; }

/* Error */
.gg-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: #1a0a0a;
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
    color: #fca5a5;
}
.gg-error svg { flex-shrink: 0; margin-top: 1px; }

/* Configure Phase */
.gg-phase-header-main { flex: 1; }
.gg-toggle-all { display: flex; gap: 4px; margin-left: auto; align-items: flex-start; }

.gg-plan-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gg-plan-item {
    background: #13131a;
    border: 1px solid #1e1e2e;
    border-radius: 8px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color 0.15s;
}
.gg-plan-item:hover { border-color: #334155; }
.gg-plan-disabled { opacity: 0.5; }

/* Description preview */
.gg-desc-preview {
    background: #0d0d0f;
    border: 1px solid #1e1e2e;
    border-radius: 8px;
    padding: 10px 14px;
}
.gg-desc-preview-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #475569;
    margin-bottom: 6px;
}
.gg-desc-preview-text {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Thumbnail */
.gg-plan-thumb {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: repeating-conic-gradient(#13131a 0% 25%, #0d0d0f 0% 50%) 0 0 / 10px 10px;
    border: 1px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gg-plan-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.gg-plan-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gg-plan-check { display: flex; align-items: center; cursor: pointer; }
.gg-plan-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: #7c3aed; cursor: pointer; }

.gg-plan-info { flex: 1; min-width: 0; }
.gg-plan-name { font-size: 13px; font-weight: 500; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gg-plan-dims { font-size: 11px; color: #475569; margin-top: 2px; }

.gg-plan-img2img {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #64748b;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.gg-plan-img2img input[type="checkbox"] { accent-color: #7c3aed; width: 14px; height: 14px; }

.gg-plan-expand { padding: 4px 6px; }

.gg-plan-prompt {
    width: 100%;
    background: #0a0a0f;
    border: 1px solid #1e293b;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.5;
    padding: 8px 10px;
    resize: vertical;
    font-family: inherit;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.gg-plan-prompt:focus { outline: none; border-color: #7c3aed; color: #e2e8f0; }
.gg-plan-prompt:disabled { opacity: 0.4; cursor: not-allowed; }

.gg-configure-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 4px;
}

/* Status list */
.gg-face-detect-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 11px;
    color: #a78bfa;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.2);
    margin-bottom: 2px;
}
.gg-face-detect-row.gg-face-detect-done {
    color: #4ade80;
    background: rgba(74, 222, 128, 0.06);
    border-color: rgba(74, 222, 128, 0.2);
}
.gg-face-detect-row.gg-face-detect-error {
    color: #f87171;
    background: rgba(248, 113, 113, 0.06);
    border-color: rgba(248, 113, 113, 0.2);
}
.gg-status-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.gg-status-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #13131a;
    border: 1px solid #1e1e2e;
    border-radius: 7px;
    padding: 9px 12px;
}
.gg-status-item.gg-status-done { border-color: #14532d33; }
.gg-status-item.gg-status-error { border-color: #7f1d1d33; }
.gg-status-item.gg-status-generating { border-color: #4c1d9533; }

.gg-status-icon { display: flex; align-items: center; flex-shrink: 0; }
.gg-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #334155; display: inline-block; }
.gg-status-done { color: #4ade80; }
.gg-status-error { color: #f87171; }

.gg-status-info { flex: 1; min-width: 0; }
.gg-status-name { font-size: 13px; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gg-status-prompt { font-size: 11px; color: #334155; line-height: 1.5; margin-top: 3px; word-break: break-word; }
.gg-status-error-msg { font-size: 11px; color: #f87171; margin-top: 2px; word-break: break-word; }

.gg-status-badge {
    font-size: 11px;
    color: #475569;
    white-space: nowrap;
    text-transform: capitalize;
}
.gg-status-item.gg-status-done .gg-status-badge { color: #4ade80; }
.gg-status-item.gg-status-error .gg-status-badge { color: #f87171; }
.gg-status-item.gg-status-generating .gg-status-badge { color: #a78bfa; }
.gg-status-retry-btn {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    padding: 3px 8px;
    border-color: #f87171;
    color: #f87171;
}
.gg-status-retry-btn:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: #fca5a5;
    color: #fca5a5;
}

/* Done Phase */
.gg-done-icon { color: #4ade80; flex-shrink: 0; margin-top: 2px; }

/* Results divider */
.gg-results-divider {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0;
}
.gg-results-divider::before,
.gg-results-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #1e1e2e;
}

/* Comparison grid */
.gg-cmp-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.gg-cmp-card {
    background: #13131a;
    border: 1px solid #1e1e2e;
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.gg-cmp-card-selected {
    border-color: #7c3aed;
}
.gg-cmp-card-generating {
    border-color: #a78bfa;
}
.gg-cmp-generating-bar {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    background: linear-gradient(90deg, #1e1040, #2d1b69, #1e1040);
    background-size: 200% 100%;
    animation: gg-shimmer 1.6s ease-in-out infinite;
    font-size: 12px;
    color: #a78bfa;
    border-bottom: 1px solid #3b1f6e;
}
@keyframes gg-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.gg-cmp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 6px;
}
.gg-cmp-name {
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
}
.gg-cmp-apply-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 12px;
    color: #a78bfa;
    user-select: none;
}
.gg-cmp-apply-toggle input[type="checkbox"] {
    accent-color: #7c3aed;
    width: 13px;
    height: 13px;
    cursor: pointer;
}
.gg-apply-btn {
    margin-top: 12px;
    position: sticky;
    bottom: 8px;
}

.gg-cmp-edit-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 0 12px 10px;
    border-bottom: 1px solid #1e1e2e;
}

.gg-cmp-prompt-edit {
    flex: 1;
    background: #0a0a0f;
    border: 1px solid #1e293b;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.5;
    padding: 6px 8px;
    resize: vertical;
    font-family: inherit;
    min-height: 54px;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.gg-cmp-prompt-edit:focus { outline: none; border-color: #7c3aed; color: #e2e8f0; }
.gg-cmp-prompt-edit:disabled { opacity: 0.4; cursor: not-allowed; }

.gg-cmp-regen-col {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 80px;
}
.gg-cmp-regen-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    width: 100%;
    justify-content: center;
}
.gg-cmp-strength-row {
    display: flex;
    align-items: center;
    gap: 4px;
}
.gg-strength-label {
    font-size: 10px;
    color: #475569;
    white-space: nowrap;
    flex-shrink: 0;
}

.gg-cmp-prompt {
    font-size: 11px;
    color: #334155;
    line-height: 1.5;
    padding: 6px 12px 8px;
    border-bottom: 1px solid #1e1e2e;
    border-top: none;
    margin-top: -1px;
    word-break: break-word;
}

.gg-cmp-row {
    display: flex;
    align-items: stretch;
}

.gg-cmp-side {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.gg-cmp-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #334155;
    padding: 5px 10px 4px;
    text-align: center;
}
.gg-cmp-label-new { color: #6d28d9; }

.gg-cmp-img-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#0d0d0f 0% 25%, #060608 0% 50%) 0 0 / 12px 12px;
    min-height: 100px;
    padding: 8px;
}

.gg-cmp-img {
    max-width: 100%;
    max-height: 180px;
    object-fit: contain;
    display: block;
}

.gg-cmp-divider {
    width: 1px;
    background: #1e1e2e;
    flex-shrink: 0;
}

.gg-cmp-empty {
    font-size: 12px;
    color: #334155;
}

.gg-cmp-error-msg {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 12px;
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.25);
    border-radius: 6px;
    padding: 8px 10px;
    margin-bottom: 10px;
    line-height: 1.4;
}
.gg-cmp-error-msg svg { flex-shrink: 0; margin-top: 1px; }

.gg-cmp-pending {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ── Master reference image ─────────────────────────────────────────── */
.gg-master-preview-wrap {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    margin: 8px 0 16px;
    align-items: flex-start;
}
.gg-master-img-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.gg-master-col-label {
    font-size: 11px;
    color: #64748b;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.gg-annotation-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    color: #64748b;
    user-select: none;
}
.gg-annotation-toggle input { display: none; }
.gg-annotation-switch {
    width: 26px;
    height: 14px;
    border-radius: 7px;
    background: #1e1e2e;
    border: 1px solid #3a3a4a;
    position: relative;
    transition: background 0.15s, border-color 0.15s;
}
.gg-annotation-switch.on {
    background: #7c3aed;
    border-color: #7c3aed;
}
.gg-annotation-thumb {
    position: absolute;
    top: 1px;
    left: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #64748b;
    transition: left 0.15s, background 0.15s;
}
.gg-annotation-switch.on .gg-annotation-thumb {
    left: 13px;
    background: #fff;
}
.gg-master-img-container {
    position: relative;
    display: inline-block;
    line-height: 0;
}
.gg-ref-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* ── Proportions column ──────────────────────────────────────────── */
.gg-master-proportions-col {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    padding-top: 22px;
}
.gg-landmarks-panel {
    width: 180px;
    flex-shrink: 0;
    background: #1a1a28;
    border: 1px solid #1e1e2e;
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.gg-proportions-panel {
    width: 180px;
    flex-shrink: 0;
    background: #1a1a28;
    border: 1px solid #1e1e2e;
    border-radius: 6px;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.gg-proportions-title {
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}
.gg-proportions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
}
.gg-prop-label {
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}
.gg-prop-value {
    font-size: 11px;
    font-weight: 600;
    color: #a78bfa;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.gg-master-preview-img  {
    max-height: 280px;
    max-width: 160px;
    border-radius: 8px;
    border: 1px solid #2d1b69;
    object-fit: contain;
    display: block;
}
.gg-comp-box {
    position: absolute;
    border-style: solid;
    border-width: 1px;
    border-radius: 2px;
    pointer-events: none;
}
.gg-comp-point {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.5);
}
.gg-comp-box-label {
    position: absolute;
    top: -14px;
    left: 0;
    font-size: 8px;
    font-weight: 600;
    padding: 0px 3px;
    border-radius: 2px;
    white-space: nowrap;
    line-height: 13px;
}
.gg-overlay-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    max-width: 160px;
    width: 100%;
}
.gg-overlay-slider {
    flex: 1;
    min-width: 0;
    max-width: 90px;
    height: 2px;
    accent-color: #7c3aed;
    cursor: pointer;
}
.gg-face-scanning {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: #a78bfa;
    padding: 4px 0;
    pointer-events: none;
}
.gg-face-scanning-done {
    color: #4ade80;
}
.gg-face-scanning-error {
    color: #f87171;
}
.gg-redetect-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(13, 13, 15, 0.75);
    border: 1px solid #2d1b69;
    border-radius: 6px;
    color: #a78bfa;
    cursor: pointer;
    backdrop-filter: blur(4px);
    pointer-events: all;
}
.gg-redetect-btn:hover:not(:disabled) {
    background: rgba(124, 58, 237, 0.2);
    border-color: #7c3aed;
}
.gg-redetect-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ─── Text B section ────────────────────────────────────────────────────── */
.gg-textb-section {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}
.gg-textb-ref-thumb {
    flex: 0 0 120px;
}
.gg-textb-ref-thumb img {
    width: 120px;
    border-radius: 8px;
    border: 1px solid #1e1e2e;
    object-fit: contain;
}
.gg-textb-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.gg-textb-textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid #2a2a3e;
    background: #13131a;
    color: #e0e0e4;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    font-family: inherit;
}
.gg-textb-textarea:focus {
    outline: none;
    border-color: #6c5ce7;
}
.gg-textb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 32px 0;
    color: #888;
    font-size: 13px;
}
.gg-comp-desc-snippet {
    padding: 4px 8px;
    font-size: 11px;
    color: #9e9eb0;
    background: #1a1a24;
    border-radius: 6px;
    line-height: 1.4;
}
.gg-master-section {
    margin-top: 12px;
    padding: 10px 12px;
    background: #13131a;
    border: 1px solid #1e1e2e;
    border-radius: 10px;
}
.gg-master-thumb-preview {
    max-width: 160px;
    max-height: 280px;
    border-radius: 8px;
    border: 1px solid #2a2a3e;
    margin-top: 8px;
    object-fit: contain;
}

/* ─── Per-component generation cards ────────────────────────────────────── */
.gg-comp-gen-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.gg-comp-gen-card {
    background: #13131a;
    border: 1px solid #1e1e2e;
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.gg-comp-gen-card.gg-comp-gen-card-busy {
    border-color: #7c3aed66;
    background: #18183a;
}
.gg-comp-gen-card.gg-comp-gen-card-applied {
    border-color: #4ade8055;
}
.gg-comp-gen-card.gg-comp-gen-card-disabled {
    opacity: 0.5;
}
.gg-comp-gen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.gg-comp-gen-name-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.gg-comp-gen-name {
    font-size: 13px;
    font-weight: 600;
    color: #e2e8f0;
}
.gg-comp-gen-status {
    display: flex;
    align-items: center;
}
.gg-comp-gen-badge {
    font-size: 10px;
    color: #a78bfa;
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.25);
    padding: 1px 6px;
    border-radius: 10px;
}
.gg-comp-gen-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
/* Image row */
.gg-comp-gen-imgs {
    display: flex;
    align-items: center;
    gap: 8px;
}
.gg-comp-gen-img-col {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}
.gg-comp-gen-img-label {
    font-size: 10px;
    color: #475569;
    text-align: center;
}
.gg-comp-gen-img-wrap-rel { position: relative; }
.gg-orig-use-toggle {
    position: absolute;
    bottom: 4px;
    right: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: #94a3b8;
    background: rgba(13, 13, 15, 0.75);
    border-radius: 3px;
    padding: 1px 4px;
    cursor: pointer;
    line-height: 1.4;
}
.gg-orig-use-toggle input { cursor: pointer; margin: 0; }
.gg-comp-gen-img-wrap {
    width: 100%;
    height: 80px;
    background: #2a2a35;
    border: 1px solid #3a3a4a;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gg-comp-gen-thumb {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.gg-comp-gen-thumb-tall {
    /* Result is a full 540×960 canvas — show at correct ratio */
    width: auto;
    height: 100%;
}
.gg-comp-gen-placeholder {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #475569;
}
.gg-comp-gen-placeholder-full {
    font-size: 10px;
    color: #334155;
    font-style: italic;
}
.gg-comp-gen-arrow {
    font-size: 16px;
    color: #334155;
    flex-shrink: 0;
}
/* Prompt toggle */
.gg-comp-gen-prompt-toggle {
    background: none;
    border: none;
    color: #475569;
    font-size: 11px;
    cursor: pointer;
    text-align: left;
    padding: 0;
}
.gg-comp-gen-prompt-toggle:hover { color: #94a3b8; }
.gg-comp-gen-settings {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ── Work Phase ─────────────────────────────────────────────────────── */
.gg-work-phase { display: flex; flex-direction: column; gap: 0; }

.gg-work-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: #0d0d0f;
    border: 1px solid #1e1e2e;
    border-radius: 8px;
    margin-bottom: 12px;
}
.gg-work-desc {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.5;
    flex: 1;
    word-break: break-word;
}

.gg-work-master {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    background: #0f0f17;
    border: 1px solid #1e1e2e;
    border-radius: 8px;
    margin-bottom: 12px;
}

.gg-gen-master-btn { align-self: flex-start; }

.gg-master-empty-placeholder {
    background: #0d0d0f;
    border: 1px dashed #1e1e2e;
    border-radius: 8px;
}

.gg-master-generating-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 160px;
    height: 200px;
    background: #0d0d0f;
    border: 1px solid #2d1b69;
    border-radius: 8px;
    color: #a78bfa;
    font-size: 12px;
}

.gg-master-gen-phase {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 0;
}
.gg-master-thumb {
    width: 40px;
    height: 52px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #2d1b69;
    flex-shrink: 0;
    margin-left: auto;
}
.gg-done-master-preview { margin-bottom: 8px; }
.gg-master-thumb-lg {
    display: block;
    max-height: 120px;
    max-width: 100%;
    border-radius: 6px;
    border: 1px solid #2d1b69;
    object-fit: contain;
    margin-top: 4px;
}

/* ── Extraction prompt list in MASTER_REVIEW ────────────────────────── */
.gg-extraction-item   { margin-bottom: 10px; }
.gg-extraction-name   { font-size: 12px; color: #a78bfa; margin-bottom: 4px; }
.gg-prompt-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}
.gg-prompt-reset-btn {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: #64748b;
    background: none;
    border: 1px solid #1e1e2e;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.gg-prompt-reset-btn:hover:not(:disabled) { color: #a78bfa; border-color: #7c3aed; }
.gg-prompt-reset-btn:disabled { opacity: 0.35; cursor: default; }
.gg-thumb-clickable { cursor: zoom-in; }
.gg-img-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}
.gg-img-modal-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 6px;
    cursor: default;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.gg-extraction-prompt {
    width: 100%;
    font-size: 11px;
    background: #0d0a14;
    border: 1px solid #2d1b69;
    border-radius: 6px;
    padding: 6px 8px;
    color: #94a3b8;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
}
.gg-extraction-prompt:focus { outline: none; border-color: #7c3aed; color: #e2e8f0; }

/* ── Section label ──────────────────────────────────────────────────── */
.gg-section-label {
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 12px 0 6px;
}

/* ── Master prompt edit in CONFIGURE ───────────────────────────────── */
.gg-master-prompt-edit {
    width: 100%;
    font-size: 12px;
    background: #0d0a14;
    border: 1px solid #2d1b69;
    border-radius: 6px;
    padding: 8px 10px;
    color: #94a3b8;
    resize: vertical;
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
    margin-bottom: 4px;
}
.gg-master-prompt-edit:focus { outline: none; border-color: #7c3aed; color: #e2e8f0; }

.gg-strength-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0 4px;
}
.gg-strength-slider {
    flex: 1;
    accent-color: #7c3aed;
    cursor: pointer;
}
.gg-size-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 6px 0 4px;
}
.gg-size-options {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.gg-size-btn {
    padding: 3px 8px;
    font-size: 11px;
    font-family: monospace;
    background: #1a1a28;
    border: 1px solid #2a2a3e;
    border-radius: 4px;
    color: #94a3b8;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.gg-size-btn:hover:not(:disabled) { border-color: #7c3aed; color: #e2e8f0; }
.gg-size-btn.active { border-color: #7c3aed; color: #a78bfa; background: #1e1230; }
.gg-size-btn:disabled { opacity: 0.4; cursor: default; }
.gg-strength-val {
    font-size: 12px;
    color: #a78bfa;
    min-width: 32px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ── Phase actions row (MASTER_REVIEW) ──────────────────────────────── */
.gg-phase-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.gg-phase-actions .btn-primary { margin-left: auto; }

/* ══════════════════════════════════════════════════════════════════════
   /generate page — Auto Generate Character
   ══════════════════════════════════════════════════════════════════════ */

/* ── Full-page shell ──────────────────────────────────────────────────── */
.gp-root {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: #0d0d0f;
    color: #e2e8f0;
    font-family: inherit;
}

/* ── Top header bar ───────────────────────────────────────────────────── */
.gp-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: 48px;
    background: #13131a;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.gp-header-title {
    font-size: 13px;
    font-weight: 600;
    color: #a78bfa;
    letter-spacing: 0.02em;
}
.gp-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.gp-back-btn { color: #64748b; }
.gp-back-btn:hover { color: #e2e8f0; }

.gp-gen-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #a78bfa;
    background: #1e1230;
    border: 1px solid #4c1d95;
    border-radius: 6px;
    padding: 3px 8px;
}
.gp-gen-count { color: #64748b; }
.gp-gen-error-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #f87171;
    background: #1c0a0a;
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    padding: 3px 8px;
}

/* ── Progress bar ─────────────────────────────────────────────────────── */
.gp-progress-bar {
    height: 2px;
    background: #1e1e2e;
    flex-shrink: 0;
}
.gp-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
    transition: width 0.4s ease;
}

/* ── DESCRIBE phase ───────────────────────────────────────────────────── */
.gp-describe {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 24px 16px;
}
.gp-describe-card {
    width: 100%;
    max-width: 700px;
    background: #13131a;
    border: 1px solid #1e1e2e;
    border-radius: 12px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.gp-describe-icon { color: #7c3aed; }
.gp-describe-title {
    font-size: 20px;
    font-weight: 700;
    color: #e2e8f0;
    margin: 0;
}
.gp-describe-sub {
    font-size: 13px;
    color: #64748b;
    margin: 0;
}
.gp-describe-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 13px;
    padding: 20px 0;
}
.gp-input-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}
.gp-input-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    border: 1px solid #1e1e2e;
    background: transparent;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.gp-input-tab:hover { border-color: #334155; color: #94a3b8; }
.gp-input-tab.active { border-color: #7c3aed; background: #7c3aed1a; color: #a78bfa; }

.gp-describe-form { display: flex; flex-direction: column; gap: 14px; }

.gp-upload-form { display: flex; flex-direction: column; gap: 12px; }

.gp-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 16px;
    border: 2px dashed #1e1e2e;
    border-radius: 8px;
    color: #475569;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.gp-drop-zone:hover, .gp-drop-zone.dragging {
    border-color: #7c3aed;
    color: #a78bfa;
}
.gp-drop-hint { font-size: 11px; color: #334155; }

.gp-upload-preview {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}
.gp-upload-thumb {
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid #334155;
    background: #0d0d0f;
    display: block;
}
.gp-upload-clear {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
}
.gp-upload-clear:hover { background: #dc2626; }
.gp-upload-name { font-size: 11px; color: #64748b; }
.gp-normalize-btn { width: 100%; justify-content: center; font-size: 12px; }
.gp-upload-error { font-size: 12px; color: #f87171; display: flex; align-items: center; gap: 4px; }

.gp-desc-input {
    width: 100%;
    background: #0d0d0f;
    border: 1px solid #1e1e2e;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 13px;
    padding: 10px 12px;
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.gp-desc-input:focus {
    outline: none;
    border-color: #7c3aed;
}
.gp-desc-input::placeholder { color: #475569; }

.gp-cat-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.gp-cat-tab { border-color: #1e1e2e; }
.gp-cat-tab:hover { border-color: #7c3aed; color: #e2e8f0; }
.gp-cat-tab-active { border-color: #7c3aed !important; color: #a78bfa !important; background: #1e1230; }

.gp-presets-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 180px;
    overflow-y: auto;
}
.gp-preset-chip { border-color: #1e1e2e; background: #0d0d0f; color: #94a3b8; white-space: normal; text-align: left; line-height: 1.4; }
.gp-preset-chip:hover { border-color: #7c3aed; color: #e2e8f0; }
.gp-preset-chip-active { border-color: #7c3aed !important; background: #1e1230; color: #a78bfa !important; }

.gp-generate-btn {
    justify-content: center;
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
}

/* ── STUDIO 3-column layout ───────────────────────────────────────────── */
.gp-studio {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

/* ── Left panel: components ───────────────────────────────────────────── */
.gp-studio-left {
    width: 230px;
    flex-shrink: 0;
    background: #0d0d0f;
    border-right: 1px solid #1e1e2e;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.gp-comp-panel { padding: 10px 8px; display: flex; flex-direction: column; gap: 6px; }
.gp-comp-panel-label {
    font-size: 10px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.gp-master-thumb-wrap {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    background: #13131a;
    aspect-ratio: 9/16;
}
.gp-master-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gp-comp-generating-mask {
    position: absolute;
    inset: 0;
    background: rgba(13,13,15,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a78bfa;
}

.gp-comp-list { display: flex; flex-direction: column; gap: 3px; }
.gp-comp-item {
    border: 1px solid #1e1e2e;
    border-radius: 6px;
    background: #13131a;
    overflow: hidden;
    transition: border-color 0.15s;
}
.gp-comp-item-active { border-color: #7c3aed; }
.gp-comp-item-done { border-color: #1a3a1a; }
.gp-comp-item-disabled { opacity: 0.4; }
.gp-comp-item-disabled:not(.gp-comp-item-active) .gp-comp-checkbox { opacity: 1; }
.gp-comp-checkbox:disabled { cursor: not-allowed; }

.gp-comp-checkbox {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #7c3aed;
}
.gp-regen-btn { margin-left: auto; flex-shrink: 0; }

.gp-comp-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
    cursor: pointer;
}
.gp-comp-item-header:hover { background: #1e1e2e; }

.gp-comp-mini-thumb {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    object-fit: cover;
    background: #0d0d0f;
    flex-shrink: 0;
}
.gp-comp-item-name {
    flex: 1;
    font-size: 10px;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gp-comp-item-status { color: #64748b; flex-shrink: 0; display: flex; align-items: center; }
.gp-regen-btn { display: flex; align-items: center; gap: 4px; }
.gp-comp-error {
    padding: 4px 7px 6px;
    font-size: 10px;
    color: #f87171;
    word-break: break-word;
}

/* ── Center panel: canvas ─────────────────────────────────────────────── */
.gp-studio-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d0d0f;
}

/* View toggle bar */
.gp-view-toggle {
    display: flex;
    gap: 2px;
    padding: 4px 8px;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
    background: #13131a;
}
.gp-view-btn { gap: 4px; }

/* Stacked canvas / SDK container */
.gp-center-views {
    flex: 1;
    position: relative;
    min-height: 0;
}

.gp-canvas-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: #0a0a0d;
}

/* SDK mount fills the same slot */
.gp-sdk-mount {
    position: absolute;
    inset: 0;
    overflow: hidden;
}
/* Contain SDK container — kill viewport heights */
.gp-sdk-mount #tdoge-sdk-container {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: unset !important;
}
/* First screen fills mount, not viewport */
.gp-sdk-mount .tdoge-sdk-first-screen {
    height: 100% !important;
    min-height: unset !important;
}

/* Hidden view pushed behind via z-index — keeps dimensions for Rive/SDK canvas */
.gp-view-behind {
    z-index: 0;
    pointer-events: none;
    visibility: hidden;
}
.gp-canvas-wrap:not(.gp-view-behind),
.gp-sdk-mount:not(.gp-view-behind) {
    z-index: 1;
    visibility: visible;
    pointer-events: auto;
}
.gp-canvas {
    width: 100%;
    height: 100%;
    display: block;
}
.gp-canvas-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    background: rgba(10,10,13,0.6);
}

/* Landmark dots */
.gp-landmark-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}
.gp-landmark-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.4);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 4px currentColor;
}

/* Canvas controls bar */
.gp-canvas-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: #13131a;
    border-top: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.gp-canvas-ctrl-sep { flex: 1; }
.gp-zoom-slider { width: 80px; accent-color: #7c3aed; }
.gp-zoom-val { font-size: 11px; color: #64748b; min-width: 28px; text-align: right; }

/* ── Right panel: controls + chat ─────────────────────────────────────── */
.gp-studio-right {
    width: 280px;
    flex-shrink: 0;
    border-left: 1px solid #1e1e2e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0d0d0f;
}

/* Controls */
.gp-controls-panel {
    padding: 10px 12px;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.gp-panel-section-label {
    font-size: 10px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
    display: block;
}
.gp-motion-row { display: flex; gap: 4px; flex-wrap: wrap; }
.gp-motion-btn {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
}

.gp-slider-row {
    display: flex;
    align-items: center;
    gap: 6px;
}
.gp-slider-label { font-size: 10px; color: #64748b; min-width: 68px; flex-shrink: 0; }
.gp-slider { flex: 1; accent-color: #7c3aed; cursor: pointer; }
.gp-slider-val { font-size: 11px; color: #a78bfa; min-width: 16px; text-align: right; }
.gp-slider-sm { height: 12px; }

.gp-offsets-grid { display: flex; flex-direction: column; gap: 4px; }
.gp-offset-row { display: flex; align-items: center; gap: 5px; }
.gp-offset-label { font-size: 10px; color: #64748b; min-width: 44px; flex-shrink: 0; }
.gp-offset-val {
    font-size: 10px;
    color: #a78bfa;
    min-width: 28px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.gp-bounds-info {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gp-bounds-info-label { font-size: 9px; color: #475569; font-weight: 600; text-transform: uppercase; }
.gp-bounds-info-item { font-size: 10px; color: #64748b; font-variant-numeric: tabular-nums; }

/* Chat panel */

/* ── Shared utils ─────────────────────────────────────────────────────── */
.gp-img-placeholder {
    background: #1e1e2e;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gp-status-done  { color: #4ade80; }
.gp-status-error { color: #f87171; }
.gp-status-dot {
    display: inline-block;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #475569;
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Confirm phase ────────────────────────────────────────────────────── */
.gp-confirm {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: auto;
}
.gp-confirm-card {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    background: #13131a;
    border: 1px solid #1e1e2e;
    border-radius: 12px;
    padding: 24px;
    max-width: 680px;
    width: 100%;
}
.gp-confirm-generating {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px;
    width: 100%;
    color: #94a3b8;
    font-size: 14px;
}
.gp-confirm-preview {
    flex-shrink: 0;
    width: 160px;
    border-radius: 8px;
    overflow: hidden;
    background: #0d0d0f;
    aspect-ratio: 9/16;
}
.gp-confirm-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gp-confirm-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}
.gp-confirm-title {
    font-size: 15px;
    font-weight: 600;
    color: #e2e8f0;
}
.gp-confirm-desc {
    font-size: 12px;
    color: #64748b;
    font-style: italic;
    word-break: break-word;
}
.gp-confirm-hint {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.5;
}
.gp-confirm-error {
    font-size: 11px;
    color: #f87171;
    background: rgba(248,113,113,0.08);
    border: 1px solid rgba(248,113,113,0.2);
    border-radius: 6px;
    padding: 6px 8px;
}
.gp-confirm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

/* ── Generation progress banner (top of page) ────────────────────────── */
.gp-gen-overlay {
    flex-shrink: 0;
    background: #13131a;
    border-bottom: 1px solid #2d2d3f;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.gp-gen-overlay-inner {
    display: contents; /* children lay out directly inside .gp-gen-overlay */
}
.gp-gen-overlay-spinner { color: #a78bfa; flex-shrink: 0; }
.gp-gen-overlay-label {
    font-size: 12px;
    font-weight: 600;
    color: #e2e8f0;
    min-width: 80px;
    flex-shrink: 0;
}
.gp-gen-overlay-sub {
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}
.gp-gen-overlay-bar-wrap {
    flex: 1;
    height: 5px;
    background: #1e1e2e;
    border-radius: 3px;
    overflow: hidden;
    min-width: 60px;
}
.gp-gen-overlay-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #7c3aed, #a78bfa);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.gp-gen-overlay-pct {
    font-size: 11px;
    color: #a78bfa;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 30px;
    text-align: right;
}

/* ── Image modal ──────────────────────────────────────────────────────── */
.gp-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}
.gp-modal-box {
    background: #13131a;
    border: 1px solid #2d2d3f;
    border-radius: 12px;
    overflow: hidden;
    max-width: min(540px, 90vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}
.gp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid #1e1e2e;
}
.gp-modal-label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
}
.gp-modal-close { color: #64748b; }
.gp-modal-close:hover { color: #e2e8f0; }
.gp-modal-img {
    display: block;
    max-width: 100%;
    max-height: calc(90vh - 48px);
    object-fit: contain;
}

/* ── Component item row (v2) ──────────────────────────────────────────── */
.gp-comp-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 7px;
}
.gp-comp-thumb-wrap {
    position: relative;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    background: #0d0d0f;
    cursor: pointer;
}
.gp-comp-thumb-wrap:hover .gp-comp-thumb-zoom { opacity: 1; }
.gp-comp-thumb-zoom {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
    color: #fff;
}
.gp-thumb-zoom-hint {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.8);
    opacity: 0;
    transition: opacity 0.15s;
}
.gp-master-thumb-wrap:hover .gp-thumb-zoom-hint { opacity: 1; }
.gp-master-thumb-wrap { cursor: pointer; }

/* Update regen-btn for always-visible inline position */
.gp-regen-btn {
    margin: 0;
    flex-shrink: 0;
    color: #475569;
}
.gp-regen-btn:hover { color: #a78bfa; }

/* ── VM text input + select ───────────────────────────────────────────── */
.gp-vm-text-input {
    width: 100%;
    background: #0d0d0f;
    border: 1px solid #1e1e2e;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 12px;
    padding: 5px 8px;
    font-family: inherit;
    transition: border-color 0.15s;
}
.gp-vm-text-input:focus {
    outline: none;
    border-color: #7c3aed;
}
.gp-vm-text-input::placeholder { color: #475569; }
.gp-select {
    width: 100%;
    background: #0d0d0f;
    border: 1px solid #1e1e2e;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 12px;
    padding: 4px 7px;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2364748b'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
    transition: border-color 0.15s;
}
.gp-select:focus {
    outline: none;
    border-color: #7c3aed;
}
.gp-select:disabled { opacity: 0.45; cursor: default; }

/* ── ChatTestTab ──────────────────────────────────────────────────────────── */

.ct-root {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* SDK bundle mount point — fills the tab content area */
.ct-sdk-mount {
    flex: 1;
    overflow: hidden;
    position: relative;
}
/* Contain SDK container — kill viewport heights */
.ct-sdk-mount #tdoge-sdk-container {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: unset !important;
}
/* First screen fills mount, not viewport */
.ct-sdk-mount .tdoge-sdk-first-screen {
    height: 100% !important;
    min-height: unset !important;
}

/* Header */
.ct-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
    gap: 8px;
}
.ct-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.ct-preset-select {
    background: #13131a;
    border: 1px solid #2d2d3f;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    max-width: 220px;
}
.ct-preset-select:focus { outline: none; border-color: #7c3aed; }
.ct-loading { color: #7c3aed; }

.ct-conn-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
}
.ct-conn-badge.ct-conn-on { color: #4ade80; }

/* Body */
.ct-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* Canvas column — right half */
.ct-canvas-col {
    display: flex;
    flex-direction: column;
    width: 50%;
    flex-shrink: 0;
    border-left: 1px solid #1e1e2e;
    background: #0d0d0f;
}
.ct-canvas-wrap {
    position: relative;
    flex: 1;
    overflow: hidden;
}
.ct-canvas {
    width: 100%;
    height: 100%;
    display: block;
}
.ct-canvas-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
}
.ct-canvas-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #1e1e2e;
    flex-shrink: 0;
    padding: 0 10px;
    height: 32px;
    gap: 8px;
}
.ct-sm-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    color: #475569;
}
.ct-canvas-fit-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ct-fit-label {
    font-size: 10px;
    color: #475569;
    white-space: nowrap;
}
.ct-fit-select {
    font-size: 10px;
    background: #1e1e2e;
    border: 1px solid #2d2d3f;
    color: #e2e8f0;
    border-radius: 3px;
    padding: 1px 4px;
    cursor: pointer;
}
.ct-zoom-slider {
    width: 70px;
    accent-color: #7c3aed;
    cursor: pointer;
}
.ct-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #475569;
    flex-shrink: 0;
}
.ct-dot.ct-dot-on { background: #4ade80; }

/* Chat column */
.ct-chat-col {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.ct-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ct-empty {
    color: #475569;
    font-size: 12px;
    text-align: center;
    margin-top: 24px;
}
.ct-msg {
    display: flex;
    max-width: 88%;
}
.ct-msg-user { align-self: flex-end; }
.ct-msg-ai   { align-self: flex-start; }
.ct-msg-text {
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
    color: #e2e8f0;
    background: #1e1e2e;
    word-break: break-word;
}
.ct-msg-user .ct-msg-text {
    background: #7c3aed;
    color: #fff;
    border-bottom-right-radius: 3px;
}
.ct-msg-ai .ct-msg-text { border-bottom-left-radius: 3px; }

.ct-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.ct-text-input {
    flex: 1;
    background: #13131a;
    border: 1px solid #2d2d3f;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 12px;
    padding: 5px 9px;
    outline: none;
    min-width: 0;
}
.ct-text-input:focus  { border-color: #7c3aed; }
.ct-text-input:disabled { opacity: 0.5; cursor: default; }
.ct-mic-active { color: #f87171 !important; border-color: #f87171 !important; }

/* Mode bar — top of chat column */
.ct-mode-bar {
    display: flex;
    gap: 2px;
    padding: 6px 10px;
    border-bottom: 1px solid #1e1e2e;
    flex-shrink: 0;
    background: #13131a;
}
.ct-mode-btn {
    padding: 3px 10px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.ct-mode-btn:hover  { color: #e2e8f0; }
.ct-mode-btn.active { background: #7c3aed; color: #fff; }

/* Voice/realtime controls row */
.ct-voice-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid #1e1e2e;
    flex-shrink: 0;
}
.ct-voice-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12px;
}
.ct-voice-status {
    font-size: 11px;
    color: #64748b;
}
.ct-voice-status.ct-status-active { color: #4ade80; }

/* ── /generate page — component hover detail card ───────────────────────────── */
.gp-hover-card {
    position: fixed;
    width: 336px;
    background: #13131a;
    border: 1px solid #2a2a3e;
    border-radius: 8px;
    padding: 10px 12px;
    z-index: 300;
    box-shadow: 0 8px 32px rgba(0,0,0,0.55);
    cursor: default;
}
.gp-hover-card-name {
    font-size: 11px;
    font-weight: 600;
    color: #a78bfa;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}
.gp-hover-prompt {
    font-size: 10px;
    color: #94a3b8;
    line-height: 1.55;
    max-height: 88px;
    overflow-y: auto;
    background: #0d0d1a;
    border-radius: 4px;
    padding: 6px 8px;
    margin-bottom: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}
.gp-hover-imgs {
    display: flex;
    gap: 6px;
}
.gp-hover-img-col {
    flex: 1;
    min-width: 0;
}
.gp-hover-img-label {
    font-size: 9px;
    color: #475569;
    text-align: center;
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.gp-hover-thumb {
    width: 100%;
    height: 90px;
    object-fit: contain;
    background: #0d0d1a;
    border-radius: 4px;
    display: block;
}
.gp-hover-thumb.gp-img-placeholder {
    height: 90px;
}

/* ─── Skin color detection ───────────────────────────────────────────────── */
.gg-skin-btn {
    padding: 2px 5px;
    background: transparent;
    border: 1px solid #2a2a3a;
    border-radius: 4px;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.gg-skin-btn:hover:not(:disabled) { color: #a78bfa; border-color: #a78bfa; }
.gg-skin-btn:disabled { opacity: 0.5; cursor: default; }
.gg-skin-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #a78bfa;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.gg-skin-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    border: 1px solid rgba(255,255,255,0.15);
    flex-shrink: 0;
}
.gg-skin-conf {
    color: #64748b;
    font-size: 9px;
}
