:root {
  --bg: #0d0a07;
  --panel: #171310;
  --panel-alt: #1f1912;
  --border: #3d3122;
  --gold: #c9a568;
  --gold-bright: #eecd92;
  --red-bright: #d9524f;
  --green: #71bc7b;
  --blue: #70b7d8;
  --text: #e2d6bd;
  --text-dim: #93876c;
  --serif: Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 300px;
  min-height: 100vh;
}

.nav-left {
  background: linear-gradient(180deg, #191309, #120d08);
  border-right: 1px solid var(--border);
  padding: 18px 0;
}

.brand {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--gold-bright);
  padding: 0 18px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.brand small {
  display: block;
  color: var(--text-dim);
  font: 11px var(--sans);
  margin-top: 4px;
}

.navlist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 20px;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  font-size: 13px;
  letter-spacing: 0.3px;
  cursor: pointer;
}

.nav-btn:hover:not(:disabled) {
  color: var(--gold-bright);
  background: #221a10;
}

.nav-btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

.nav-btn:disabled {
  color: #4a4130;
  cursor: not-allowed;
}

.nav-btn[aria-current='page'] {
  color: var(--gold-bright);
  border-left-color: var(--red-bright);
  background: #241b10;
  font-weight: 600;
}

.nav-note {
  margin: 24px 18px 0;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.5;
}

.center {
  min-width: 0;
  padding: 22px 24px;
  overflow: auto;
}

.view[hidden] {
  display: none;
}

.page-head,
.tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head h1,
.tree-head h1 {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--gold-bright);
  margin: 0;
}

.page-head span {
  color: var(--text-dim);
  font-size: 13px;
}

.tree-points-box {
  display: flex;
  align-items: baseline;
  gap: 9px;
  border: 1px solid var(--gold);
  border-radius: 5px;
  padding: 7px 12px;
  background: #22180c;
  color: var(--text-dim);
  font-size: 12px;
}

.tree-points-box strong {
  color: var(--gold-bright);
  font-size: 22px;
}

.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 5px 5px 0 0;
}

.tree-toolbar label {
  color: var(--text-dim);
  font-size: 12px;
}

.tree-toolbar select,
.tree-toolbar input,
.tree-toolbar button,
#import-submit {
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  min-height: 34px;
  padding: 6px 10px;
}

.tree-toolbar select {
  color: var(--gold-bright);
}

.tree-toolbar button,
#import-submit {
  color: var(--gold-bright);
  border-color: var(--gold);
  cursor: pointer;
}

.tree-toolbar button:disabled,
#import-submit:disabled {
  color: var(--text-dim);
  border-color: var(--border);
  cursor: not-allowed;
}

#tree-search-form {
  display: flex;
  flex: 1;
  min-width: 180px;
}

#tree-search {
  flex: 1;
  min-width: 90px;
  border-radius: 4px 0 0 4px;
}

#tree-search-form button {
  border-radius: 0 4px 4px 0;
  margin-left: -1px;
}

.tree-version {
  margin-left: auto;
  color: var(--text-dim);
  font-size: 11px;
}

.tree-canvas {
  position: relative;
  height: calc(100vh - 150px);
  min-height: 520px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0 0 5px 5px;
  background:
    radial-gradient(circle at center, rgb(40 29 16 / 50%), transparent 60%),
    #090805;
}

#passive-tree-svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#passive-tree-svg.dragging {
  cursor: grabbing;
}

.tree-edge {
  stroke: #3a3023;
  stroke-width: 13;
  stroke-linecap: round;
}

.tree-edge.allocated {
  stroke: #b28a45;
  stroke-width: 20;
}

.tree-node {
  fill: #211b13;
  stroke: #635039;
  stroke-width: 12;
  cursor: pointer;
  vector-effect: non-scaling-stroke;
}

.tree-node:hover,
.tree-node.selected,
.tree-node:focus-visible {
  stroke: var(--blue);
  stroke-width: 4;
  outline: none;
}

.tree-node.available {
  fill: #26311f;
  stroke: var(--green);
}

.tree-node.allocated {
  fill: #a7782f;
  stroke: var(--gold-bright);
}

.tree-node-keystone {
  fill: #291b2d;
  stroke: #a878b0;
}

.tree-node-notable {
  fill: #2d2514;
  stroke: var(--gold);
}

.tree-node-jewel {
  fill: #17242b;
  stroke: #5d98ae;
}

.tree-node-mastery {
  fill: #202a31;
  stroke: #587f93;
  cursor: help;
}

.tree-node-start {
  fill: #5c3320;
  stroke: var(--red-bright);
}

.tree-node.search-match {
  stroke: #fff08b;
  stroke-width: 6;
}

.tree-loading,
.tree-help {
  position: absolute;
  z-index: 2;
  pointer-events: none;
  color: var(--text-dim);
  background: rgb(13 10 7 / 82%);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 7px 10px;
  font-size: 11px;
}

.tree-loading {
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
}

.tree-help {
  left: 10px;
  bottom: 10px;
}

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

.card h2 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--gold);
  font-family: var(--serif);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#import-code {
  display: block;
  width: 100%;
  background: var(--panel-alt);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  font-family: monospace;
  margin: 10px 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px dotted var(--border);
}

.stat-row .k {
  color: var(--text-dim);
}

.stat-row .v {
  color: var(--gold-bright);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.item-card,
.gem-group-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.item-card {
  display: block;
  width: 100%;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.item-card:hover,
.item-card:focus-visible {
  border-color: var(--gold);
}

.item-card .slot {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
}

.item-card .name,
.gem-group-card .head {
  color: #d8c257;
  font-size: 15px;
  font-family: var(--serif);
  margin: 3px 0 6px;
}

.gem-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gem-pill {
  padding: 5px 11px;
  border-radius: 20px;
  background: #241d13;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}

.nav-right {
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
}

.nav-right h2,
.inspector-subhead {
  font-family: var(--serif);
  color: var(--gold);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 18px 0 8px;
}

.nav-right h3 {
  color: var(--gold-bright);
  font-family: var(--serif);
  margin: 12px 0 8px;
}

.node-type-label {
  display: inline-block;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 11px;
}

.node-stat-list {
  padding-left: 18px;
  color: var(--text);
  line-height: 1.55;
}

.badge {
  display: inline-block;
  background: #241a10;
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px;
}

.muted {
  color: var(--text-dim);
  font-size: 12px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#status-region {
  line-height: 1.5;
}

#status-region:empty {
  display: none;
}

#status-region.error {
  color: var(--red-bright);
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-left {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 10px 0 0;
  }

  .brand {
    padding-bottom: 9px;
    margin-bottom: 0;
  }

  .navlist {
    display: flex;
    overflow-x: auto;
  }

  .navlist li {
    flex: 0 0 auto;
  }

  .nav-btn {
    width: auto;
    border-left: 0;
    border-bottom: 3px solid transparent;
    padding: 10px 14px;
    white-space: nowrap;
  }

  .nav-btn[aria-current='page'] {
    border-bottom-color: var(--red-bright);
  }

  .nav-note {
    display: none;
  }

  .center {
    padding: 14px;
  }

  .tree-toolbar {
    flex-wrap: wrap;
  }

  #tree-search-form {
    order: 3;
    flex-basis: 100%;
  }

  .tree-version {
    margin-left: 0;
  }

  .tree-canvas {
    height: 62vh;
    min-height: 430px;
  }

  .nav-right {
    position: static;
    height: auto;
    min-height: 180px;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}
