:root {
  color-scheme: dark;
  --bg: #050b12;
  --panel: rgba(9, 22, 33, 0.86);
  --panel-2: rgba(15, 35, 50, 0.88);
  --panel-solid: #0d1a27;
  --text: #f6ead4;
  --muted: #9dafbf;
  --subtle: #6e8191;
  --line: rgba(139, 171, 190, 0.24);
  --line-strong: rgba(224, 184, 91, 0.44);
  --gold: #e4b95d;
  --teal: #48d4cd;
  --blue: #78aeea;
  --danger: #dc786f;
  --green: #7edb9a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 78% 8%, rgba(72, 212, 205, 0.15), transparent 28%),
    radial-gradient(circle at 18% 20%, rgba(228, 185, 93, 0.13), transparent 26%),
    linear-gradient(180deg, #07111c 0%, #050b12 56%, #04070d 100%);
  color: var(--text);
}
button, input, select { font: inherit; }
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--gold); }
h1, h2, h3, p { margin: 0; }
.tools-shell, .tools-shell * { letter-spacing: 0; }

.tools-shell {
  width: min(1640px, 100%);
  margin: 0 auto;
  padding: 12px;
}
.tool-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(9, 28, 43, 0.94), rgba(4, 13, 22, 0.96));
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  color: var(--text);
}
.brand img {
  width: 42px;
  height: 56px;
  object-fit: contain;
}
.brand strong {
  display: block;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.1rem;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
}
.brand span span {
  color: var(--muted);
  font-size: 0.88rem;
}
.header-actions, .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tool-button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 27, 39, 0.88);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}
.tool-button {
  padding: 0 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}
.icon-button { width: 38px; padding: 0; }
.tool-button:hover, .icon-button:hover, .tool-button:focus-visible, .icon-button:focus-visible {
  border-color: var(--gold);
  outline: none;
}
.tool-button.primary {
  border-color: var(--line-strong);
  color: var(--gold);
  background: rgba(228, 185, 93, 0.1);
}
.tool-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.controls {
  position: sticky;
  top: 12px;
  display: grid;
  gap: 14px;
  padding: 14px;
}
.panel-title {
  display: grid;
  gap: 5px;
}
.panel-title h1, .panel-title h2 {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  line-height: 1.05;
  text-transform: uppercase;
}
.note, .status-line {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}
.field-grid {
  display: grid;
  gap: 10px;
}
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field {
  display: grid;
  gap: 5px;
}
.field span, .toggle span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}
.field input, .field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 8, 15, 0.72);
  color: var(--text);
  outline: none;
  padding: 8px 10px;
}
.field input:focus, .field select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(228, 185, 93, 0.1);
}
.toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
}
.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--gold);
}

.results-panel {
  min-width: 0;
  min-height: 520px;
  padding: 14px;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.metric {
  border: 1px solid rgba(139, 171, 190, 0.18);
  border-radius: 8px;
  background: rgba(2, 8, 15, 0.54);
  padding: 12px;
}
.metric span {
  display: block;
  color: var(--subtle);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}
.metric strong {
  display: block;
  margin-top: 4px;
  color: var(--gold);
  font-size: 1.45rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 8, 15, 0.58);
  color: var(--muted);
  cursor: pointer;
  padding: 0 11px;
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}
.tab[aria-selected="true"], .tab.active {
  color: var(--gold);
  border-color: var(--line-strong);
  background: rgba(228, 185, 93, 0.1);
}
.empty {
  display: grid;
  min-height: 280px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}
.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid rgba(139, 171, 190, 0.18);
  border-radius: 8px;
  background: rgba(1, 5, 10, 0.48);
}
table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}
th, td {
  border-bottom: 1px solid rgba(139, 171, 190, 0.14);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 0.83rem;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(10, 23, 34, 0.96);
  color: var(--teal);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}
td.num {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tr.final-row td {
  background: rgba(228, 185, 93, 0.09);
  color: var(--gold);
  font-weight: 900;
}
.final-row + tr td {
  border-top: 1px solid rgba(228, 185, 93, 0.22);
}
.notes-cell {
  max-width: 360px;
  color: var(--muted);
}
.notes-cell div {
  max-height: 96px;
  overflow: auto;
  white-space: pre-wrap;
}
.info-box {
  display: grid;
  gap: 7px;
  border: 1px solid rgba(139, 171, 190, 0.18);
  border-radius: 8px;
  background: rgba(2, 8, 15, 0.48);
  padding: 10px;
}
.info-box table {
  min-width: 0;
}
.custom-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) repeat(4, minmax(54px, 74px));
  gap: 8px;
  align-items: end;
  border: 1px solid rgba(139, 171, 190, 0.16);
  border-radius: 8px;
  padding: 9px;
}
.custom-row strong { font-size: 0.86rem; }

.tree-app {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 116px);
}
.tree-sidebar {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 34px);
  overflow: auto;
  padding: 12px;
}
.tree-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}
.tree-group {
  border: 1px solid rgba(139, 171, 190, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(2, 8, 15, 0.42);
}
.tree-choice {
  display: flex;
  width: 100%;
  justify-content: space-between;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.tree-choice.sub {
  color: var(--muted);
  padding-left: 20px;
  font-size: 0.86rem;
}
.tree-choice.active {
  color: var(--gold);
  background: rgba(228, 185, 93, 0.1);
}
.tree-main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 640px;
}
.tree-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
}
.cost-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(2, 8, 15, 0.58);
  color: var(--green);
  padding: 0 12px;
  font-weight: 900;
}
.cost-pill.warn { color: var(--gold); }
.cost-pill.over { color: var(--danger); }
.tree-viewport {
  position: relative;
  min-height: 590px;
  overflow: auto;
  border-top: 1px solid rgba(139, 171, 190, 0.16);
  background:
    linear-gradient(90deg, rgba(139, 171, 190, 0.035) 1px, transparent 1px) 0 0 / 64px 64px,
    linear-gradient(rgba(139, 171, 190, 0.035) 1px, transparent 1px) 0 0 / 64px 64px,
    rgba(1, 5, 10, 0.38);
}
.tree-canvas {
  position: relative;
  min-width: 100%;
  min-height: 100%;
  transform-origin: top left;
}
.tree-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.skill-node {
  position: absolute;
  display: grid;
  align-content: start;
  width: 220px;
  min-height: 104px;
  border: 1px solid rgba(139, 171, 190, 0.42);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(72, 212, 205, 0.12), rgba(5, 12, 21, 0.94));
  color: var(--text);
  cursor: pointer;
  padding: 11px;
  text-align: left;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
}
.skill-node:hover, .skill-node:focus {
  border-color: var(--gold);
  outline: none;
}
.skill-node.selected {
  border-color: rgba(126, 219, 154, 0.84);
  background: linear-gradient(145deg, rgba(126, 219, 154, 0.2), rgba(5, 12, 21, 0.94));
}
.skill-node.wip {
  border-color: rgba(220, 120, 111, 0.62);
}
.skill-node strong {
  display: block;
  font-size: 0.93rem;
  line-height: 1.15;
}
.skill-node small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.25;
}
.skill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.skill-meta span {
  border: 1px solid rgba(139, 171, 190, 0.16);
  border-radius: 6px;
  background: rgba(2, 8, 15, 0.55);
  color: var(--teal);
  padding: 3px 6px;
  font-size: 0.68rem;
  font-weight: 850;
}
.skill-details {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border: 1px solid rgba(139, 171, 190, 0.16);
  border-radius: 8px;
  background: rgba(2, 8, 15, 0.42);
  padding: 10px;
}
.skill-details strong { color: var(--gold); }
.skill-details p { color: var(--muted); line-height: 1.45; }
.selected-list {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}
.selected-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(139, 171, 190, 0.1);
  padding-bottom: 7px;
  color: var(--muted);
  font-size: 0.82rem;
}
.tool-directory {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.directory-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 520px);
  gap: 24px;
  align-items: end;
  padding: clamp(34px, 6vw, 72px) 4px 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.directory-heading h1 {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 5rem;
  font-weight: 500;
  line-height: 0.95;
  text-transform: uppercase;
}
.directory-heading > p {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}
.directory-kicker {
  margin-bottom: 8px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}
.tool-card {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  min-height: 224px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(72, 212, 205, 0.07), transparent 44%),
    var(--panel);
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 20px;
}
.tool-card:hover, .tool-card:focus-visible {
  border-color: var(--gold);
  color: var(--text);
  outline: none;
  transform: translateY(-2px);
}
.tool-card-icon {
  display: grid;
  width: 70px;
  height: 70px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(3, 12, 18, 0.68);
  box-shadow: inset 0 0 24px rgba(72, 212, 205, 0.08);
}
.tool-card-icon img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}
.tool-card-icon.skill-icon img {
  width: 62px;
  height: 62px;
}
.tool-card-copy {
  min-width: 0;
}
.tool-card strong {
  display: block;
  margin-top: 10px;
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.1;
  text-transform: uppercase;
}
.tool-card-copy > span:not(.tool-status):not(.tool-capabilities) {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.tool-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}
.tool-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(126, 219, 154, 0.7);
}
.tool-capabilities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 16px;
}
.tool-capabilities b {
  border-left: 2px solid rgba(72, 212, 205, 0.42);
  color: #c8d7d6;
  font-size: 0.7rem;
  font-weight: 750;
  padding-left: 7px;
}
.tool-open {
  align-self: end;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}
.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(5, 12, 21, 0.96);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
[hidden] { display: none !important; }

@media (max-width: 980px) {
  .tool-header, .tool-grid, .tree-app, .tree-toolbar, .directory-heading, .tool-directory {
    grid-template-columns: 1fr;
  }
  .controls, .tree-sidebar {
    position: static;
    max-height: none;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tree-main { min-height: 560px; }
  .tree-viewport { min-height: 500px; }
  .directory-heading h1 { font-size: 3.4rem; }
  .tool-card strong { font-size: 1.75rem; }
}
@media (max-width: 640px) {
  .tools-shell { padding: 8px; }
  .field-grid.two, .metrics { grid-template-columns: 1fr; }
  .custom-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .custom-row strong { grid-column: 1 / -1; }
  .header-actions, .button-row { width: 100%; }
  .tool-button { flex: 1; }
  .brand strong { font-size: 1.35rem; }
  .brand span span { font-size: 0.78rem; }
  .directory-heading { padding-top: 28px; }
  .directory-heading h1 { font-size: 2.65rem; }
  .tool-card {
    grid-template-columns: 58px minmax(0, 1fr);
    min-height: 0;
    padding: 15px;
  }
  .tool-card-icon {
    width: 58px;
    height: 58px;
  }
  .tool-card-icon img,
  .tool-card-icon.skill-icon img {
    width: 48px;
    height: 48px;
  }
  .tool-open { display: none; }
  .tool-card strong { font-size: 1.45rem; }
}
