/* ======================================================================
   Aipics — Photo editor workspace
   ====================================================================== */
.editor-page { background: #0B1024; overflow: hidden; }
.editor-page .aipics-navbar { background: rgba(255, 255, 255, .96); }
.editor-app {
    display: grid; grid-template-columns: 88px 300px minmax(0, 1fr); height: calc(100vh - var(--nav-h)); height: calc(100dvh - var(--nav-h));
    background: #0F172A; color: #E2E8F0;
}

/* Rail */
.ed-rail { background: #0B1024; border-right: 1px solid rgba(255, 255, 255, .06); overflow-y: auto; padding: 10px 8px; display: flex; flex-direction: column; gap: 4px; scrollbar-width: none; }
.ed-rail::-webkit-scrollbar { display: none; }
.rail-btn {
    border: 0; background: none; color: #94A3B8; border-radius: 14px; padding: 9px 4px; display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: .66rem; font-weight: 500; transition: all .2s; line-height: 1.2; text-align: center;
}
.rail-btn i { font-size: 1.05rem; }
.rail-btn:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.rail-btn.active { color: #fff; background: var(--grad-main); box-shadow: 0 8px 20px rgba(37, 99, 235, .35); }

/* Panel */
.ed-panel { background: #111a33; border-right: 1px solid rgba(255, 255, 255, .06); display: flex; flex-direction: column; min-height: 0; }
.ed-panel-head { padding: 16px 18px; border-bottom: 1px solid rgba(255, 255, 255, .06); display: flex; justify-content: space-between; align-items: center; }
.ed-panel-head h2 { color: #fff; font-family: var(--font-head); }
.ed-panel-head .btn-close { filter: invert(1); }
.ed-panel-body { padding: 16px 18px 24px; overflow-y: auto; flex: 1; scrollbar-width: thin; scrollbar-color: #334155 transparent; }
.panel-sec { display: none; }
.panel-sec.active { display: block; animation: fadein .2s; }
.ed-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #64748B; margin-bottom: 8px; }
.ed-hint { font-size: .8rem; color: #94A3B8; background: rgba(255, 255, 255, .04); border-radius: 10px; padding: 10px 12px; margin: 0; }
.ed-hint a { color: #A5B4FC; }
.ed-panel .form-control, .ed-panel .form-select { background-color: #0B1024; border-color: #1E293B; color: #E2E8F0; }
.ed-panel .form-control:focus, .ed-panel .form-select:focus { border-color: var(--ai-purple); }
.ed-panel .form-control-color { width: 44px; padding: 3px; height: 34px; }
.ed-panel .form-check-label { color: #CBD5E1; }
.ed-panel .btn-light { background: #1E293B; color: #E2E8F0; border: 0; }
.ed-panel .btn-light:hover { background: #334155; color: #fff; }
.ed-panel .btn-soft { background: rgba(99, 102, 241, .15); color: #C7D2FE; }
.ed-panel .btn-soft:hover { background: rgba(99, 102, 241, .28); color: #fff; }

.slider-row { margin-bottom: 12px; }
.slider-row label { display: flex; justify-content: space-between; font-size: .82rem; color: #CBD5E1; margin-bottom: 2px; }
.slider-row output { color: #A5B4FC; font-weight: 600; font-variant-numeric: tabular-nums; }
.ed-panel .form-range { height: 1.2rem; }
.ed-panel .form-range::-webkit-slider-runnable-track { background: #1E293B; height: 4px; border-radius: 4px; }
.ed-panel .form-range::-webkit-slider-thumb { margin-top: -6px; width: 16px; height: 16px; background: #fff; box-shadow: 0 0 0 4px rgba(124, 58, 237, .5); }
.ed-panel .form-range::-moz-range-track { background: #1E293B; height: 4px; border-radius: 4px; }
.ed-panel .form-range::-moz-range-thumb { width: 16px; height: 16px; background: #fff; border: 0; box-shadow: 0 0 0 4px rgba(124, 58, 237, .5); }

.chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-sm { border: 1px solid #1E293B; background: #0B1024; color: #CBD5E1; border-radius: 10px; padding: .35rem .7rem; font-size: .78rem; font-weight: 500; transition: all .15s; }
.chip-sm:hover { border-color: #6366F1; color: #fff; }
.chip-sm.active { background: var(--grad-main); border-color: transparent; color: #fff; }
.btn-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-grid-2 .btn { font-size: .82rem; padding: .6rem .5rem; }
.lock-btn { border: 1px solid #1E293B; background: #0B1024; color: #64748B; border-radius: 10px; width: 38px; height: 34px; flex-shrink: 0; }
.lock-btn.active { color: #A5B4FC; border-color: #6366F1; }
.preset-list { display: flex; flex-direction: column; gap: 6px; }
.preset-btn { display: flex; align-items: center; gap: 10px; border: 1px solid #1E293B; background: #0B1024; color: #CBD5E1; border-radius: 12px; padding: .55rem .75rem; font-size: .82rem; text-align: left; }
.preset-btn i { width: 18px; color: #A5B4FC; }
.preset-btn span { flex: 1; }
.preset-btn small { color: #64748B; }
.preset-btn:hover { border-color: #6366F1; color: #fff; }

.sample-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sample-thumb { border-radius: 10px; overflow: hidden; aspect-ratio: 1; border: 2px solid transparent; }
.sample-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.sample-thumb:hover { border-color: var(--ai-purple); }
.sample-thumb:hover img { transform: scale(1.08); }
.ed-drop { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 26px 14px; border: 2px dashed #334155; border-radius: 16px; cursor: pointer; transition: all .2s; color: #CBD5E1; }
.ed-drop i { font-size: 1.8rem; color: #A5B4FC; }
.ed-drop small { color: #64748B; }
.ed-drop:hover { border-color: var(--ai-purple); background: rgba(124, 58, 237, .08); }

.filter-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.filter-thumb { border: 0; background: none; padding: 0; color: #CBD5E1; font-size: .72rem; font-weight: 500; text-align: center; }
.filter-thumb canvas { width: 100%; aspect-ratio: 1; border-radius: 12px; object-fit: cover; display: block; border: 2px solid transparent; margin-bottom: 4px; background: #1E293B; }
.filter-thumb.active canvas { border-color: #A78BFA; box-shadow: 0 0 0 3px rgba(124, 58, 237, .35); }
.filter-thumb.active { color: #fff; }

.ai-tool-btn { display: flex; align-items: center; gap: 12px; width: 100%; border: 1px solid #1E293B; background: #0B1024; border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; text-align: left; color: #E2E8F0; position: relative; transition: all .2s; }
.ai-tool-btn:hover { border-color: #6366F1; transform: translateX(2px); }
.ai-tool-btn.highlight { border-color: #A78BFA; box-shadow: 0 0 0 3px rgba(124, 58, 237, .35); animation: glowpulse 1.6s ease-in-out 3; }
@keyframes glowpulse { 50% { box-shadow: 0 0 0 7px rgba(124, 58, 237, .15); } }
.ai-ic { width: 38px; height: 38px; border-radius: 11px; background: var(--grad-main); display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; }
.ai-txt { flex: 1; min-width: 0; }
.ai-txt strong { display: block; font-size: .85rem; font-weight: 600; }
.ai-txt small { color: #94A3B8; font-size: .72rem; }
.ai-txt small i { color: #F59E0B; }
.ai-tier { color: #F59E0B; font-size: .8rem; }

.bg-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 10px; }
.bg-swatch { aspect-ratio: 1; border-radius: 10px; border: 2px solid #1E293B; }
.bg-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px #7C3AED; }

.layer-props { background: rgba(255, 255, 255, .03); border: 1px solid #1E293B; border-radius: 14px; padding: 12px; }
.tog-btn { width: 36px; height: 34px; border-radius: 10px; border: 1px solid #1E293B; background: #0B1024; color: #94A3B8; }
.tog-btn.active { color: #fff; background: var(--grad-main); border-color: transparent; }
.shape-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shape-btn { aspect-ratio: 1.3; border-radius: 12px; border: 1px solid #1E293B; background: #0B1024; color: #A5B4FC; font-size: 1.3rem; }
.shape-btn:hover { border-color: #6366F1; color: #fff; }
.frame-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.frame-btn { border: 0; background: none; color: #CBD5E1; font-size: .7rem; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; }
.fr-prev { width: 100%; aspect-ratio: 1; border-radius: 10px; background: linear-gradient(135deg, #6366F1, #06B6D4); display: block; border: 2px solid transparent; }
.frame-btn.active .fr-prev { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #7C3AED; }
.fr-thin { box-shadow: inset 0 0 0 3px #fff; }
.fr-thick { box-shadow: inset 0 0 0 8px #fff; }
.fr-polaroid { box-shadow: inset 0 0 0 5px #fff, inset 0 -14px 0 5px #fff; }
.fr-rounded { border-radius: 22px; }
.fr-double { box-shadow: inset 0 0 0 3px #fff, inset 0 0 0 6px #0F172A, inset 0 0 0 8px #fff; }
.fr-gradient { border: 4px solid; border-image: linear-gradient(135deg, #F97316, #EC4899) 1; }
.fr-film { box-shadow: inset 0 7px 0 #000, inset 0 -7px 0 #000; }
.export-info { font-size: .82rem; color: #CBD5E1; background: rgba(255, 255, 255, .04); border-radius: 10px; padding: 10px 12px; }

/* Stage */
.ed-stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.ed-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: #111a33; border-bottom: 1px solid rgba(255, 255, 255, .06); flex-wrap: wrap; }
.tb-group { display: flex; align-items: center; gap: 4px; }
.tb-right { gap: 8px; }
.tb-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: #CBD5E1; display: inline-flex; align-items: center; justify-content: center; transition: all .15s; }
.tb-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .08); color: #fff; }
.tb-btn:disabled { opacity: .35; }
.tb-sep { width: 1px; height: 22px; background: rgba(255, 255, 255, .1); margin: 0 6px; display: inline-block; }
.tb-zoom { min-width: 52px; text-align: center; font-size: .8rem; font-weight: 600; color: #E2E8F0; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: #0B1024; border-radius: 12px; padding: 3px; }
.seg-btn { border: 0; background: none; color: #94A3B8; padding: .4rem .8rem; border-radius: 9px; font-size: .8rem; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.seg-btn.active, .seg-btn:active { background: var(--grad-main); color: #fff; }
.project-name { width: 150px; background: #0B1024; border-color: #1E293B; color: #E2E8F0; }
.project-name:focus { background: #0B1024; color: #fff; }
.ed-topbar .btn-light { background: #1E293B; color: #E2E8F0; }
.ed-topbar .btn-soft { background: rgba(99, 102, 241, .18); color: #C7D2FE; }

.ed-canvas-wrap {
    flex: 1; min-height: 0; overflow: auto; position: relative; display: grid; place-items: center; padding: 28px;
    background: radial-gradient(circle at 50% 40%, #16213f, #0B1024 70%);
}
.ed-canvas-box { position: relative; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); line-height: 0; }
.ed-canvas-box canvas { display: block; }
#edCanvas { width: 100%; height: 100%; }
.ed-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.ed-overlay.masking { cursor: crosshair; }
.ed-compare { position: absolute; inset: 0; --pos: 50%; touch-action: none; cursor: ew-resize; }
.ed-compare canvas { position: absolute; inset: 0; width: 100%; height: 100%; clip-path: inset(0 calc(100% - var(--pos)) 0 0); }
.cmp-handle { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 3px; background: #fff; transform: translateX(-50%); box-shadow: 0 0 12px rgba(0, 0, 0, .4); }
.cmp-handle .ba-knob { position: absolute; top: 50%; left: 50%; width: 44px; height: 44px; transform: translate(-50%, -50%); border-radius: 50%; background: #fff; color: #7C3AED; display: flex; align-items: center; justify-content: center; gap: 3px; font-size: .75rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); line-height: 1; }
.ed-compare .ba-label { line-height: 1.4; }
.ed-crop { position: absolute; inset: 0; line-height: normal; }
.ed-crop img { display: block; max-width: 100%; }
.ed-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.ed-empty-card { background: rgba(255, 255, 255, .97); color: var(--ai-navy); border-radius: 28px; padding: 44px 40px; text-align: center; max-width: 460px; cursor: pointer; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); transition: transform .2s; }
.ed-empty-card:hover { transform: translateY(-3px); }
.ed-empty-card .dz-icon { width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 22px; display: flex; align-items: center; justify-content: center; font-size: 30px; color: #fff; background: var(--grad-main); box-shadow: var(--shadow-glow); }
.ed-empty a { color: #A5B4FC; }
.ed-dragover { position: absolute; inset: 12px; border: 3px dashed #A78BFA; border-radius: 24px; background: rgba(124, 58, 237, .18); display: none; align-items: center; justify-content: center; text-align: center; color: #fff; z-index: 5; pointer-events: none; }
.ed-dragover.show { display: flex; }
.ed-dragover i { font-size: 3rem; }
.ed-status { display: flex; justify-content: space-between; gap: 16px; padding: 7px 16px; font-size: .74rem; color: #64748B; background: #0B1024; border-top: 1px solid rgba(255, 255, 255, .06); }

/* Tablet / mobile editor */
@media (max-width: 991.98px) {
    .editor-app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: calc(100dvh - var(--nav-h)); }
    .ed-stage { grid-row: 1; }
    .ed-rail { grid-row: 2; min-width: 0; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-right: 0; border-top: 1px solid rgba(255, 255, 255, .08); padding: 6px; gap: 2px; }
    .rail-btn { min-width: 68px; padding: 7px 4px; }
    .ed-panel { position: fixed; left: 0; right: 0; bottom: 74px; z-index: 1040; max-height: 52vh; border-radius: 22px 22px 0 0; transform: translateY(calc(100% + 100px)); visibility: hidden; transition: transform .3s var(--ease), visibility .3s; box-shadow: 0 -20px 50px rgba(0, 0, 0, .5); border: 0; }
    .ed-panel.open { transform: none; visibility: visible; }
    .ed-topbar { padding: 8px; gap: 6px; }
    .ed-canvas-wrap { padding: 14px; }
    .ed-status { display: none; }
    .editor-page .mobile-bottom-nav { display: none !important; }
}
@media (max-width: 575.98px) {
    .tb-btn { width: 32px; height: 32px; }
    .tb-zoom { min-width: 42px; font-size: .72rem; }
    .ed-topbar .btn-sm { padding: .4rem .6rem; }
    .ed-empty-card { padding: 32px 22px; }
}
