/* GIA Splitter dark UI */

* { box-sizing: border-box; }

:root {
  --bg: #0b0d12;
  --panel: #12151d;
  --panel-2: #171b25;
  --border: rgba(255, 255, 255, 0.08);
  --border-soft: rgba(255, 255, 255, 0.05);
  --text: #e8ebf2;
  --muted: #8b93a7;
  --accent: #5b8cff;
  --accent-2: #39d0d8;
  --accent-grad: linear-gradient(135deg, #5b8cff, #39d0d8);
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
}

html, body { margin: 0; height: 100%; }

/* Base stack covers Latin, Cyrillic, Vietnamese (all system UI fonts carry
   full Vietnamese diacritics), plus broad CJK and Thai fallbacks so every
   supported language renders on Windows, macOS, Linux, and mobile. */
body {
  font-family:
    "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "PingFang SC", "Hiragino Sans", "Microsoft YaHei",
    "Microsoft JhengHei", "Yu Gothic UI", Meiryo, "Malgun Gothic",
    "Apple SD Gothic Neo", "Leelawadee UI", Thonburi, "Noto Sans Thai",
    sans-serif;
  background:
    radial-gradient(1100px 520px at 75% -12%, rgba(91, 140, 255, 0.1), transparent 60%),
    radial-gradient(900px 460px at 15% 112%, rgba(57, 208, 216, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}

/* Language-specific preferred fonts (html[lang] is set by the i18n system) */
:lang(zh-Hans) body { font-family: "Segoe UI", system-ui, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif; }
:lang(zh-Hant) body { font-family: "Segoe UI", system-ui, "PingFang TC", "Hiragino Sans CNS", "Microsoft JhengHei", "Noto Sans TC", sans-serif; }
:lang(ja) body { font-family: "Segoe UI", system-ui, "Hiragino Sans", "Yu Gothic UI", Meiryo, "Noto Sans JP", sans-serif; }
:lang(ko) body { font-family: "Segoe UI", system-ui, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; }
:lang(th) body { font-family: "Segoe UI", system-ui, "Leelawadee UI", Thonburi, "Noto Sans Thai", sans-serif; }
/* Thai stacked diacritics need extra line height to avoid clipping */
:lang(th) body, :lang(th) .btn, :lang(th) .hint, :lang(th) .split-info,
:lang(th) .chip span, :lang(th) .export-count { line-height: 1.6; }

/* themed scrollbars */
* { scrollbar-width: thin; scrollbar-color: #333a4a #12151d; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: #12151d; }
*::-webkit-scrollbar-thumb { background: #333a4a; border-radius: 5px; border: 2px solid #12151d; }
*::-webkit-scrollbar-thumb:hover { background: #424b5f; }

.hidden { display: none !important; }
.muted { color: var(--muted); }

#app { display: flex; flex-direction: column; height: 100vh; }

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 54px;
  min-height: 54px;
  padding: 0 18px;
  background: rgba(18, 21, 29, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; user-select: none; min-width: 0; }
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  font-size: 15px;
  border-radius: 9px;
  background: var(--accent-grad);
  color: #0b0d12;
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(91, 140, 255, 0.4);
}
.brand-text { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand-text span { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-tag {
  color: var(--muted);
  font-size: 12.5px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.meta-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-stats { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ---------- language selector ---------- */
.lang-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 0 4px 0 10px;
}
.lang-icon { font-size: 13px; opacity: 0.8; }
#lang-select {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 8px 6px;
  outline: none;
  cursor: pointer;
  max-width: 160px;
  /* rtl anchors the native dropdown's RIGHT edge to the control, so the
     list expands inward instead of past the viewport edge */
  direction: rtl;
}
#lang-select option { background: var(--panel-2); color: var(--text); direction: ltr; text-align: left; }

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.08s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: rgba(255, 255, 255, 0.2); background: #1d2230; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.primary {
  background: var(--accent-grad);
  border: none;
  color: #0a0f1a;
  box-shadow: 0 2px 14px rgba(91, 140, 255, 0.35);
}
.btn.primary:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 4px 20px rgba(91, 140, 255, 0.5); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); }
.btn.big { padding: 12px 26px; font-size: 15px; border-radius: 11px; }
.btn.tiny { padding: 5px 10px; font-size: 12px; border-radius: 7px; font-weight: 500; }

/* ---------- layout ---------- */
#main { flex: 1; min-height: 0; display: flex; }

/* ---------- dropzone hero ---------- */
#dropzone { flex: 1; display: grid; place-items: center; padding: 20px; }

.drop-card {
  text-align: center;
  max-width: 560px;
  background: rgba(18, 21, 29, 0.8);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  padding: 46px 54px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.drop-icon {
  width: 64px; height: 64px;
  margin: 0 auto 18px;
  display: grid; place-items: center;
  font-size: 30px;
  border-radius: 18px;
  background: var(--accent-grad);
  color: #0b0d12;
  box-shadow: 0 6px 30px rgba(91, 140, 255, 0.45);
}
.drop-card h1 { margin: 0 0 10px; font-size: 26px; letter-spacing: 0.3px; }
.drop-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.6; }
.drop-card p strong { color: var(--text); font-weight: 600; }
.drop-card .hint { margin-top: 18px; margin-bottom: 0; }

.hint { font-size: 11.5px; line-height: 1.5; color: var(--muted); }

/* page-wide drag overlay (label localized via data-drop-label, set by i18n) */
body.dragging::after {
  content: attr(data-drop-label);
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  background: rgba(11, 13, 18, 0.75);
  border: 3px dashed var(--accent);
  z-index: 100;
  pointer-events: none;
}

/* ---------- workbench (master-detail) ---------- */
#workbench { flex: 1; min-height: 0; display: flex; width: 100%; }

#model-panel {
  width: 320px;
  min-width: 240px;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--border);
  min-height: 0;
}

/* draggable divider between panels (managed by initPanelResize) */
.vsplit {
  flex: 0 0 6px;
  margin: 0 -3px;
  cursor: col-resize;
  position: relative;
  z-index: 5;
  background: transparent;
  transition: background 0.15s;
}
.vsplit:hover, .vsplit.dragging { background: rgba(91, 140, 255, 0.35); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
}
.panel-head h2 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--muted);
  font-weight: 700;
}

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--panel-2);
}

/* single-row toolbar: buttons keep their size, the flexible control (sort
   select / export summary) shrinks with ellipsis instead of wrapping */
.model-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--border-soft);
}
.model-toolbar .btn.tiny { padding: 5px 8px; flex-shrink: 0; }
.export-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}
.export-count.warn { color: #f0a35c; }

#model-list { flex: 1; overflow-y: auto; padding: 6px 8px 8px; }

.panel-hint { margin: 0; padding: 8px 14px 12px; border-top: 1px solid var(--border-soft); }

.model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.model-row:hover { background: rgba(255, 255, 255, 0.04); }
.model-row.active { background: rgba(91, 140, 255, 0.13); border-color: rgba(91, 140, 255, 0.4); }
/* while a decoration drag is active, other models advertise themselves as targets */
#model-list.dec-drag .model-row:not(.active) { border-color: rgba(57, 208, 216, 0.35); border-style: dashed; }
.model-row.drop-target { background: rgba(57, 208, 216, 0.18); border-color: var(--accent-2); border-style: solid; }
/* targets that would exceed the 999-entry limit are dimmed immediately and
   turn red when hovered with the drag */
#model-list.dec-drag .model-row.drop-full { opacity: 0.5; border-color: rgba(255, 110, 110, 0.5); border-style: dashed; }
#model-list.dec-drag .model-row.drop-full .model-count { color: #ff8a8a; border-color: rgba(255, 110, 110, 0.4); }
.model-row.drop-invalid { opacity: 1; background: rgba(255, 90, 90, 0.14); border-color: #ff6e6e; border-style: solid; cursor: not-allowed; }
.model-row.flash { animation: row-flash 1.2s ease-out; }
@keyframes row-flash {
  0% { background: rgba(57, 208, 216, 0.35); }
  100% { background: transparent; }
}

.model-row .model-export { accent-color: var(--accent); margin: 0; cursor: pointer; flex-shrink: 0; }
/* excluded from export: dimmed content, but viewing/selection stays intact */
.model-row.excluded .model-name,
.model-row.excluded .model-count,
.model-row.excluded .tag-new,
.model-row.excluded .tag-graph { opacity: 0.42; }

.model-name { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-badges { display: flex; align-items: center; gap: 7px; }
.model-count {
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.tag-new {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #0a0f1a;
  background: var(--accent-grad);
  padding: 2px 7px;
  border-radius: 999px;
}

/* ---------- detail panel ---------- */
#detail-panel { flex: 1 1 400px; min-width: 340px; min-height: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); }

/* ---------- 3D viewer panel ---------- */
#viewer-panel {
  flex: 1.3 1 340px;
  min-width: 300px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
}
#viewer-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 6px;
}
#viewer-toolbar input[type="search"] {
  flex: 0 1 190px;
  min-width: 90px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 9px;
  outline: none;
}
#viewer-toolbar input[type="search"]:focus { border-color: var(--accent); }
.v-stats { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.v-coords { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

#viewer-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 0 12px 8px;
  border-bottom: 1px solid var(--border-soft);
}
#viewer-tools .btn.on { border-color: rgba(57, 208, 216, 0.55); color: var(--accent-2); }
.v-select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  outline: none;
  cursor: pointer;
}
#viewer-tools input[type="range"] { width: 70px; accent-color: var(--accent); }
#viewer-tools input[type="color"] {
  width: 26px; height: 24px;
  padding: 1px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

#v-viewport { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#v-viewport canvas { display: block; }
.viewer-labels { position: absolute; inset: 0; pointer-events: none; }
.rubber-band {
  position: absolute;
  border: 1px solid var(--accent-2);
  background: rgba(57, 208, 216, 0.12);
  pointer-events: none;
  z-index: 5;
}
.quickview {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  z-index: 6;
}
.quickview .btn { padding: 3px 6px; font-size: 10.5px; min-width: 30px; }
.viewer-hint { margin: 0; padding: 7px 12px 9px; border-top: 1px solid var(--border-soft); }

/* search hits in the table */
#dec-table tbody tr.search-hit .dec-name { color: #ffd257; }

/* rename-selected popover */
.detail-actions { position: relative; }
.rename-pop {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  background: #141823;
  border: 1px solid var(--accent);
  border-radius: 9px;
  padding: 7px;
  box-shadow: var(--shadow);
}
.rename-pop input {
  width: 220px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  font: inherit;
  padding: 6px 9px;
  outline: none;
}

/* squeeze the three columns before giving up on the viewer */
@media (max-width: 1250px) {
  #model-panel { width: 230px; min-width: 200px; }
  #detail-panel { min-width: 300px; }
  #viewer-panel { min-width: 260px; }
}
@media (max-width: 900px) {
  #viewer-panel, .vsplit[data-panel="viewer"] { display: none; }
  #detail-panel { border-right: none; }
  #model-panel { width: 300px; min-width: 240px; }
}

#detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 13px 18px 11px;
  border-bottom: 1px solid var(--border-soft);
}
.detail-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.detail-title h3 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.detail-actions { display: flex; gap: 7px; }

#split-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 18px;
  background: rgba(23, 27, 37, 0.6);
  border-bottom: 1px solid var(--border-soft);
}
.split-info { font-size: 12.5px; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.split-info.armed { color: var(--text); }
.split-info b { color: var(--accent-2); font-weight: 700; }

/* entity-group view: the detail panel swaps the split bar for the ungroup
   bar and shows the member list instead of a Decoration table */
#group-bar {
  display: none;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 10px 18px;
  background: rgba(23, 27, 37, 0.6);
  border-bottom: 1px solid var(--border-soft);
}
#group-bar .split-info { flex: 1 1 200px; }
#detail-panel.group-view #split-bar,
#detail-panel.group-view .dec-hint,
#detail-panel.group-view .table-hint.gil-only,
#detail-panel.group-view .btn.move,
#detail-panel.group-view .drag-handle { display: none; }
#detail-panel.group-view #group-bar { display: flex; }
.group-hint { display: none; }
#detail-panel.group-view .group-hint { display: block; }
.member-count {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  padding: 0 7px;
  border-radius: 999px;
  vertical-align: 1px;
}
.dec-name .tag-group, .dec-name .tag-graph { margin-left: 6px; vertical-align: 1px; }

/* ---------- decoration table ---------- */
#dec-table-wrap { flex: 1; min-height: 0; overflow-y: auto; padding: 0 18px 16px; }

#dec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#dec-table th, #dec-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border-soft); }
#dec-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  background: #12151d;
  font-weight: 700;
}
#dec-table th.num, #dec-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
#dec-table .col-drag { width: 26px; padding-right: 2px; }
#dec-table .col-check { width: 30px; }
/* the # column shrinks to its content; freed space flows to the Name column */
#dec-table th.col-idx { width: 1%; }
.drag-handle { cursor: grab; color: var(--muted); font-size: 12px; opacity: 0.7; }
#dec-table tbody tr:hover .drag-handle { opacity: 1; }
#dec-table tbody tr.dragging { opacity: 0.4; }
#dec-table tbody tr.drop-before td { border-top: 2px solid var(--accent-2); }
#dec-table tbody tr.drop-after td { border-bottom: 2px solid var(--accent-2); }
.detail-actions .move { padding: 5px 8px; font-size: 10px; }
#dec-table input[type="checkbox"] { accent-color: var(--accent); margin: 0; cursor: pointer; display: block; }
#dec-table tbody tr { cursor: pointer; user-select: none; }
#dec-table tbody tr:hover { background: rgba(255, 255, 255, 0.035); }
#dec-table tbody tr.selected { background: rgba(91, 140, 255, 0.14); }
#dec-table tbody tr.selected td { border-bottom-color: rgba(91, 140, 255, 0.25); }
#dec-table .dec-name { word-break: break-word; }
#dec-table .dec-id { color: var(--muted); }
#dec-table tbody tr.selected .dec-id { color: var(--text); }

.table-hint { margin: 12px 2px 0; }

/* ---------- inline rename ---------- */
/* Compact metrics: the host's box is frozen by startInlineRename, and the
   input's border+padding are absorbed by negative margins, so entering
   edit mode changes neither column widths nor row height. */
.rename-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--text);
  font: inherit;
  padding: 0 4px;
  margin: -1px -5px;
  outline: none;
}

/* ---------- export bar ---------- */
#export-bar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 18px;
  background: rgba(18, 21, 29, 0.92);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(10px);
  z-index: 6;
  flex-wrap: wrap;
}

.export-summary { display: flex; gap: 10px; }
.chip {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 6px 13px;
  min-width: 84px;
}
.chip b { font-size: 14.5px; font-weight: 700; }
.chip span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; }
.chip b .arrow { color: var(--accent-2); font-weight: 400; padding: 0 3px; }
.chip b.partial { color: var(--accent-2); }

.tag-graph {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 999px;
}
.tag-group {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--accent-2);
  border: 1px solid rgba(57, 208, 216, 0.5);
  padding: 1px 6px;
  border-radius: 999px;
}
.model-row.excluded .tag-group { opacity: 0.42; }

.export-name { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 4px; }
.export-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}
.export-name input {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 7px 11px;
  outline: none;
  transition: border-color 0.15s;
}
.export-name input:focus { border-color: var(--accent); }

.export-actions { display: flex; gap: 8px; align-items: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2a1518;
  color: #ffb4b4;
  border: 1px solid rgba(255, 100, 100, 0.35);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  z-index: 200;
  box-shadow: var(--shadow);
  animation: toast-in 0.2s ease-out;
}
.toast.ok { background: #12241a; color: #9be8b7; border-color: rgba(100, 255, 160, 0.3); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- file-type modes ----------
   The UI adapts to the loaded file type: body carries mode-gia or mode-gil.
   gia-only elements exist for .gia documents (export selection, reordering,
   renaming), gil-only elements for .gil documents (extraction ops, options,
   extra columns). Before a file is loaded, neither class is set and only the
   hero is visible, so the defaults don't matter there. */
body.mode-gil .gia-only { display: none !important; }
body:not(.mode-gil) .gil-only { display: none !important; }

/* ---------- hero format lines ---------- */
.hero-formats { text-align: left; }
.fmt-line { display: block; margin-bottom: 8px; }
.fmt-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  font-family: ui-monospace, Consolas, monospace;
  color: var(--accent-2);
  border: 1px solid rgba(57, 208, 216, 0.35);
  border-radius: 6px;
  padding: 1px 7px;
  margin-right: 6px;
  vertical-align: 1px;
}

/* ---------- object panel extras (.gil) ---------- */
#obj-sort {
  margin-left: auto;
  flex: 0 1 auto;
  min-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#obj-search {
  flex: 1;
  min-width: 90px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 5px 9px;
  outline: none;
}
#obj-search:focus { border-color: var(--accent); }
.opt-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.opt-label input { accent-color: var(--accent); margin: 0; cursor: pointer; }
.opt-label:hover { color: var(--text); }

/* parent rows reuse .model-row; extraction-selected rows get .checked.
   Fixed row height in .gil mode keeps the virtualized list's math exact. */
body.mode-gil .model-row { height: 36px; padding-top: 0; padding-bottom: 0; }
.model-row.checked { background: rgba(57, 208, 216, 0.09); }
.model-row.checked.active { background: rgba(91, 140, 255, 0.13); }
.model-row.no-deco { opacity: 0.5; }
.model-row.no-deco .model-export { visibility: hidden; }

/* object tree (.gil): prefab group members are nested under their group,
   so each object is listed once; the group row carries a fold toggle */
.tree-fold {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-right: -2px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 15px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.tree-fold:hover { background: var(--border); color: var(--accent-2); }
.tree-fold.folded { transform: rotate(-90deg); }
body.mode-gil .model-row.nested {
  margin-left: 22px;
  padding-left: 12px;
  border-left: 1px solid var(--border-soft);
  border-radius: 0 9px 9px 0;
}
body.mode-gil .model-row.nested .model-name { font-weight: 500; }
.model-id {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* row holds selected decorations/entries (selection persists while browsing) */
.sel-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 6px rgba(57, 208, 216, 0.7);
  flex-shrink: 0;
}

/* empty-state message inside lists */
.list-msg { padding: 18px 12px; text-align: center; color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.list-msg .sub { font-size: 11.5px; opacity: 0.8; }

/* ---------- extraction ops bar (.gil) ---------- */
#gil-ops, #gil-export {
  margin: 0;
  padding: 8px 18px 10px;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(23, 27, 37, 0.6);
}
#gil-ops legend, #gil-export legend {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  padding: 0;
}
/* row 1: summary + undo/redo (editing) · row 2: the extraction actions ·
   row 3: options. Extraction buttons get a dedicated row for clarity */
.gil-ops-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.gil-ops-row .split-info { margin-right: auto; white-space: pre-line; }
/* export row: the button never wraps; the summary shrinks and truncates
   instead (its tooltip carries the full text) */
#gil-export .gil-ops-row { flex-wrap: nowrap; }
#gil-export .split-info { flex: 1 1 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#gil-export .btn { flex: none; }
.gil-actions-row { display: flex; gap: 8px; padding-top: 8px; }
.gil-actions-row .btn { flex: 1 1 0; min-width: 0; white-space: normal; line-height: 1.3; }
.gil-opts-row { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-top: 8px; }

/* sortable decoration-table headers (.gil) */
body.mode-gil #dec-table th[data-sort] { cursor: pointer; }
body.mode-gil #dec-table th[data-sort]:hover { color: var(--text); }
#dec-table th.sort-asc::after { content: ' ▲'; font-size: 9px; }
#dec-table th.sort-desc::after { content: ' ▼'; font-size: 9px; }

/* collision cell */
#dec-table td.coll-on { color: #9be8b7; }
#dec-table td.coll-off { color: #f0a35c; }

/* ---------- modal dialogs ---------- */
.modal {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  max-width: 560px;
  width: calc(100vw - 48px);
}
.modal::backdrop { background: rgba(11, 13, 18, 0.7); backdrop-filter: blur(3px); }
.modal h3 { margin: 0 0 12px; font-size: 16px; }
.modal-body { font-size: 13px; line-height: 1.55; color: var(--text); max-height: 55vh; overflow-y: auto; }
.modal-body p { margin: 0 0 10px; }
.modal-body ul { margin: 0 0 10px; padding-left: 20px; }
.modal-body li { margin-bottom: 4px; }
.modal-body .w { color: #f0a35c; }
.modal-body .e { color: #ff9b9b; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- progress overlay ---------- */
#progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  background: rgba(11, 13, 18, 0.7);
  backdrop-filter: blur(3px);
}
.progress-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 26px;
  min-width: 300px;
}
.progress-label { font-size: 13px; font-weight: 600; margin-bottom: 12px; text-align: center; }
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}
#progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent-grad);
  border-radius: 999px;
  transition: width 0.15s linear;
}

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .brand-tag, .file-meta { display: none; }
  #model-panel { width: 210px; min-width: 180px; }
  .drop-card { padding: 34px 26px; }
}
