/* ════════════════════════════════════════════════════════════════
   DXED Arena: Emblem Studio.
   Follows the lobby design system (menus.css): charcoal surfaces,
   off-white text, amber for primary action/selection, cyan for
   technical states only. Rajdhani. No glow, no glass.
   ════════════════════════════════════════════════════════════════ */

.emb-root {
  /* fallback tokens: inherited from #scrMenu when mounted inside it */
  --ink0: #0a0c0f; --ink1: #101319; --ink2: #171b23; --ink3: #1f2530;
  --line: rgba(255,255,255,.07); --line2: rgba(255,255,255,.13);
  --tx: #edeae4; --tx2: #a7adb7; --tx3: #737a86;
  --amb: #ffa54d; --cyn: #2fe3cb; --red: #ff5a5e;
  --r-s: 8px; --r-m: 12px; --r-l: 16px;
  position: relative;
  display: flex; flex-direction: column;
  height: 100%; min-height: 0;
  font-family: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  color: var(--tx);
}
.emb-root * { box-sizing: border-box; }
.emb-root input, .emb-root button { font-family: inherit; }

/* ════════════ LOCKER ════════════ */

.emb-locker { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 20px 28px; }
.emb-locker-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.emb-title { margin: 2px 0 0; font-size: 24px; font-weight: 700; letter-spacing: .01em; }
.emb-locker-meta { display: flex; align-items: center; gap: 12px; }
.emb-slots { font-size: 12.5px; font-weight: 600; color: var(--tx3); letter-spacing: .04em; }

.emb-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
}
.emb-card {
  background: var(--ink1); border: 1px solid var(--line); border-radius: var(--r-m);
  overflow: hidden; transition: border-color .15s;
}
.emb-card:hover { border-color: var(--line2); }
.emb-card.active { border-color: color-mix(in srgb, var(--amb) 55%, transparent); }
.emb-card-thumb {
  position: relative; aspect-ratio: 1/1; display: flex; align-items: center; justify-content: center;
  background:
    repeating-conic-gradient(var(--ink2) 0% 25%, var(--ink1) 0% 50%) 0 0 / 28px 28px;
  border-bottom: 1px solid var(--line);
}
.emb-card-img { width: 74%; height: 74%; object-fit: contain; image-rendering: auto; }
.emb-card-removed { padding: 18px 14px; text-align: center; color: var(--tx3); font-size: 12.5px; line-height: 1.45; }
.emb-card-removed b { display: block; color: var(--red); font-size: 13.5px; margin-bottom: 4px; }
.emb-badge {
  position: absolute; top: 8px; left: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink0); background: var(--amb); border-radius: 4px; padding: 2px 7px;
}
.emb-badge.warn { background: none; color: var(--amb); border: 1px solid color-mix(in srgb, var(--amb) 45%, transparent); }
.emb-fav {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px;
  background: none; border: none; cursor: pointer; font-size: 16px; line-height: 1;
  color: var(--tx3); transition: color .15s;
}
.emb-fav:hover { color: var(--tx2); }
.emb-fav.on { color: var(--amb); }
.emb-card-name {
  padding: 9px 12px 2px; font-size: 15px; font-weight: 700; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: text;
}
.emb-card-btns { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px 12px; }
.emb-rename {
  width: 100%; background: var(--ink2); border: 1px solid var(--line2); border-radius: 6px;
  color: var(--tx); font: 700 14px/1.3 'Rajdhani', sans-serif; padding: 3px 8px; outline: none;
}
.emb-rename:focus { border-color: var(--amb); }

/* ════════════ EDITOR SHELL ════════════ */

.emb-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.emb-topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--ink0);
  flex: none;
}
.emb-name {
  width: 220px; max-width: 34vw;
  background: var(--ink2); border: 1px solid var(--line); border-radius: var(--r-s);
  color: var(--tx); font: 700 15px/1 'Rajdhani', sans-serif; letter-spacing: .02em;
  padding: 8px 10px; outline: none;
}
.emb-name:focus { border-color: var(--amb); }
.emb-top-mid { display: flex; align-items: center; gap: 6px; margin: 0 auto; }
.emb-top-right { display: flex; align-items: center; gap: 10px; }
.emb-count { font-size: 12px; font-weight: 700; color: var(--tx3); letter-spacing: .05em; padding: 0 6px; }
.emb-savestate { font-size: 12px; font-weight: 600; color: var(--cyn); letter-spacing: .04em; }

.emb-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 236px minmax(0, 1fr) 264px;
  gap: 0;
}

/* ── shared small tool buttons ── */
.emb-tool {
  min-width: 30px; height: 30px; padding: 0 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; border-radius: 6px;
  color: var(--tx2); font-size: 14px; line-height: 1; cursor: pointer;
  transition: color .13s, background .13s, border-color .13s;
}
.emb-tool:hover { color: var(--tx); background: var(--ink3); }
.emb-tool.on, .emb-tool.tog.on { color: var(--amb); border-color: color-mix(in srgb, var(--amb) 40%, transparent); }
.emb-tgroup { display: inline-flex; gap: 2px; padding: 0 6px; border-right: 1px solid var(--line); }
.emb-tgroup:last-child { border-right: none; }
.emb-zoom-val { font-size: 12px; font-weight: 700; min-width: 46px; }

/* ════════════ LIBRARY (left) ════════════ */

.emb-lib {
  min-height: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 12px; border-right: 1px solid var(--line); background: var(--ink1);
}
.emb-search {
  background: var(--ink2); border: 1px solid var(--line); border-radius: var(--r-s);
  color: var(--tx); font: 600 13.5px/1 'Rajdhani', sans-serif;
  padding: 8px 10px; outline: none; width: 100%;
}
.emb-search:focus { border-color: var(--amb); }
.emb-search::placeholder { color: var(--tx3); }
.emb-lib-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.emb-lib-tab {
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--tx3); font: 700 11px/1 'Rajdhani', sans-serif; letter-spacing: .06em; text-transform: uppercase;
  padding: 5px 8px; cursor: pointer; transition: color .13s, border-color .13s;
}
.emb-lib-tab:hover { color: var(--tx2); }
.emb-lib-tab.sel { color: var(--amb); border-color: color-mix(in srgb, var(--amb) 45%, transparent); }
.emb-lib-grid {
  flex: 1; min-height: 0; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 5px;
  align-content: start; padding-right: 2px;
}
.emb-shape {
  position: relative; aspect-ratio: 1/1;
  display: flex; align-items: center; justify-content: center;
  background: var(--ink2); border: 1px solid var(--line); border-radius: 7px;
  color: var(--tx2); cursor: pointer; padding: 6px;
  transition: color .13s, border-color .13s, background .13s;
}
.emb-shape svg { width: 100%; height: 100%; }
.emb-shape:hover { color: var(--tx); border-color: var(--line2); background: var(--ink3); }
.emb-shape.locked { color: var(--tx3); opacity: .55; cursor: not-allowed; }
.emb-lock { position: absolute; right: 2px; bottom: 1px; font-size: 10px; }

/* ════════════ CENTER ════════════ */

.emb-center { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--ink0); }
.emb-toolbar {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
}
.emb-canvas-wrap {
  flex: 1; min-height: 0; overflow: auto;
  display: flex; padding: 18px;
}
.emb-canvas {
  position: relative; margin: auto;
  width: 100%; max-width: 720px; aspect-ratio: 1/1; flex: none;
  background:
    repeating-conic-gradient(#12151c 0% 25%, #0d1015 0% 50%) 0 0 / 32px 32px;
  border: 1px solid var(--line2); border-radius: 4px;
  touch-action: none;
}
.emb-canvas svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.emb-guide { stroke: var(--cyn); stroke-width: 1; stroke-dasharray: 5 4; vector-effect: non-scaling-stroke; }

/* gizmo: box is passive, handles are live */
.emb-gizmo {
  position: absolute; pointer-events: none;
  border: 1px dashed var(--amb); border-radius: 1px;
}
.emb-h {
  position: absolute; width: 12px; height: 12px; pointer-events: auto;
  background: var(--ink0); border: 2px solid var(--amb); border-radius: 3px;
  transform: translate(-50%, -50%); cursor: nwse-resize;
  /* generous invisible hit area */
  box-shadow: 0 0 0 8px rgba(0,0,0,0.001);
}
.emb-h[data-h="nw"] { left: 0; top: 0; }
.emb-h[data-h="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.emb-h[data-h="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.emb-h[data-h="se"] { left: 100%; top: 100%; }
.emb-h-rot {
  left: 50%; top: -26px; border-radius: 50%; cursor: grab;
}
.emb-h-rot::after {
  content: ''; position: absolute; left: 50%; top: 100%; width: 1px; height: 16px;
  background: color-mix(in srgb, var(--amb) 55%, transparent);
}

/* ── properties strip ── */
.emb-props {
  flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 8px 12px; border-top: 1px solid var(--line); background: var(--ink1);
  min-height: 48px;
}
.emb-props-empty { font-size: 12.5px; color: var(--tx3); letter-spacing: .03em; }
.emb-p { display: inline-flex; align-items: center; gap: 5px; }
.emb-p label { font-size: 11px; font-weight: 700; color: var(--tx3); letter-spacing: .06em; text-transform: uppercase; }
.emb-p input[type="number"] {
  width: 58px; background: var(--ink2); border: 1px solid var(--line); border-radius: 6px;
  color: var(--tx); font: 600 13px/1 'Rajdhani', sans-serif; padding: 6px 6px; outline: none;
}
.emb-p input[type="number"]:focus { border-color: var(--amb); }
.emb-p-op input[type="range"] { width: 84px; accent-color: var(--amb); }
.emb-swatch {
  width: 30px; height: 30px; border: 1px solid var(--line2); border-radius: 7px; cursor: pointer;
  flex: none; padding: 0;
}
.emb-swatch.small { width: 24px; height: 24px; }
.emb-check { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: var(--tx2); cursor: pointer; }
.emb-check input { accent-color: var(--amb); }
.emb-p-outline { gap: 7px; }
.emb-p-outline input[type="number"] { width: 52px; }
.emb-p-multi { font-size: 11.5px; font-weight: 700; color: var(--cyn); letter-spacing: .05em; }

/* ── preview strip ── */
.emb-previews {
  flex: none; display: flex; align-items: stretch; gap: 12px;
  padding: 10px 12px; border-top: 1px solid var(--line); background: var(--ink0);
  overflow-x: auto;
}
.emb-pv { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.emb-pv-cap { font-size: 9.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--tx3); }
.emb-pv-box {
  display: flex; align-items: center; justify-content: center;
  background: repeating-conic-gradient(#12151c 0% 25%, #0d1015 0% 50%) 0 0 / 12px 12px;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px; min-width: 40px; min-height: 40px;
}
.emb-pv-card { flex: 1; min-width: 230px; align-items: stretch; }
.emb-mockcard {
  flex: 1; display: flex; align-items: center; gap: 12px;
  background: linear-gradient(100deg, var(--ink2), var(--ink1));
  border: 1px solid var(--line2); border-radius: var(--r-s); padding: 8px 14px;
}
.emb-mock-emblem { flex: none; }
.emb-mock-id { min-width: 0; }
.emb-mock-id b { display: block; font-size: 15px; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emb-mock-id span { font-size: 10.5px; color: var(--tx3); letter-spacing: .05em; text-transform: uppercase; font-weight: 700; }
.emb-mock-lvl { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--amb); letter-spacing: .05em; }

/* ════════════ LAYER PANEL (right) ════════════ */

.emb-layers {
  min-height: 0; display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: var(--ink1);
}
.emb-lp-head {
  flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 8px;
}
.emb-lp-actions { display: inline-flex; gap: 2px; }
.emb-lp-list { flex: 1; min-height: 0; overflow-y: auto; position: relative; }
.emb-lp-inner { position: relative; }
.emb-row {
  display: flex; align-items: center; gap: 6px; padding: 0 8px 0 4px;
  border-bottom: 1px solid var(--line); cursor: pointer; user-select: none;
  font-size: 13px;
}
.emb-row:hover { background: var(--ink2); }
.emb-row.sel { background: color-mix(in srgb, var(--amb) 10%, var(--ink2)); box-shadow: inset 2px 0 0 var(--amb); }
.emb-row.in-group { padding-left: 18px; }
.emb-row-grip { color: var(--tx3); font-size: 11px; letter-spacing: -2px; cursor: grab; padding: 6px 2px; touch-action: none; }
.emb-row-thumb {
  width: 22px; height: 22px; flex: none; display: flex;
  background: var(--ink0); border: 1px solid var(--line); border-radius: 4px; padding: 2px;
}
.emb-row-thumb svg { width: 100%; height: 100%; }
.emb-row-name { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.emb-row-name i { font-style: normal; color: var(--tx3); font-size: 11px; }
.emb-row-btns { display: none; align-items: center; gap: 1px; }
.emb-row:hover .emb-row-btns, .emb-row.sel .emb-row-btns { display: inline-flex; }
.emb-ico {
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 5px; color: var(--tx3); cursor: pointer; font-size: 12px;
}
.emb-ico:hover { color: var(--tx); background: var(--ink3); }
.emb-ico.off { color: var(--tx3); opacity: .5; }
.emb-ico.on { color: var(--amb); }
.emb-row-group { background: var(--ink2); font-weight: 700; }
.emb-caret { color: var(--tx3); font-size: 11px; padding: 4px; transition: transform .12s; }
.emb-caret.closed { transform: rotate(-90deg); }
.emb-drop-ind {
  position: absolute; left: 0; right: 0; height: 2px; background: var(--amb); z-index: 5; pointer-events: none;
}

/* ════════════ COLOR PICKER ════════════ */

.emb-picker {
  position: absolute; z-index: 60; width: 252px; max-height: 70%; overflow-y: auto;
  background: var(--ink1); border: 1px solid var(--line2); border-radius: var(--r-m);
  padding: 12px; box-shadow: 0 14px 34px rgba(0,0,0,.5);
}
.emb-pk-sv {
  position: relative; width: 100%; aspect-ratio: 3/2; border-radius: var(--r-s);
  border: 1px solid var(--line); cursor: crosshair; touch-action: none;
}
.emb-pk-dot {
  position: absolute; width: 12px; height: 12px; border: 2px solid #fff; border-radius: 50%;
  transform: translate(-50%, -50%); pointer-events: none; box-shadow: 0 0 0 1px rgba(0,0,0,.6);
}
.emb-pk-hue {
  position: relative; height: 14px; margin-top: 10px; border-radius: 7px; cursor: crosshair; touch-action: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
}
.emb-pk-hdot {
  position: absolute; top: 50%; width: 6px; height: 18px; border-radius: 3px;
  background: #fff; border: 1px solid rgba(0,0,0,.5);
  transform: translate(-50%, -50%); pointer-events: none;
}
.emb-pk-fields { display: flex; gap: 6px; margin-top: 10px; }
.emb-pk-fields label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--tx3);
}
.emb-pk-fields input {
  width: 100%; background: var(--ink2); border: 1px solid var(--line); border-radius: 5px;
  color: var(--tx); font: 600 12px/1 'Rajdhani', sans-serif; padding: 5px 5px; outline: none;
}
.emb-pk-fields label:first-child { flex: 1.6; }
.emb-pk-fields label { flex: 1; }
.emb-pk-fields input:focus { border-color: var(--amb); }
.emb-pk-oprow { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.emb-pk-oprow label { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tx3); }
.emb-pk-oprow input { flex: 1; accent-color: var(--amb); }
.emb-pk-sec { margin: 10px 0 5px; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--tx3); }
.emb-pk-row { display: flex; flex-wrap: wrap; gap: 5px; }
.emb-chip {
  width: 24px; height: 24px; border: 1px solid var(--line2); border-radius: 6px; cursor: pointer; padding: 0;
}
.emb-chip:hover { border-color: var(--tx3); }
.emb-pk-none { font-size: 11.5px; color: var(--tx3); }
.emb-pk-foot { margin-top: 12px; display: flex; justify-content: flex-end; }

/* ════════════ MOBILE TABS (hidden on desktop) ════════════ */

.emb-mtabs { display: none; }

/* ════════════ RESPONSIVE / MOBILE ════════════ */

@media (max-width: 980px) {
  .emb-body { grid-template-columns: 200px minmax(0, 1fr) 220px; }
}

body.dx-mobile .emb-locker { padding: 12px 12px calc(24px + env(safe-area-inset-bottom, 0px)); }
body.dx-mobile .emb-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
body.dx-mobile .emb-card-btns .gs-btn { min-height: 42px; flex: 1 1 44%; }
body.dx-mobile .emb-title { font-size: 20px; }

body.dx-mobile .emb-editor { position: relative; }
body.dx-mobile .emb-topbar { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
body.dx-mobile .emb-name { width: 130px; }
body.dx-mobile .emb-body { display: flex; flex-direction: column; }

/* library + layer panel become full-height drawers over the canvas */
body.dx-mobile .emb-lib, body.dx-mobile .emb-layers {
  position: absolute; top: 0; bottom: 44px; z-index: 40;
  width: min(320px, 88vw); display: none;
  border-right: 1px solid var(--line2); border-left: 1px solid var(--line2);
  box-shadow: 0 0 40px rgba(0,0,0,.55);
}
body.dx-mobile .emb-lib { left: 0; }
body.dx-mobile .emb-layers { right: 0; }
body.dx-mobile .emb-editor.show-lib .emb-lib { display: flex; }
body.dx-mobile .emb-editor.show-layers .emb-layers { display: flex; }
body.dx-mobile .emb-lib-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
body.dx-mobile .emb-shape { min-width: 42px; min-height: 42px; }
body.dx-mobile .emb-row { min-height: 42px; }
body.dx-mobile .emb-ico, body.dx-mobile .emb-tool { min-width: 36px; min-height: 36px; }
body.dx-mobile .emb-h { width: 18px; height: 18px; }
body.dx-mobile .emb-h-rot { top: -34px; }
body.dx-mobile .emb-canvas-wrap { padding: 10px; }
body.dx-mobile .emb-props { gap: 6px; padding: 8px 10px; }
body.dx-mobile .emb-p input[type="number"] { width: 52px; min-height: 36px; }
body.dx-mobile .emb-swatch { width: 42px; height: 42px; }
body.dx-mobile .emb-previews { padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); }
body.dx-mobile .emb-pv-card { min-width: 200px; }

body.dx-mobile .emb-mtabs {
  display: flex; flex: none; height: 44px; z-index: 45;
  border-top: 1px solid var(--line); background: var(--ink0);
}
.emb-mtab {
  flex: 1; background: none; border: none; cursor: pointer;
  font: 700 13px/1 'Rajdhani', sans-serif; letter-spacing: .06em; text-transform: uppercase;
  color: var(--tx3); min-height: 44px;
}
.emb-mtab.sel { color: var(--amb); box-shadow: inset 0 2px 0 var(--amb); }

body.dx-mobile .emb-picker { width: min(300px, 92vw); left: 50% !important; transform: translateX(-50%); }
