/* Against the Darkmaster — GM Tools */

:root {
  --bg-deep: #0c0a0d;
  --bg: #141118;
  --bg-panel: #1c1720;
  --bg-card: #221c28;
  --bg-hover: #2a2233;
  --border: #3d3248;
  --border-soft: #2e2636;
  --text: #e8e0d8;
  --text-muted: #9a8f9e;
  --text-dim: #6b6270;
  --accent: #c45c3e;
  --accent-soft: #a34a32;
  --accent-glow: rgba(196, 92, 62, 0.25);
  --gold: #c9a227;
  --gold-soft: #a88820;
  --link: #d4a574;
  --sup: #6b9b6e;
  --lig: #8fb86b;
  --mod: #d4a84b;
  --gri: #d4783c;
  --let: #c94a4a;
  --miss: #4a4450;
  --sidebar-w: 280px;
  --header-h: 56px;
  --radius: 8px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(196, 92, 62, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 90% 100%, rgba(100, 40, 80, 0.06), transparent);
  min-height: 100vh;
}

a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  color: var(--gold);
  text-decoration: underline;
}

/* ── Layout ── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: linear-gradient(180deg, #1a141c 0%, #121015 100%);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent) 0%, #6b2040 100%);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  color: #fff;
  box-shadow: 0 0 12px var(--accent-glow);
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.brand span {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.search-wrap {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-wrap::before {
  content: "⌕";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 1rem;
  pointer-events: none;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.nav-user a {
  color: var(--link);
  text-decoration: none;
  white-space: nowrap;
}

.nav-user a:hover {
  color: var(--gold);
}

.nav-user-name {
  color: var(--text);
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 600px) {
  .nav-user-name {
    display: none;
  }
}

/* Shared multi-page nav */
.brand-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-link:hover {
  text-decoration: none;
  color: inherit;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-left: 12px;
}

.site-nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.site-nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
  border-color: var(--border);
}

.site-nav-link.active {
  background: rgba(196, 92, 62, 0.18);
  border-color: var(--accent);
  color: var(--text);
  font-weight: 600;
}

@media (max-width: 720px) {
  .site-nav {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    padding: 10px;
    flex-direction: column;
    align-items: stretch;
    z-index: 95;
    margin: 0;
  }

  .site-nav.open {
    display: flex;
  }

  .site-nav-link {
    border-radius: var(--radius);
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--accent-soft);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-soft);
  color: #fff;
}

.btn-menu {
  display: none;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--bg-panel);
  border-right: 1px solid var(--border-soft);
  overflow-y: auto;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  padding: 12px 0 32px;
}

.nav-group {
  margin-bottom: 8px;
}

.nav-group-title {
  padding: 10px 18px 4px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-soft);
}

.nav-link {
  display: block;
  padding: 7px 18px 7px 22px;
  color: var(--text-muted);
  font-size: 0.88rem;
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: rgba(196, 92, 62, 0.1);
  color: var(--text);
  border-left-color: var(--accent);
}

/* ── Main content ── */
.main {
  padding: 24px 28px 80px;
  max-width: 1200px;
  overflow-x: hidden;
}

.hero {
  margin-bottom: 28px;
  padding: 24px 28px;
  border-radius: 12px;
  background: linear-gradient(135deg, #1e1622 0%, #1a1220 50%, #221018 100%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.hero h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  max-width: 60ch;
}

.section {
  margin-bottom: 40px;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.section.hidden-by-search {
  display: none;
}

.section-header {
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.section-header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.02em;
}

.section-sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card.hidden-by-search {
  display: none;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

.card p {
  margin: 0 0 8px;
  color: var(--text);
}

.card p:last-child {
  margin-bottom: 0;
}

.card ul {
  margin: 8px 0;
  padding-left: 1.2em;
  color: var(--text);
}

.card li {
  margin-bottom: 4px;
}

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

.grid-2 > .card {
  margin-bottom: 0;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
  margin: 0 -4px;
  border-radius: 6px;
  border: 1px solid var(--border-soft);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  background: var(--bg-deep);
}

.data-table th {
  position: sticky;
  top: 0;
  background: #1a1520;
  color: var(--gold);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
  color: var(--text);
}

.data-table tbody tr:hover {
  background: rgba(196, 92, 62, 0.06);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table td p {
  margin: 0 0 4px;
  font-size: inherit;
}

.data-table td ul {
  margin: 4px 0;
  padding-left: 1.1em;
}

.data-table.compact td,
.data-table.compact th {
  padding: 6px 10px;
}

.data-table.center td:not(:first-child),
.data-table.center th:not(:first-child) {
  text-align: center;
}

.data-table .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* Attack table cells */
.cell-miss {
  color: var(--text-dim) !important;
  font-style: italic;
}

.cell-sup {
  color: var(--sup);
  font-weight: 600;
}

.cell-lig {
  color: var(--lig);
  font-weight: 600;
}

.cell-mod {
  color: var(--mod);
  font-weight: 600;
}

.cell-gri {
  color: var(--gri);
  font-weight: 600;
}

.cell-let {
  color: var(--let);
  font-weight: 600;
}

/* Critical severity */
.sev-sup { border-left: 3px solid var(--sup); }
.sev-lig { border-left: 3px solid var(--lig); }
.sev-mod { border-left: 3px solid var(--mod); }
.sev-gri { border-left: 3px solid var(--gri); }
.sev-let { border-left: 3px solid var(--let); }

.row-max {
  background: rgba(201, 162, 39, 0.06);
}

.row-max td:first-child::after {
  content: " max";
  font-size: 0.7rem;
  color: var(--gold);
  font-weight: 600;
  text-transform: uppercase;
}

/* ── Toolbar / lookup ── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.toolbar label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.toolbar select,
.toolbar input[type="number"],
.toolbar input[type="text"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.toolbar select:focus,
.toolbar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.toolbar input[type="number"] {
  width: 90px;
  font-family: var(--mono);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.tab {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.12s;
}

.tab:hover {
  border-color: var(--accent-soft);
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.legend .l-sup { background: var(--sup); }
.legend .l-lig { background: var(--lig); }
.legend .l-mod { background: var(--mod); }
.legend .l-gri { background: var(--gri); }
.legend .l-let { background: var(--let); }

.note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 8px 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  border-left: 3px solid var(--border);
}

.note ul {
  margin: 6px 0 0;
  padding-left: 1.2em;
}

.flow-steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
}

.flow-steps li {
  counter-increment: step;
  position: relative;
  padding: 12px 12px 12px 48px;
  margin-bottom: 8px;
  background: var(--bg-panel);
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
}

.flow-steps li::before {
  content: counter(step);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

/* Highlight matched row */
tr.highlight-row {
  background: rgba(201, 162, 39, 0.18) !important;
  outline: 1px solid var(--gold);
}

tr.highlight-row td {
  color: #fff !important;
}

/* Condition name accent */
.cond-name {
  font-weight: 700;
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 6px;
}

/* Archetype level chips */
.level-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}

.level-chip {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-family: var(--mono);
  cursor: pointer;
}

.level-chip.active {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1208;
  font-weight: 700;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.stat-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 8px 10px;
}

.stat-box .label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-box .value {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

/* Footer */
.footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
}

/* Search no results */
.no-results {
  display: none;
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
}

.no-results.visible {
  display: block;
}

/* Responsive */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    width: var(--sidebar-w);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .btn-menu {
    display: inline-flex;
  }

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

  .main {
    padding: 16px;
  }

  .brand h1 {
    font-size: 0.95rem;
  }
}

@media (max-width: 560px) {
  .search-wrap {
    max-width: none;
  }

  .brand span {
    display: none;
  }
}

/* Print */
@media print {
  .sidebar,
  .topbar,
  .btn {
    display: none !important;
  }

  .app {
    display: block;
  }

  .main {
    max-width: none;
    padding: 0;
  }

  .card,
  .section {
    break-inside: avoid;
  }

  body {
    background: #fff;
    color: #000;
  }

  .data-table th {
    background: #eee;
    color: #000;
  }
}
