/* Bytedex UI polish. Loaded separately from style.css on purpose. */

.dex {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  padding: 0;
  overflow: hidden;
  font-family: var(--dt-font-mono, ui-monospace, "Cascadia Code", "Courier New", monospace);
}

.dex-header {
  padding: 12px 16px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
}

.dex-title {
  margin: 0;
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 18px;
  font-weight: 500;
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
  letter-spacing: 0.04em;
}

.dex-back-btn {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 12px;
  letter-spacing: 0.06em;
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid var(--dt-border-mid, var(--border-strong, #2a5a3a));
  background: transparent;
  color: var(--dt-text-secondary, var(--text-secondary, #7ab890));
  cursor: pointer;
  touch-action: manipulation;
  min-height: 30px;
  transition: border-color 0.1s, color 0.1s;
}

.dex-back-btn:hover {
  border-color: var(--dt-text-active, var(--accent-teal, #4aabcf));
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
}

.dex-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 16px;
  margin: 0;
  border-bottom: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.dex-tabs::-webkit-scrollbar { display: none; }

.dex-tab {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 12px;
  letter-spacing: 0.05em;
  padding: 4px 12px;
  border-radius: 3px;
  border: 1px solid var(--dt-border-mid, var(--border-strong, #2a5a3a));
  background: transparent;
  color: var(--dt-text-secondary, var(--text-secondary, #7ab890));
  cursor: pointer;
  touch-action: manipulation;
  min-height: 28px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.1s, color 0.1s;
}
.dex-tab:hover {
  border-color: var(--dt-border-hover, #2a6a3a);
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
}
.dex-tab.active,
.dex-tab.on {
  background: transparent;
  border-color: var(--dt-text-active, var(--accent-teal, #4aabcf));
  color: var(--dt-text-active, var(--accent-teal, #4aabcf));
  font-weight: 500;
}
.dex-tab-count {
  color: var(--dt-text-amber, var(--accent-gold, #e8b800));
  margin-left: 4px;
}

.dex-body {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.dex-lines,
.dex-archive,
.dex-logs,
.dex-awards {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  margin-top: 0;
}

.dex-controls {
  padding: 8px 16px;
  margin: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
}

.dex-search {
  flex: 1;
  min-width: 180px;
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--dt-border-mid, var(--border-strong, #2a5a3a));
  background: var(--dt-bg-tile, var(--bg-base, #0a1a14));
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
  outline: none;
  transition: border-color 0.1s;
}
.dex-search::placeholder {
  color: var(--dt-text-muted, var(--text-muted, #3a6a4a));
  font-family: var(--dt-font-mono, ui-monospace, monospace);
}
.dex-search:focus { border-color: var(--dt-text-active, var(--accent-teal, #4aabcf)); }

.dex-select,
.dex-sort,
.dex-filter {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--dt-border-mid, var(--border-strong, #2a5a3a));
  background: var(--dt-bg-tile, var(--bg-base, #0a1a14));
  color: var(--dt-text-secondary, var(--text-secondary, #7ab890));
  cursor: pointer;
  outline: none;
  transition: border-color 0.1s, color 0.1s;
  min-height: 30px;
}
.dex-select:focus,
.dex-select:hover,
.dex-sort:focus,
.dex-sort:hover,
.dex-filter:focus,
.dex-filter:hover {
  border-color: var(--dt-text-active, var(--accent-teal, #4aabcf));
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
}

.dex-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.dex-filter-bar::-webkit-scrollbar { display: none; }

.dex-filter-tag,
.dex-filter-bar .filter-btn {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 11px;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 3px;
  border: 1px solid var(--dt-border-mid, var(--border-strong, #2a5a3a));
  background: transparent;
  color: var(--dt-text-secondary, var(--text-secondary, #7ab890));
  cursor: pointer;
  touch-action: manipulation;
  min-height: 26px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.1s, color 0.1s;
}
.dex-filter-tag:hover,
.dex-filter-bar .filter-btn:hover {
  border-color: var(--dt-text-active, var(--accent-teal, #4aabcf));
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
}
.dex-filter-tag.active-all,
.dex-filter-tag.active[data-elem="All"],
.dex-filter-bar .filter-btn.active[data-elem="All"] {
  background: transparent;
  border-color: var(--dt-text-active, var(--accent-teal, #4aabcf));
  color: var(--dt-text-active, var(--accent-teal, #4aabcf));
}

.dex-filter-tag.active[data-elem="Blaze"]   { background: transparent; color:#e8593c; border-color:#e8593c; }
.dex-filter-tag.active[data-elem="Tide"]    { background: transparent; color:#2a7fd4; border-color:#2a7fd4; }
.dex-filter-tag.active[data-elem="Verdant"] { background: transparent; color:#3e8e2f; border-color:#3e8e2f; }
.dex-filter-tag.active[data-elem="Spark"]   { background: transparent; color:#e8b800; border-color:#e8b800; }
.dex-filter-tag.active[data-elem="Frost"]   { background: transparent; color:#7ec8e3; border-color:#7ec8e3; }
.dex-filter-tag.active[data-elem="Gale"]    { background: transparent; color:#a8d8a8; border-color:#a8d8a8; }
.dex-filter-tag.active[data-elem="Terra"]   { background: transparent; color:#8b6914; border-color:#8b6914; }
.dex-filter-tag.active[data-elem="Lumen"]   { background: transparent; color:#e8e8b8; border-color:#e8e8b8; }
.dex-filter-tag.active[data-elem="Lunar"]   { background: transparent; color:#6644aa; border-color:#6644aa; }
.dex-filter-tag.active[data-elem="Null"]    { background: transparent; color:#909090; border-color:#909090; }

.dex-stats-line {
  padding: 4px 16px 8px;
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--dt-text-secondary, var(--text-secondary, #7ab890));
  letter-spacing: 0.03em;
}
.dex-stat-compiled { color: var(--dt-text-active, var(--accent-teal, #4aabcf)); }
.dex-stat-golden { color: var(--dt-text-amber, var(--accent-gold, #e8b800)); }
.dex-stat-glitch { color: var(--dt-text-purple, #6644aa); }

.dex-list {
  overflow-y: auto;
  scrollbar-width: none;
  flex: 1;
  min-height: 0;
}
.dex-list::-webkit-scrollbar { display: none; }

.dex-line-row,
.dex-line {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 10px 16px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
  border-radius: 0;
  background: transparent;
  overflow-x: auto;
  scrollbar-width: none;
  flex-wrap: nowrap;
}
.dex-line-row::-webkit-scrollbar,
.dex-line::-webkit-scrollbar { display: none; }
.dex-line-row:hover,
.dex-line:hover { background: rgba(255,255,255,0.01); }

.dex-evo-arrow,
.evo-arrow {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 14px;
  color: var(--dt-border-mid, var(--border-strong, #2a5a3a));
  flex-shrink: 0;
  padding: 0 4px;
  align-self: center;
  user-select: none;
}

.dex-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
  background: var(--dt-bg-tile, var(--bg-base, #0a1a14));
  min-width: 100px;
  max-width: 120px;
  width: auto;
  text-align: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.12s, background 0.12s;
  flex-shrink: 0;
  opacity: 1;
}
.dex-cell:hover {
  border-color: var(--dt-border-hover, #2a6a3a);
  background: var(--dt-bg-tile-hover, var(--bg-card, #142b1e));
}

.dex-cell-chrome {
  width: 100%;
  height: 14px;
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 2px;
}
.dex-cell-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dt-border-dim, var(--border, #1a3a28));
}

.dex-cell.compiled,
.dex-cell.got {
  border-color: var(--dt-border-mid, var(--border-strong, #2a5a3a));
  background: var(--dt-bg-tile, var(--bg-base, #0a1a14));
  box-shadow: none;
}
.dex-cell.compiled .dex-cell-dot:nth-child(1),
.dex-cell.got .dex-cell-dot:nth-child(1) { background: #27c93f66; }
.dex-cell.compiled .dex-cell-dot:nth-child(2),
.dex-cell.got .dex-cell-dot:nth-child(2) { background: #ffbd2e66; }
.dex-cell.compiled .dex-cell-dot:nth-child(3),
.dex-cell.got .dex-cell-dot:nth-child(3) { background: #ff5f5766; }

.dex-cell.seen {
  border-color: var(--dt-border-dim, var(--border, #1a3a28));
  opacity: 0.7;
}

.dex-cell.unknown,
.dex-cell.mystery {
  border-color: var(--dt-border-dim, var(--border, #1a3a28));
  opacity: 0.45;
  cursor: default;
}
.dex-cell.unknown:hover,
.dex-cell.mystery:hover {
  border-color: var(--dt-border-dim, var(--border, #1a3a28));
  background: var(--dt-bg-tile, var(--bg-base, #0a1a14));
}
.dex-cell.golden {
  border-color: #e8b80033;
  box-shadow: 0 0 6px #e8b80018;
}
.dex-cell.glitch {
  border-color: #6644aa33;
}

.dex-cell-sprite,
.dex-sprite {
  width: 72px;
  height: 72px;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  cursor: inherit;
  transition: none;
}
.dex-sprite:hover {
  transform: none;
  filter: none;
}
.dex-cell.unknown .dex-cell-sprite,
.dex-cell.mystery .dex-cell-sprite,
.dex-sprite.silhouette {
  filter: brightness(0) saturate(0);
  opacity: 0.3;
}
.dex-cell.seen .dex-cell-sprite,
.dex-cell.seen .sprite {
  filter: saturate(0.6);
  opacity: 0.7;
}

.dex-cell-name,
.dex-name {
  width: 100%;
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 11px;
  font-weight: 500;
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
  text-align: center;
  line-height: 1.2;
  margin-top: 0;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dex-cell.unknown .dex-cell-name,
.dex-cell.mystery .dex-cell-name,
.dex-cell.unknown .dex-name,
.dex-cell.mystery .dex-name {
  color: var(--dt-text-muted, var(--text-muted, #3a6a4a));
  letter-spacing: 0.1em;
}

.dex-cell-stage,
.dex-stage {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 9px;
  color: var(--dt-text-muted, var(--text-muted, #3a6a4a));
  letter-spacing: 0.04em;
}

.dex-cell-elements {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}

.dex-cell-elem,
.dex-lb-elem {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  border-radius: 3px;
  border: 1px solid;
  letter-spacing: 0.03em;
  white-space: nowrap;
  background: transparent;
}
.dex-cell-elem {
  font-size: 9px;
  padding: 1px 5px;
}
.dex-lb-elem {
  font-size: 11px;
  padding: 2px 8px;
}

.dex-cell-elem[data-elem="Blaze"], .dex-lb-elem[data-elem="Blaze"] { color:#e8593c; border-color:#e8593c44; }
.dex-cell-elem[data-elem="Tide"], .dex-lb-elem[data-elem="Tide"] { color:#2a7fd4; border-color:#2a7fd444; }
.dex-cell-elem[data-elem="Verdant"], .dex-lb-elem[data-elem="Verdant"] { color:#3e8e2f; border-color:#3e8e2f44; }
.dex-cell-elem[data-elem="Spark"], .dex-lb-elem[data-elem="Spark"] { color:#e8b800; border-color:#e8b80044; }
.dex-cell-elem[data-elem="Frost"], .dex-lb-elem[data-elem="Frost"] { color:#7ec8e3; border-color:#7ec8e344; }
.dex-cell-elem[data-elem="Gale"], .dex-lb-elem[data-elem="Gale"] { color:#a8d8a8; border-color:#a8d8a844; }
.dex-cell-elem[data-elem="Terra"], .dex-lb-elem[data-elem="Terra"] { color:#8b6914; border-color:#8b691444; }
.dex-cell-elem[data-elem="Lumen"], .dex-lb-elem[data-elem="Lumen"] { color:#e8e8b8; border-color:#e8e8b844; }
.dex-cell-elem[data-elem="Lunar"], .dex-lb-elem[data-elem="Lunar"] { color:#6644aa; border-color:#6644aa44; }
.dex-cell-elem[data-elem="Null"], .dex-lb-elem[data-elem="Null"] { color:#909090; border-color:#90909044; }

.dex-cell-status {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 9px;
  letter-spacing: 0.06em;
}
.status-compiled,
.dex-compiled { color: var(--dt-text-active, var(--accent-teal, #4aabcf)); font-weight: 500; }
.status-seen,
.dex-seen-only { color: var(--dt-text-muted, var(--text-muted, #3a6a4a)); font-weight: 500; }

.dex-cell-variant {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 9px;
  margin-left: 3px;
}
.dex-cell-variant.gold,
.dex-vmark.golden { color: var(--dt-text-amber, var(--accent-gold, #e8b800)); }
.dex-cell-variant.glitch,
.dex-vmark.glitch { color: var(--dt-text-purple, #6644aa); }

.dex-lightbox-overlay,
.ref-modal.dex-lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: none;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.dex-lightbox,
.ref-card.dex-lightbox {
  position: static;
  background: var(--dt-bg-surface, var(--bg-surface, #0f2318));
  border: 1px solid var(--dt-border-mid, var(--border-strong, #2a5a3a));
  border-radius: 6px;
  overflow: hidden;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 0;
  text-align: initial;
  box-shadow: none;
}
.dex-lightbox::-webkit-scrollbar,
.ref-card.dex-lightbox::-webkit-scrollbar { display: none; }

.dex-lightbox-chrome {
  height: 24px;
  background: rgba(0,0,0,0.3);
  border-bottom: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 5px;
  flex-shrink: 0;
}
.dlc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.dlc-dot:nth-child(1) { background: #27c93f; }
.dlc-dot:nth-child(2) { background: #ffbd2e; }
.dlc-dot:nth-child(3) { background: #ff5f57; }

.dlc-close,
.ref-close.dlc-close {
  position: static;
  margin-left: auto;
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--dt-text-muted, var(--text-muted, #3a6a4a));
  cursor: pointer;
  padding: 2px 6px;
  background: transparent;
  border: 0;
}
.dlc-close:hover,
.ref-close.dlc-close:hover { color: var(--dt-text-primary, var(--text-primary, #c8e6c0)); }

.dex-lightbox-portrait,
.ref-img.dex-lightbox-portrait {
  width: 192px;
  height: 192px;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  display: block;
  margin: 16px auto 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.dex-lb-name,
.ref-title.dex-lb-name {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 18px;
  font-weight: 500;
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
  text-align: center;
  margin: 8px 0 4px;
  letter-spacing: 0.02em;
}

.dex-lb-variant-badge {
  display: block;
  text-align: center;
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 11px;
  margin-bottom: 8px;
}
.dex-lb-variant-badge.gold { color: var(--dt-text-amber, var(--accent-gold, #e8b800)); }
.dex-lb-variant-badge.glitch { color: var(--dt-text-purple, #6644aa); }

.dex-lb-elements {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 10px;
}

.dex-lb-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 10px 16px;
  border-top: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
  border-bottom: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
}
.dex-lb-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.dex-lb-stat-label {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 9px;
  color: var(--dt-text-muted, var(--text-muted, #3a6a4a));
  letter-spacing: 0.08em;
}
.dex-lb-stat-value {
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 14px;
  font-weight: 500;
  color: var(--dt-text-primary, var(--text-primary, #c8e6c0));
}

.dex-lb-meta {
  padding: 8px 16px;
  border-bottom: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--dt-text-secondary, var(--text-secondary, #7ab890));
  line-height: 1.7;
}
.dex-lb-meta-row {
  display: flex;
  gap: 8px;
}
.dex-lb-meta-label {
  color: var(--dt-text-muted, var(--text-muted, #3a6a4a));
  min-width: 60px;
}
.dex-lb-meta-value { color: var(--dt-text-secondary, var(--text-secondary, #7ab890)); }

.dex-lb-lore,
.ref-concept.dex-lb-lore {
  padding: 10px 16px;
  margin: 0;
  font-family: var(--dt-font-mono, ui-monospace, monospace);
  font-size: 11px;
  color: var(--dt-text-secondary, var(--text-secondary, #7ab890));
  line-height: 1.7;
  font-style: italic;
  border-bottom: 1px solid var(--dt-border-dim, var(--border, #1a3a28));
}

.dex-archive > .dim,
.dex-logs > .dim,
.dex-awards > .dim,
.dex-archive > p,
.dex-logs > p,
.dex-awards > p {
  padding: 8px 16px;
  margin: 0;
}

.dex-awards,
.dex-logs,
.dex-archive {
  overflow-y: auto;
  scrollbar-width: none;
}
.dex-awards::-webkit-scrollbar,
.dex-logs::-webkit-scrollbar,
.dex-archive::-webkit-scrollbar { display: none; }

@media (max-width: 600px) {
  .dex-cell {
    min-width: 80px;
    max-width: 96px;
    padding: 6px 6px 8px;
  }

  .dex-cell-sprite,
  .dex-sprite {
    width: 56px;
    height: 56px;
  }
  .dex-cell-name,
  .dex-name { font-size: 10px; }

  .dex-line-row,
  .dex-line {
    padding: 8px 10px;
    gap: 0;
  }

  .dex-controls { flex-direction: column; }
  .dex-search {
    min-width: unset;
    width: 100%;
  }

  .dex-lightbox-portrait,
  .ref-img.dex-lightbox-portrait {
    width: 140px;
    height: 140px;
  }
  .dex-lb-stats { grid-template-columns: repeat(2, 1fr); }
}
