:root {
  --bg: #121214;
  --panel: #1b1b1f;
  --panel-2: #232328;
  --line: #2e2e35;
  --text: #e9e6df;
  --muted: #9a978f;
  --accent: #e8c47a;

  --weapon: #d38a3a;
  --vitality: #6fae3e;
  --spirit: #9b6ad6;

  --g-best: #33c27a;
  --g-good: #9ccc4a;
  --g-mid: #8d8d93;
  --g-bad: #e3a43a;
  --g-avoid: #e5534b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 10px 16px;
  background: rgba(18, 18, 20, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.topbar h1 { font-size: 18px; margin: 0; letter-spacing: 0.02em; }
.topbar h1 .sub { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 6px; }

.back {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
.back:hover { border-color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-left: auto; }
.filters label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 2px; }

select, .search {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
}

main { max-width: 1500px; margin: 0 auto; padding: 16px; }

.status { color: var(--muted); min-height: 1.4em; margin-bottom: 8px; }
.status.error { color: var(--g-avoid); }

.search { width: 100%; max-width: 640px; margin-bottom: 14px; }

h2 { font-size: 16px; margin: 26px 0 10px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }

/* Hero picker */

.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}

.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.hero-card:hover { border-color: var(--accent); background: var(--panel-2); }
.hero-card img { width: 64px; height: 64px; object-fit: contain; }
.hero-card .name { font-weight: 600; text-align: center; }
.hero-card .wr { font-size: 12px; color: var(--muted); }

/* Hero header */

.hero-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 28px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.hero-head img { width: 84px; height: 84px; object-fit: contain; }
.hero-head h2 { margin: 0; font-size: 24px; color: var(--text); text-transform: none; letter-spacing: 0; }
.hero-head .meta { color: var(--muted); }

.lean { display: grid; grid-template-columns: auto 160px auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.lean .bar { position: relative; height: 8px; background: var(--panel-2); border-radius: 4px; }
.lean .bar i { position: absolute; top: 0; bottom: 0; border-radius: 4px; }
.lean .bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }

.legend { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 0; }
.legend-note { color: var(--muted); font-size: 12px; }

/* Grades */

.grade {
  display: inline-block;
  min-width: 46px;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  color: #111;
}
.g-best { background: var(--g-best); }
.g-good { background: var(--g-good); }
.g-mid { background: var(--g-mid); }
.g-bad { background: var(--g-bad); }
.g-avoid { background: var(--g-avoid); }

.core-tag {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Item tiers */

.tiers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 12px;
  align-items: start;
}

.tier {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
}
.tier h3 { margin: 2px 4px 8px; font-size: 14px; display: flex; justify-content: space-between; }
.tier h3 small { color: var(--muted); font-weight: 400; }

.item { border-radius: 6px; }
.item + .item { margin-top: 2px; }
.item.open { background: var(--panel-2); }

.item-row {
  display: grid;
  grid-template-columns: 30px 1fr auto auto auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 4px 6px;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.item-row:hover { background: var(--panel-2); }
.item-row img { width: 30px; height: 30px; object-fit: contain; }
.item-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .sc { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); min-width: 38px; text-align: right; }
.item-row .flag { font-size: 10px; color: var(--muted); margin-left: 6px; }

.slot-weapon .item-row { border-left-color: var(--weapon); }
.slot-vitality .item-row { border-left-color: var(--vitality); }
.slot-spirit .item-row { border-left-color: var(--spirit); }

.why { padding: 4px 10px 10px 44px; font-size: 13px; }
.why ul { margin: 4px 0 8px; padding-left: 16px; }
.why li { margin: 3px 0; }
.why .desc { color: var(--muted); border-top: 1px solid var(--line); padding-top: 6px; }
.why .stats { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.pos { color: var(--g-best); }
.neg { color: var(--g-avoid); }

/* Item view switch */

.item-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 26px 0 0; }
.item-bar h2 { margin: 0; }

.view-tabs, .tier-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.view-tabs button, .tier-tabs button {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 12px;
  font: inherit;
  cursor: pointer;
}
.view-tabs button:hover, .tier-tabs button:hover { color: var(--text); }
.view-tabs button.active, .tier-tabs button.active { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }
.board-controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.grade-filter { align-items: center; }
.grade-filter .lbl { color: var(--muted); font-size: 12px; margin-right: 4px; }
.tile.top-match { outline: 2px dashed var(--accent); outline-offset: 2px; }
.tier-tabs small { opacity: 0.7; font-weight: 400; margin-left: 4px; }

.hint { color: var(--muted); font-size: 12px; margin: 10px 0; }
kbd {
  display: inline-block;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--panel);
  font: 11px/1.5 ui-monospace, monospace;
  color: var(--text);
}

/* Draft board */

.board-tier + .board-tier { margin-top: 18px; }
.board-tier h3 { font-size: 14px; margin: 0 0 8px; }
.board-tier h3 small { color: var(--muted); font-weight: 400; margin-left: 6px; }

.slot-row { display: grid; grid-template-columns: 22px 1fr; gap: 8px; margin-bottom: 8px; }
.slot-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 4px;
  color: #111;
  font-weight: 700;
}
.slot-label.weapon { background: var(--weapon); }
.slot-label.vitality { background: var(--vitality); }
.slot-label.spirit { background: var(--spirit); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }

.tile {
  --g: var(--g-mid);
  position: relative;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--g) 14%, var(--panel));
  border: 2px solid color-mix(in srgb, var(--g) 70%, transparent);
  border-radius: 8px;
  overflow: hidden;
}
.tile-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  padding: 6px 4px 4px;
  background: none;
  border: 0;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.tile-main:hover { filter: brightness(1.25); }
.tile-enh {
  width: 100%;
  padding: 1px 4px;
  border: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.4);
  color: #111;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.tile-enh:hover { filter: brightness(1.2); }
.tile-enh.offered { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile img { width: 46px; height: 46px; object-fit: contain; }
.tile .t-name { font-size: 11px; line-height: 1.2; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 2.4em; }
.tile .t-grade {
  position: absolute;
  top: -1px;
  right: -1px;
  padding: 0 4px;
  border-radius: 0 6px 0 6px;
  background: var(--g);
  color: #111;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.tile .core-tag { position: absolute; top: 2px; left: 2px; padding: 0 3px; font-size: 9px; background: var(--bg); }
.tile.t-best { --g: var(--g-best); box-shadow: 0 0 10px color-mix(in srgb, var(--g-best) 45%, transparent); }
.tile.t-good { --g: var(--g-good); }
/* Only the normal half is dimmed, so a strong enhanced strip still stands out. */
.tile.t-bad { --g: var(--g-bad); }
.tile.t-avoid { --g: var(--g-avoid); border-color: color-mix(in srgb, var(--g) 35%, transparent); }
.tile.t-bad .tile-main { opacity: 0.7; }
.tile.t-avoid .tile-main { opacity: 0.45; }
.tile .tile-main:hover { opacity: 1; }
.tile.offered { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile.offered .tile-main { opacity: 1; }

.enh-tag {
  display: inline-block;
  padding: 0 5px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f3d27a, #e9a8f0);
  color: #111;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: 1px;
}
.enh-why { margin: 2px 0 8px; padding: 6px 8px; border: 1px dashed #e9a8f0; border-radius: 6px; }
.moe { color: var(--muted); font-size: 11px; }
.enh-adds { color: var(--muted); margin-top: 4px; font-size: 12px; }
.grade.mini { min-width: 0; font-size: 9px; padding: 0 4px; }

/* Offer tray */

.tray:empty { display: none; }
.tray {
  position: sticky;
  top: 64px;
  z-index: 5;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.verdict { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 16px; margin-bottom: 8px; }
.verdict b { color: var(--accent); }
.verdict .clear { margin-left: auto; background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 3px 10px; cursor: pointer; font: inherit; font-size: 12px; }
.offer-list { display: grid; gap: 4px; }
.offer {
  display: grid;
  grid-template-columns: 22px 34px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  background: var(--panel);
  border: 0;
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.offer:hover { outline: 1px solid var(--line); }
.offer .rk { color: var(--muted); font-weight: 700; text-align: center; }
.offer img { width: 34px; height: 34px; object-fit: contain; }
.offer .o-why { display: block; font-size: 11px; color: var(--muted); }
.offer .sc { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }

/* Camera scan */

.search-row { display: flex; gap: 8px; max-width: 760px; margin-bottom: 14px; }
.search-row .search { margin-bottom: 0; flex: 1; min-width: 0; }
.scan-btn {
  flex: none;
  padding: 6px 14px;
  background: var(--accent);
  color: #111;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.scan-btn:hover { filter: brightness(1.1); }

.scan {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.85);
}
.scan[hidden] { display: none; }
.scan-box {
  width: 100%;
  max-width: 900px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.scan-box video { display: block; width: 100%; max-height: 65vh; object-fit: contain; background: #000; border-radius: 8px; }
.scan-box video[hidden] { display: none; }
.scan-status { margin: 10px 2px; color: var(--muted); }
.scan-status.error { color: var(--g-avoid); }
.scan-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scan-actions button, .scan-file {
  padding: 10px 16px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}
.scan-actions .primary { flex: 1; background: var(--accent); border-color: var(--accent); color: #111; font-weight: 700; font-size: 16px; }
.scan-actions button:disabled { opacity: 0.6; cursor: wait; }

/* Scan log */

.scanlog-btn {
  flex: none;
  padding: 6px 12px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.scanlog-btn:hover { border-color: var(--accent); }
.scanlog-box { max-height: calc(100vh - 32px); overflow-y: auto; }
.scanlog-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.scanlog-head h2 { margin: 0 auto 0 0; }
.scanlog-head label { color: var(--muted); display: flex; align-items: center; gap: 4px; }
.scanlog-head button, .log-actions button, .log-actions .btn {
  padding: 5px 12px;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.log-entry { display: grid; grid-template-columns: 180px 1fr; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.log-thumb { width: 180px; height: 100px; object-fit: cover; border-radius: 6px; background: var(--panel-2); display: block; }
.log-body { min-width: 0; font-size: 13px; }
.log-meta { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.log-body pre { white-space: pre-wrap; word-break: break-word; font-size: 11px; color: var(--muted); margin: 4px 0; }
.log-actions { display: flex; gap: 6px; margin-top: 6px; }
@media (max-width: 640px) {
  .log-entry { grid-template-columns: 1fr; }
  .log-thumb { width: 100%; height: 140px; }
}

/* Abilities */

.ability-controls { display: flex; gap: 18px; margin-bottom: 10px; color: var(--muted); }

.ab-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.ab-summary .arrow { color: var(--muted); }
.ab-chip { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.ab-chip img { width: 28px; height: 28px; object-fit: contain; filter: brightness(1.1); }

.blocks { display: flex; flex-wrap: wrap; gap: 10px; }
.block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  min-width: 170px;
}
.block.filler { border-style: dashed; background: transparent; }
.block .bt { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.step { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.step img { width: 26px; height: 26px; object-fit: contain; }
.step .lvl { font-size: 11px; color: var(--muted); }
.step .swr { margin-left: auto; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); }

.about { margin-top: 28px; color: var(--muted); }
.about summary { cursor: pointer; color: var(--text); }

@media (max-width: 640px) {
  .topbar { position: static; }
  .tray { top: 0; }
  .filters { margin-left: 0; }
  .lean { grid-template-columns: auto 110px auto; }
  .why { padding-left: 12px; }
}
