:root {
  color-scheme: dark;
  --bg: #10130f;
  --panel: #1a1f18;
  --panel-2: #24291f;
  --line: #3d4634;
  --text: #f1f2e8;
  --muted: #a8ad9c;
  --accent: #d7e87f;
  --recycle: #58b4dd;
  --recycle-outgoing: #9be7ff;
  --craft: #d89a47;
  --craft-outgoing: #f3c86f;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 24px;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 1px solid var(--line);
  background: #2f3a26;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.1;
}

.brand p {
  color: var(--muted);
  margin-top: 4px;
}

.data-source {
  color: var(--muted);
  font-size: 12px;
}

.data-source a {
  color: var(--muted);
}

.controls,
.details {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
button {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

button {
  cursor: pointer;
  background: var(--accent);
  border-color: var(--accent);
  color: #15180f;
  font-weight: 800;
}

button.secondary {
  background: transparent;
  color: var(--text);
}

.button-row,
.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-option {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  font-size: 14px;
  margin-bottom: 16px;
}

.toggle-option input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

.toolbar {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  padding: 0 18px;
}

#graph {
  min-height: 0;
  height: 100%;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.edge {
  display: inline-block;
  width: 22px;
  height: 3px;
}

.edge.recycle {
  background: var(--recycle);
}

.edge.craft {
  background: var(--craft);
}

.details h2 {
  font-size: 20px;
  margin-bottom: 10px;
}

.detail-image-card {
  --corner-color: #7f8796;
  --corner-glow: rgba(127, 135, 150, 0.18);
  position: relative;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  min-height: 160px;
  background:
    radial-gradient(circle at 0% 100%, var(--corner-color) 0%, var(--corner-color) 11%, transparent 24%),
    radial-gradient(circle at 84% 18%, var(--corner-glow) 0%, transparent 42%),
    #1d2028;
}

.detail-image-card img {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: contain;
  object-position: center 60%;
  background: transparent;
  padding: 18px 28px 8px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
  transform: scale(0.9);
  transform-origin: center;
}

.detail-image-card[data-rarity="common"] {
  --corner-color: transparent;
  --corner-glow: rgba(127, 135, 150, 0);
}

.detail-image-card[data-rarity="uncommon"] {
  --corner-color: rgba(45, 189, 85, 0.5);
  --corner-glow: rgba(45, 189, 85, 0.2);
}

.detail-image-card[data-rarity="rare"] {
  --corner-color: rgba(30, 167, 227, 0.5);
  --corner-glow: rgba(30, 167, 227, 0.2);
}

.detail-image-card[data-rarity="epic"] {
  --corner-color: rgba(192, 54, 157, 0.5);
  --corner-glow: rgba(192, 54, 157, 0.2);
}

.detail-image-card[data-rarity="legendary"] {
  --corner-color: rgba(246, 198, 0, 0.5);
  --corner-glow: rgba(246, 198, 0, 0.22);
}

.details h3 {
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0 8px;
  text-transform: uppercase;
}

dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 12px;
  margin: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  text-align: right;
}

.relation-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.relation-list li {
  border: 1px solid var(--line);
  background: #20261c;
  border-radius: 6px;
  padding: 10px;
}

.craft-summary[hidden] {
  display: none;
}

.warning-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
}

.warning-list li {
  border: 1px solid #8c6f34;
  background: #2b2518;
  border-radius: 6px;
  color: #f1d58b;
  padding: 10px;
}

.relation-pill {
  display: inline-block;
  margin-right: 8px;
  color: #11150d;
  background: var(--muted);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.relation-pill.recycle {
  background: var(--recycle);
}

.relation-pill.recycle.outgoing {
  background: var(--recycle-outgoing);
}

.relation-pill.craft {
  background: var(--craft);
}

.relation-pill.craft.outgoing {
  background: var(--craft-outgoing);
}

@media (max-width: 900px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    max-height: 45vh;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    height: 55vh;
  }

  #graph {
    height: 100%;
  }
}
