/**
 * main.css — Divinity Config Builder styles.
 *
 * Sections:
 *  1. CSS variables / reset
 *  2. Layout (nav + content)
 *  3. Navigation
 *  4. Section header
 *  5. Tables (.tbl)
 *  6. Cards (.item-card)
 *  7. Badges & tags
 *  8. Capacity bar
 *  9. Minecraft color spans (mc*)
 * 10. Formula section
 * 11. Alerts
 * 12. Search input
 * 13. Misc helpers
 * 14. Scrollbar
 * 15. Responsive
 */

/* =========================================================
   1. Variables / reset
   ========================================================= */

:root {
  --bg:        #0e0e12;
  --bg2:       #16161d;
  --bg3:       #1e1e28;
  --border:    #2a2a38;
  --text:      #d4d4e8;
  --muted:     #6a6a8a;
  --accent:    #7c6af5;
  --accent2:   #9d8fff;
  --green:     #4caf50;
  --red:       #f44336;
  --yellow:    #ffc107;
  --blue:      #2196f3;
  --orange:    #ff9800;
  --nav-w:     220px;
  --radius:    8px;
  --font-mono: 'Consolas', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =========================================================
   2. Layout
   ========================================================= */

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#nav {
  width: var(--nav-w);
  min-width: var(--nav-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* =========================================================
   3. Navigation
   ========================================================= */

.nav-logo {
  padding: 18px 16px 12px;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent2);
  border-bottom: 1px solid var(--border);
  letter-spacing: .3px;
}

.nav-logo span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

.nav-group {
  padding: 10px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  color: var(--text);
  font-size: 13px;
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
  position: relative;
}

.nav-item:hover {
  background: var(--bg3);
  color: #fff;
}

.nav-item.active {
  background: var(--bg3);
  border-left-color: var(--accent);
  color: var(--accent2);
  font-weight: 600;
}

.nav-item .nav-icon { font-size: 15px; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.nav-badge:empty { display: none; }

.lang-switch {
  display: flex;
  gap: 4px;
  padding: 8px 16px 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.lang-btn {
  flex: 1;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  background: var(--bg2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}

.lang-btn:hover {
  color: var(--text);
  background: var(--bg3);
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* =========================================================
   4. Section header
   ========================================================= */

.section-header {
  margin-bottom: 20px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.section-desc {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
}

/* =========================================================
   5. Tables
   ========================================================= */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg2);
  border-radius: var(--radius);
  overflow: hidden;
}

.tbl thead tr {
  background: var(--bg3);
  border-bottom: 2px solid var(--border);
}

.tbl th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.tbl td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.tbl tbody tr:last-child td { border-bottom: none; }

.tbl tbody tr.data-row:hover { background: var(--bg3); }

.tbl tbody tr.row-disabled { opacity: .45; }

.tbl td.num {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent2);
}

.tbl tbody tr.cat-header td {
  background: var(--bg2);
  padding: 10px 12px;
  font-size: 14px;
  letter-spacing: 0.02em;
  border-top: 2px solid var(--accent2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl tbody tr.cat-header:hover td { background: var(--bg2); }

/* =========================================================
   6. Cards (.item-card)
   ========================================================= */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}

.item-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s;
}

.item-card:hover { border-color: var(--accent); }

/* Collapsible card body via native <details> */
.card-details { display: block; }
.card-details > summary { list-style: none; cursor: pointer; }
.card-details > summary::-webkit-details-marker { display: none; }
.card-details > summary::marker { display: none; }
.card-details:not([open]) > summary.item-card__header { border-bottom: none; }
/* Small chevron before icon */
.card-details > summary.item-card__header::before {
  content: '▼';
  font-size: 9px;
  color: var(--muted);
  flex-shrink: 0;
  transition: transform .15s;
}
.card-details:not([open]) > summary.item-card__header::before {
  transform: rotate(-90deg);
}

.item-card__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.item-card__icon { font-size: 18px; }

.item-card__name {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card__meta {
  font-size: 11px;
  color: var(--muted);
}

.item-card__body {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.info-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  flex-wrap: wrap;
}

.info-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
  min-width: 110px;
}

/* =========================================================
   7. Badges & tags
   ========================================================= */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}

.badge-green  { background: #1e3d20; color: var(--green); }
.badge-red    { background: #3d1e1e; color: var(--red);   }
.badge-blue   { background: #1a2e42; color: var(--blue);  }
.badge-yellow { background: #3d310e; color: var(--yellow);}

.tag {
  display: inline-block;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--accent2);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
}

/* =========================================================
   8. Capacity bar
   ========================================================= */

.cap-bar {
  display: inline-block;
  width: 60px;
  height: 5px;
  background: var(--bg3);
  border-radius: 3px;
  vertical-align: middle;
  overflow: hidden;
  margin-left: 6px;
}

.cap-fill {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .3s;
}

/* =========================================================
   9. Minecraft color spans
   ========================================================= */

/* Base text color (fallback white) */
.mc-preview { font-family: var(--font-mono); font-size: 12px; }

.mc0 { color: #000000; } /* black */
.mc1 { color: #0000AA; }
.mc2 { color: #00AA00; }
.mc3 { color: #00AAAA; }
.mc4 { color: #AA0000; }
.mc5 { color: #AA00AA; }
.mc6 { color: #FFAA00; }
.mc7 { color: #AAAAAA; }
.mc8 { color: #555555; }
.mc9 { color: #5555FF; }
.mca { color: #55FF55; }
.mcb { color: #55FFFF; }
.mcc { color: #FF5555; }
.mcd { color: #FF55FF; }
.mce { color: #FFFF55; }
.mcf { color: #FFFFFF; }
.mcl { font-weight: bold; }
.mco { font-style: italic; }
.mcm { text-decoration: line-through; }
.mcn { text-decoration: underline; }
.mcr { /* reset — handled by JS, no CSS needed */ }

/* =========================================================
   10. Formula section
   ========================================================= */

.info-banner {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  background: var(--bg2);
}

.info-banner__title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.info-banner__desc { color: var(--muted); font-size: 13px; }

.mode-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.mode-btn {
  display: inline-block;
  padding: 5px 16px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: default;
  transition: none;
}

.formula-display {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent2);
  word-break: break-all;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 700px) { .row-2 { grid-template-columns: 1fr; } }

/* =========================================================
   11. Alerts
   ========================================================= */

.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  line-height: 1.5;
}

.alert-warn {
  background: #2e2000;
  border-color: #7a5100;
  color: #ffd54f;
}

.alert-info {
  background: #00234e;
  border-color: #0a47a0;
  color: #90caf9;
}

.alert-error {
  background: #2e0808;
  border-color: #7a1a1a;
  color: #ef9a9a;
}

/* =========================================================
   11b. Section toolbar (download button + hint)
   ========================================================= */

.section-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-hint {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}

.btn-download:hover  { background: var(--accent2); }
.btn-download:active { transform: translateY(1px); }
.btn-download code   { background: transparent; border: none; color: #fff; padding: 0; font-size: 12px; }

/* =========================================================
   11c. Editable inputs (inline editing)
   ========================================================= */

.edit-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  padding: 2px 6px;
  width: 100%;
  min-width: 60px;
  transition: border-color .12s, background .12s;
  outline: none;
}

.edit-input:hover  { border-color: var(--border); }
.edit-input:focus  { border-color: var(--accent); background: var(--bg3); }

/* Format inputs — monospace to see color codes clearly */
.edit-input--format {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent2);
}

/* Narrow number inputs */
.edit-input--num {
  width: 80px;
  text-align: right;
}

/* Tiny inline number (e.g. priority inside card header) */
.edit-input--inline {
  width: 60px;
  display: inline-block;
}

/* Full-width formula input */
.edit-input--formula {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--accent2);
  border-color: var(--border);
  background: var(--bg3);
  padding: 8px 12px;
  border-radius: var(--radius);
}

/* Card name input (replaces the bold title) */
.item-card__name-input {
  flex: 1;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}
.item-card__name-input:focus { color: var(--accent2); }

/* Checkbox styling */
.edit-check {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent);
  vertical-align: middle;
  margin-right: 4px;
}

/* Live mc preview below format inputs */
.mc-preview--live {
  font-family: var(--font-mono);
  font-size: 11px;
  opacity: .75;
  padding-left: 4px;
}

/* =========================================================
   12. Search input
   ========================================================= */

.search-input {
  width: 100%;
  max-width: 380px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  margin-bottom: 12px;
  transition: border-color .15s;
}

.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--muted); }

/* =========================================================
   13. Misc helpers
   ========================================================= */

.muted { color: var(--muted); }
.small { font-size: 11px; }

code, .code-id {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--accent2);
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
  font-size: 14px;
}

/* Loading section */
#section-load { display: flex; flex-direction: column; gap: 4px; }

.file-drop-zone-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.btn-create-empty {
  align-self: flex-start;
  margin-top: 4px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  transition: color .15s;
}
.btn-create-empty:hover { color: var(--accent2); }

.zone-loaded-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 4px 0;
}
.zone-file-chip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ── Item Generator card layout ───────────────────────────── */
.ig-card { margin-bottom: 20px; }
.ig-card__body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 14px 14px;
}

.ig-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.ig-section + .ig-section { margin-top: 3px; }

.ig-section__title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: var(--bg2);
  transition: background .12s;
}
.ig-section__title::-webkit-details-marker { display: none; }
.ig-section__title::before { content: '▶'; font-size: 9px; color: var(--muted); transition: transform .15s; }
details[open] > .ig-section__title::before { transform: rotate(90deg); }
.ig-section__title:hover { background: var(--bg3); }

.ig-section__body {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.ig-subhead {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 10px 0 5px;
}

/* Compact stat-pool table */
.tbl-compact td, .tbl-compact th { padding: 3px 8px; font-size: 12px; }
.tbl-compact code { font-size: 11px; }

/* ── IG folder groups ────────────────────────────────────── */
.ig-folder-group {
  border: 2px solid transparent;
  border-radius: var(--radius);
  margin-bottom: 8px;
  transition: border-color .15s, background .15s;
}
.ig-folder-group.drag-over {
  border-color: var(--accent);
  background: #1a1a2e;
}

.ig-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent2);
  padding: 8px 6px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.ig-folder-root { color: var(--muted); }
.ig-grp-dl { margin-left: auto; padding: 2px 8px; font-size: 12px; }

/* Inline new-file input in MODULES toolbars */
.ig-new-wrap { display: flex; align-items: center; gap: 4px; }
.ig-new-input { width: 140px !important; height: 28px; padding: 2px 8px; font-size: 12px; }
.ig-tpl-select { width: 130px !important; height: 28px; font-size: 12px; padding: 0 4px; }

/* Set element rows */
.ig-elem-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.ig-elem-row:last-child { border-bottom: none; }
.ig-elem-id { min-width: 80px; font-size: 12px; color: var(--accent2); padding-top: 6px; flex-shrink: 0; }
.ig-add-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.ig-drop-hint {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 18px;
  border: 2px dashed var(--border);
  border-radius: 6px;
  margin: 4px 0 8px;
}

/* ── Drag handle & collapse button ──────────────────────── */
.ig-drag-handle {
  color: var(--muted);
  cursor: grab;
  font-size: 16px;
  padding: 0 2px;
  line-height: 1;
  user-select: none;
}
.ig-drag-handle:active { cursor: grabbing; }

.ig-collapse-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color .12s;
  flex-shrink: 0;
}
.ig-collapse-btn:hover { color: var(--accent2); }

/* Collapsed card — only header, no body */
.ig-card--collapsed .ig-card__body { display: none; }
.ig-card--collapsed {
  opacity: 0.85;
}

.ig-family-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  margin-right: 6px;
}
.ig-family-input {
  width: 110px;
  font-size: 11px;
  padding: 2px 6px;
  opacity: 0.6;
  transition: opacity .15s, width .15s;
}
.ig-family-input:focus {
  opacity: 1;
  width: 150px;
}

/* ── Lore preview ─────────────────────────────────────────── */
.lore-preview {
  margin-top: 6px;
  background: #0a0a10;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}
.lore-line { min-height: 1.5em; }
.lore-blank { height: 8px; }

.file-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  background: var(--bg2);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}

.file-drop-zone:hover, .file-drop-zone.drag-over {
  border-color: var(--accent);
  background: #1a1a2e;
}

.file-drop-zone input[type=file] { display: none; }

.file-drop-zone__label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
}

.file-drop-zone__name {
  font-weight: 600;
  color: #fff;
  font-size: 14px;
}

.file-drop-zone__hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.file-drop-zone__status {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
}

.file-drop-zone__status.loaded { color: var(--green); }
.file-drop-zone__status.error  { color: var(--red);   }

/* =========================================================
   14. Scrollbar
   ========================================================= */

::-webkit-scrollbar               { width: 8px; height: 8px; }
::-webkit-scrollbar-track         { background: var(--bg2); }
::-webkit-scrollbar-thumb         { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover   { background: var(--muted); }

/* =========================================================
   16. List editor (chip lists for string arrays)
   ========================================================= */

.list-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.list-chip {
  display: inline-flex;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.list-chip__input {
  background: transparent;
  border: none;
  color: var(--accent2);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 6px;
  width: auto;
  min-width: 40px;
  max-width: 160px;
  outline: none;
}

.list-chip__del {
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  line-height: 1;
  transition: color .12s, background .12s;
}
.list-chip__del:hover { color: var(--red); background: #3d1e1e; }

.list-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.list-add__input {
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 3px 8px;
  width: 120px;
  outline: none;
  transition: border-color .12s;
}
.list-add__input:focus { border-color: var(--accent); border-style: solid; }

.btn-add-item {
  background: var(--bg3);
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent2);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 8px;
  transition: background .12s;
}
.btn-add-item:hover { background: var(--accent); color: #fff; }

/* collapsible <details> used by collapsibleList / collapsibleKv / collapsibleJson */
.list-details {
  width: 100%;
}

.list-details > summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
  padding: 3px 0;
  list-style: none;  /* hide default triangle */
  display: flex;
  align-items: center;
  gap: 4px;
}
.list-details > summary::before { content: '▶ '; font-size: 9px; }
.list-details[open] > summary::before { content: '▼ '; }
.list-details > summary:hover { color: var(--accent2); }

/* small count badge inside summary */
.det-count {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10px;
  padding: 0 6px;
  color: var(--muted);
  margin-left: 4px;
}

/* Card dim for disabled entries */
.card-disabled { opacity: .55; }

/* =========================================================
   17. KV editor (key → value row pairs)
   ========================================================= */

.kv-editor {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kv-row, .kv-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kv-sep {
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}

.kv-key { width: 130px; flex-shrink: 0; }
.kv-val { flex: 1; }

/* =========================================================
   18. JSON / object textarea editor
   ========================================================= */

.obj-editor {
  width: 100%;
}

.obj-editor summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  user-select: none;
  padding: 3px 0;
}
.obj-editor summary:hover { color: var(--accent2); }

.obj-hint {
  font-size: 10px;
  color: var(--muted);
  margin: 4px 0 2px;
}

.obj-textarea {
  width: 100%;
  min-height: 100px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--accent2);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 8px;
  outline: none;
  resize: vertical;
  transition: border-color .12s;
}
.obj-textarea:focus { border-color: var(--accent); }

/* =========================================================
   19. Entry actions bar (+ Add, Sync buttons)
   ========================================================= */

.entry-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}

.btn-add-entry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: #1e3d20;
  border: 1px solid var(--green);
  border-radius: 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.btn-add-entry:hover { background: #2a5228; }

.btn-sync {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  background: var(--bg3);
  border: 1px solid var(--blue);
  border-radius: 6px;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.btn-sync:hover { background: #1a2e42; }

/* =========================================================
   20. Remove (delete) button
   ========================================================= */

.btn-del {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 3px 7px;
  transition: color .12s, border-color .12s, background .12s;
}
.btn-del:hover { color: var(--red); border-color: var(--red); background: #3d1e1e; }

/* =========================================================
   21. "New" entry highlight (from sync)
   ========================================================= */

.entry-new {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
  background: #001a3d !important;
  animation: fadeInNew .4s ease;
}

@keyframes fadeInNew {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================
   22. Formula section extras
   ========================================================= */

.mode-btn--click {
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.mode-btn--click:hover { background: var(--bg3) !important; }

.custom-preview-row { background: #1a1a2e !important; }
.custom-preview-row td:first-child::before {
  content: '✏️ ';
  font-size: 11px;
}

/* =========================================================
   23. Editable ID input
   ========================================================= */

.edit-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent2);
  background: var(--bg3);
  border: 1px dashed var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  min-width: 80px;
  max-width: 180px;
  cursor: text;
}
.edit-id:focus { border-color: var(--accent); border-style: solid; }

/* =========================================================
   24. Settings section
   ========================================================= */

.settings-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.settings-card h3 {
  margin-bottom: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.settings-row:last-child { margin-bottom: 0; }

.settings-label {
  font-size: 13px;
  color: var(--muted);
  min-width: 160px;
  flex-shrink: 0;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.radio-label input[type=radio] {
  accent-color: var(--accent);
  cursor: pointer;
}

.btn-setting {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg3);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.btn-setting:hover          { border-color: var(--accent); background: var(--bg); }
.btn-setting:disabled       { opacity: .4; cursor: not-allowed; }

.btn-export  { border-color: var(--accent); color: var(--accent2); }
.btn-export:hover  { background: #1a1030; }
.btn-import  { border-color: var(--blue);  color: var(--blue); }
.btn-import:hover  { background: #001a3d; }
.btn-save-now { border-color: var(--green); color: var(--green); }
.btn-save-now:hover { background: #1e3d20; }
.btn-stop     { border-color: var(--red);  color: var(--red); }
.btn-stop:hover { background: #3d1e1e; }

/* Auto-save status line */
.autosave-status {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--bg3);
  border: 1px solid var(--border);
  min-height: 36px;
  display: flex;
  align-items: center;
  width: 100%;
}
.as-off { color: var(--muted); }
.as-on  { color: var(--text);  }

/* Loaded files list in export card */
.loaded-list {
  list-style: none;
  padding: 0;
  margin: 0 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.loaded-list li {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  color: var(--muted);
}

.loaded-list li code {
  color: var(--accent2);
  background: transparent;
  border: none;
  padding: 0;
}

/* =========================================================
   15. Build Preview
   ========================================================= */

.build-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  align-items: start;
}

.build-section-title {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.build-slot-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 6px;
}

.build-slot-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.build-slot-label {
  min-width: 90px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  flex-shrink: 0;
}

.build-slot-select { flex: 1; min-width: 130px; max-width: 220px; }

.build-gem-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding-left: 20px;
}

.build-gem-select {
  flex: 1;
  min-width: 110px;
  max-width: 190px;
  font-size: 11px !important;
  height: 24px !important;
}

.build-name-preview  { font-size: 12px; flex-shrink: 0; }
.build-socket-icon   { font-size: 11px; min-width: 22px; flex-shrink: 0; color: var(--muted); }

.build-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.build-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
}

.build-card__title { font-weight: 600; font-size: 12px; margin-bottom: 6px; }

.build-set-entry {
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.build-set-entry:last-child { border-bottom: none; }

@media (max-width: 1100px) {
  .build-layout { grid-template-columns: 1fr; }
}

/* =========================================================
   16. Responsive
   ========================================================= */

@media (max-width: 600px) {
  :root { --nav-w: 180px; }
  #content { padding: 16px; }
}
