:root {
  --bg: #070600;
  --panel: #111111;
  --code: #0d0d0d;
  --text: #d9d9d9;
  --heading: #ffffff;
  --muted: #6d6875;
  --coral: #ff1053;
  --mauve: #d972ff;
  --blue: #1098f7;
  --pumpkin: #fc7a1e;
  --border: #6d6875;
  --green: #34d399;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Fira Sans Condensed", sans-serif;
  font-weight: 300;
}

body {
  min-height: 100vh;
}

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

/* ── PAGE LAYOUT ───────────────────────────────── */
.page {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto auto 1fr;
  grid-template-areas:
    "hero"
    "toolbar"
    "pills"
    "meta"
    "table";
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  min-height: 100vh;
}

.page.stack-closed .stack-panel {
  display: none;
}

/* ── HERO ──────────────────────────────────────── */
.hero {
  grid-area: hero;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.accent-bar {
  width: 8px;
  min-width: 8px;
  background: var(--coral);
  height: 72px;
  flex-shrink: 0;
}

.accent-bar-modal {
  height: 52px;
}

h1,
h2 {
  margin: 0;
  font-family:
    "Bebas Neue",
    Impact,
    Arial Black,
    sans-serif;
  color: var(--heading);
  letter-spacing: 1px;
}

h1 {
  font-size: 3rem;
  line-height: 1;
}
h2 {
  font-size: 2rem;
  line-height: 1;
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 780px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
}

/* ── TOOLBAR ───────────────────────────────────── */
.toolbar {
  grid-area: toolbar;
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 10px 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.toolbar-search {
  flex: 1;
  min-width: 200px;
}

.toolbar-search input {
  width: 100%;
  height: 100%;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-group label {
  font-family:
    "Bebas Neue",
    Impact,
    Arial Black,
    sans-serif;
  color: var(--heading);
  letter-spacing: 0.5px;
  font-size: 1rem;
  white-space: nowrap;
}

input[type="text"],
select,
button {
  border: 1px solid var(--border);
  background: var(--code);
  color: var(--text);
  font-family: "Fira Mono", Consolas, monospace;
  font-size: 0.88rem;
  padding: 6px 8px;
  border-radius: 0;
  outline: none;
}

button {
  background: var(--coral);
  color: var(--bg);
  font-family:
    "Bebas Neue",
    Impact,
    Arial Black,
    sans-serif;
  letter-spacing: 0.7px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.9);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--code);
}

.btn-mauve {
  background: var(--mauve);
}

.btn-small {
  padding: 4px 8px;
  font-size: 0.85rem;
}

.btn-stack-open {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-stack-open:hover {
  border-color: var(--green);
  color: var(--green);
}

/* ── CATEGORY PICKER BUTTON ────────────────────── */
.cat-picker-trigger {
  position: relative;
  background: var(--code);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: "Fira Mono", Consolas, monospace;
  font-size: 0.88rem;
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cat-picker-trigger:hover {
  border-color: var(--mauve);
}

.cat-count-badge {
  background: var(--mauve);
  color: var(--bg);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 1px 5px;
  min-width: 18px;
  text-align: center;
}

/* ── CATEGORY PICKER POPOVER ───────────────────── */
.cat-popover {
  position: fixed;
  z-index: 900;
  background: var(--panel);
  border: 1px solid var(--border);
  width: 420px;
  max-height: 480px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.cat-popover.hidden {
  display: none;
}

.cat-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.cat-popover-header h2 {
  font-size: 1.3rem;
}

.cat-popover-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.cat-popover-search input {
  width: 100%;
}

.cat-popover-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.cat-popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.cat-popover-item:hover {
  background: var(--code);
}

.cat-popover-item.selected {
  background: rgba(217, 114, 255, 0.08);
}

.cat-checkbox {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cat-popover-item.selected .cat-checkbox {
  background: var(--mauve);
  border-color: var(--mauve);
}

.cat-checkbox::after {
  content: "";
  display: none;
}

.cat-popover-item.selected .cat-checkbox::after {
  display: block;
  content: "✓";
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.cat-popover-icon {
  font-size: 18px;
  color: var(--muted);
  width: 20px;
  text-align: center;
}

.cat-popover-label {
  flex: 1;
  font-size: 0.9rem;
}

.cat-popover-count {
  color: var(--muted);
  font-family: "Fira Mono", Consolas, monospace;
  font-size: 0.8rem;
}

.cat-popover-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

/* active category pills in toolbar area */
.active-cats {
  grid-area: pills;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.active-cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(217, 114, 255, 0.12);
  border: 1px solid var(--mauve);
  color: var(--mauve);
  padding: 2px 8px;
  font-size: 0.82rem;
  font-family: "Fira Mono", Consolas, monospace;
  cursor: default;
}

.active-cat-pill .material-icons {
  font-size: 14px;
  vertical-align: middle;
}

.active-cat-pill .pill-x {
  cursor: pointer;
  opacity: 0.6;
  font-size: 0.9rem;
}

.active-cat-pill .pill-x:hover {
  opacity: 1;
}

/* ── RESULTS META ──────────────────────────────── */
.results-meta {
  grid-area: meta;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  color: var(--muted);
  font-family: "Fira Mono", Consolas, monospace;
  font-size: 0.88rem;
}

/* ── TABLE ─────────────────────────────────────── */
.table-area {
  grid-area: table;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.table-wrap {
  overflow-x: auto;
  flex: 1;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

thead tr {
  background: var(--coral);
}

th {
  text-align: left;
  padding: 6px 10px;
  color: var(--bg);
  font-family:
    "Bebas Neue",
    Impact,
    Arial Black,
    sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover {
  background: rgba(0, 0, 0, 0.15);
}

.sort-arrow {
  display: inline-block;
  margin-left: 5px;
  font-size: 0.75rem;
  opacity: 0.4;
}

th.sorted .sort-arrow {
  opacity: 1;
}

td {
  padding: 10px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}

tbody tr:nth-child(even) {
  background: var(--code);
}
tbody tr {
  cursor: pointer;
}
tbody tr:hover {
  background: #161616;
}

.tool-name {
  font-weight: 700;
  color: var(--heading);
  white-space: normal;
  overflow-wrap: break-word;
  word-wrap: break-word;
  hyphens: auto;
}

.tool-type {
  font-family: "Fira Mono", Consolas, monospace;
  font-size: 0.88rem;
}
.tool-type-open {
  color: var(--mauve);
}
.tool-type-paid {
  color: var(--pumpkin);
}

.tool-desc {
  color: var(--muted);
  font-size: 1.08rem;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.category-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--border);
  padding: 1px 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  line-height: 1.3;
  white-space: nowrap;
}

.category-chip .material-icons {
  font-size: 13px;
  color: var(--muted);
}

/* category description tooltip */
.category-chip[title],
.badge[title],
.active-cat-pill[title] {
  position: relative;
}

/* ── STACK ADD BUTTON (in table rows) ──────────── */
.stack-add-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.stack-add-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

.stack-add-btn.in-stack {
  background: var(--green);
  border-color: var(--green);
  color: var(--bg);
}

/* ── STACK PANEL (sidebar) ─────────────────────── */
.stack-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.5);
}

.stack-header {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.stack-header h2 {
  font-size: 1.5rem;
  flex: 1;
}

.stack-close-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px;
  height: 34px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.stack-close-btn:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.stack-close-btn .material-icons {
  font-size: 20px;
}

.stack-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
}

.stack-empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
  padding: 16px 0;
}

.stack-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(109, 104, 117, 0.25);
}

.stack-item-info {
  flex: 1;
  min-width: 0;
}

.stack-item-name {
  color: var(--heading);
  font-weight: 700;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stack-item-type {
  font-family: "Fira Mono", Consolas, monospace;
  font-size: 0.78rem;
}

.stack-remove-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 24px;
  height: 24px;
  font-size: 1rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.stack-remove-btn:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.stack-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stack-footer .stack-summary {
  font-family: "Fira Mono", Consolas, monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── DETAIL MODAL ──────────────────────────────── */
.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.74);
}

.modal-card {
  position: relative;
  z-index: 1001;
  max-width: 860px;
  width: calc(100% - 32px);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  margin: 24px auto;
  padding: 18px;
  background: var(--panel);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.modal-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding-right: 56px;
}

.modal-type {
  margin-top: 6px;
  font-family: "Fira Mono", Consolas, monospace;
}

.modal-section {
  margin-bottom: 18px;
  font-size: 1.25rem;
}

.modal-label {
  font-family:
    "Bebas Neue",
    Impact,
    Arial Black,
    sans-serif;
  color: var(--heading);
  margin-bottom: 6px;
  font-size: 1.4rem;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  background: var(--code);
  color: var(--text);
  padding: 3px 8px;
  font-size: 0.9rem;
}

.badge .material-icons {
  font-size: 15px;
  color: var(--muted);
}

/* ── ALTERNATIVES (grouped by category) ────────── */
.alternatives-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.alt-cat-group {
}

.alt-cat-heading {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-family:
    "Bebas Neue",
    Impact,
    Arial Black,
    sans-serif;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

.alt-cat-heading .material-icons {
  font-size: 16px;
}

.alt-tools-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.alt-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: var(--code);
  padding: 4px 10px;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
  font-size: 0.88rem;
}

.alt-tool-chip:hover {
  border-color: var(--blue);
  background: rgba(16, 152, 247, 0.08);
}

.alt-tool-chip strong {
  color: var(--heading);
  font-weight: 700;
}

.alt-tool-chip .alt-type {
  font-family: "Fira Mono", Consolas, monospace;
  font-size: 0.78rem;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

/* ── RESPONSIVE ────────────────────────────────── */
@media (max-width: 1100px) {
  .page {
    max-width: 100%;
  }
}

@media (max-width: 700px) {
  .accent-bar {
    height: 56px;
  }
  h1 {
    font-size: 2.2rem;
  }
  .toolbar {
    flex-direction: column;
  }
  .tool-desc {
    display: none;
  }
}
