:root {
  color-scheme: dark;
  --ink: #151515;
  --ink-2: #1c1c1c;
  --panel: #242424;
  --panel-2: #303030;
  --line: #414141;
  --line-strong: #76613b;
  --gold: #d7ab54;
  --gold-light: #ffd36b;
  --frost: #ffd36b;
  --text: #e5e5e5;
  --muted: #ababab;
  --danger: #d67d72;
  --radius: 3px;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  display: flex;
  flex-direction: column;
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(180deg, #242020, var(--ink) 340px);
  line-height: 1.45;
}

button {
  font: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--frost);
  outline-offset: 3px;
}

.topbar {
  position: relative;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: stretch;
  flex-direction: row;
  gap: 20px;
  min-height: 54px;
  padding: 0 max(20px, calc((100% - 1160px) / 2));
  border-bottom: 1px solid #090909;
  background: linear-gradient(#292929, #191919);
  box-shadow: 0 2px 0 #444, 0 4px 12px #0008;
}

.brand {
  display: flex;
  align-items: center;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
  width: fit-content;
  min-height: 54px;
}

.brand-logo {
  display: block;
  width: 100px;
  height: auto;
  max-height: 48px;
  object-fit: contain;
}

.primary-nav {
  display: flex;
  align-self: stretch;
  gap: 0;
  min-height: 37px;
}

.nav-tab {
  position: relative;
  border: 1px solid #101010;
  border-bottom: 0;
  padding: 8px 22px;
  color: #ccc;
  background: linear-gradient(#393939, #252525);
  box-shadow: inset 0 1px #ffffff12;
  font-size: .875rem;
  font-weight: bold;
  text-shadow: 0 1px #000;
  cursor: pointer;
}

.nav-tab::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  background: transparent;
}

.nav-tab:hover,
.nav-tab.is-active {
  color: var(--gold-light);
  background: linear-gradient(#4a3430, #292323);
}

.nav-tab.is-active::after {
  background: var(--gold);
}

main {
  flex: 1;
  width: min(1200px, 100%);
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.site-footer {
  display: flex;
  justify-content: center;
  text-align: center;
  flex-wrap: wrap;
  gap: 6px 20px;
  width: min(1160px, calc(100% - 24px));
  margin: 0 auto;
  padding: 12px 0 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .75rem;
}

.view {
  display: none;
}

.nav-tab[hidden],
.view[hidden] {
  display: none !important;
}

.view.is-active {
  display: block;
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.workspace-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.talents-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: .8125rem;
  font-weight: normal;
}

h1 {
  margin: 0;
  color: var(--gold-light);
  font-size: clamp(1.375rem, 3vw, 1.75rem);
  font-weight: bold;
  text-shadow: 0 2px 1px #000;
}

.build-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.required-level,
.points-total {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border-radius: 2px;
  padding: 0 10px;
}

.required-level {
  border: 1px solid var(--line);
  background: #1a1a1a;
  color: var(--text);
}

.required-level .label {
  font-size: .875rem;
  font-weight: normal;
  color: var(--muted);
}

.required-level strong {
  color: #ffffff;
  font-size: 1.125rem;
  line-height: 1;
}

.points-total {
  border: 1px solid var(--line-strong);
  background: #292419;
  color: var(--muted);
  font-size: .85rem;
}

.points-total strong {
  color: var(--gold-light);
  font-size: 1.125rem;
  line-height: 1;
}

.button,
.segment {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 0 14px;
  color: var(--text);
  background: linear-gradient(#45403a, #2a2723);
  box-shadow: inset 0 1px #ffffff0d, 0 1px 2px #0008;
  font-size: .875rem;
  cursor: pointer;
}

.button:hover,
.segment:hover {
  border-color: var(--gold);
  background: linear-gradient(#595043, #383127);
}

.button-quiet {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.button-danger {
  border-color: rgba(214, 125, 114, .4);
  color: #f0aaa1;
  background: rgba(214, 125, 114, .08);
}

.button-danger:hover {
  border-color: var(--danger);
  background: rgba(214, 125, 114, .15);
}

.class-picker {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  padding: 10px;
  border: 1px solid #444;
  border-top-color: #565656;
  background: #262626;
  box-shadow: inset 0 0 0 1px #191919;
  overflow-x: auto;
  scrollbar-width: thin;
}

.class-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 4px 10px 4px 5px;
  font-size: .875rem;
  color: var(--muted);
  background: linear-gradient(#343434, #222);
  cursor: pointer;
}

.class-chip:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--class-color), transparent 45%);
}

.class-chip.is-active {
  color: var(--class-color);
  border-color: var(--class-color);
  background: color-mix(in srgb, var(--class-color) 12%, #191919);
  box-shadow: inset 0 -2px var(--class-color);
}

.class-icon {
  width: 27px;
  height: 27px;
  border-radius: 2px;
  object-fit: cover;
}

.talent-trees {
  display: grid;
  grid-template-columns: repeat(3, minmax(268px, 1fr));
  gap: 10px;
}

.tree {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #1b1b1b;
  box-shadow: 0 2px 5px #0008, inset 0 0 0 1px #111;
}

.tree-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(#3c3c3c, #252525);
  box-shadow: inset 0 1px #ffffff0d;
}

.tree-head h2 {
  margin: 0;
  color: var(--gold-light);
  font-size: 1rem;
  font-weight: bold;
  text-shadow: 0 1px #000;
}

.tree-points {
  color: var(--muted);
  font-size: .82rem;
}

.tree-points strong {
  color: var(--gold-light);
  font-size: 1rem;
}

.tree-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 66px);
  grid-template-rows: repeat(7, 66px);
  justify-content: center;
  gap: 8px;
  min-height: 558px;
  padding: 23px;
  background-image:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(rgba(3, 8, 12, .34), rgba(3, 8, 12, .56)),
    var(--tree-background);
  background-position: top, center, center;
  background-size: 100% 74px, 100% 100%, 100% 100%;
}

.talent {
  position: relative;
  z-index: 2;
  align-self: center;
  justify-self: center;
  width: 54px;
  height: 54px;
  border: 2px solid #616161;
  border-radius: 3px;
  padding: 0;
  background: #050a0e;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .45);
}

.talent img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 1px;
  object-fit: cover;
  filter: grayscale(.88) brightness(.45);
}

.talent.is-available {
  border-color: #68a844;
}

.talent.is-available img {
  filter: grayscale(.35) brightness(.74);
}

.talent.has-points {
  border-color: #7bd64d;
  box-shadow: 0 0 0 1px #101010, 0 2px 5px #000;
}

.talent.has-points img {
  filter: none;
}

.talent.is-maxed {
  border-color: var(--gold-light);
}

.rank {
  position: absolute;
  right: -5px;
  bottom: -6px;
  min-width: 25px;
  padding: 2px 4px;
  border: 1px solid #505c65;
  border-radius: 2px;
  color: #b7c2c2;
  background: #080808;
  font-size: .75rem;
  font-weight: 700;
  text-align: center;
}

.has-points .rank {
  color: #7be34e;
  border-color: #568641;
}

.is-maxed .rank {
  color: var(--gold-light);
  border-color: var(--gold);
}

.talent:hover {
  outline: 1px solid #fff5;
  outline-offset: 2px;
}

.talent[data-locked="true"] {
  cursor: not-allowed;
}

.dependency {
  position: absolute;
  z-index: 1;
  width: 2px;
  background: rgba(126, 145, 150, .3);
  transform-origin: top center;
}

.dependency.is-active {
  background: var(--gold);
  box-shadow: 0 0 6px rgba(205, 168, 74, .6);
}

.talent-tooltip {
  position: fixed;
  z-index: 50;
  display: none;
  width: min(330px, calc(100vw - 24px));
  pointer-events: none;
  border: 1px solid #9c9baf;
  border-radius: 4px;
  padding: 12px 13px;
  color: #fff;
  background: linear-gradient(135deg, #101024fa, #080811fa);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .9), 0 12px 34px rgba(0, 0, 0, .7);
  font-family: Arial, sans-serif;
  font-size: .875rem;
  line-height: 1.42;
}

.talent-tooltip.is-visible {
  display: block;
}

.tooltip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.tooltip-head strong {
  color: #fff;
  font-size: .95rem;
}

.tooltip-rank {
  flex: 0 0 auto;
  color: #fff;
}

.tooltip-requirement {
  margin: 0 0 7px;
  color: #ff5c57;
}

.tooltip-requirement.is-met {
  color: #36e56f;
}

.tooltip-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  min-height: 1.42em;
  color: #fff;
}

.tooltip-meta span:last-child {
  margin-left: auto;
  text-align: right;
}

.tooltip-meta+.tooltip-description {
  margin-top: 7px;
}

.tooltip-description {
  margin: 0;
  color: #ffd100;
  white-space: pre-line;
}

.tooltip-hint {
  margin: 9px 0 0;
  color: #949aa2;
  font-size: .76rem;
}

.segmented {
  display: flex;
  gap: 5px;
}

.segment {
  min-height: 36px;
  border-color: var(--line);
  color: var(--muted);
  background: transparent;
}

.segment.is-active {
  color: var(--text);
  border-color: var(--gold);
  background: rgba(205, 168, 74, .12);
}

.race-grid,
.ability-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.race-card,
.ability-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--panel);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 15px;
}

.card-top h2 {
  margin: 0;
  color: var(--gold-light);
  font-size: 1.125rem;
  font-weight: bold;
}

.faction {
  color: var(--muted);
  font-size: .82rem;
}

.class-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.class-pill {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 4px 9px;
  color: var(--class-color);
  font-size: .875rem;
  background: rgba(255, 255, 255, .02);
}

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

.racial-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.racial-list strong {
  font-size: .9rem;
  font-weight: 600;
}

.racial-list p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  line-height: 1.45;
}

.type {
  color: var(--gold);
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.ability-card {
  position: relative;
  min-height: 116px;
}

.ability-card::before {
  content: "";
  position: absolute;
  top: 18px;
  bottom: 18px;
  left: 0;
  width: 2px;
  background: var(--class-color);
}

.ability-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .9rem;
}

.count {
  color: var(--muted);
  font-size: .78rem;
}

.toast {
  position: fixed;
  z-index: 40;
  right: 20px;
  bottom: 20px;
  transform: translateY(12px);
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 10px 14px;
  color: var(--text);
  background: #29251f;
  opacity: 0;
  pointer-events: none;
  transition: .18s ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.nav-tab-editor {
  color: var(--gold);
}

.editor-heading {
  align-items: center;
}

.editor-toolbar {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .025);
}

.editor-toolbar label,
.editor-fields label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: .875rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.editor-toolbar select,
.editor-fields input,
.editor-fields select,
.description-editor textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 8px 10px;
  color: var(--text);
  background: #171717;
  font: inherit;
  letter-spacing: normal;
  text-transform: none;
}

.editor-toolbar select {
  min-width: 190px;
}

.editor-toolbar select:focus,
.editor-fields input:focus,
.editor-fields select:focus,
.description-editor textarea:focus {
  border-color: var(--gold);
  outline: 0;
  box-shadow: 0 0 0 2px rgba(205, 168, 74, .12);
}

.editor-status {
  flex: 1 1 220px;
  margin: 0 0 9px;
  color: var(--muted);
  font-size: .82rem;
  text-align: right;
}

.editor-status.is-error {
  color: #f0aaa1;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(390px, 1fr) minmax(330px, 440px);
  gap: 16px;
  align-items: start;
}

.editor-canvas,
.editor-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.editor-canvas .tree-head {
  align-items: center;
}

.editor-canvas .tree-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: .78rem;
}

.editor-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 66px);
  grid-template-rows: repeat(7, 66px);
  justify-content: center;
  gap: 8px;
  min-height: 558px;
  padding: 23px;
  background-image:
    linear-gradient(rgba(3, 8, 12, .30), rgba(3, 8, 12, .52)),
    var(--tree-background);
  background-position: center;
  background-size: 100% 100%;
}

.editor-cell {
  z-index: 0;
  border: 1px dashed rgba(183, 213, 220, .12);
  border-radius: 2px;
  background: rgba(0, 0, 0, .08);
}

.editor-cell.is-drag-over {
  border-color: var(--gold);
  background: rgba(205, 168, 74, .12);
}

.editor-dependency {
  position: absolute;
  z-index: 1;
  width: 2px;
  pointer-events: none;
  background: rgba(205, 168, 74, .55);
  box-shadow: 0 0 5px rgba(205, 168, 74, .25);
  transform-origin: top center;
}

.editor-talent {
  position: relative;
  z-index: 2;
  align-self: center;
  justify-self: center;
  width: 54px;
  height: 54px;
  border: 2px solid #59656e;
  border-radius: 3px;
  padding: 0;
  background: #050a0e;
  cursor: grab;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .45);
}

.editor-talent:active {
  cursor: grabbing;
}

.editor-talent:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}

.editor-talent.is-selected {
  border-color: var(--gold-light);
  box-shadow: 0 0 0 3px rgba(241, 217, 133, .16), 0 8px 18px rgba(0, 0, 0, .5);
}

.editor-talent img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 1px;
  object-fit: cover;
}

.editor-talent span {
  position: absolute;
  top: 55px;
  left: 50%;
  width: 92px;
  overflow: hidden;
  color: var(--muted);
  font-size: .64rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

.editor-panel {
  position: sticky;
  top: 80px;
  min-height: 420px;
  padding: 18px;
}

.editor-empty {
  display: grid;
  min-height: 380px;
  place-content: center;
  text-align: center;
}

.editor-empty-mark {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 2.5rem;
}

.editor-empty h2 {
  margin: 10px 0 5px;
  font-family: Georgia, serif;
  font-weight: 500;
}

.editor-empty p {
  max-width: 250px;
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1.5;
}

.editor-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.editor-panel-head code {
  display: block;
  margin-top: 4px;
  color: var(--gold-light);
}

.editor-kicker {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.editor-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.editor-fields .field-wide {
  grid-column: 1 / -1;
}

.description-editor {
  margin: 19px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  padding: 16px 0 0;
}

.description-editor legend {
  padding: 0 9px 0 0;
  color: var(--gold-light);
  font-family: Georgia, serif;
}

.description-editor label {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .74rem;
}

.description-editor textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.4;
}

.tooltip-preview-wrap {
  margin-top: 18px;
}

.editor-tooltip-preview {
  position: static;
  display: block;
  width: 100%;
  margin-top: 8px;
  pointer-events: auto;
}

@media (max-width: 980px) {
  .talent-trees {
    grid-template-columns: none;
    grid-auto-flow: column;
    grid-auto-columns: minmax(280px, 72vw);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 10px;
  }

  .tree {
    scroll-snap-align: start;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar {
    align-items: stretch;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0 10px;
    padding: 0 12px;
  }

  .brand {
    min-height: 48px;
  }

  .brand-logo {
    width: 80px;
    max-height: 42px;
  }

  .primary-nav {
    min-height: 38px;
    flex-wrap: wrap;
    flex: 1 1 200px;
  }

  .nav-tab {
    flex: 1;
    padding: 8px 10px;
  }

  main {
    padding: 18px 12px 32px;
  }

  .workspace-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 16px;
  }

  .build-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .points-total {
    margin-right: auto;
  }

  .class-chip span {
    display: inline;
  }

  .class-chip {
    padding: 5px 8px;
  }

  .class-icon {
    width: 24px;
    height: 24px;
  }

  .talent-trees {
    grid-auto-columns: minmax(280px, 100%);
  }

  .race-grid,
  .ability-grid {
    grid-template-columns: 1fr;
  }

  .editor-heading {
    align-items: flex-start;
  }

  .editor-heading .build-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .editor-toolbar {
    align-items: stretch;
  }

  .editor-toolbar label,
  .editor-toolbar select {
    width: 100%;
  }

  .editor-status {
    flex-basis: 100%;
    margin: 3px 0 0;
    text-align: left;
  }

  .tree-grid,
  .editor-grid {
    grid-template-columns: repeat(4, minmax(52px, 66px));
    padding: 16px 8px 24px;
  }

  .editor-fields {
    grid-template-columns: 1fr;
  }

  .editor-fields .field-wide {
    grid-column: auto;
  }

  .talent-tooltip {
    position: fixed;
    top: auto !important;
    right: 12px;
    bottom: 12px;
    left: 12px !important;
    width: auto;
    transform: none !important;
  }

  .editor-tooltip-preview {
    position: static;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
