/* ===== Silver Cloud Studio — Dark-first premium (glassmorphism) =====
   Hướng thiết kế: workspace tối như công cụ sáng tạo pro (Figma/Lightroom),
   accent emerald phát sáng, kính mờ, ảnh render nổi bật trên nền tối.
   Token màu bám xu hướng UI cao cấp 2026 (dark-first + neon glow nhỏ). */
[hidden] { display: none !important; }

:root {
  /* surfaces (near-black ám xanh → nhiều lớp) */
  --bg:        #0a0e0c;
  --bg-soft:   #0e1311;
  --surface:   #141a17;
  --surface-2: #1b2320;
  --surface-3: #232d29;
  /* borders */
  --line:        rgba(255,255,255,.08);
  --line-strong: rgba(255,255,255,.15);
  /* text */
  --text:   #eef3f0;
  --text-2: #a6b2ab;
  --text-3: #6f7c74;
  /* brand emerald/lime + glow */
  --brand:      #35d27e;
  --brand-soft: #2bb673;
  --brand-deep: #1c9a60;
  --teal:       #14b8a6;
  --glow:       rgba(53,210,126,.45);
  --glow-soft:  rgba(53,210,126,.16);
  /* functional */
  --danger: #f0584b;
  --warn:   #f5a623;
  /* shape & depth */
  --radius: 16px;
  --shadow:       0 10px 34px rgba(0,0,0,.45);
  --shadow-float: 0 22px 64px rgba(0,0,0,.62);
  /* legacy aliases (cho code cũ còn tham chiếu) */
  --green-900: #0a1f15; --green-800: var(--brand-deep); --green-700: var(--brand-soft);
  --green-600: var(--brand-soft); --green-500: var(--brand); --green-300: var(--brand);
  --green-050: rgba(53,210,126,.10); --ink: var(--text); --muted: var(--text-2); --card: var(--surface);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 112% -8%, rgba(53,210,126,.12), transparent 60%),
    radial-gradient(900px 520px at -12% 4%, rgba(20,184,166,.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 92px;
}
::selection { background: var(--glow); color: #06120c; }

/* ===== Login ===== */
.login-screen {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background:
    radial-gradient(720px 460px at 50% 24%, rgba(53,210,126,.18), transparent 62%),
    linear-gradient(160deg, #0b1612, var(--bg) 72%);
}
.login-card {
  width: 100%; max-width: 372px; display: flex; flex-direction: column; gap: 9px;
  padding: 30px 24px calc(26px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.03));
  backdrop-filter: blur(26px) saturate(150%); -webkit-backdrop-filter: blur(26px) saturate(150%);
  border: 1px solid var(--line-strong); border-radius: 24px;
  box-shadow: var(--shadow-float); text-align: center;
}
.login-logo {
  width: 80px; height: 80px; border-radius: 22px; margin: 0 auto 4px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.08), 0 12px 34px var(--glow);
}
.login-brand { font-weight: 800; letter-spacing: 2.5px; font-size: 18px; }
.login-sub { font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.login-label { text-align: left; font-size: 12px; font-weight: 700; color: var(--text-2); margin-top: 4px; }
.login-pass-wrap { position: relative; }
.login-pass-wrap .text-input { padding-right: 46px; }
.login-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: rgba(255,255,255,.06); border-radius: 9px; cursor: pointer; font-size: 15px; color: var(--text-2); }
.login-remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); text-align: left; margin: 8px 0 2px; cursor: pointer; }
.login-remember input { width: 16px; height: 16px; accent-color: var(--brand); }
.login-submit { width: 100%; margin-top: 6px; }
.login-err { background: rgba(240,88,75,.16); color: #ffb4ab; border: 1px solid rgba(240,88,75,.4); padding: 9px 12px; border-radius: 10px; font-size: 13px; }
.login-install { margin-top: 6px; background: rgba(255,255,255,.07); color: var(--text); border: 1px solid var(--line-strong); padding: 11px; border-radius: 12px; cursor: pointer; font-weight: 700; }
.login-tip { font-size: 11.5px; color: var(--text-3); line-height: 1.55; margin: 12px 0 0; }
.login-tip p { margin: 5px 0 0; }
.login-tip-title { font-weight: 700; color: var(--text-2); margin: 0 0 2px !important; }
.share-ico { width: 15px; height: 15px; vertical-align: -3px; margin: 0 1px; color: #0a84ff; }

/* ===== Wizard steps ===== */
.wizard-steps {
  position: sticky; top: 0; z-index: 21;
  display: flex; gap: 6px; padding: 9px 12px;
  background: rgba(10,14,12,.72); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line); overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.wstep {
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center; gap: 7px;
  min-width: max-content; border: 1px solid transparent; cursor: pointer;
  padding: 8px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 700;
  color: var(--text-3); background: rgba(255,255,255,.04); white-space: nowrap; transition: all .18s;
}
.wstep.active {
  color: #06120c; background: linear-gradient(120deg, var(--brand), var(--teal));
  box-shadow: 0 4px 16px var(--glow);
}
.wstep-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 800;
  background: rgba(255,255,255,.10); color: var(--text-2);
}
.wstep.active .wstep-dot { background: rgba(6,18,12,.22); color: #06120c; }

/* ===== Topbar ===== */
.topbar {
  position: relative; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px;
  background: rgba(14,19,17,.6); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 38px; height: 38px; border-radius: 11px; display: block; box-shadow: 0 0 0 1px var(--line), 0 6px 18px var(--glow-soft); }
.brand-name { font-weight: 800; letter-spacing: 1.6px; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--text-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.help-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(255,255,255,.05); color: var(--text); font-size: 16px; font-weight: 800; cursor: pointer; transition: all .15s; }
.help-btn:hover { background: rgba(255,255,255,.1); }
.help-btn:active { transform: scale(.94); }
.engine-badge {
  font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.06); border: 1px solid var(--line-strong); color: var(--text-2); white-space: nowrap;
}
.engine-badge.live { background: var(--glow-soft); color: var(--brand); border-color: rgba(53,210,126,.4); }

/* ===== Layout ===== */
main { max-width: 920px; margin: 0 auto; padding: 16px; }
.step-pane, .mode-pane { display: block; }
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px;
}
.spacer { height: 8px; }
.hint { color: var(--text-2); font-size: 13px; margin: 10px 2px 0; }
.field-label { display: block; font-weight: 700; font-size: 13px; margin: 14px 2px 8px; color: var(--text); }
.field-label:first-child { margin-top: 0; }

/* ===== Segmented control ===== */
.seg { display: flex; gap: 6px; background: rgba(255,255,255,.04); padding: 5px; border-radius: 13px; flex-wrap: wrap; border: 1px solid var(--line); }
.seg button {
  flex: 1 1 auto; min-width: 120px; border: 0; background: transparent; cursor: pointer;
  padding: 11px 14px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--text-2); transition: all .15s;
}
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.4), inset 0 0 0 1px var(--line-strong); }
.seg.small button { padding: 9px 10px; min-width: 90px; font-size: 13px; }

/* ===== Inputs ===== */
.text-input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 11px;
  font-size: 15px; font-family: inherit; color: var(--text); background: rgba(255,255,255,.04);
}
.text-input::placeholder { color: var(--text-3); }
.text-input:focus { outline: none; border-color: var(--brand); background: rgba(53,210,126,.06); box-shadow: 0 0 0 3px var(--glow-soft); }
textarea.text-input { resize: vertical; }
.search { margin: 0; }

/* ===== Uploader ===== */
.uploader {
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 200px; border: 1.5px dashed var(--line-strong); border-radius: 14px;
  background: rgba(255,255,255,.03); cursor: pointer; overflow: hidden; text-align: center; transition: all .18s;
}
.uploader:hover, .uploader.dragover { background: rgba(53,210,126,.07); border-color: var(--brand); }
.uploader-empty { padding: 24px; color: var(--text-2); }
.up-ic { font-size: 34px; color: var(--brand); }
.up-title { font-weight: 700; margin-top: 8px; color: var(--text); }
.up-sub { color: var(--text-3); }
.photo-preview { width: 100%; max-height: 420px; object-fit: contain; display: block; background: #050806; }
.photo-clear { position: absolute; top: 10px; right: 10px; width: 34px; height: 34px; border: 0; cursor: pointer; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; }
.guide { display: flex; gap: 10px; margin-top: 12px; }
.guide-col { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 11px; font-size: 12px; border: 1px solid var(--line); }
.guide-col b { font-size: 13px; }
.guide-col span { color: var(--text-2); }
.guide-col.ok { background: rgba(53,210,126,.08); } .guide-col.ok b { color: var(--brand); }
.guide-col.no { background: rgba(240,88,75,.08); } .guide-col.no b { color: var(--danger); }

/* ===== Chips ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chips.inline { margin-top: 0; }
.chip { border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); color: var(--text-2); cursor: pointer; padding: 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: all .15s; }
.chip:hover { border-color: var(--brand); color: var(--text); }
.chip.active { background: linear-gradient(120deg, var(--brand), var(--teal)); color: #06120c; border-color: transparent; }

/* ===== Module tabs ===== */
.module-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; }
.module-tabs button { flex: 0 0 auto; border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); cursor: pointer; padding: 9px 14px; border-radius: 999px; font-size: 14px; font-weight: 700; color: var(--text-2); transition: all .15s; }
.module-tabs button.active { background: linear-gradient(120deg, var(--brand-deep), var(--brand-soft)); color: #06120c; border-color: transparent; box-shadow: 0 4px 14px var(--glow-soft); }
.module-tabs .count { display: inline-block; min-width: 18px; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: rgba(255,255,255,.12); color: var(--text); font-size: 11px; line-height: 18px; text-align: center; }
.module-tabs button.active .count { background: rgba(6,18,12,.25); color: #06120c; }
.module-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.module-toolbar .search { flex: 1 1 200px; }

/* ===== Module grid ===== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tile { position: relative; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; overflow: hidden; transition: border-color .15s, transform .12s, box-shadow .15s; }
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.tile.selected { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand), 0 8px 26px var(--glow-soft); }
.tile-thumb { height: 80px; display: flex; align-items: center; justify-content: center; font-size: 32px; background: radial-gradient(120% 120% at 50% 0%, rgba(53,210,126,.12), transparent 70%), var(--surface-2); }
.tile-thumb img { width: 100%; height: 100%; object-fit: contain; }
.tile-body { padding: 9px 11px 11px; }
.tile-name { font-weight: 700; font-size: 13.5px; line-height: 1.25; color: var(--text); }
.tile-sci { font-size: 11px; color: var(--text-3); font-style: italic; margin-top: 1px; }
.tile-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.tile-tags span { font-size: 10px; color: var(--brand); background: var(--glow-soft); padding: 2px 7px; border-radius: 999px; }
.tile-check { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #06120c; display: none; align-items: center; justify-content: center; font-size: 14px; font-weight: 900; }
.tile.selected .tile-check { display: flex; }
.empty-note { color: var(--text-3); font-size: 14px; padding: 24px; text-align: center; grid-column: 1 / -1; }

/* ===== Footer nav (bước 1–2) ===== */
.wizard-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(10,14,12,.72); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-top: 1px solid var(--line);
}
.nav-back { border: 1px solid var(--line-strong); background: rgba(255,255,255,.05); color: var(--text); cursor: pointer; padding: 12px 16px; border-radius: 12px; font-weight: 700; font-size: 14px; }
.summary { flex: 1; font-size: 13px; color: var(--text-2); line-height: 1.35; }
.summary b { color: var(--brand); }
.btn-primary {
  border: 0; cursor: pointer; padding: 14px 24px; border-radius: 12px; font-size: 15px; font-weight: 800;
  color: #06120c; background: linear-gradient(120deg, var(--brand), var(--teal)); white-space: nowrap;
  box-shadow: 0 8px 22px var(--glow); transition: transform .12s, box-shadow .15s, opacity .15s;
}
.btn-primary:hover { box-shadow: 0 12px 30px var(--glow); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; filter: grayscale(.3); }
.btn-primary.sm { padding: 10px 16px; font-size: 14px; border-radius: 11px; flex: 0 0 auto; }

/* ===== Result ===== */
.result { position: fixed; inset: 0; z-index: 50; background: rgba(4,8,6,.8); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; padding: 16px; }
.result-inner { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; width: 100%; max-width: 900px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-float); }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.result-tabs { flex: 0 0 auto; }
.result-tabs button { min-width: 100px; }
.icon-btn { border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--text); width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 16px; }
.icon-btn.light { background: rgba(255,255,255,.06); color: var(--text); }
.img-wrap { position: relative; background: #050806; display: flex; align-items: center; justify-content: center; min-height: 240px; }
.img-wrap img { width: 100%; max-height: 70vh; object-fit: contain; display: block; }
.img-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(4,8,6,.66); }
.result-actions { display: flex; gap: 10px; padding: 14px; flex-wrap: wrap; }
.result-actions button { flex: 1; min-width: 120px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.05); color: var(--text); cursor: pointer; padding: 12px; border-radius: 11px; font-weight: 700; font-size: 14px; }
.result-actions #downloadBtn { background: linear-gradient(120deg, var(--brand), var(--teal)); color: #06120c; border-color: transparent; }

/* ===== Overlay / spinner / toast ===== */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(4,8,6,.74); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--text); }
.spinner { width: 30px; height: 30px; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
.spinner.big { width: 46px; height: 46px; border-width: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 70; background: var(--surface-3); color: var(--text); border: 1px solid var(--line-strong); padding: 12px 18px; border-radius: 12px; font-size: 14px; max-width: 90%; box-shadow: var(--shadow-float); }
.toast.err { background: rgba(240,88,75,.18); border-color: rgba(240,88,75,.5); color: #ffb4ab; }

/* ===== Help / project sheets + coach ===== */
.sheet-overlay { position: fixed; inset: 0; z-index: 65; background: rgba(4,8,6,.6); display: flex; align-items: flex-end; }
.sheet-overlay .sheet {
  width: 100%; max-height: 85vh; overflow: auto;
  background: rgba(20,26,23,.96); backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--line-strong); border-top-left-radius: 24px; border-top-right-radius: 24px;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-float);
}
.coach { position: fixed; inset: 0; z-index: 75; background: rgba(4,8,6,.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.coach-card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 20px; padding: 22px; max-width: 360px; width: 100%; box-shadow: var(--shadow-float); }
.coach-step { font-size: 12px; font-weight: 800; color: var(--brand); letter-spacing: 1px; }
.coach-title { font-size: 18px; font-weight: 800; margin: 6px 0 8px; }
.coach-body { color: var(--text-2); font-size: 14px; line-height: 1.55; }
.coach-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.coach-skip { border: 0; background: none; color: var(--text-3); cursor: pointer; font-weight: 700; font-size: 14px; }

/* ===== Bước Bố cục — Creative Canvas ===== */
.layout-view { position: fixed; inset: 0; z-index: 55; display: flex; flex-direction: column; background: var(--bg); }
.layout-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(14,19,17,.7); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line); z-index: 48; position: relative;
}
.layout-title { flex: 1; min-width: 0; }
.layout-title b { display: block; font-size: 15px; font-weight: 800; color: var(--text); }
.layout-title small { display: block; font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.layout-stage-host { flex: 1; position: relative; width: 100%; height: 100%; overflow: hidden; background: radial-gradient(120% 120% at 50% 20%, #0f1714, #070b09); }
.layout-stage-host .konvajs-content { box-shadow: 0 14px 50px rgba(0,0,0,.6); }
.rotate-hint { position: absolute; top: calc(env(safe-area-inset-top) + 48px); left: 50%; transform: translateX(-50%); z-index: 3; background: rgba(20,26,23,.92); color: var(--text); font-size: 12px; font-weight: 600; padding: 7px 14px; border-radius: 999px; box-shadow: var(--shadow); pointer-events: none; white-space: nowrap; border: 1px solid var(--line); }
@media (min-width: 820px), (orientation: landscape) { .rotate-hint { display: none; } }

.fab-add {
  position: absolute; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  width: 58px; height: 58px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--teal)); color: #06120c;
  font-size: 28px; border: none; box-shadow: 0 10px 26px var(--glow); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: transform .2s;
}
.fab-add:active { transform: scale(.92); }

.layer-panel { position: absolute; top: calc(env(safe-area-inset-top) + 62px); right: 12px; z-index: 46; width: min(260px, 70vw); max-height: 62vh; overflow: auto; padding: 8px; background: rgba(20,26,23,.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--line-strong); border-radius: 14px; box-shadow: var(--shadow-float); }
.layer-panel:empty { display: none; }

.bottom-sheet {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
  background: rgba(18,24,21,.9); backdrop-filter: blur(26px); -webkit-backdrop-filter: blur(26px);
  border-top: 1px solid var(--line-strong); border-top-left-radius: 24px; border-top-right-radius: 24px;
  box-shadow: var(--shadow-float); display: flex; flex-direction: column;
  max-height: 80vh; transition: transform .35s cubic-bezier(.1,.9,.2,1), opacity .3s;
}
.bottom-sheet:not(.open) { transform: translateY(100%); opacity: 0; pointer-events: none; }
.bottom-sheet.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
.sheet-drag-handle { width: 100%; height: 24px; display: flex; align-items: center; justify-content: center; cursor: grab; }
.sheet-drag-handle span { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); }
.asset-tabs { display: flex; padding: 0 16px; border-bottom: 1px solid var(--line); }
.atab { flex: 1; text-align: center; padding: 12px 0; font-weight: 600; font-size: 14px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--text-2); cursor: pointer; }
.atab.active { color: var(--brand); border-bottom-color: var(--brand); }
.sheet-content { overflow-y: auto; padding: 16px calc(16px + env(safe-area-inset-bottom)); flex: 1; }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 12px; }
.tray-chip { width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 10px 6px; text-align: center; cursor: pointer; background: rgba(255,255,255,.04); transition: transform .2s, box-shadow .2s, border-color .2s; }
.tray-chip:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(0,0,0,.4); border-color: var(--brand); }
.tray-chip img { width: 100%; aspect-ratio: 1; object-fit: contain; pointer-events: none; transition: transform .2s; }
.tray-chip:hover img { transform: scale(1.05); }
.tray-chip span { font-size: 11px; font-weight: 600; display: block; margin-top: 4px; color: var(--text-2); }
.tray-empty { color: var(--text-3); font-size: 13px; padding: 8px 14px; grid-column: 1 / -1; text-align: center; }

.selection-toolbar { position: absolute; z-index: 47; top: calc(env(safe-area-inset-top) + 70px); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; padding: 8px; background: rgba(20,26,23,.9); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-radius: 16px; border: 1px solid var(--line-strong); box-shadow: var(--shadow-float); }
.selection-toolbar button { width: 44px; height: 44px; border-radius: 12px; border: none; background: rgba(255,255,255,.06); color: var(--text); font-size: 18px; cursor: pointer; transition: all .2s; }
.selection-toolbar button:hover { background: rgba(255,255,255,.12); transform: scale(1.05); }
.selection-toolbar button:active { transform: scale(.95); }
.selection-toolbar button.danger { color: var(--danger); background: rgba(240,88,75,.12); }

.material-view { display: flex; flex-direction: column; gap: 16px; }
.editor-tools { display: flex; gap: 8px; }
.etool { flex: 1; padding: 10px; border-radius: 10px; border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); color: var(--text-2); font-weight: 600; cursor: pointer; }
.etool.active { border-color: var(--brand); background: var(--glow-soft); color: var(--brand); }
.material-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; }
.material-chips img { width: 60px; height: 60px; border-radius: 8px; cursor: pointer; border: 2px solid transparent; }
.material-chips img.active { border-color: var(--brand); }
.tex-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.tex-controls label { flex: 1 1 120px; font-size: 12px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.mask-list { display: flex; flex-direction: column; gap: 6px; }
.mat-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: none; color: var(--text-2); font-size: 11px; font-weight: 600; cursor: pointer; }

/* ===== Bảng layer / danh sách mask (dùng chung .lp-*) ===== */
.layer-panel.panel-hidden { display: none !important; }
.lp-empty { padding: 14px 10px; font-size: 12.5px; color: var(--text-2); text-align: center; }
.lp-row { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid var(--line); }
.lp-row.active { border-color: var(--brand); background: var(--glow-soft); }
.lp-name { flex: 1; min-width: 0; font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.lp-op { width: 56px; flex: 0 0 auto; }
.lp-eye, .lp-ic { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; border: none; background: rgba(255,255,255,.06); color: var(--text); font-size: 13px; cursor: pointer; }
.lp-ic.danger { color: var(--danger); background: rgba(240,88,75,.12); }
.lp-row + .lp-row { margin-top: 2px; }

/* ===== Nhãn chi phí API ===== */
.api-cost { display: inline-block; font-size: 10.5px; font-weight: 800; line-height: 1.5; padding: 1px 8px; border-radius: 999px; margin-left: 7px; vertical-align: middle; letter-spacing: .2px; white-space: nowrap; }
.api-cost.low  { background: rgba(53,210,126,.16); color: var(--brand); border: 1px solid rgba(53,210,126,.4); }
.api-cost.high { background: rgba(245,166,35,.16); color: var(--warn); border: 1px solid rgba(245,166,35,.42); }
.api-cost.mini { margin-left: 6px; padding: 0 6px; }

/* ===== Responsive ===== */
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .guide { flex-direction: column; }
  .btn-primary { padding: 13px 18px; }
}
