/* ============================================================
   BUGFISH TOOLS — tool.css (platform edition)
   The parts of bugfishtm.github.io's style.css the tools use
   (variables, buttons, tool view, tool kit), plus the page
   shell for the platform at the end.
   ============================================================ */

:root {
  color-scheme: dark;

  /* Graphite dark scheme — pulled darker + colder for a scarier mood.
     Same orange accent as before; just less light bleeding in. */
  --bg:           #0a0b0d;   /* page background            */
  --bg2:          #101115;   /* surface / cards            */
  --bg3:          #16171c;   /* raised surface             */
  --bg4:          #1e2026;   /* hover surface              */
  --border:       #23252c;   /* default border             */
  --border2:      #33353f;   /* strong border              */

  /* Orange — unchanged on purpose */
  --orange:       #ff6600;
  --orange-soft:  #ff8533;
  --orange-dim:   #b34700;
  --orange-faint: rgba(255,102,0,0.10);
  --orange-glow:  rgba(255,102,0,0.28);

  /* Blood accent — used sparingly for danger/horror cues */
  --blood:        #c0202a;
  --blood-glow:   rgba(200,32,42,0.22);

  --text:         #b9bac0;
  --text-dim:     #6b6d76;
  --text-mid:     #94969e;
  --text-bright:  #e8e9ea;

  --green:        #2fbf6f;
  --red:          #ff4242;
  --cyan:         #35c9f0;
  --cyan-glow:    rgba(53,201,240,0.28);
  --magenta:      #ff2a6d;

  /* Condensed display face for the landing page — system fonts only
     (Bahnschrift ships with Windows 10+, the rest are platform fallbacks). */
  --display:      "Bahnschrift", "Avenir Next Condensed", "Roboto Condensed", "Arial Narrow", "Segoe UI", system-ui, sans-serif;

  --nav-h:        64px;
  --hud-h:        30px;
  --maxw:         1240px;
  --radius:       10px;
  --font:         'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono:         'Cascadia Code', 'Consolas', 'Courier New', monospace;
  --transition:   0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-color: var(--bg4) var(--bg); }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a  { color: var(--orange-soft); text-decoration: none; }
a:hover { color: var(--orange); }
ul { list-style: none; }
img { max-width: 100%; }
/* The hidden attribute must win over any display rule set by a class. */
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--bg4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--orange-dim); }

::selection { background: var(--orange); color: #0a0b0d; }

/* ---- Global horror atmosphere ----
   A fixed vignette + faint scanlines sit above the page background but
   below all content, so every page feels like it's lit by one dying
   bulb. Pointer-events off so nothing is blocked. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  /* Pure black with alpha darkens exactly like multiply would, without
     forcing a full-screen blend layer (which made mobile scrolling janky). */
  background:
    radial-gradient(ellipse at 50% 32%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.55) 100%),
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 3px, rgba(0,0,0,0.05) 3px 4px);
}
/* Keep real content above the vignette. */
#navbar, main, #footer { position: relative; z-index: 2; }
#navbar { z-index: 1000; }
/* ============================================================
   PAGE SCAFFOLD
   ============================================================ */
main {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: calc(var(--nav-h) + 40px) 24px 64px;
}

main.full-bleed {
  max-width: none;
  padding: var(--nav-h) 0 0;
}

.page-header { margin-bottom: 36px; }

.page-title {
  font-family: var(--mono);
  color: var(--text-bright);
  font-size: clamp(26px, 4vw, 36px);
  letter-spacing: 2px;
  margin-bottom: 10px;
}
.page-title .accent { color: var(--orange); }

.page-sub {
  color: var(--text-dim);
  font-size: 15px;
  max-width: 720px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 38px 0 18px;
}
.section-header:first-child { margin-top: 0; }

.section-title {
  font-family: var(--mono);
  color: var(--orange);
  font-size: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.section-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--border2), transparent);
}

.blink { animation: blink 1.1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--orange);
  color: #16130f;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  line-height: 1.4;
  white-space: nowrap;
  border: 1px solid var(--orange);
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-transform: uppercase;
}
.btn:hover {
  background: var(--orange-soft);
  border-color: var(--orange-soft);
  box-shadow: 0 0 22px var(--orange-glow);
  color: #16130f;
}

.btn.outline {
  background: transparent;
  color: var(--orange);
}
.btn.outline:hover {
  background: var(--orange);
  color: #16130f;
}

.btn.ghost {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--text-mid);
}
.btn.ghost:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: var(--bg3);
  box-shadow: none;
}

.btn.small { padding: 6px 13px; font-size: 11px; letter-spacing: 0.8px; border-radius: 7px; }

.btn.disabled,
.btn:disabled {
  background: var(--bg3);
  border-color: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.55;
  box-shadow: none;
}

/* ============================================================
   EMPTY / ERROR STATES
   ============================================================ */
.news-empty, .load-error {
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 13px;
  padding: 24px;
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  text-align: center;
}

/* ============================================================
   TOOLS — index (technical list, search, categories, tags)
   ============================================================ */
.tools-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tools-toolbar .search-wrap { margin-bottom: 0; flex: 1 1 320px; max-width: 560px; }
.search-kbd {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  border: 1px solid var(--border2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 6px;
  line-height: 18px;
}
.tools-stats {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.tools-stats b { color: var(--orange-soft); }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 18px;
}
.tag {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--text-mid);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
  line-height: 1.5;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  white-space: nowrap;
}
.tag::before { content: "#"; color: var(--orange-dim); }
.tag:hover { color: var(--text-bright); border-color: var(--orange-dim); }
.tag.active { color: var(--orange); border-color: var(--orange); background: var(--orange-faint); }
.tag .tag-n { color: var(--text-dim); margin-left: 5px; font-size: 10px; }
.tag-more { font-style: normal; }
.tag-more::before { content: ""; }

.tools-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin: -6px 0 16px;
}
.tools-filter .tag { cursor: pointer; }
.tools-filter .tag::after { content: " ×"; color: var(--text-dim); }

.tools-recent {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}
.tools-recent a {
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: none;
  color: var(--text-mid);
  border: 1px dashed var(--border2);
  border-radius: 5px;
  padding: 2px 9px;
}
.tools-recent a:hover { color: var(--orange); border-color: var(--orange-dim); }

/* One tool per row. Desktop: id | name + description | tags | arrow.
   The whole row is clickable through a stretched link; the tag
   buttons sit above that link so they filter instead of opening. */
.tool-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  overflow: hidden;
}
.tool-list-head,
.tool-row {
  display: grid;
  grid-template-columns: 58px 132px minmax(0, 1fr) minmax(0, 290px) 36px;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
}
.tool-list-head {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  padding-top: 9px;
  padding-bottom: 9px;
}
.tool-row {
  position: relative;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.tool-row:last-child { border-bottom: none; }
.tool-row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--orange);
  transform: scaleY(0);
  transition: transform 0.25s ease;
}
.tool-row:hover, .tool-row:focus-within { background: var(--bg3); }
.tool-row:hover::before, .tool-row:focus-within::before { transform: scaleY(1); }

.tool-icon {
  width: 50px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--orange);
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 7px;
  letter-spacing: 0;
  overflow: hidden;
  white-space: nowrap;
}
.tool-row:hover .tool-icon { border-color: var(--orange-dim); box-shadow: 0 0 14px var(--orange-faint); }
.tool-id {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tool-id b { color: var(--text-mid); font-weight: 400; }
.tool-main { min-width: 0; }
.tool-link {
  color: var(--text-bright);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.3px;
}
.tool-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.tool-link:focus-visible { outline: none; }
.tool-row:focus-within { outline: 1px solid var(--orange-dim); outline-offset: -1px; }
.tool-row:hover .tool-link { color: var(--orange); }
.tool-desc {
  display: block;
  color: var(--text-mid);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 2px;
}
.tool-flag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 8px;
  vertical-align: 2px;
  white-space: nowrap;
}
.tool-flag.net { color: var(--cyan); border: 1px solid rgba(53,201,240,0.4); }
.tool-flag.game { color: var(--green); border: 1px solid rgba(47,191,111,0.4); }
.tool-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  position: relative;
  z-index: 2;
  justify-content: flex-end;
}
.tool-tags .tag { font-size: 10px; padding: 1px 7px; background: var(--bg); }
.tool-fav {
  position: relative;
  z-index: 2;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 17px;
  cursor: pointer;
  line-height: 1;
  padding: 6px;
  border-radius: 6px;
}
.tool-fav:hover { color: var(--orange-soft); }
.tool-fav.on { color: var(--orange); text-shadow: 0 0 10px var(--orange-glow); }
.tool-empty { padding: 28px; text-align: center; font-family: var(--mono); color: var(--text-dim); font-size: 13px; }
.tools-storage {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
a.tool-privacy:hover { color: var(--text-bright); }

/* Consent box in front of any tool that talks to a third party. */
.tk-consent {
  border: 1px solid rgba(53,201,240,0.4);
  border-left: 3px solid var(--cyan);
  background: rgba(53,201,240,0.05);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.6;
}
.tk-consent .tk-check { align-items: flex-start; font-size: 13px; }
.tk-consent .tk-check input { margin-top: 3px; flex-shrink: 0; }
.tk-consent .tk-note { margin-top: 6px; }
.tk-consent.given { border-color: rgba(47,191,111,0.45); border-left-color: var(--green); background: rgba(47,191,111,0.05); }
.md-remote {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  border: 1px dashed var(--border2);
  border-radius: 6px;
  padding: 6px 10px;
}

/* ============================================================
   TOOLS — single tool view
   ============================================================ */
.tool-crumbs {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}
.tool-crumbs b { color: var(--orange); font-weight: 400; }
.tool-head {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.tool-head .tool-icon { width: 64px; height: 52px; font-size: 15px; flex-shrink: 0; }
.tool-head-body { flex: 1; min-width: 0; }
.tool-title {
  font-family: var(--mono);
  color: var(--text-bright);
  font-size: clamp(21px, 3vw, 28px);
  letter-spacing: 1px;
  line-height: 1.25;
}
.tool-lead { color: var(--text-mid); font-size: 14px; margin: 6px 0 10px; max-width: 860px; }
.tool-head .tool-tags { justify-content: flex-start; }
.tool-privacy {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--green);
  border: 1px solid rgba(47,191,111,0.35);
  border-radius: 4px;
  padding: 1px 7px;
}
.tool-privacy.net { color: var(--cyan); border-color: rgba(53,201,240,0.4); }
.tool-body { min-height: 200px; }
.tool-loading { font-family: var(--mono); color: var(--text-dim); padding: 30px 0; }
.tool-related { margin-top: 36px; }
.tool-related .tool-list-head { grid-template-columns: 1fr; }
.tool-related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.tool-related-grid a {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-bright);
  font-size: 13px;
  font-weight: 600;
  transition: border-color var(--transition), background var(--transition);
}
.tool-related-grid a:hover { border-color: var(--orange-dim); background: var(--bg3); color: var(--orange); }
.tool-related-grid .tool-icon { width: 42px; height: 32px; font-size: 10px; flex-shrink: 0; }

/* ============================================================
   TOOL KIT — shared controls used inside every tool (tk-*)
   ============================================================ */
.tk { display: grid; gap: 16px; }
.tk-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  min-width: 0;
}
.tk-panel > .tk-h:first-child { margin-top: 0; }
.tk-h {
  font-family: var(--mono);
  color: var(--orange);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 18px 0 10px;
}
.tk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tk-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tk-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tk-grid.narrow { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tk-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tk-row.end { justify-content: flex-end; }
.tk-row.tight { gap: 6px; }
.tk-grow { flex: 1 1 200px; min-width: 0; }
.tk-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tk-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.tk-label em { font-style: normal; color: var(--orange-soft); letter-spacing: 1px; }
.tk-input, .tk-textarea, .tk-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--text-bright);
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 11px;
  outline: none;
  caret-color: var(--orange);
  transition: border-color var(--transition), box-shadow var(--transition);
  min-width: 0;
}
.tk-input:focus, .tk-textarea:focus, .tk-select:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-faint);
}
.tk-input::placeholder, .tk-textarea::placeholder { color: var(--text-dim); opacity: 0.8; }
.tk-input[readonly], .tk-textarea[readonly] { background: #08090b; color: var(--text); }
.tk-textarea { min-height: 150px; resize: vertical; line-height: 1.55; tab-size: 2; }
.tk-textarea.short { min-height: 80px; }
.tk-textarea.tall { min-height: 300px; }
.tk-select { cursor: pointer; }
.tk-select option { background: var(--bg2); }
.tk-input[type="color"] { padding: 3px; height: 40px; cursor: pointer; }
.tk-input.sm { width: auto; padding: 6px 9px; }
.tk-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.tk input[type="checkbox"], .tk input[type="radio"], .tk input[type="range"] { accent-color: var(--orange); }
.tk input[type="checkbox"], .tk input[type="radio"] { width: 16px; height: 16px; cursor: pointer; }
.tk input[type="range"] { width: 100%; cursor: pointer; }
.tk-out {
  background: #08090b;
  border: 1px solid var(--border);
  border-left: 3px solid var(--orange);
  border-radius: 7px;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-bright);
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 42px;
  line-height: 1.6;
  max-height: 520px;
  overflow: auto;
}
.tk-out.big { font-size: clamp(20px, 4vw, 30px); letter-spacing: 2px; text-align: center; color: var(--orange); }
.tk-out.nowrap { white-space: pre; word-break: normal; }
.tk-note { font-size: 12px; color: var(--text-dim); line-height: 1.6; }
.tk-note code, .tk code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--orange-soft);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
}
.tk-ok   { color: var(--green) !important; }
.tk-err  { color: var(--red) !important; }
.tk-warn { color: var(--orange-soft) !important; }
.tk-dim  { color: var(--text-dim) !important; }
.tk-msg {
  font-family: var(--mono);
  font-size: 12px;
  padding: 9px 12px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: var(--bg);
}
.tk-msg.ok  { color: var(--green); border-color: rgba(47,191,111,0.45); }
.tk-msg.err { color: var(--red); border-color: rgba(255,66,66,0.45); }
.tk-msg.warn{ color: var(--orange-soft); border-color: var(--orange-dim); }
.tk-msg:empty { display: none; }

/* segmented mode switch */
.tk-seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  padding: 3px;
  max-width: 100%;
}
.tk-seg button {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-mid);
  background: none;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.tk-seg button:hover { color: var(--text-bright); }
.tk-seg button.on { background: var(--orange); color: #16130f; font-weight: 700; }

/* key / value result table */
.tk-kv { display: grid; grid-template-columns: minmax(90px, max-content) minmax(0, 1fr) auto; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tk-kv > * { padding: 8px 12px; border-bottom: 1px solid var(--border); min-width: 0; }
.tk-kv > :nth-last-child(-n+3) { border-bottom: none; }
.tk-kv .k { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); background: var(--bg3); display: flex; align-items: center; }
.tk-kv .v { font-family: var(--mono); font-size: 13px; color: var(--text-bright); word-break: break-all; display: flex; align-items: center; }
.tk-kv .c { display: flex; align-items: center; padding: 4px 8px; }
.tk-kv.nocopy { grid-template-columns: minmax(90px, max-content) minmax(0, 1fr); }
.tk-kv.nocopy > :nth-last-child(-n+3) { border-bottom: 1px solid var(--border); }
.tk-kv.nocopy > :nth-last-child(-n+2) { border-bottom: none; }

.tk-copy {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-mid);
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 5px;
  padding: 3px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.tk-copy:hover { color: var(--orange); border-color: var(--orange-dim); }
.tk-copy.done { color: var(--green); border-color: rgba(47,191,111,0.5); }

.tk-scroll { overflow-x: auto; max-width: 100%; }
.tk-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tk-table th, .tk-table td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tk-table th { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); background: var(--bg3); white-space: nowrap; }
.tk-table td { color: var(--text); }
.tk-table td.mono, .tk-table .mono { font-family: var(--mono); color: var(--text-bright); word-break: break-all; }
.tk-table tr:hover td { background: rgba(255,255,255,0.015); }

.tk-drop {
  border: 1px dashed var(--border2);
  border-radius: 9px;
  padding: 22px 16px;
  text-align: center;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.tk-drop:hover, .tk-drop.over { border-color: var(--orange); background: var(--orange-faint); color: var(--text-bright); }
.tk-drop b { color: var(--orange); font-weight: 400; }

.tk-meter { height: 8px; background: var(--bg4); border-radius: 4px; overflow: hidden; }
.tk-meter > span { display: block; height: 100%; width: 0; background: var(--red); transition: width 0.3s ease, background 0.3s ease; }

.tk-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: 1px solid var(--border2);
  border-radius: 999px;
  padding: 1px 9px;
  color: var(--text-mid);
  white-space: nowrap;
}
.tk-badge.ok { color: var(--green); border-color: rgba(47,191,111,0.45); }
.tk-badge.err { color: var(--red); border-color: rgba(255,66,66,0.45); }
.tk-badge.warn { color: var(--orange-soft); border-color: var(--orange-dim); }
.tk-badge.info { color: var(--cyan); border-color: rgba(53,201,240,0.4); }

.tk-swatch {
  width: 100%;
  height: 64px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  cursor: pointer;
  position: relative;
}
.tk-preview {
  border: 1px solid var(--border2);
  border-radius: 9px;
  background:
    repeating-conic-gradient(#15161a 0% 25%, #1b1c21 0% 50%) 50% / 18px 18px;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.tk-canvas { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
.tk-mark { background: rgba(255,102,0,0.28); color: var(--text-bright); border-bottom: 2px solid var(--orange); border-radius: 2px; }
.tk-mark.alt { background: rgba(53,201,240,0.22); border-bottom-color: var(--cyan); }
.tk-hl-out { white-space: pre-wrap; word-break: break-word; }
.tk-list { display: grid; gap: 6px; }
.tk-list > div { display: flex; gap: 10px; align-items: center; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; font-family: var(--mono); font-size: 13px; color: var(--text-bright); min-width: 0; }
.tk-list > div > span:first-child { flex: 1; min-width: 0; word-break: break-all; }
.tk-stat { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; text-align: center; }
.tk-stat b { display: block; font-family: var(--mono); font-size: 22px; color: var(--text-bright); font-variant-numeric: tabular-nums; }
.tk-stat span { font-family: var(--mono); font-size: 10px; letter-spacing: 1.5px; color: var(--text-dim); text-transform: uppercase; }
.tk-diff-add { background: rgba(47,191,111,0.14); color: #9ff0c3; }
.tk-diff-del { background: rgba(255,66,66,0.13); color: #ffb0b0; }
.tk-diff-add ins, .tk-diff-del del { text-decoration: none; background: rgba(255,255,255,0.14); border-radius: 2px; }

.tk-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  z-index: 2000;
  background: var(--bg3);
  border: 1px solid var(--orange-dim);
  color: var(--text-bright);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 1px;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 32px);
}
.tk-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Markdown preview output */
.md-out { color: var(--text); font-size: 14px; line-height: 1.7; word-break: break-word; }
.md-out h1, .md-out h2, .md-out h3, .md-out h4, .md-out h5, .md-out h6 { color: var(--text-bright); margin: 18px 0 8px; line-height: 1.3; }
.md-out h1 { font-size: 24px; } .md-out h2 { font-size: 20px; } .md-out h3 { font-size: 17px; }
.md-out p, .md-out ul, .md-out ol, .md-out blockquote, .md-out pre, .md-out table { margin: 0 0 12px; }
.md-out ul, .md-out ol { padding-left: 22px; }
.md-out ul { list-style: disc; } .md-out ol { list-style: decimal; }
.md-out li.task { list-style: none; margin-left: -20px; }
.md-out blockquote { border-left: 3px solid var(--orange-dim); padding: 4px 14px; color: var(--text-mid); background: var(--bg3); }
.md-out code { font-family: var(--mono); font-size: 12.5px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; color: var(--orange-soft); }
.md-out pre { background: #08090b; border: 1px solid var(--border); border-radius: 7px; padding: 12px; overflow-x: auto; }
.md-out pre code { border: none; padding: 0; background: none; color: var(--text-bright); }
.md-out table { border-collapse: collapse; display: block; overflow-x: auto; }
.md-out th, .md-out td { border: 1px solid var(--border2); padding: 5px 10px; }
.md-out th { background: var(--bg3); color: var(--text-bright); }
.md-out hr { border: none; border-top: 1px solid var(--border2); margin: 18px 0; }
.md-out img { max-width: 100%; }
.md-out a { text-decoration: underline; }

/* Game boards */
.bp-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.bp-grid { display: grid; gap: 6px; user-select: none; touch-action: manipulation; max-width: 470px; margin: 0 auto; }
.bp-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: clamp(13px, 3.2vw, 18px);
  font-weight: 700;
  color: var(--text-mid);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: default;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  padding: 0;
}
.bp-cell.lane { background: rgba(255,102,0,0.07); border-color: var(--orange-dim); color: var(--text-bright); }
.bp-cell.pick { cursor: pointer; }
.bp-cell.pick:hover { background: var(--orange); color: #16130f; border-color: var(--orange); }
.bp-cell.used { color: var(--border2); background: #07080a; border-style: dashed; }
.bp-cell.hint { box-shadow: inset 0 0 0 2px var(--cyan); }
.bp-buffer { display: flex; gap: 6px; flex-wrap: wrap; }
.bp-slot {
  width: 34px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  border: 1px dashed var(--border2); border-radius: 5px; color: var(--orange);
}
.bp-slot.filled { border-style: solid; border-color: var(--orange-dim); background: var(--orange-faint); }
.bp-daemon { font-family: var(--mono); font-size: 13px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg); }
.bp-daemon .seq span { display: inline-block; padding: 1px 5px; border-radius: 3px; color: var(--text-mid); }
.bp-daemon .seq span.hit { color: #16130f; background: var(--orange); }
.bp-daemon.done { border-color: rgba(47,191,111,0.5); }
.bp-daemon.done .seq span { background: var(--green); color: #0a0b0d; }
.bp-daemon.failed { border-color: rgba(255,66,66,0.4); opacity: 0.6; }
.bp-daemon .name { flex: 1 1 100%; font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-dim); }

.snake-stage { position: relative; max-width: 560px; margin: 0 auto; width: 100%; }
.snake-stage canvas { width: 100%; height: auto; display: block; border: 1px solid var(--border2); border-radius: 9px; background: #07080a; touch-action: none; }
.snake-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center; justify-content: center;
  background: rgba(7,8,10,0.78);
  border-radius: 9px;
  font-family: var(--mono);
  text-align: center;
  padding: 16px;
}
.snake-overlay[hidden] { display: none; }
.snake-overlay h3 { color: var(--orange); letter-spacing: 4px; font-size: 20px; }
.snake-pad { display: none; grid-template-columns: repeat(3, 58px); gap: 8px; justify-content: center; margin-top: 12px; }
.snake-pad button { height: 50px; font-size: 18px; }
.snake-pad .sp { visibility: hidden; }

/* ============================================================
   FOOTER
   ============================================================ */
#footer { margin-top: auto; }
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 26px 24px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--mono);
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: var(--text-dim); transition: color var(--transition); }
.footer-links a:hover { color: var(--orange); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  #nav-burger { display: flex; }

  .nav-menu {
    position: fixed;
    top: var(--nav-h);
    left: 0; right: 0;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 10px 16px 18px;
    margin: 0;
    display: none;
    max-height: calc(100vh - var(--nav-h));
    max-height: calc(100dvh - var(--nav-h));
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 24px 40px rgba(0,0,0,0.5);
  }
  .nav-menu.open { display: flex; }

  .nav-link {
    width: 100%;
    justify-content: space-between;
    padding: 13px 14px;
    font-size: 15px;
  }

  .nav-dropdown::before { content: none; }

  .nav-dropdown {
    position: static;
    opacity: 1;
    visibility: hidden;
    transform: none;
    box-shadow: none;
    border: none;
    border-left: 2px solid var(--border2);
    border-radius: 0;
    background: transparent;
    min-width: 0;
    margin: 0 0 4px 18px;
    padding: 0 0 0 6px;
    display: none;
  }
  .nav-item.open .nav-dropdown { display: block; visibility: visible; }
}

/* Tools list: drop the id column, tags move under the description. */
@media (max-width: 1000px) {
  .tool-list-head { display: none; }
  .tool-row {
    grid-template-columns: 50px minmax(0, 1fr) 36px;
    grid-template-areas: "icon main fav" "icon tags fav";
    row-gap: 8px;
    align-items: start;
    padding: 13px 14px;
  }
  .tool-row .tool-icon { grid-area: icon; }
  .tool-row .tool-id { display: none; }
  .tool-row .tool-main { grid-area: main; }
  .tool-row .tool-tags { grid-area: tags; justify-content: flex-start; }
  .tool-row .tool-fav { grid-area: fav; align-self: center; }
  .bp-wrap { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  main { padding: calc(var(--nav-h) + 28px) 16px 48px; }
  .prose { padding: 28px 20px; }

  .project-card { flex-direction: column; gap: 16px; padding: 20px; }
  .project-img { width: 72px; height: 72px; }
  .project-actions .btn { flex: 1 1 calc(50% - 4px); }

  .explore-card { align-items: flex-start; }
  .explore-img { width: 48px; height: 48px; }

  /* Category tabs become one swipeable strip instead of 3-4 wrapped rows. */
  .cat-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-left: -16px;
    margin-right: -16px;
    padding-left: 16px;
    padding-right: 16px;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
            mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 24px), transparent 100%);
  }
  .cat-tabs::-webkit-scrollbar { display: none; }
  .cat-tab { flex-shrink: 0; }

  /* Tag cloud + recent tools: one swipeable line each on phones. */
  .tag-cloud, .tools-recent {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-left: -16px;
    margin-right: -16px;
    padding: 0 16px 2px;
  }
  .tag-cloud::-webkit-scrollbar, .tools-recent::-webkit-scrollbar { display: none; }
  .tag-cloud > *, .tools-recent > * { flex-shrink: 0; white-space: nowrap; }
  .tools-toolbar { gap: 8px; }

  .tk-panel { padding: 14px; }
  .tk-grid.two, .tk-grid.three { grid-template-columns: minmax(0, 1fr); }
  .tk-kv { grid-template-columns: minmax(0, 1fr) auto; }
  .tk-kv .k { grid-column: 1 / -1; border-bottom: none; padding-bottom: 2px; background: none; }
  .tk-kv.nocopy { grid-template-columns: minmax(0, 1fr); }
  .tool-head { gap: 12px; }
  .tool-head .tool-icon { width: 50px; height: 42px; font-size: 12px; }
  .tool-row { grid-template-columns: 44px minmax(0, 1fr) 32px; column-gap: 12px; }
  .tool-row .tool-icon { width: 44px; height: 34px; font-size: 11px; }
}

/* Touch screens: on-screen controls for the games, no keyboard hints,
   and 16px form text so iOS Safari does not zoom into focused inputs. */
@media (hover: none) and (pointer: coarse) {
  .snake-pad { display: grid; }
  .search-kbd { display: none; }
  .search-input, .tk-input, .tk-textarea, .tk-select { font-size: 16px; }
}

@media (max-width: 460px) {
  .section-title { font-size: 14px; letter-spacing: 2px; }
}

/* Reduce motion for users that prefer it */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}


/* ============================================================
   PLATFORM SHELL — bar with the way back, footer
   ============================================================ */
:root { --nav-h: 0px; }
.pf-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 24px;
  background: rgba(10, 11, 13, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.pf-bar .tool-crumbs { margin: 0; }
.tool-head .tag { cursor: default; }
@media (max-width: 600px) {
  .pf-bar { padding: 8px 16px; gap: 10px; }
}
