/* ============================================================
   CTF Helper — dark theme
   ============================================================ */

:root {
  /* near-black layered surfaces */
  --bg:        #0b0d12;
  --bg-1:      #11141b;
  --bg-2:      #161a23;
  --bg-3:      #1d2330;
  --surface:   #12151d;
  --border:    #242a38;
  --border-2:  #30374a;

  /* text */
  --text:      #e6e9f0;
  --text-dim:  #9aa3b5;
  --text-mute: #656d80;

  /* accent — muted violet, with a cold-blue secondary */
  --accent:        #8b7cf6;
  --accent-soft:   #a99cf9;
  --accent-faint:  rgba(139, 124, 246, 0.14);
  --accent-line:   rgba(139, 124, 246, 0.35);
  --cyan:          #46c7d6;
  --amber:         #e0a340;
  --green:         #5bc98b;
  --red:           #f06d6d;

  --radius:   10px;
  --radius-sm: 7px;
  --shadow:   0 8px 30px rgba(0, 0, 0, 0.45);

  --mono: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", ui-monospace, Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;

  --topbar-h: 58px;
  --sidebar-w: 268px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.mono { font-family: var(--mono); }
.muted { color: var(--text-mute); font-size: 12px; }
.hidden { display: none !important; }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

::selection { background: var(--accent-faint); }

/* scrollbar */
::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3c4458; }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: relative;
  z-index: 40;
  flex-shrink: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
}
body.scrolled .topbar { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  letter-spacing: 0.2px;
  flex-shrink: 0;
}
.brand-mark {
  font-family: var(--mono);
  color: var(--accent);
  background: var(--accent-faint);
  padding: 3px 7px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.brand-name { font-size: 15px; }

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 640px;
  display: flex;
  align-items: center;
}
.search-input {
  width: 100%;
  height: 38px;
  padding: 0 84px 0 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input::placeholder { color: var(--text-mute); font-family: var(--sans); }
.search-input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-faint);
}
.search-hint {
  position: absolute;
  right: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-mute);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  pointer-events: none;
}
.search-clear {
  position: absolute;
  right: 10px;
  display: none;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}
.search-clear:hover { color: var(--text); }
.searching .search-hint { display: none; }
.searching .search-clear { display: block; }

.topbar-actions { flex-shrink: 0; }

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: var(--bg-3); border-color: var(--border-2); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-2); }
.btn-danger-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-dim);
  height: 30px;
  padding: 0 10px;
}
.btn-danger-ghost:hover { color: var(--red); background: rgba(240, 109, 109, 0.08); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-mute);
  transition: background 0.2s, box-shadow 0.2s;
}
.status-dot.active {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

/* ============================================================
   Target panel
   ============================================================ */
.target-panel {
  position: relative;
  z-index: 30;
  flex-shrink: 0;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  padding: 16px 18px;
  animation: slideDown 0.18s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.target-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 1200px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field-wide { grid-column: 1 / -1; }
.field-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mute);
  font-weight: 600;
}
.field-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 11px;
  font-size: 13px;
  font-family: var(--sans);
  outline: none;
  resize: vertical;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px var(--accent-faint);
}
.target-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  max-width: 1200px;
}
.target-saved { font-size: 12px; color: var(--text-mute); opacity: 0; transition: opacity 0.2s; }
.target-saved.show { opacity: 1; }

/* ============================================================
   Layout
   ============================================================ */
.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100%;
  overflow-y: auto;
  padding: 16px 10px 40px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.nav-cat { margin-bottom: 2px; }
.nav-cat-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, color 0.12s;
}
.nav-cat-head:hover { background: var(--bg-2); color: var(--text); }
.nav-cat-icon { font-size: 14px; width: 16px; text-align: center; }
.nav-cat-caret {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-mute);
  transition: transform 0.18s;
}
.nav-cat.collapsed .nav-cat-caret { transform: rotate(-90deg); }
.nav-links { display: flex; flex-direction: column; overflow: hidden; }
.nav-cat.collapsed .nav-links { display: none; }
.nav-link {
  padding: 7px 12px 7px 37px;
  background: none;
  border: none;
  border-left: 2px solid transparent;
  color: var(--text-mute);
  font-family: var(--sans);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.nav-link:hover { color: var(--text); background: var(--bg-2); }
.nav-link.active {
  color: var(--accent-soft);
  border-left-color: var(--accent);
  background: var(--accent-faint);
}
.nav-cat.active-cat > .nav-cat-head {
  color: var(--accent-soft);
  background: var(--accent-faint);
}

.content {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  padding: 26px 40px 120px;
}

/* ============================================================
   Sections & groups
   ============================================================ */
.cat-section { margin-bottom: 44px; scroll-margin-top: 76px; }
/* tab behaviour: one category visible at a time (search overrides) */
.cat-section.inactive { display: none; }
body.searching .cat-section.inactive { display: block; }
.cat-title {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 20px;
  font-weight: 650;
  margin: 0 0 4px;
  letter-spacing: -0.2px;
}
.cat-title .cat-emoji { font-size: 19px; }
.cat-desc {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.group { margin-bottom: 22px; }
.group-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 0;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  margin-bottom: 12px;
}
.group-caret { font-size: 10px; color: var(--text-mute); transition: transform 0.18s; }
.group.collapsed .group-caret { transform: rotate(-90deg); }
.group.collapsed .block-list { display: none; }
.group-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-mute);
  font-family: var(--mono);
  font-weight: 400;
}

.group-note {
  color: var(--text-dim);
  font-size: 13px;
  margin: -4px 0 14px;
  padding: 10px 14px;
  background: var(--bg-1);
  border-left: 2px solid var(--border-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ============================================================
   Command blocks
   ============================================================ */
.block-list { display: flex; flex-direction: column; gap: 10px; }

/* wide screens: two-column command grid to use horizontal space */
@media (min-width: 1180px) {
  .block-list:not(.no-grid) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
  }
}
@media (min-width: 1920px) {
  .block-list:not(.no-grid) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.cmd {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cmd:hover {
  border-color: var(--border-2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.cmd-desc {
  padding: 11px 14px 9px;
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.45;
}
.cmd-body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  padding: 11px 10px 11px 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.cmd > .cmd-body:first-child { border-top: none; }
.cmd-code {
  flex: 1;
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  overflow-x: auto;
  padding-top: 2px;
  tab-size: 2;
}
.cmd-code .tok { color: var(--cyan); }
.cmd-code .var { color: var(--amber); }

.cmd-actions { display: flex; gap: 5px; flex-shrink: 0; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.13s;
  font-size: 14px;
  line-height: 1;
}
.icon-btn:hover { background: var(--bg-3); color: var(--text); border-color: var(--border-2); }
.icon-btn.copied { color: var(--green); border-color: var(--green); background: rgba(91, 201, 139, 0.1); }
.icon-btn.pinned { color: var(--amber); border-color: var(--amber); background: rgba(224, 163, 64, 0.1); }
.icon-btn svg { width: 15px; height: 15px; }

.cmd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 9px 14px 11px;
}
.tag {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-mute);
  background: var(--bg-1);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 20px;
}

/* ============================================================
   Reverse shell generator
   ============================================================ */
.rev-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.rev-controls .field { min-width: 180px; flex: 1; max-width: 280px; }
.rev-subhead {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-mute);
  font-weight: 600;
  margin: 18px 0 10px;
}
.shell-name {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-soft);
  background: var(--accent-faint);
  border: 1px solid var(--accent-line);
  padding: 2px 9px;
  border-radius: 20px;
  margin: 11px 0 0 14px;
}
.shell-name + .cmd-body { border-top: none; padding-top: 4px; }

/* ============================================================
   Reference rows (term / description)
   ============================================================ */
.ref-list { display: flex; flex-direction: column; gap: 2px; }
.ref-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.ref-row + .ref-row { margin-top: 6px; }
.ref-term { color: var(--accent-soft); font-size: 12.5px; }
.ref-desc { color: var(--text-dim); font-size: 13px; }

/* ============================================================
   Checklists (stuck helper / methodology)
   ============================================================ */
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.13s, background 0.13s, opacity 0.13s;
}
.check-row:hover { border-color: var(--border-2); }
.check-box {
  flex-shrink: 0;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  border: 1.5px solid var(--border-2);
  border-radius: 5px;
  position: relative;
  transition: all 0.13s;
}
.check-row.done .check-box {
  background: var(--green);
  border-color: var(--green);
}
.check-row.done .check-box::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b0d12;
  font-size: 12px;
  font-weight: 700;
}
.check-row.done .check-text { color: var(--text-mute); text-decoration: line-through; }

/* ============================================================
   Reference table (hash modes)
   ============================================================ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.ref-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ref-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.ref-table td { padding: 9px 14px; border-bottom: 1px solid var(--border); }
.ref-table tbody tr:last-child td { border-bottom: none; }
.ref-table tbody tr:hover { background: var(--bg-1); }
.ref-table td:first-child { font-family: var(--mono); color: var(--accent-soft); font-weight: 600; }
.ref-table td:nth-child(2) { font-family: var(--mono); color: var(--text); }
.ref-table td:nth-child(3) { color: var(--text-dim); }

/* ============================================================
   Link cards
   ============================================================ */
.link-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.link-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.13s, transform 0.13s, background 0.13s;
}
.link-card:hover { border-color: var(--accent-line); transform: translateY(-2px); background: var(--bg-2); }
.link-label { color: var(--text); font-weight: 600; font-size: 13.5px; }
.link-ext { color: var(--accent); font-size: 12px; }
.link-note { color: var(--text-mute); font-size: 12px; }

/* ============================================================
   Quick access
   ============================================================ */
.quick-access {
  margin-bottom: 40px;
  padding: 18px;
  background: linear-gradient(180deg, var(--accent-faint), transparent 70%);
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
}
.quick-access-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}
.quick-access-head h2 {
  font-size: 15px;
  margin: 0;
  color: var(--accent-soft);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   No results
   ============================================================ */
.no-results {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-mute);
}

/* ============================================================
   Highlight (search match)
   ============================================================ */
mark.hl {
  background: rgba(224, 163, 64, 0.28);
  color: var(--text);
  border-radius: 3px;
  padding: 0 1px;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast .toast-accent { color: var(--green); margin-right: 6px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 920px) {
  .target-grid { grid-template-columns: 1fr 1fr; }
  .sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-h);
    bottom: 0;
    height: auto;
    z-index: 35;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .content { padding: 20px 16px 100px; }
  .brand-name { display: none; }
  .menu-toggle { display: block; }
}
@media (max-width: 560px) {
  .target-grid { grid-template-columns: 1fr; }
  .search-hint { display: none; }
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar-actions .btn span:last-child { display: none; }
}
