/* ════════════════════════════════════════════════════════════════════════
   MASPRINTO STUDIO — stylesheet
   Extracted from inline <style>. Brace-bug fix in .preview-scene__sidebar.
   Canva-grade polish layer appended at the very end (search "POLISH LAYER").
   ════════════════════════════════════════════════════════════════════════ */

/* ════════════════════════════════════════════════════════
   MASPRINTO STUDIO — merchant design editor
   Visual refresh: topbar + dock + flyout panel + side chips
   ════════════════════════════════════════════════════════ */

:root {
    /* Design system (new) */
    --accent:       #4f46e5;
    --accent-700:   #4338ca;
    --accent-soft:  #eef2ff;
    --accent-line:  #c7d2fe;
    --ink:          #0f172a;
    --muted:        #64748b;
    --faint:        #94a3b8;
    --line:         #e2e8f0;
    --line-2:       #f1f5f9;
    --bg:           #f1f5f9;
    --panel:        #ffffff;
    --ok:           #10b981;
    --bad:          #ef4444;
    --sh-sm:        0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
    --sh-md:        0 6px 20px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.06);
    --sh-lg:        0 18px 50px rgba(15,23,42,.18);
    --r-sm:         9px;
    --r-md:         13px;
    --r-lg:         18px;
    --tool-w:       72px;
    --mbar-h:       64px;   /* tinggi bottom-bar mobile; sheet duduk di atasnya */
    --sheet-h:      40dvh;  /* tinggi TETAP & seragam bottom-sheet menu mobile (semua menu sama) */
    /* Legacy compat (studio.js inline styles reference these) */
    --primary:      #4f46e5;
    --primary-hover:#4338ca;
    --surface:      #ffffff;
    --text:         #0f172a;
    --text-light:   #64748b;
    --border:       #e2e8f0;
    --success:      #10b981;
    --danger:       #ef4444;
    --warning:      #f59e0b;
    --radius:       16px;
    --shadow-card:  0 4px 6px -1px rgba(15,23,42,.06);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', 'Outfit', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    /* dvh = area viewport yang BENAR-BENAR terlihat di mobile (memperhitungkan
       address-bar). vh dipakai sbg fallback browser lama. Safe-area padding di
       atas/samping; bawah ditangani oleh .mobile-bar agar bottom-bar tak ketutup. */
    height: 100vh;
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
button { font-family: inherit; cursor: pointer; }

/* ── App shell ── */
.app {
    display: flex;
    flex-direction: column;
    /* Isi 100% dari content-box body (sudah = dvh − safe-area-top). JANGAN pakai
       min-height:100vh — itu memaksa lebih tinggi dari layar shg bottom-bar terpotong. */
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* ════════════ TOPBAR ════════════ */
.topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    flex: none;
    padding: 0 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    z-index: 30;
}
.tb-back {
    flex: none;
    border-radius: 10px;
    border: 1.5px solid var(--line);
    background: #fff;
    display: grid; place-items: center;
    font-size: 15px; color: var(--ink);
}
.tb-back:hover { background: var(--bg); }
.tb-title { min-width: 0; flex: 1; overflow: hidden; }
.tb-title b {
    display: block; font-size: 14px; font-weight: 800;
    letter-spacing: -.01em; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; line-height: 1.3;
}
.tb-title small {
    display: block; font-size: 10.5px;
    color: var(--faint); line-height: 1.2;
}

/* Edit / Preview segment */
.seg {
    display: flex;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 3px; gap: 2px; flex: none;
}
.seg button {
    border: 0; background: transparent;
    color: var(--muted); font-weight: 700; font-size: 13px;
    padding: 7px 12px; border-radius: 9px;
    display: flex; align-items: center; gap: 6px;
}
.seg button.on {
    background: #fff; color: var(--accent);
    box-shadow: var(--sh-sm);
}
.seg button i { font-size: 12px; }

/* Save button in topbar */
.btn-save-topbar {
    border: 0; background: var(--accent); color: #fff;
    font-weight: 700; font-size: 13px;
    padding: 10px 14px; border-radius: 11px;
    display: flex; align-items: center; gap: 7px;
    box-shadow: 0 2px 10px rgba(79,70,229,.28);
    white-space: nowrap; flex: none;
    text-decoration: none;
}
.btn-save-topbar:hover { background: var(--accent-700); color: #fff; }
.btn-save-topbar i { font-size: 13px; }

/* ════════════ WORKSPACE ════════════ */
.work {
    flex: 1;
    display: flex;
    min-height: 0;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* ════════════ DESKTOP DOCK ════════════ */
.dock {
    width: var(--tool-w);
    flex: none;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 6px;
    z-index: 20;
}
.dock-btn {
    width: 100%; border: 0; background: transparent;
    border-radius: 12px;
    display: flex; flex-direction: column;
    align-items: center; gap: 5px;
    padding: 11px 4px; color: var(--muted);
    transition: all .15s;
}
.dock-btn i { font-size: 19px; }
.dock-btn span { font-size: 10px; font-weight: 700; letter-spacing: .01em; }
.dock-btn:hover { background: var(--bg); color: var(--ink); }
.dock-btn.on { background: var(--accent-soft); color: var(--accent); }
/* Menu Info didorong ke PALING BAWAH dock (dock = flex column) */
.dock-btn[data-panel="info"] { margin-top: auto; }

/* ════════════ CANVAS STAGE ════════════ */
.stage {
    flex: 1;
    position: relative;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 1px 1px, rgba(15,23,42,.05) 1px, transparent 0) 0 0/22px 22px,
        var(--bg);
}

/* ════════════ RIGHT SIDEBAR (Area Cetak) ════════════ */
.studio-area-sidebar {
    width: 300px;
    flex: 0 0 300px;
    height: 100%;
    background: var(--panel);
    border-left: 1px solid var(--line);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
    z-index: 20;
}
.studio-area-sidebar-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--ink);
    margin: 0;
}
.studio-area-sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Canvas containers */
#canvas-containers {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.canvas-wrapper { display: none; position: relative; }
.canvas-wrapper.active { display: block; }

/* Shirt overlay (shadow layer over canvas) */
.shirt-overlay-img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: contain; object-position: top center;
    pointer-events: none; z-index: 5;
    mix-blend-mode: multiply;
}

/* Drop indicator */
.studio-drop-indicator {
    position: absolute; border-radius: 16px;
    border: 2px dashed rgba(79,70,229,.85);
    background: rgba(79,70,229,.08);
    pointer-events: none; display: none; z-index: 10;
}
.studio-drop-indicator::after {
    content: "Drop di area";
    position: absolute; left: 50%; top: 50%;
    transform: translate(-50%,-50%);
    font-weight: 900; letter-spacing: .3px;
    color: rgba(67,56,202,.95); text-transform: uppercase;
    font-size: 12px; background: rgba(255,255,255,.7);
    padding: 6px 10px; border-radius: 999px;
    border: 1px solid rgba(79,70,229,.25);
    box-shadow: 0 6px 20px rgba(2,6,23,.10);
}
.canvas-wrapper.mp-drop-hover::after { content: ""; display: none; }

/* ── Floating side chips ── */
.sides {
    position: absolute;
    left: 50%; bottom: 76px;
    transform: translateX(-50%);
    display: flex; align-items: center; gap: 4px;
    z-index: 22;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 6px 10px;
    box-shadow: var(--sh-lg);
    max-width: calc(100% - 40px);
    overflow-x: auto; scrollbar-width: none;
}
.sides::-webkit-scrollbar { display: none; }
/* Side-picker buttons → chip style */
.sides .btn-outline {
    border: 0 !important; background: transparent !important;
    color: var(--muted) !important;
    font-weight: 700; font-size: 13px;
    padding: 8px 16px; border-radius: 999px;
    white-space: nowrap; flex: none;
    display: flex; align-items: center; gap: 6px;
    transition: all .15s;
}
.sides .btn-outline i { font-size: 12px; }
.sides .btn-outline:hover { background: var(--bg) !important; color: var(--ink) !important; }
.sides .btn-outline.active {
    background: var(--accent) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(79,70,229,.3);
}

/* ── Canvas action bar ── */
.studio-canvas-controls {
    position: absolute;
    right: 12px; bottom: 12px;
    z-index: 120;
    display: flex; align-items: flex-end;
    justify-content: flex-end;
    gap: 10px; pointer-events: none;
}
.studio-canvas-controls > * { pointer-events: auto; }
.studio-controls-right { display: flex; flex-direction: column; align-items: flex-end; gap: 7px; }

.studio-global-actionbar {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(15,23,42,.10);
    box-shadow: var(--sh-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.studio-global-actionbar.studio-actionbar-inline {
    padding: 0;
    background: none;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
.studio-global-actionbar .act-btn {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1.5px solid rgba(15,23,42,.15);
    background: #f8fafc;
    color: var(--ink);
    font-weight: 700;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    transition: all .15s;
}
.studio-global-actionbar.studio-actionbar-inline .act-btn-inline {
    background: transparent;
    border: 1.5px solid rgba(15,23,42,.20);
    color: var(--ink);
}
.studio-global-actionbar.studio-actionbar-inline .act-btn-inline:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}
.studio-global-actionbar.studio-actionbar-inline .act-btn-inline.is-active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}
.studio-global-actionbar.studio-actionbar-inline .act-btn-inline.danger {
    border-color: rgba(239,68,68,.35);
    color: rgba(185,28,28,1);
}
.studio-global-actionbar.studio-actionbar-inline .act-btn-inline.danger:hover {
    border-color: var(--bad);
    background: rgba(239,68,68,.08);
}
.studio-global-actionbar .act-btn i { font-size: 14px; }
.studio-global-actionbar .act-btn:hover {
    color: var(--accent);
    border-color: var(--accent-line);
    background: var(--accent-soft);
}
.studio-global-actionbar .act-btn.is-active {
    background: var(--accent-soft);
    border-color: rgba(79,70,229,.55);
    color: var(--accent);
}
.studio-global-actionbar .act-btn.danger {
    background: rgba(239,68,68,.08);
    border-color: rgba(239,68,68,.35);
    color: rgba(185,28,28,1);
}
.studio-global-actionbar .act-btn.danger:hover {
    background: rgba(239,68,68,.12);
    border-color: rgba(239,68,68,.55);
}

.studio-reset-view {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 11px; border-radius: 12px;
    border: 1px solid rgba(15,23,42,.10);
    background: rgba(255,255,255,.96);
    box-shadow: var(--sh-md);
    font-weight: 900; font-size: 11px; color: var(--ink);
}
.studio-reset-view i { font-size: 13px; }

.studio-zoombar {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 9px; border-radius: 14px;
    border: 1px solid rgba(15,23,42,.10);
    background: rgba(255,255,255,.96);
    box-shadow: var(--sh-md);
}
.studio-zoombar button {
    width: 34px; height: 34px; border-radius: 10px;
    border: 1.5px solid rgba(15,23,42,.10);
    background: #f8fafc; color: var(--ink);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px;
}
.studio-zoombar button:hover { color: var(--accent); border-color: var(--accent-line); }
#zoomPercent { font-size: 12px; font-weight: 900; min-width: 44px; text-align: center; color: var(--ink); }

/* ── Preview scene ── */
.preview-scene {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;          /* body (baris) di atas, tombol Download di bawah */
    gap: 16px;
    padding: 20px;
    background: #fff;
    z-index: 50;
    /* FIT tanpa scroll: scene mengisi stage, media di dalamnya di-cap ke tinggi tersedia */
    overflow: hidden;
    align-items: stretch;
}
/* Baris isi preview: kolom mockup (kiri) + sidebar "Mockup view" (kanan) */
.preview-scene__body {
    display: flex;
    flex-direction: row;
    gap: 24px;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    align-items: stretch;
}
.preview-scene__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;   /* center vertikal → mockup tidak nempel atas */
    gap: 12px;
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow: hidden;          /* cegah scroll di kolom mockup */
}
/* Base mockup (foto / snapshot pola) — fit by HEIGHT agar tidak overflow & perlu scroll */
.preview-scene__inner img {
    width: auto;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--r-lg);
    display: block;
    border: none;
}

/* ── Preview layered media (foto + tint + desain) ── */
.preview-media {
    position: relative;
    display: inline-block;
    line-height: 0;
    max-width: 100%;
    max-height: 100%;
}
/* Base = foto mockup. Tetap dapat kartu (shadow+border) dari rule img di atas,
   tapi di-fit by height di sini. Specificity (0,2,0) > .preview-scene__inner img (0,1,1). */
.preview-scene__inner .preview-media__base {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
}
/* (Tint warna kini lewat canvas → data URL pada .preview-media__base; tak ada layer tint CSS) */
/* Layer desain menutupi kotak foto persis */
.preview-media__design-layer {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
}
/* Desain: TIDAK boleh kena border/box-shadow/max-width:600 dari rule img umum.
   Specificity (0,2,1) > .preview-scene__inner img (0,1,1) → override bersih.
   ⚠ blend NORMAL (bukan multiply): multiply mengalikan warna desain × warna kaos →
   di kaos berwarna (mis. merah) desain ikut ter-warna. Normal = warna asli desain
   dipertahankan. Kesan "tercetak di kain" datang dari layer .preview-media__shade
   (lipatan kain) di atasnya, bukan dari blend warna kaos. */
.preview-scene__inner .preview-media__design {
    width: 100%; height: 100%;
    max-width: none; max-height: none;
    object-fit: contain;
    border: 0; box-shadow: none; border-radius: 0;
    mix-blend-mode: normal;
    /* opacity .92 → sedikit tekstur/warna kain tembus (tinta "meresap" ke serat),
       mengurangi kesan stiker tanpa mengubah warna desain secara mencolok. */
    opacity: .92;
}
/* Shading kain: foto mockup diulang, multiply, DIMASK ke siluet desain → lipatan/
   bayangan kain "tembus" ke desain (kaos dasar tidak ikut menggelap). opacity penuh
   agar lipatan terlihat jelas pada area cetak → desain mengikuti kontur kain. */
.preview-scene__inner .preview-media__shade {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    max-width: none; max-height: none;
    object-fit: contain;
    border: 0; box-shadow: none; border-radius: 0;
    pointer-events: none;
    mix-blend-mode: multiply;
    opacity: 1;
    -webkit-mask-size: contain; mask-size: contain;
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
}
.preview-scene__sidebar {
    width: 320px;
    flex: none;
    background: var(--panel);
    border-radius: var(--r-lg);
    border: 1px solid var(--line);
    padding: 20px;
    box-shadow: var(--sh-md);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
}
.preview-sidebar__title {
    font-size: 16px;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 16px 0;
}
.preview-mockup-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
/* Card diperkecil ~15-20% (padding & radius mengecil), thumbnail jadi fokus visual
   utama (~78% area card). Border netral default; ungu HANYA untuk state aktif/
   terpilih (lihat .active & .preview-mockup-check.checked). Transisi 180ms konsisten
   dgn spesifikasi 150-200ms. */
.preview-mockup-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 6px;
    border: 1.5px solid var(--line);
    background: var(--bg);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink);
    text-align: center;
}
/* Hover: bayangan tipis + border sedikit lebih gelap — TANPA warna ungu (ungu
   dikhususkan utk state aktif/terpilih, biar tidak ambigu dgn hover biasa). */
.preview-mockup-btn:hover {
    border-color: rgba(15,23,42,.28);
    box-shadow: 0 2px 8px rgba(15,23,42,.08);
}
.preview-mockup-btn.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79,70,229,.15);
}
.preview-mockup-thumb {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 9px;
    object-fit: contain;
    background: var(--panel);
    border: 1px solid var(--line);
    display: block;
}
/* Centang "jadikan foto produk" (Fase 3 multi-foto) — badge bulat kecil di pojok
   kanan-atas thumbnail, target klik terpisah dari card (lihat 08-ui.js
   stopPropagation). Kosong = outline tipis (menandakan bisa diklik, tanpa menutupi
   thumbnail); terisi = ungu solid + centang putih. */
.preview-mockup-check {
    position: absolute; top: 6px; right: 6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,.85);
    border: 1.5px solid rgba(15,23,42,.22);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; color: transparent;
    cursor: pointer;
    transition: background .18s ease, border-color .18s ease, color .18s ease;
    z-index: 2;
}
.preview-mockup-check:hover { border-color: var(--accent); }
.preview-mockup-check.checked {
    background: var(--accent); border-color: var(--accent); color: #fff;
}
/* A3: cegah simpan/seret/salin gambar pratinjau (mockup utama + thumbnail). Unduh
   hanya lewat tombol Download Mockup; menu klik-kanan diblokir via JS (08-ui.js). */
.preview-scene__inner canvas,
.preview-scene__inner img,
.preview-mockup-main,
.preview-mockup-thumb,
.preview-mockup-btn canvas {
    -webkit-user-drag: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
/* Tombol Download Mockup — di bawah grid Mockup view (mode preview) */
.preview-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 14px;
    padding: 10px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--ink);
    font-size: 12.5px;
    font-weight: 800;
    cursor: pointer;
    transition: all .15s;
}
.preview-download-btn:hover { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.preview-download-btn:disabled { opacity: .6; cursor: wait; }
/* A2: tombol Download Mockup di bawah body (bukan di dalam sidebar "Mockup view") —
   tidak full-width, rata KANAN (sejajar di bawah sidebar Mockup view). */
.preview-download-btn--below {
    flex: 0 0 auto;
    width: auto;
    min-width: 320px;
    align-self: flex-end;
    margin-top: 0;
}
/* Layar sempit: sidebar 320px memakan seluruh lebar → mockup 0px. Tumpuk kolom. */
@media (max-width: 820px) {
    .preview-scene { gap: 12px; }
    .preview-scene__body { flex-direction: column; gap: 12px; }
    .preview-scene__inner { min-height: 0; }
    /* Mockup view (mobile): sidebar full-width, kapasitas tinggi tetap → SCROLL VERTIKAL. */
    .preview-scene__sidebar { width: auto; flex: none; max-height: 45dvh; overflow-y: auto; }
    /* Grid thumbnail: 4 kolom + card diperkecil (padding/gap/label lebih kecil) di mobile
       agar card "Mockup view" tak makan banyak ruang, bungkus ke baris berikutnya &
       scroll ke bawah saat mockup banyak. */
    .preview-mockup-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; }
    .preview-mockup-btn { padding: 5px; gap: 4px; font-size: 10px; border-radius: 10px; }
    .preview-mockup-thumb { border-radius: 7px; }
    .preview-mockup-check { width: 18px; height: 18px; top: 4px; right: 4px; font-size: 8px; }
    /* Tombol Download Mockup PENUH (full-width) di mobile — override desktop (rata kanan). */
    .preview-download-btn--below {
        width: 100%;
        min-width: 0;
        align-self: stretch;
    }
}

.preview-scene__inner .preview-spinner {
    font-size: 13px; color: var(--muted);
    display: flex; align-items: center; gap: 8px;
}
.preview-scene__legend {
    display: flex; align-items: center; gap: 7px;
    background: rgba(255,255,255,.9);
    border: 1px solid var(--line); border-radius: 999px;
    padding: 6px 14px;
    font-size: 12px; font-weight: 700; color: var(--muted);
    box-shadow: var(--sh-sm);
    backdrop-filter: blur(8px);
}
.preview-scene__nav {
    display: none;
}
.preview-scene__nav button {
    border: 1.5px solid var(--line);
    background: rgba(255,255,255,.9);
    color: var(--muted);
    font-size: 12px; font-weight: 700;
    padding: 7px 16px; border-radius: 999px;
    cursor: pointer; transition: all .15s;
}
.preview-scene__nav button:hover { background: var(--bg); color: var(--ink); }
.preview-scene__nav button.on {
    background: var(--accent); color: #fff; border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(79,70,229,.3);
}

/* ── Preview mode badge ── */
.preview-mode-badge {
    position: absolute; top: 16px; left: 16px; z-index: 25;
    background: rgba(15,23,42,.78); color: #fff;
    font-size: 11.5px; font-weight: 700;
    padding: 6px 12px; border-radius: 999px;
    backdrop-filter: blur(6px);
    display: none; align-items: center; gap: 7px;
}
.preview-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }

/* ── Safety hint (bottom of canvas, subtle) ── */
.safety-hint-bar {
    position: absolute; bottom: 8px; left: 50%;
    transform: translateX(-50%);
    background: rgba(255,255,255,.82);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 14px;
    font-size: 10.5px; color: var(--muted);
    display: flex; align-items: center; gap: 6px;
    backdrop-filter: blur(6px);
    white-space: nowrap; z-index: 15;
    max-width: calc(100% - 32px);
    overflow: hidden; text-overflow: ellipsis;
}
.safety-hint-bar i { color: var(--accent); font-size: 11px; }

/* ════════════ FLYOUT PANEL ════════════ */
.studio-panel {
    position: absolute;
    z-index: 40;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
    /* positioned relative to .work (has position:relative) */
    left: calc(var(--tool-w) + 12px);
    top: 14px; bottom: 14px;
    width: 300px;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.studio-panel.open {
    display: flex;
    animation: panelIn .18s ease;
}
@keyframes panelIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: none; }
}

/* Panel header */
.panel-hd {
    display: flex; align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--line-2);
    flex: none;
}
.panel-hd-title {
    margin: 0; font-size: 15px; font-weight: 800;
    letter-spacing: -.01em; color: var(--ink);
}
.panel-hd-close { border: 0;
    background: var(--bg); border-radius: 8px;
    display: grid; place-items: center;
    color: var(--muted); font-size: 14px;
}
.panel-hd-close:hover { background: #e9ebf1; color: var(--ink); }
.panel-grip { display: none; }

/* Hidden tab-bar — kept for studio.js compatibility */
.tab-bar { display: none !important; }

/* Tab content = scrollable panel body */
.tab-content {
    flex: 1; overflow-y: auto;
    padding: 14px 16px 20px;
    display: flex; flex-direction: column;
}
.tab-content::-webkit-scrollbar { width: 5px; }
.tab-content::-webkit-scrollbar-thumb { background: #cfd3dd; border-radius: 4px; }

/* Step panels */
.step-panel { display: none; flex: 1; }
.step-panel.active { display: block; }
/* Panel 0 (Tampilan) — never shown in flyout; hidden always */
.step-panel:first-child.active { display: none !important; }
/* Save panel */
.step-panel--save { display: none; }
.step-panel--save.active {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    min-height: 200px; padding: 0 4px;
}

/* ════════════ MOBILE BOTTOM BAR ════════════ */
.mobile-bar { display: none; }

/* ════════════ SCRIM ════════════ */
.scrim {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.35);
    z-index: 35; opacity: 0; pointer-events: none;
    transition: opacity .2s; display: none;
}
.scrim.show { opacity: 1; pointer-events: auto; display: block; }

/* ════════════ LOADING SCREEN ════════════
   Backdrop blur + dim (bukan putih solid) — Studio di belakangnya tetap
   kelihatan (blur), bukan ke-cut total ke layar putih kosong. Dipakai untuk
   load pertama halaman DAN untuk proses "Simpan" (showLoading/hideLoading di
   01-backend.js) — satu sistem loading yang sama di semua tempat. */
#loadingScreen {
    position: fixed; inset: 0; z-index: 99999;
    background: rgba(255,255,255,.6);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    display: flex; align-items: center; justify-content: center;
    flex-direction: column; gap: 16px; transition: opacity .4s;
}
#loadingScreen.fade-out { opacity: 0; pointer-events: none; }
/* blur-only: dipakai khusus proses "Simpan" (06-save.js) — cuma backdrop blur,
   tanpa logo/dots. Load pertama Studio & pilih template tetap pakai tampilan
   penuh (class ini tidak ditambahkan di situ). */
#loadingScreen.blur-only .loading-brand,
#loadingScreen.blur-only .loading-dots { display: none; }
.loading-brand {
    font-family: 'Outfit', system-ui, sans-serif;
    font-weight: 600; font-size: 22px; letter-spacing: -.02em;
    color: #0e0d0a; animation: brandFade 1.6s ease-in-out infinite;
}
.loading-dots { display: flex; align-items: center; justify-content: center; gap: 7px; height: 10px; }
.loading-dots span { width: 6px; height: 6px; border-radius: 50%; background: #4f46e5; animation: dotMove 1.1s ease-in-out infinite; }
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }
/* Log progres — kartu "floating" glassmorphism (bukan teks melayang polos di
   atas kanvas). Header identitas + body daftar baris rata-kiri, hierarki jelas:
   baris berjalan (current) ditonjolkan, baris selesai diredupkan. Cuma tampil
   di mode blur-only (proses Simpan) — default disembunyikan. */
.loading-log {
    width: 100%; max-width: 320px;
    background: linear-gradient(160deg, rgba(255,255,255,.62), rgba(196,181,253,.28));
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 16px;
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 16px 40px rgba(79,70,229,.16), 0 4px 12px rgba(15,23,42,.08);
    overflow: hidden;
    animation: logCardIn .35s ease;
}
#loadingScreen:not(.blur-only) .loading-log { display: none; }
.loading-log-header {
    display: flex; align-items: center; gap: 7px;
    padding: 10px 14px;
    font-family: 'Outfit', system-ui, sans-serif;
    font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    color: #4f46e5;
    background: rgba(79,70,229,.08);
    border-bottom: 1px solid rgba(79,70,229,.14);
}
.loading-log-header i { font-size: 12px; }
.loading-log-body {
    display: flex; flex-direction: column; gap: 1px;
    padding: 10px 8px 12px; max-height: 170px; overflow: hidden;
}
.loading-log-body .log-line {
    font-family: 'Outfit', system-ui, sans-serif; font-size: 12.5px; line-height: 1.5;
    text-align: left; color: #94a3b8; font-weight: 500;
    padding: 4px 8px; border-radius: 7px;
    transition: color .3s, background .3s, font-weight .2s;
    animation: logLineIn .25s ease;
}
.loading-log-body .log-line.current {
    color: #3730a3; font-weight: 700;
    background: rgba(167,139,250,.20);
}
@keyframes logCardIn { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@keyframes logLineIn { from { opacity: 0; transform: translateY(4px); } }
@keyframes brandFade { 0%,100% { opacity:.35; } 50% { opacity:1; } }
@keyframes dotMove { 0%,80%,100% { opacity:.25; transform:translateY(0); } 40% { opacity:1; transform:translateY(-7px); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════ FORMS & INPUTS (pane content) ════════════ */
label { font-size: 13px; font-weight: 700; color: var(--ink); display: block; }
input[type="text"], input[type="number"], textarea, select {
    width: 100%; padding: 8px 14px; border-radius: 10px;
    border: 1.5px solid var(--line); font-family: inherit;
    font-weight: 500; font-size: 14px; outline: none;
    background: var(--panel); color: var(--ink);
    transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,70,229,.10);
}

/* ════════════ BUTTONS ════════════ */
button { padding: 11px 15px; border-radius: 10px; border: none; font-weight: 700; font-size: 14px; cursor: pointer; transition: .2s; background: var(--accent); color: white; }
.btn-outline { background: white; border: 1.5px solid var(--line); color: var(--ink); }
.btn-outline.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn-danger { background: #fef2f2; color: var(--bad); border: 1.5px solid #fee2e2; }
.btn-full { width: 100%; padding: 14px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.sides .btn-group { flex-wrap: nowrap; margin-top: 0; gap: 2px; }
.btn-sm { background: black; border: 1px solid var(--border); border-radius: 6px; padding: 8px; cursor: pointer; transition: .2s; }
.btn-sm:hover { background: #f1f5f9; color: var(--accent); border-color: var(--accent); }
.btn-success { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: #fff; border: none; }
.btn-success:hover { filter: brightness(1.05); }

/* ════════════ TOAST & CONFIRM ════════════ */
#toast-wrap {
    position: fixed; top: 16px; right: 16px;
    z-index: 3000; display: flex; flex-direction: column;
    gap: 8px; pointer-events: none;
}
.toast-item {
    background: #0f172a; color: #fff;
    padding: 10px 14px; border-radius: 10px;
    box-shadow: 0 8px 20px rgba(2,6,23,.25);
    font-size: 13px; max-width: 320px; pointer-events: auto;
}
.toast-item.warn { background: #92400e; }
.toast-item.error { background: #991b1b; }
.toast-item.success { background: #065f46; }

#confirm-overlay {
    position: fixed; inset: 0; background: rgba(2,6,23,.45);
    display: none; align-items: center; justify-content: center;
    z-index: 3200; padding: 16px;
}
#confirm-box { background: #fff; border-radius: 14px; width: 100%; max-width: 360px; padding: 16px; box-shadow: 0 12px 30px rgba(15,23,42,.25); border: 1px solid var(--line); }
#confirm-message { font-size: 14px; color: var(--ink); margin-bottom: 14px; text-align: center; }
#confirm-icon { width: 36px; height: 36px; border-radius: 999px; display: flex; align-items: center; justify-content: center; font-size: 16px; margin: 0 auto 10px; font-weight: 800; }
#confirm-overlay[data-type="danger"] #confirm-icon { background: #fee2e2; color: #991b1b; }
#confirm-overlay[data-type="warning"] #confirm-icon { background: #fef3c7; color: #92400e; }
#confirm-overlay[data-type="info"] #confirm-icon { background: #dbeafe; color: #1d4ed8; }
#confirm-actions { display: flex; gap: 8px; justify-content: center; }
#confirm-actions button { padding: 9px 12px; border-radius: 8px; border: none; font-weight: 700; cursor: pointer; }
#confirm-cancel { background: #e2e8f0; color: #0f172a; }
#confirm-ok { background: var(--accent); color: #fff; }


/* ════════════ STUDIO PANEL CONTENT STYLES ════════════ */

/* Sub-nav (Area / Desain / Atur / Info) */
.studio-desain-subnav {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 12px; padding: 8px;
    background: #f8fafc; border: 1px solid var(--line);
    border-radius: 12px;
}
.studio-desain-subbtn {
    flex: 1; min-width: min(100%, 80px);
    padding: 9px 6px; border-radius: 10px;
    border: 1.5px solid var(--line);
    background: var(--panel); color: var(--ink);
    font-size: 10.5px; font-weight: 800;
    line-height: 1.25; text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s, color .2s;
}
.studio-desain-subbtn--icon {
    flex: 1; min-width: 44px; max-width: 72px;
    padding: 10px 6px; font-size: 17px; line-height: 1;
    display: inline-flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 5px;
}
.studio-desain-subbtn--icon .studio-subnav-label { font-size: 9.5px; font-weight: 900; color: #334155; line-height: 1; }
.studio-desain-subbtn:hover { border-color: rgba(79,70,229,.35); color: var(--accent); }
.studio-desain-subbtn.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 0 1px rgba(79,70,229,.12); }
.studio-desain-subbtn.active .studio-subnav-label { color: var(--accent); }
.studio-desain-subbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(79,70,229,.28); }

/* Pane container */
.studio-desain-pane { padding-bottom: 4px; }

/* Area selector bar */
.studio-area-picker { margin-bottom: 16px; }
.studio-area-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.studio-area-chip {
    padding: 5px 10px; font-size: 12px; font-weight: 900;
    background: #f8fafc; border: 1.5px solid var(--line);
    color: var(--ink); border-radius: 8px; cursor: pointer; letter-spacing: .2px;
}
.studio-area-chip:hover { border-color: var(--accent); color: var(--accent); }
.studio-area-empty-msg { font-size: 11px; color: var(--muted); font-style: italic; margin: 0; }

/* Section labels */
.studio-section-label {
    font-size: 11px; font-weight: 800; color: var(--muted);
    margin-bottom: 7px; display: block;
    text-transform: uppercase; letter-spacing: .03em;
}
.studio-step-label { font-size: 14px; font-weight: 700; color: var(--muted); display: block; }

/* Rotate card */
.studio-rotate-card { margin-top: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.studio-rotate-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.studio-rotate-range { flex: 1; min-width: 100px; }
.studio-rotate-num { width: 80px; flex-shrink: 0; }
.studio-deg-label { font-size: 12px; color: var(--muted); flex-shrink: 0; }
.studio-hint-text { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.studio-mt-15 { margin-top: 15px; }
.studio-mt-10 { margin-top: 10px; }

/* Upload dropzone */
.studio-upload-dropzone {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-align: center; gap: 8px;
    min-height: 110px; width: 100%;
    border-radius: 14px;
    border: 2px dashed rgba(79,70,229,.30);
    background: linear-gradient(180deg, rgba(238,242,255,.9) 0%, rgba(248,250,252,1) 100%);
    padding: 14px; cursor: pointer; position: relative;
}
.studio-upload-dropzone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.studio-drop-icon { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: rgba(79,70,229,.12); color: rgba(67,56,202,1); font-size: 17px; }
.studio-drop-title { font-weight: 900; letter-spacing: -.2px; color: var(--ink); font-size: 13.5px; }
.studio-drop-sub { font-size: 11px; color: var(--muted); line-height: 1.4; }
.studio-upload-dropzone--compact { min-height: 68px; padding: 10px 14px; flex-direction: row; justify-content: flex-start; gap: 12px; text-align: left; }
.studio-upload-dropzone--compact .studio-drop-icon { width: 34px; height: 34px; font-size: 14px; flex-shrink: 0; }
.studio-upload-dropzone--compact .studio-drop-title { font-size: 12px; }
.studio-upload-dropzone--compact .studio-drop-sub { font-size: 10px; }
.studio-file-trigger-wrap { position: relative; overflow: hidden; }
.studio-file-trigger-wrap input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Upload gallery */
.studio-upload-gallery-wrap { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.studio-upload-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; }
.studio-upload-gallery-empty { grid-column: 1 / -1; margin: 0; font-size: 12px; color: var(--muted); font-style: italic; line-height: 1.45; }
.studio-upload-thumb {
    display: flex; flex-direction: column; align-items: stretch;
    gap: 5px; padding: 7px; margin: 0;
    border: 1px solid var(--line); border-radius: 11px;
    background: var(--panel); cursor: pointer; text-align: left;
    font-family: inherit; transition: border-color .2s, box-shadow .2s; min-width: 0;
}
.studio-upload-thumb:hover { border-color: rgba(79,70,229,.35); box-shadow: 0 4px 12px rgba(79,70,229,.08); }
.studio-upload-thumb--pending { border-style: dashed; border-color: rgba(79,70,229,.45); background: #f8fafc; }
.studio-upload-thumb-img-wrap { display: block; aspect-ratio: 1; border-radius: 7px; overflow: hidden; background: #f1f5f9; border: 1px solid var(--line); }
.studio-upload-thumb-img-wrap img { width: 100%; height: 100%; object-fit: contain; display: block; -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }
.studio-upload-thumb-name { font-size: 10px; font-weight: 700; color: var(--ink); line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; word-break: break-word; }
.studio-upload-thumb-sub { font-size: 9px; font-weight: 600; color: var(--muted); line-height: 1.3; }

/* Upload action bar */
.studio-upload-action-bar { display: flex; gap: 6px; margin-top: 7px; align-items: center; }
.studio-upload-progress-host { margin-bottom: 8px; }

/* Area picker inline */
.studio-area-picker-wrap { margin-top: 10px; background: #f8fafc; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.studio-area-picker-label { font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.studio-area-picker-list { display: flex; flex-wrap: wrap; gap: 6px; }
.studio-area-picker-btn { padding: 7px 13px; border-radius: 8px; border: 1.5px solid #c7d2fe; background: #fff; font-size: 12px; font-weight: 700; color: #4338ca; cursor: pointer; transition: background .15s; }
.studio-area-picker-btn:hover { background: var(--accent-soft); }

/* Manual edit panel */
.studio-manual-panel { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.studio-manual-panel--nested { margin-top: 0; padding-top: 14px; border-top: 1px solid var(--line); }
.studio-manual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 14px; }
.studio-align-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-bottom: 14px; }
.input-manual label { font-size: 9px; font-weight: 700; color: var(--muted); margin-bottom: 3px; display: block; }
.input-manual input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 12px; }
.studio-manual-placeholder { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; padding: 12px; background: #f8fafc; border-radius: 10px; border: 1px dashed var(--line); }

/* Guide / info pane */
.guide-box { margin-top: 20px; padding: 14px; background: var(--panel); border-radius: 12px; border: 1px solid var(--line); }
.guide-box.studio-guide-always-open::before { display: none; }
.guide-box h4 { margin: 0; font-size: 13.5px; font-weight: 800; display: flex; align-items: center; gap: 9px; letter-spacing: -.3px; }
.guide-box p { font-size: 12px; color: var(--muted); line-height: 1.6; margin: 0 0 12px 0; }
.guide-box ul { margin: 0; padding: 0; list-style: none; }
.guide-box li { position: relative; padding-left: 20px; margin-bottom: 8px; font-size: 11.5px; line-height: 1.5; color: var(--ink); }
.guide-box li i { position: absolute; left: 0; top: 3px; font-size: 12px; }
.guide-box .recom-list li i { color: var(--ok); }
.guide-box .reject-list li i { color: var(--bad); }
.guide-box .guide-link { color: var(--accent); font-weight: 800; text-decoration: none; font-size: 12px; display: inline-flex; align-items: center; gap: 5px; margin-top: 10px; transition: .2s; }
.guide-box .guide-link:hover { gap: 8px; opacity: .8; }

/* Save panel */
.studio-save-info { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.studio-save-info__icon { font-size: 22px; color: var(--ok); animation: studio-bounce-down 1.2s ease-in-out infinite; }
@keyframes studio-bounce-down { 0%,100% { transform:translateY(0); } 50% { transform:translateY(6px); } }
.btn-save-main {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px; background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff; border: none; border-radius: 10px;
    padding: 13px 28px; font-size: 15px; font-weight: 600;
    cursor: pointer; box-shadow: 0 4px 14px rgba(16,185,129,.35);
    transition: filter .15s, transform .12s, box-shadow .15s; letter-spacing: .01em;
    margin-top: 16px;
}
.btn-save-main:hover { filter: brightness(1.06); box-shadow: 0 6px 20px rgba(16,185,129,.45); }
.btn-save-main:active { transform: scale(.97); }
.btn-save-main:disabled { opacity: .6; cursor: not-allowed; filter: none; }

/* Studio produk info */
#studio-produk-info { background: #f0fdf4; border: 1px solid #86efac; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 12px; color: #166534; line-height: 1.6; }
#studio-produk-not-found { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 12px; color: #9a3412; line-height: 1.5; }
#studio-auth-user { font-size: 11px; color: var(--faint); text-align: center; margin-top: 10px; }

/* Pane 4 info overflow fix */
#studio-desain-pane-4 { max-height: none; overflow: visible; padding-bottom: 0; }

/* ════════════ LAYER LIST STYLES ════════════ */
.studio-layer-section-header {
    padding: 8px 0 6px 0;
    margin: 12px 0 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 11px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.studio-layer-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: 10px;
    border: 1.5px solid var(--line);
    background: var(--panel);
    cursor: pointer; transition: all .2s;
}
.studio-layer-item:hover {
    border-color: rgba(79,70,229,.35);
    background: var(--accent-soft);
}
.studio-layer-item.active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
    box-shadow: 0 0 0 2px rgba(79,70,229,.15);
}
.studio-layer-item-icon {
    width: 32px; height: 32px;
    border-radius: 8px; background: #f8fafc;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 14px; color: var(--accent);
}
.studio-layer-item.active .studio-layer-item-icon {
    background: rgba(79,70,229,.15);
}
.studio-layer-item-info {
    flex: 1; min-width: 0;
}
.studio-layer-item-name {
    font-size: 13px; font-weight: 700; color: var(--ink);
    display: block; margin-bottom: 2px;
}
.studio-layer-item-size {
    font-size: 11px; color: var(--muted); font-weight: 500;
}
.studio-layer-item-actions {
    display: flex; gap: 6px; flex-shrink: 0;
}
.studio-layer-item-btn {
    width: 28px; height: 28px; border-radius: 6px;
    border: 1px solid var(--line); background: transparent;
    color: var(--muted); font-size: 12px;
    cursor: pointer; transition: all .2s;
    display: flex; align-items: center; justify-content: center;
}
.studio-layer-item-btn:hover {
    border-color: var(--accent); color: var(--accent); background: var(--accent-soft);
}
.studio-layer-item-btn.danger {
    border-color: rgba(239,68,68,.35); color: rgba(185,28,28,1);
}
.studio-layer-item-btn.danger:hover {
    border-color: var(--bad); background: rgba(239,68,68,.08);
}

/* ════════════ NESTED LAYER ITEMS ════════════ */
.studio-layer-item--nested {
    margin-left: 24px;
    border-left: 2px solid var(--accent-soft);
    padding-left: 12px;
    opacity: 0.9;
}
.studio-layer-item--nested:hover {
    opacity: 1;
}

/* ════════════ TEMPLATE PICKER MODAL ════════════ */
#template-picker-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(2,6,23,.6); z-index: 99998;
    align-items: center; justify-content: center; padding: 20px;
}
.template-picker-card {
    display: flex; flex-direction: column; align-items: flex-start;
    width: 100%; padding: 16px 18px; background: #f8fafc;
    border: 2px solid var(--line); border-radius: 14px;
    cursor: pointer; text-align: left; transition: .2s; font-family: inherit;
}
.template-picker-card:hover { border-color: var(--accent); background: var(--accent-soft); }
.tp-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.tp-meta { font-size: 12px; color: var(--faint); margin-top: 3px; }

/* Tombol close "Atur" hanya untuk mode bottom-sheet mobile (sidebar selalu tampil di desktop). */
.studio-area-sidebar-close { display: none; }

/* ════════════ RESPONSIVE — MOBILE ════════════ */
@media (max-width: 820px) {
    /* Dock hidden on mobile */
    .dock { display: none; }

    /* Upload gallery: thumbnail lebih kecil di mobile — sebelumnya minmax(96px,1fr)
       kepanjangan/kebesaran di layar sempit. */
    .studio-upload-gallery { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 7px; }
    .studio-upload-thumb { padding: 5px; gap: 4px; border-radius: 9px; }
    .studio-upload-thumb-name { font-size: 9px; }
    .studio-upload-thumb-sub { font-size: 8px; }

    /* Right sidebar → bottom-sheet "Atur" di mobile (berisi Warna, Area Sablon,
       Atur Rotasi, & Pengaturan Objek). Dibuka via tombol Atur di bottom-bar. */
    .studio-area-sidebar {
        display: flex;
        position: absolute;          /* relatif ke .work, sama spt .studio-panel */
        left: 0; right: 0; bottom: 0; top: auto;
        width: auto; flex: none;
        height: var(--sheet-h);        /* tinggi TETAP & seragam (sama tiap menu) */
        max-height: var(--sheet-h);
        border-left: 0;
        border-top: 1px solid var(--line);
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 44px rgba(15, 23, 42, .20);
        transform: translateY(120%);
        transition: transform .24s cubic-bezier(.2, .8, .2, 1);
        z-index: 40;
        gap: 14px;
        padding: 8px 16px 18px;
        overflow-y: auto;
    }
    .studio-area-sidebar.open { transform: translateY(0); }
    /* Hidden on Drag: lihat catatan di .studio-panel.dragging-hide di atas. */
    .studio-area-sidebar.open.dragging-hide { transform: translateY(120%) !important; }

    /* Menu "Ukuran Sablon" & "Varian" terpisah dari "Atur" (mobile saja): sidebar tetap
       SATU elemen (hindari duplikasi id seperti #jenisArea), tapi saat dibuka via tombol
       Ukuran/Varian, [data-mobile-view] memfilter section [data-sec] lain supaya HANYA
       bagian yang relevan tampil — terasa seperti menu sendiri. Desktop tak terpengaruh
       (aturan ini di dalam @media mobile & [data-mobile-view] cuma di-set oleh JS mobile). */
    .studio-area-sidebar[data-mobile-view] > [data-sec] { display: none; }
    .studio-area-sidebar[data-mobile-view="atur"] > [data-sec="atur"] { display: block; }
    .studio-area-sidebar[data-mobile-view="ukuran"] > [data-sec="ukuran"] { display: block; }
    .studio-area-sidebar[data-mobile-view="varian"] > [data-sec="varian"] { display: block; }
    /* Grip handle (drag indicator) */
    .studio-area-sidebar::before {
        content: "";
        flex: none;
        width: 40px; height: 4px;
        margin: 4px auto 2px;
        border-radius: 99px;
        background: var(--line);
    }
    .studio-area-sidebar-title { padding-bottom: 10px; padding-right: 38px; }
    /* Tombol close (samakan gaya dgn .panel-hd-close panel lain), pojok kanan-atas sheet. */
    .studio-area-sidebar-close {
        display: grid; place-items: center;
        position: absolute; top: 12px; right: 14px;
        border: 0; background: var(--bg); border-radius: 8px;
        color: var(--muted); font-size: 14px;
        z-index: 2;
    }
    .studio-area-sidebar-close:hover { background: #e9ebf1; color: var(--ink); }

    /* Topbar compact — no horizontal overflow; title truncates, controls stay put */
    .topbar { height: 54px; gap: 8px; padding: 0 10px; overflow: hidden; flex-wrap: nowrap; }
    .tb-title { flex: 1 1 auto; min-width: 0; }
    .seg { flex: none; }
    .seg button { padding: 8px 10px; font-size: 12px; min-height: 38px; }
    .seg button span { display: none; }
    .btn-save-topbar .save-label { display: none; }
    .btn-save-topbar { padding: 0; width: 40px; height: 40px; justify-content: center; flex: none; }
    .btn-save-topbar i { font-size: 15px; }
    .studio-global-actionbar { padding: 6px 8px; }
    .studio-global-actionbar .act-btn { padding: 6px 10px; font-size: 11px; }
    .studio-global-actionbar .act-btn span { display: none; }

    /* Flyout becomes bottom sheet. position:absolute relatif ke .work (yang berakhir
       TEPAT di atas bottom-bar), jadi bottom:0 = duduk di atas bar → bottom-bar
       tetap terlihat & bisa diklik utk pindah panel langsung. */
    .studio-panel {
        left: 0 !important; right: 0 !important;
        top: auto !important; bottom: 0 !important;
        width: auto !important;
        border-radius: 20px 20px 0 0;
        border-left: 0; border-right: 0;
        transform: translateY(120%);
        display: flex !important; /* always in layout, use transform */
        transition: transform .24s cubic-bezier(.2,.8,.2,1);
        height: var(--sheet-h);    /* tinggi TETAP & seragam tiap menu (isi panjang → scroll) */
        max-height: var(--sheet-h);
    }
    .studio-panel.open {
        transform: translateY(0);
        animation: none;
    }
    /* Hidden on Drag: sembunyikan bottom-sheet saat pengguna menggeser desain di kanvas
       (mobile) agar layar bersih — tetap dalam layout, cuma di-slide turun sementara. */
    .studio-panel.open.dragging-hide {
        transform: translateY(120%) !important;
    }
    .panel-hd { padding: 8px 16px 12px; position: relative; }
    .panel-grip { display: block; position: absolute; left: 50%; top: 7px; transform: translateX(-50%); width: 40px; height: 4px; border-radius: 99px; background: var(--line); }
    .panel-hd-title { margin-top: 6px; }
    .tab-content { padding: 12px 14px 32px; max-height: none; }

    /* Side chips higher */
    .sides { bottom: 84px; }

    /* Kontrol kanvas (Reset + zoom): disembunyikan di mobile — zoom pakai pinch-to-zoom
       (touch gesture, lihat touchstart/touchmove di 05-editor.js), tombol Reset/Zoom
       in/out desktop tidak diperlukan & mengganggu di layar sempit. */
    .studio-canvas-controls { display: none; }

    /* Scrim mobile: JANGAN blokir/redupkan kanvas saat menu terbuka → kanvas (di atas
       bottom-sheet) tetap bisa diedit. Penutupan menu lewat tombol ✕ atau bottom-bar.
       (Scrim full-screen sebelumnya menangkap semua sentuhan → kanvas tak bisa disentuh.) */
    .scrim, .scrim.show {
        background: transparent;
        pointer-events: none;
    }

    /* Safety hint hidden on mobile (replaced by in-pane notes) */
    .safety-hint-bar { display: none; }

    /* Mobile bottom bar — 4 ikon (Atur, Desain, Layer, Info).
       z-index di atas scrim (35) & sheet (40) → SELALU terlihat + bisa diklik utk
       pindah panel langsung. Sheet (.studio-panel / .studio-area-sidebar) ber-
       position:absolute dlm .work yg berakhir tepat di atas bar, jadi keduanya
       tampak bersamaan tanpa saling menutup. */
    .mobile-bar {
        display: flex;
        position: relative;
        z-index: 45;
        height: var(--mbar-h); flex: none;
        background: var(--panel);
        border-top: 1px solid var(--line);
        padding: 6px 6px;
        gap: 4px;
        padding-bottom: max(6px, env(safe-area-inset-bottom));
    }
    .mb-btn {
        flex: 1; border: 0; background: transparent;
        border-radius: 12px;
        display: flex; flex-direction: column;
        align-items: center; justify-content: center;
        gap: 4px; color: var(--muted);
        min-height: 48px;
        transition: background .15s, color .15s;
    }
    .mb-btn i { font-size: 20px; }
    .mb-btn span { font-size: 10px; font-weight: 700; }
    .mb-btn.on { color: var(--accent); background: var(--accent-soft); }

    /* Inputs: prevent iOS zoom */
    input, select, textarea { font-size: 16px !important; }

    /* Studio desain sub-btn */
    .studio-desain-subbtn { font-size: 10px; padding: 9px 5px; }
    .studio-desain-subbtn--icon { font-size: 16px; padding: 10px 5px; min-width: 44px; max-width: none; }

    .studio-manual-grid { grid-template-columns: 1fr; gap: 9px; }
    .studio-align-grid .btn-sm { min-height: 44px; font-size: 16px; }
    .studio-area-chip { font-size: 11px; }
}

/* ── Small phones (≤480px): tighten chrome, keep touch targets ── */
@media (max-width: 480px) {
    .topbar { gap: 6px; padding: 0 8px; }
    .tb-title small { display: none; }            /* hemat ruang, judul tetap */
    .tb-title b { font-size: 13px; }
    .seg { padding: 2px; }
    .seg button { padding: 7px 9px; }
    .sides { bottom: 80px; max-width: calc(100% - 24px); }
    .sides .btn-outline { padding: 8px 13px; font-size: 12.5px; }
}

/* ── Very small phones (≤360px): paling ringkas ── */
@media (max-width: 360px) {
    .mb-btn i { font-size: 18px; }
    .mb-btn span { font-size: 9px; }
    .seg button i { font-size: 13px; }
    .btn-save-topbar { width: 38px; height: 38px; }
}

/* ── Landscape phones: bottom sheet boleh lebih tinggi ── */
@media (max-height: 480px) and (max-width: 820px) {
    .studio-panel { max-height: 88dvh; }
    .sides { bottom: 72px; }
}


/* ════════════════════════════════════════════════════════════════════════
   POLISH LAYER — Canva-grade consistency pass
   Appended last so it overrides earlier rules by source order.
   Visual only: no IDs/classes used by studio.js are renamed or removed.
   ════════════════════════════════════════════════════════════════════════ */

/* Unified focus ring for keyboard users */
.dock-btn:focus-visible, .mb-btn:focus-visible, .seg button:focus-visible,
.btn-save-topbar:focus-visible, .tb-back:focus-visible, .sides .btn-outline:focus-visible,
.studio-area-chip:focus-visible, .studio-zoombar button:focus-visible,
.studio-reset-view:focus-visible, .act-btn:focus-visible,
.studio-layer-item-btn:focus-visible, .btn-sm:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .30);
}

/* FIX: align-grid buttons were rendered with a black background
   (original .btn-sm { background: black }). Restore a light control surface. */
.btn-sm {
    background: var(--panel);
    color: var(--ink);
    border: 1.5px solid var(--line);
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 40px;
    transition: border-color .15s, background .15s, color .15s;
}
.btn-sm:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.btn-sm:active { transform: translateY(.5px); }

/* Left dock: clearer active state with an accent rail */
.dock-btn { position: relative; transition: background .15s, color .15s; }
.dock-btn.on::before {
    content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}

/* Right sidebar: brand-accent "add area" button + tidy header */
.studio-area-sidebar button[onclick="tambahAreaPrint()"] {
    background: var(--accent) !important;
    border-radius: 10px !important;
    box-shadow: 0 2px 8px rgba(79, 70, 229, .25);
    transition: background .15s, transform .12s;
}
.studio-area-sidebar button[onclick="tambahAreaPrint()"]:hover { background: var(--accent-700) !important; }
.studio-area-sidebar button[onclick="tambahAreaPrint()"]:active { transform: scale(.96); }
.studio-area-sidebar { padding: 18px 16px; gap: 1px; }
.studio-area-sidebar-title { padding-bottom: 12px; border-bottom: 1px solid var(--line-2); }

/* Bottom-right controls: cohesive cluster */
.studio-controls-right { gap: 9px; }
.studio-reset-view, .studio-zoombar { border-radius: 13px; }
.studio-zoombar button { border-radius: 9px; transition: border-color .15s, color .15s, background .15s; }
.studio-zoombar button:hover { background: var(--accent-soft); }

/* Side chips */
.sides { padding: 6px 8px; gap: 3px; box-shadow: var(--sh-md); }
.sides .btn-outline { transition: background .15s, color .15s; }

/* Flyout panel + area chips spacing rhythm */
.studio-panel { box-shadow: 0 20px 56px rgba(15, 23, 42, .20); }
.panel-hd { padding: 15px 16px 11px; }
.studio-area-chip { transition: border-color .15s, background .15s, color .15s; }
.studio-area-chip.active, .studio-area-chip[aria-selected="true"] {
    border-color: var(--accent); background: var(--accent-soft); color: var(--accent);
}

/* Layer rows hover */
.studio-layer-item { transition: border-color .15s, background .15s, box-shadow .15s; }

/* Drop indicator */
.studio-drop-indicator { border-width: 2.5px; border-radius: 14px; background: rgba(79, 70, 229, .10); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .studio-panel.open { animation: none; }
}
