/* Kslicer. Vista 3D oscura (pizarra) con el modelo en color filamento; panel claro a la derecha, como un taller
   ordenado. Un solo acento cálido (el filamento) para acciones; la selección en turquesa frío. */
:root {
  --canvas: #2b323c;      /* fondo de la vista 3D (también en app.js) */
  --bar: #1f262f;         /* barra superior */
  --bar-ink: #d9dfe7;
  --panel: #f4f6f8;
  --panel-2: #ffffff;
  --line: #dde2e8;
  --ink: #1d2733;
  --muted: #677385;
  --filament: #f08a24;    /* acento: color del modelo y botón principal */
  --filament-ink: #3a1f05;
  --select: #17a39e;      /* selección */
  --danger: #cf3f3f;
  --ok: #24875a;
  --radius-s: 5px;
  --radius-m: 8px;
  font: 14px/1.45 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { display: flex; flex-direction: column; overflow: hidden; background: var(--canvas); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }

/* ---------- barra superior ---------- */
#top { height: 44px; flex: none; display: flex; align-items: center; gap: 22px; padding: 0 16px;
  background: var(--bar); color: var(--bar-ink); border-bottom: 1px solid #141a21; }
.brand { font-size: 19px; font-weight: 800; letter-spacing: -0.4px; color: var(--filament); }
.brand span { color: var(--bar-ink); font-weight: 600; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs button { background: none; border: 0; padding: 0 14px; height: 100%; cursor: pointer; color: #9aa6b5;
  border-bottom: 2px solid transparent; font-weight: 600; }
.tabs button:hover:not(:disabled) { color: var(--bar-ink); }
.tabs button.on { color: #fff; border-bottom-color: var(--filament); }
.tabs button:disabled { color: #566271; cursor: default; }
.file-name { margin-left: auto; color: #9aa6b5; font-size: 13px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 40vw; }

#main { flex: 1; display: flex; min-height: 0; }

/* ---------- vista 3D ---------- */
#view { flex: 1; position: relative; min-width: 0; }
#view canvas { display: block; }
#view.drop-over::after { content: ""; position: absolute; inset: 10px; border: 2px dashed var(--filament);
  border-radius: var(--radius-m); pointer-events: none; }

#toolbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); display: flex; align-items: center;
  gap: 2px; padding: 4px; background: #f4f6f8f2; border: 1px solid #c9d1db; border-radius: var(--radius-m);
  box-shadow: 0 6px 18px #0b101633; z-index: 2; }
#toolbar button { position: relative; width: 36px; height: 34px; display: grid; place-items: center; border: 0;
  background: none; border-radius: var(--radius-s); cursor: pointer; color: var(--ink); }
#toolbar button:hover:not(:disabled) { background: #e2e7ed; }
#toolbar button:active:not(:disabled) { background: #d4dbe3; }
#toolbar button:disabled { color: #b3bcc7; cursor: default; }
#toolbar svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }
#toolbar .sep { width: 1px; height: 22px; background: #cdd4dd; margin: 0 4px; }
#toolbar button[data-tip]:hover::after, #toolbar button[data-tip]:focus-visible::after {
  content: attr(data-tip); position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  white-space: nowrap; background: var(--bar); color: #fff; font-size: 12px; padding: 4px 8px;
  border-radius: var(--radius-s); pointer-events: none; }

#empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center;
  color: #c7d0db; max-width: 420px; padding: 0 20px; }
.empty-title { font-size: 18px; font-weight: 600; color: #eef2f6; margin: 0 0 6px; }
.empty-sub { margin: 0 0 16px; font-size: 13px; }

#hud { position: absolute; left: 14px; bottom: 10px; color: #a9b4c2; font-size: 12px; pointer-events: none;
  font-variant-numeric: tabular-nums; }
#layerBar { position: absolute; right: 14px; top: 64px; bottom: 40px; width: 62px; display: flex;
  flex-direction: column; align-items: center; background: #1f262fd9; border: 1px solid #3a4553;
  border-radius: var(--radius-m); padding: 10px 0; color: var(--bar-ink); }
#layerLabel { font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; margin-bottom: 8px; }
#layerLabel b { display: block; font-size: 16px; color: var(--filament); }
#layer { writing-mode: vertical-lr; direction: rtl; flex: 1; accent-color: var(--filament); width: 24px; }

/* ---------- panel lateral ---------- */
#side { width: 320px; flex: none; display: flex; flex-direction: column; background: var(--panel);
  border-left: 1px solid #141a21; }
#side .scroll { flex: 1; overflow-y: auto; }
.group { padding: 14px 16px; border-bottom: 1px solid var(--line); }
h2 { font-size: 13px; font-weight: 700; margin: 0 0 8px; display: flex; align-items: baseline; gap: 6px; }
h2 .count { color: var(--muted); font-weight: 500; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.hint.warn { color: #9a5a0c; } .hint.bad { color: var(--danger); }

select, .filebtn, input[type=number] { display: block; width: 100%; background: var(--panel-2);
  border: 1px solid #cfd6df; border-radius: var(--radius-s); padding: 6px 8px; }
.filebtn { margin-top: 6px; cursor: pointer; color: var(--muted); font-size: 13px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.filebtn:hover { border-color: var(--select); color: var(--ink); }
.row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.row input { flex: 1; width: 0; }
.row span { color: var(--muted); font-size: 12px; }

/* lista de objetos */
#objList { position: relative; list-style: none; margin: 0; padding: 0; max-height: 38vh; overflow-y: auto; background: var(--panel-2);
  border: 1px solid #cfd6df; border-radius: var(--radius-s); }
#objList:empty { display: none; }
#objList li { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 8px;
  padding: 5px 8px; cursor: pointer; border-bottom: 1px solid #edf0f3; font-size: 13px; }
#objList li:last-child { border-bottom: 0; }
#objList li:hover { background: #eef3f7; }
#objList li.sel { background: #dff4f3; box-shadow: inset 3px 0 0 var(--select); }
#objList li i { width: 12px; height: 12px; border-radius: 3px; background: var(--filament); }
#objList li.out i { background: var(--danger); }
#objList li.dup i { background: repeating-linear-gradient(45deg, var(--filament) 0 3px, #f6b26b 3px 6px); }
#objList li span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#objList li em { font-style: normal; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.xy { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.xy label { display: flex; align-items: center; gap: 6px; }
.xy label span { font-weight: 700; color: var(--muted); width: 12px; }
.xy em { grid-column: 1 / -1; font-style: normal; color: var(--muted); font-size: 12px; }

/* vista previa */
dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 13px; }
dt { color: var(--muted); } dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.chk { display: flex; align-items: center; gap: 8px; margin: 4px 0; cursor: pointer; font-size: 13px; }
.chk i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
#legend .chk span { flex: 1; } #legend .chk em { color: var(--muted); font-style: normal; font-size: 12px;
  font-variant-numeric: tabular-nums; }
details { padding: 10px 16px; font-size: 12px; } summary { cursor: pointer; color: var(--muted); }
pre { white-space: pre-wrap; background: var(--panel-2); border: 1px solid var(--line); padding: 8px;
  border-radius: var(--radius-s); max-height: 220px; overflow: auto; }

/* acciones */
#actions { flex: none; padding: 12px 16px 14px; border-top: 1px solid var(--line); background: var(--panel-2);
  display: flex; flex-direction: column; gap: 8px; }
.primary { display: block; width: 100%; padding: 10px; border: 0; border-radius: var(--radius-m);
  background: var(--filament); color: var(--filament-ink); font-weight: 700; font-size: 15px; text-align: center;
  text-decoration: none; cursor: pointer; }
.primary:hover:not(:disabled) { background: #f59a3e; }
.primary:disabled { background: #e3e7ec; color: #98a3b1; cursor: default; }
#emptyOpen { width: auto; display: inline-block; padding: 9px 20px; }
select.engine { font-size: 12px; padding: 5px 8px; color: var(--muted); }
.status { font-size: 13px; color: var(--muted); min-height: 1.2em; }
.status:empty { display: none; }
.status.ok { color: var(--ok); } .status.err { color: var(--danger); }
.spin { display: inline-block; width: 11px; height: 11px; border: 2px solid #c3ccd6; border-top-color: var(--filament);
  border-radius: 50%; animation: r .8s linear infinite; margin-right: 6px; vertical-align: -1px; }
@keyframes r { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

@media (max-width: 760px) {
  #main { flex-direction: column; }
  #side { width: auto; height: 46vh; border-left: 0; border-top: 1px solid #141a21; }
  #toolbar { top: 8px; }
  .file-name { display: none; }
}

/* giro de la pieza elegida */
.rot { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 6px 10px; margin-top: 10px; }
.rot > span { font-size: 12px; color: var(--muted); }
.rot > div { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.rot button { padding: 5px 0; font-size: 12px; font-variant-numeric: tabular-nums; background: var(--panel-2);
  border: 1px solid #cfd6df; border-radius: var(--radius-s); cursor: pointer; }
.rot button:hover { border-color: var(--select); }
