/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #111318;
  --surface:   #1a1d24;
  --surface2:  #21252e;
  --border:    #2c3140;
  --text:      #d8dde8;
  --text-dim:  #b8c8d8;
  --accent:    #4a7fa8;
  --accent-hi: #7aafc8;

  /* Element colours — muted */
  --fire:  #c47878;
  --water: #6899b8;
  --earth: #a08050;
  --wind:  #5aaa78;
  --light: #b8a840;
  --dark:  #9068b8;

  /* Glow — softer */
  --glow: 0 0 6px #8855cc55, 0 0 12px #66339922;

  --surface-accent: color-mix(in srgb, var(--accent-hi) 10%, var(--surface2));
  --unit: 8px;
  --radius: 6px;
  --font: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

html {
  scrollbar-gutter: stable;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100vh;
}

a { color: var(--accent-hi); }
a:hover { color: #fff; }

/* ── Header ───────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
}
header h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
}

/* ── Main Layout ──────────────────────────────────────────── */
main { padding: 24px 24px; max-width: 1600px; margin: 0 auto; }

.hidden { display: none !important; }

/* ── Upload Section ───────────────────────────────────────── */
#upload-section { margin-bottom: 24px; }

/* ── Hero layout (pre-load) ───────────────────────────────── */
#upload-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 64px 24px 40px;
  text-align: center;
}

#upload-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 38px;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 0.02em;
}

.upload-btn-hero {
  padding: 16px 0;
  font-size: 18px;
  width: 200px;
  text-align: center;
}

.upload-hint-box {
  max-width: 630px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  line-height: 1.6;
}
.upload-hint-box a { color: var(--accent-hi); text-decoration: none; }
.upload-hint-box a:hover { color: var(--text); }

/* After load: hero hides entirely — upload controls live in the tab bar */
.app-loaded #upload-section { display: none; }

#json-upload { display: none; }

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
  font-family: var(--font);
  line-height: 1;
}
.upload-btn:hover { background: var(--accent-hi); }

.info-box {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 16px;
  background: rgba(200, 160, 0, 0.12);
  border: 1px solid rgba(200, 160, 0, 0.35);
  border-left: 3px solid #c8a000;
  color: #e8d080;
}
.info-box a { color: #f0c840; }
.info-box a:hover { color: #fff; }

.info-box.info-box-stored {
  background: rgba(0, 160, 80, 0.12);
  border: 1px solid rgba(0, 160, 80, 0.35);
  border-left: 3px solid #00a050;
  color: #60d899;
}

.info-box.info-box-blue {
  background: rgba(59, 130, 246, 0.10);
  border: 1px solid rgba(59, 130, 246, 0.30);
  border-left: 3px solid #3b82f6;
  color: #93c5fd;
}

.info-box.info-box-blue {
  background: rgba(80, 140, 220, 0.10);
  border: 1px solid rgba(80, 140, 220, 0.30);
  border-left: 3px solid #5b8af5;
  color: #93b4f8;
}


/* ── App header ───────────────────────────────────────────── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
}

#app-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 28px;
  font-weight: 400;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

/* ── Tabs ─────────────────────────────────────────────────── */
#tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  align-items: center;
}

#tabs-upload-row {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}

#upload-status {
  font-size: 13px;
  color: #4a5568;
  white-space: nowrap;
}

.upload-btn-compact {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: #fff;
  border-bottom-color: var(--accent-hi);
}

#count-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 400;
}

.tab-content { display: none; }
.tab-content.active { display: flex; flex-direction: column; }

/* ── Inventory Layout ─────────────────────────────────────── */
#tab-inventory { flex-direction: row; gap: 24px; align-items: flex-start; }

/* ── Filters column ───────────────────────────────────────── */
#filters-col {
  flex: 0 0 220px;
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 40px);
}

/* ── Filters ──────────────────────────────────────────────── */
#filters {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  width: 272px;
  min-width: 272px;
  max-width: 272px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  min-height: 0;
}

.filter-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.filter-hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 14px;
}

/* ── Skill Search Widget ──────────────────────────────────── */
.skill-search-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skill-search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  padding: 8px 8px;
  outline: none;
  transition: border-color 0.15s;
}
.skill-search-input:focus { border-color: var(--accent-hi); }
.skill-search-input::placeholder { color: var(--text-dim); }

.skill-dropdown {
  display: none;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--accent-hi);
  border-radius: var(--radius);
  padding: 8px;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 6px 24px rgba(0,0,0,0.6);
  align-content: flex-start;
}
.skill-dropdown.open {
  display: flex;
}

.skill-selected-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 0;
}

/* active pills in selected area get an × */
.pill-selected {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
}
.pill-selected:hover { background: var(--accent-hi); border-color: var(--accent-hi); }
.pill-selected-x { font-size: 14px; opacity: 0.7; line-height: 1; }

.pill.pill-with-icon {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 0;
  padding-left: 8px;
}
.pill.pill-with-icon .pill-icon {
  justify-self: start;
}
.pill.pill-with-icon span:last-child {
  text-align: center;
}
.pill-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}
.pill.pill-with-icon:hover {
  background: color-mix(in srgb, var(--accent-hi) 18%, var(--surface2));
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.filter-row .pill,
.filter-row-3 .pill {
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  text-align: center;
}
.pill {
  display: inline-block;
  padding: 8px 0px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  line-height: 1.4;
}
.pill:hover { background: var(--surface-accent); color: var(--text); }
.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.pill.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

/* Element pills — colour-coded border even when inactive */
.pill[data-elem="1"] { color: var(--fire); }
.pill[data-elem="2"] { color: var(--water); }
.pill[data-elem="3"] { color: var(--earth); }
.pill[data-elem="4"] { color: var(--wind); }
.pill[data-elem="5"] { color: var(--light); }
.pill[data-elem="6"] { color: var(--dark); }

.pill[data-elem="1"]:hover { background: color-mix(in srgb, var(--fire) 20%, var(--surface2)); }
.pill[data-elem="2"]:hover { background: color-mix(in srgb, var(--water) 20%, var(--surface2)); }
.pill[data-elem="3"]:hover { background: color-mix(in srgb, var(--earth) 20%, var(--surface2)); }
.pill[data-elem="4"]:hover { background: color-mix(in srgb, var(--wind) 20%, var(--surface2)); }
.pill[data-elem="5"]:hover { background: color-mix(in srgb, var(--light) 20%, var(--surface2)); }
.pill[data-elem="6"]:hover { background: color-mix(in srgb, var(--dark) 20%, var(--surface2)); }

.pill[data-elem="1"].active { background: var(--fire); border-color: var(--fire); color: #fff; }
.pill[data-elem="2"].active { background: var(--water); border-color: var(--water); color: #fff; }
.pill[data-elem="3"].active { background: var(--earth); border-color: var(--earth); color: #fff; }
.pill[data-elem="4"].active { background: var(--wind); border-color: var(--wind); color: #fff; }
.pill[data-elem="5"].active { background: var(--light); border-color: var(--light); color: #111; }
.pill[data-elem="6"].active { background: var(--dark); border-color: var(--dark); color: #fff; }

#clear-filters, #cl-clear-all, #hm-clear-filters {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  font-size: 15px;
  transition: color 0.15s, border-color 0.15s;
}
#clear-filters:hover, #cl-clear-all:hover, #hm-clear-filters:hover { color: var(--text); border-color: var(--text-dim); }

#back-to-top {
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--accent-hi);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  width: 100%;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  animation: btt-fade-in 0.3s ease;
}
#back-to-top:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
@keyframes btt-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Sort Bar ─────────────────────────────────────────────── */
#sort-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

#sort-bar-rows {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 0;
  min-width: 0;
  align-items: center;
}

.sort-bar-spacer { display: none; }

#view-toggle {
  display: flex;
  gap: 4px;
}

.view-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.view-btn:hover { color: var(--text); border-color: var(--text-dim); }
.view-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.sort-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

.sort-then { opacity: 0.6; }

.sort-pill-tooltip {
  position: fixed;
  transform: translate(-50%, calc(-100% + 6px));
  background: #111118;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  z-index: 500;
  box-shadow: 0 3px 12px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.sort-pill-tooltip.visible {
  opacity: 1;
  transform: translate(-50%, -100%);
}

.sort-row-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sort-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sort-row .pill {
  font-size: 14px;
  padding: 4px 8px;
}

/* ── Inventory Area ───────────────────────────────────────── */
#inventory-area { flex: 1; min-width: 0; }

/* ── Artifact Grid ────────────────────────────────────────── */
.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
}

/* ── Artifact List ────────────────────────────────────────── */
.artifact-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.artifact-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px;
  transition: border-color 0.15s, background 0.15s;
}
.artifact-row:hover {
  border-color: color-mix(in srgb, var(--accent-hi) 50%, var(--border));
}

.artifact-row-locked { border-color: #7a6520; }
.artifact-row-locked:hover { border-color: #a88830; }
.artifact-row-scrap  { border-color: #7040a0; }
.artifact-row-scrap:hover  { border-color: #c080ff; }

.row-state {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.row-state-locked { color: #e8d080; }
.row-state-scrap  { color: #c080ff; }

.artifact-row-quirky {
  background: #2d1b30;
  border-color: #b04878;
}
.artifact-row-quirky:hover { border-color: #e060a0; }

.row-thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.artifact-row-quirky .row-thumb { background: #2d1b30; }
.row-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.row-info {
  flex: 0 0 280px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.row-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.row-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}
.row-elem-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}
.row-kind-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
}

.row-skills {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 0.75fr)) repeat(2, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}
.row-skill-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 8px;
  background: var(--surface2);
  border-radius: 4px;
  min-width: 0;
}
.row-skill-name {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-skill-val {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.row-skill-max {
  color: #e3b7ff;
  text-shadow: 0px 0px 1px #7f12b7, 0px 0px 1px #7f12b7, 0px 0px 1px #7f12b7, 0px 0px 2px #7f12b7, 0px 0px 2px #7f12b7, 0px 0px 2px #7f12b7;
}
.artifact-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: visible;
  position: relative;
  cursor: default;
  transition: border-color 0.15s, transform 0.15s;
  aspect-ratio: 1;
}
.artifact-card:hover {
  border-color: var(--accent-hi);
  transform: translateY(-2px);
  z-index: 10001;
}
.artifact-card-quirky {
  border-color: #b04878;
}
.artifact-card-quirky:hover {
  border-color: #e060a0;
}
.artifact-card-quirky .card-img-wrap {
  background: var(--surface2);
}

.card-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-img-wrap img {
  width: 85%;
  height: 85%;
  object-fit: cover;
  display: block;
  margin-top: 24px;
  opacity: 0.7;
  transition: opacity 0.15s ease;
}
.artifact-card:hover .card-img-wrap img {
  opacity: 1;
}
.card-img-wrap .img-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 20px;
}

.card-top-left {
  position: absolute;
  bottom: 4px;
  left: 5px;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}
.card-level {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}
.card-level-max { color: #e8d080; }

.card-quirky-label {
  font-size: 11px;
  font-weight: 700;
  color: #e080b8;
}

.card-icon-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 2;
  pointer-events: none;
  padding: 6px 4px 10px;
  border-radius: var(--radius) var(--radius) 0 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.45) 0%, rgba(0,0,0,0) 100%);
}
.card-icon-row-img {
  width: 35px;
  height: 35px;
  object-fit: contain;
}
.card-weapon-label {
  height: 35px;
  width: 68px;
  object-fit: contain;
  display: block;
}
.artifact-card-locked { border-color: #7a6520; }
.artifact-card-locked:hover { border-color: #a88830; }
.artifact-card-scrap { border-color: #7040a0; }
.artifact-card-scrap:hover { border-color: #c080ff; }

.card-state-locked { color: #e8d080; }
.card-state-scrap   { color: #c080ff; }


.card-skill-val {
  position: absolute;
  bottom: 4px;
  right: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  line-height: 1;
  pointer-events: none;
}
.card-skill-val-max {
  color: #e3b7ff;
  text-shadow: 0px 0px 1px #7f12b7, 0px 0px 1px #7f12b7, 0px 0px 1px #7f12b7, 0px 0px 2px #7f12b7, 0px 0px 2px #7f12b7, 0px 0px 2px #7f12b7;
}

/* ── Tooltip ──────────────────────────────────────────────── */
.tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #111118;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  width: 290px;
  z-index: 10000;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6);
}
/* Flip tooltip below card when near top of viewport */
.artifact-card:hover .tooltip {
  display: block;
}
.artifact-card.tooltip-below .tooltip {
  bottom: auto;
  top: calc(100% + 8px);
}

.tooltip-name-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.tooltip-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tooltip-level {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.tooltip-level-max {
  color: #e8d080;
}
.tooltip-level-quirky {
  color: #e080b8;
}
.tooltip-level.tooltip-state-locked { color: #e8d080; }
.tooltip-level.tooltip-state-scrap  { color: #c080ff; }
.tooltip-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  margin-bottom: 8px;
  padding-bottom: 8px;
}
.tooltip-elem-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tooltip-elem {
  font-weight: 700;
  font-size: 15px;
}
.tooltip-meta-sep {
  color: var(--border);
}
.tooltip-kind {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
}
.tooltip-icon {
  width: 29px;
  height: 29px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: auto;
}
.row-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: auto;
}
.tooltip-skill {
  font-size: 15px;
  color: var(--text);
  padding: 4px 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.tooltip-skill:first-of-type { border-top: none; }
.tooltip-skill-name { color: var(--text-dim); flex: 1; padding-right: 8px; }
.tooltip-skill-val { color: var(--text); white-space: nowrap; }
.tooltip-skill.max-quality .tooltip-skill-name,
.tooltip-skill.max-quality .tooltip-skill-val {
  color: #e3b7ff;
  text-shadow: 0px 0px 1px #7f12b7, 0px 0px 1px #7f12b7, 0px 0px 1px #7f12b7, 0px 0px 2px #7f12b7, 0px 0px 2px #7f12b7, 0px 0px 2px #7f12b7;
}

/* Element text colours for tooltip */
.elem-text-1 { color: var(--fire); }
.elem-text-2 { color: var(--water); }
.elem-text-3 { color: var(--earth); }
.elem-text-4 { color: var(--wind); }
.elem-text-5 { color: var(--light); }
.elem-text-6 { color: var(--dark); }

/* ── Render throbber ──────────────────────────────────────── */
#render-throbber {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 16px;
  padding: 40px 0;
  width: 100%;
}

.throbber-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-hi);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── No results ───────────────────────────────────────────── */
#no-results {
  font-size: 16px;
  padding: 16px 24px;
  text-align: center;
  margin: 24px auto;
  max-width: 480px;
  width: fit-content;
  grid-column: 1 / -1;
  background: rgba(200, 160, 0, 0.10);
  border: 1px solid rgba(200, 160, 0, 0.30);
  border-radius: var(--radius);
  color: #d4aa40;
}

/* ── Checklist ────────────────────────────────────────────── */
#tab-checklist {
  flex-direction: row;
  gap: 24px;
  align-items: flex-start;
}

#checklist-sidebar-wrap {
  flex: 0 0 220px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 120px);
}

#checklist-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

#checklist-content {
  flex: 1;
  min-width: 0;
}

#checklist-table-wrap {
  display: inline-block;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

#checklist-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 15px;
  table-layout: fixed;
}
#checklist-table th, #checklist-table td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 8px;
  text-align: center;
}
#checklist-table th:last-child, #checklist-table td:last-child {
  border-right: none;
}
#checklist-table tbody tr:last-child td {
  border-bottom: none;
}
#checklist-table thead th {
  background: var(--surface2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.04em;
  width: 120px;
  min-width: 120px;
  max-width: 120px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: default;
  position: sticky;
  top: 0;
  z-index: 2;
  border-top: none;
}
/* Round top-left and top-right corners */
#checklist-table thead th:first-child { border-radius: var(--radius) 0 0 0; }
#checklist-table thead th:last-child  { border-radius: 0 var(--radius) 0 0; }
/* Round bottom corners of last row */
#checklist-table tbody tr:last-child td:first-child { border-radius: 0 0 0 var(--radius); }
#checklist-table tbody tr:last-child td:last-child  { border-radius: 0 0 var(--radius) 0; }
#checklist-table thead th:first-child {
  z-index: 3;
  left: 0;
  cursor: default;
}

.cl-th-draggable {
  cursor: grab;
  user-select: none;
}
.cl-th-draggable:active { cursor: grabbing; }
.cl-th-draggable.cl-dragging { opacity: 0.4; }
.cl-th-draggable.cl-drag-over {
  background: color-mix(in srgb, var(--accent) 30%, var(--surface));
  border-color: var(--accent-hi);
}
#checklist-table td:first-child, #checklist-table th:first-child {
  text-align: left;
  width: 160px;
  min-width: 160px;
  max-width: 160px;
  background: var(--surface);
  position: sticky;
  left: 0;
  z-index: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Count cells */
.cl-cell-link {
  cursor: pointer;
  transition: background 0.12s;
}
.cl-cell-link:hover { background: color-mix(in srgb, var(--accent) 15%, var(--surface)) !important; }

.cl-count {
  font-size: 16px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.cl-link-icon {
  width: 9px;
  height: 9px;
  opacity: 0.45;
  flex-shrink: 0;
  transition: opacity 0.12s;
}
.cl-cell-link:hover .cl-link-icon { opacity: 0.9; }
.cl-count-many { color: var(--accent-hi); }  /* 3+: blue */
.cl-count-two  { color: #4cbe88; }           /* 2: green */
.cl-count-one  { color: #c8b824; }           /* 1: yellow */
.cl-cross { color: #e05555; font-size: 17px; font-weight: 700; }

.cl-row-elem { font-size: 14px; font-weight: 700; }
.cl-row-kind { font-size: 14px; }
.cl-row-label { white-space: nowrap; padding-left: 8px !important; }
.cl-row-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 4px;
  position: relative;
  top: -1px;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 700px) {
  #tab-inventory { flex-direction: column; }
  #filters-col { position: static; flex: none; max-height: none; }
}

/* ── Cleanup Tab ──────────────────────────────────────────── */
#tab-cleanup {
  flex-direction: column;
  gap: 16px;
}

#cleanup-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 700px;
}

#cleanup-rules {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#cleanup-actions {
  display: flex;
  gap: 8px;
}

#cleanup-add-limit {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#cleanup-add-limit:hover { background: var(--accent-hi); }

#cleanup-clear-all {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
#cleanup-clear-all:hover { color: #f07070; border-color: #f07070; }

.cleanup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cleanup-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cleanup-card-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.cleanup-remove-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.cleanup-remove-btn:hover { color: #f07070; border-color: #f07070; }

.cleanup-desc {
  font-size: 14px;
  color: var(--text-dim);
  margin: 0;
}

.cleanup-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cleanup-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.cleanup-inline .filter-label { margin: 0; }

.cleanup-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  padding: 8px 8px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}
.cleanup-select:focus { border-color: var(--accent-hi); }

.cleanup-n-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  padding: 8px 8px;
  outline: none;
  width: 70px;
  text-align: center;
}
.cleanup-n-input:focus { border-color: var(--accent-hi); }

.cleanup-skill-tags {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cleanup-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.cleanup-label-row .filter-label { margin-bottom: 0; }

.cleanup-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-dim);
  cursor: pointer;
  user-select: none;
}
.cleanup-toggle-cb {
  accent-color: var(--accent-hi);
  cursor: pointer;
}

.cleanup-skill-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.cleanup-reset-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.cleanup-reset-btn:hover { color: var(--accent-hi); border-color: var(--accent-hi); }

/* ── Filter help icon ─────────────────────────────────────── */
.filter-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.filter-label-row .filter-label {
  margin-bottom: 0;
}

.filter-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  cursor: default;
  flex-shrink: 0;
  line-height: 1;
}

/* ── Superfluous reason strings ───────────────────────────── */
.tooltip-superfluous-reason {
  font-size: 13px;
  color: #e8d080;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

.row-superfluous-reason {
  width: 100%;
  font-size: 13px;
  color: #e8d080;
  padding-top: 4px;
  margin-top: 2px;
  line-height: 1.4;
  flex-basis: 100%;
}

.cleanup-mode-toggle {
  display: flex;
  gap: 4px;
}
.cleanup-mode-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius);
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.cleanup-mode-btn:hover { color: var(--text); border-color: var(--text-dim); }
.cleanup-mode-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.cleanup-collapse-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.cleanup-collapse-btn:hover { color: var(--text); }

.cleanup-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

.cleanup-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.cleanup-card.collapsed-card {
  cursor: pointer;
}



/* ── Checklist selectable row labels ─────────────────────── */
.cl-row-selectable {
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.cl-row-selectable:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface)) !important;
}
.cl-row-selected {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface)) !important;
  border-left: 3px solid var(--accent-hi);
}

/* ── Checklist tip box ───────────────────────────────────── */
.cl-tip-box {
  padding: 8px 8px;
  background: rgba(200, 184, 36, 0.08);
  border: 1px solid rgba(200, 184, 36, 0.25);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 0 8px;
}
.cl-tip-label {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #c8b824;
  background: rgba(200, 184, 36, 0.15);
  border-radius: 3px;
  padding: 1px 8px;
  margin-right: 0;
  margin-top: 2px;
}

/* ── Heatmap Tab ──────────────────────────────────────────── */
#heatmap-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}
.heatmap-empty {
  color: var(--text-dim);
  font-size: 16px;
}
#heatmap-wrap {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.heatmap-table {
  border-collapse: separate;
  border-spacing: 4px;
  table-layout: fixed;
}
.heatmap-corner {
  width: 100px;
}
.heatmap-col-header {
  width: 90px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 8px 4px;
  vertical-align: bottom;
}
.heatmap-col-header img { display: block; margin: 0 auto 4px; }
.heatmap-row-label {
  text-align: right;
  font-size: 14px;
  color: var(--text-dim);
  padding: 0 8px 0 0;
  white-space: nowrap;
  vertical-align: middle;
}
.heatmap-weapon-label {
  height: 28px;
  width: auto;
  object-fit: contain;
  display: block;
  margin-left: auto;
}
.heatmap-cell {
  width: 90px;
  height: 56px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-align: center;
  vertical-align: middle;
  cursor: pointer;
  transition: filter 0.12s, transform 0.1s;
}
.heatmap-cell:hover {
  filter: brightness(1.3);
  transform: scale(1.04);
}
.heatmap-count {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.heatmap-col-spacer, .heatmap-row-spacer {
  width: 16px;
  min-width: 16px;
  background: transparent !important;
  border: none !important;
  padding: 0;
}
.heatmap-spacer-row td {
  height: 16px;
  background: transparent !important;
  border: none !important;
  padding: 0;
}
.heatmap-total-header {
  color: var(--text);
  font-style: italic;
}
.heatmap-total-label {
  font-style: italic;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}
.heatmap-total-cell {
  opacity: 0.85;
}
.heatmap-grand-total {
  background: rgba(100, 100, 120, 0.35) !important;
  border-color: rgba(140, 140, 160, 0.3) !important;
  cursor: default;
}

/* ── Heatmap sidebar ──────────────────────────────────────── */
#tab-heatmap {
  flex-direction: row;
  gap: 24px;
  align-items: flex-start;
}
#heatmap-sidebar {
  flex: 0 0 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 20px;
}

.tooltip-superfluous-reason-red,
.row-superfluous-reason-red {
  color: #e05555;
}

/* When loaded from storage, show the info box inline in the compact row */
.app-loaded #upload-ext-info.info-box-stored {
  display: block;
  font-size: 15px;
  padding: 8px 8px;
}

/* ── Demo mode ────────────────────────────────────────────── */
#demo-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #7a5c00;
  color: #f0c840;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
  letter-spacing: 0.04em;
}
body.demo-mode #demo-bar { display: block; }
body.demo-mode main { padding-top: 40px; }

#upload-hero-btns {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.upload-btn-demo {
  background: transparent;
  border: none;
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  color: #fff;
}
.upload-btn-demo:hover {
  background: rgba(255, 255, 255, 0.08);
}

.row-skill-level {
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.7;
  margin-left: auto;
  white-space: nowrap;
}

.tooltip-skill-level {
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.7;
  margin-left: 4px;
}

.row-skill-val-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

/* ── Mobile warning ───────────────────────────────────────── */
#mobile-warning {
  display: none;
  margin: 24px 16px 0;
  padding: 16px 24px;
  background: rgba(220, 80, 60, 0.12);
  border: 1px solid rgba(220, 80, 60, 0.4);
  border-left: 4px solid #dc503c;
  border-radius: var(--radius);
  color: #f08878;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  line-height: 1.5;
}
@media (max-width: 768px) {
  #mobile-warning { display: block; }
}

/* ── Language toggle ──────────────────────────────────────── */
.lang-segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.lang-seg {
  background: var(--surface2);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  height: 32px;
  display: inline-flex;
  align-items: center;
  font-family: var(--font);
}
.lang-seg:first-child { border-left: none; }
.lang-seg:hover { color: var(--text); background: var(--surface-accent); }
.lang-seg.active {
  background: var(--accent);
  color: #fff;
}
.lang-seg.active:hover { background: var(--accent-hi); }

/* In hero, match height with the hero buttons */
#lang-toggle-hero {
  height: 38px;
  display: flex;
  justify-content: center;
  margin-top: 12px;
}
#lang-toggle-hero .lang-seg {
  height: 100%;
  font-size: 15px;
  padding: 0 20px;
}
