/* ── Reset & Variables ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0c0d0f;
  --bg2: #131418;
  --bg3: #1a1b20;
  --border: #252730;
  --border2: #2e3040;
  --text: #e8eaf0;
  --muted: #6b7080;
  --accent: #5865f2;
  --accent2: #7c84f5;
  --accent-dim: rgba(88,101,242,0.12);
  --green: #3dd68c;
  --red: #f25858;
  --yellow: #f2c55a;
  --mono: 'Space Mono', monospace;
  --sans: 'DM Sans', sans-serif;
  --radius: 8px;
  --radius-lg: 14px;
}

html { font-size: 15px; scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: var(--sans); font-weight: 400; line-height: 1.6; min-height: 100vh; }

/* ── Typography ───────────────────────────────────────────────── */
h1,h2,h3 { font-weight: 600; line-height: 1.25; }
a { color: var(--accent2); text-decoration: none; }
a:hover { color: var(--text); }
.mono { font-family: var(--mono); }

/* ── Layout ────────────────────────────────────────────────────── */
.container { max-width: 1280px; margin: 0 auto; padding: 0 1.5rem; }

/* ── Header ─────────────────────────────────────────────────────  */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(12,13,15,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
}
.header-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; gap: 1rem;
  height: 58px;
}
.logo {
  font-family: var(--mono); font-size: 1.1rem; font-weight: 700;
  color: var(--text); text-decoration: none; white-space: nowrap;
  letter-spacing: -0.02em;
}
.logo-bracket { color: var(--accent); }
.logo-text { color: var(--text); }
.logo:hover .logo-text { color: var(--accent2); }

/* ── Search ─────────────────────────────────────────────────────  */
.search-form {
  display: flex; align-items: center; gap: 0;
  flex: 1; max-width: 500px; margin-left: auto;
  border: 1px solid var(--border2); border-radius: var(--radius);
  overflow: hidden; background: var(--bg2);
  transition: border-color .2s;
}
.search-form:focus-within { border-color: var(--accent); }
.search-form input {
  flex: 1; background: transparent; border: none; outline: none;
  padding: .5rem .875rem; color: var(--text); font-family: var(--sans); font-size: .9rem;
}
.search-form input::placeholder { color: var(--muted); }
.search-btn {
  background: transparent; border: none; color: var(--muted);
  padding: .5rem .75rem; cursor: pointer; font-family: var(--mono);
  font-size: .85rem; transition: color .2s;
}
.search-btn:hover { color: var(--accent2); }

/* ── Hero ────────────────────────────────────────────────────── */
.hero {
  position: relative; overflow: hidden;
  padding: 5rem 1.5rem 4rem;
  border-bottom: 1px solid var(--border);
}
.hero-inner { position: relative; z-index: 1; max-width: 1280px; margin: 0 auto; }
.hero-title {
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 700; letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text);
}
.hero-accent {
  color: var(--accent);
  font-family: var(--mono);
}
.hero-sub {
  margin-top: 1rem; color: var(--muted); font-size: 1rem;
  letter-spacing: 0.05em; text-transform: uppercase; font-size: .8rem;
}
.hero-grid-bg {
  position: absolute; inset: 0; z-index: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: .35;
  mask-image: radial-gradient(ellipse 80% 80% at 0% 50%, black 20%, transparent 80%);
}

/* ── Category nav ────────────────────────────────────────────── */
.cat-nav {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; white-space: nowrap;
}
.cat-nav .container { display: flex; gap: .5rem; flex-wrap: wrap; }
.cat-pill {
  display: inline-block; padding: .3rem .8rem;
  border: 1px solid var(--border2); border-radius: 999px;
  font-size: .8rem; color: var(--muted); text-decoration: none;
  transition: all .15s;
}
.cat-pill:hover { border-color: var(--accent); color: var(--accent2); }
.cat-pill.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent2); }

/* ── Page body ───────────────────────────────────────────────── */
.page-body { padding: 2.5rem 1.5rem 4rem; }

/* ── Tool section ────────────────────────────────────────────── */
.tool-section { margin-bottom: 3rem; }
.section-header {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.section-title {
  font-size: 1rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.section-count {
  font-family: var(--mono); font-size: .75rem; color: var(--accent);
  background: var(--accent-dim); padding: .1rem .5rem; border-radius: 999px;
}

/* ── Tool grid ───────────────────────────────────────────────── */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .75rem;
}
.tool-card {
  display: block; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg2);
  transition: border-color .15s, transform .15s, background .15s;
}
.tool-card:hover {
  border-color: var(--accent); background: var(--bg3);
  transform: translateY(-2px);
  color: inherit;
}
.tool-card-inner { padding: 1.1rem 1.2rem; }
.tool-name { font-size: .92rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.tool-desc { font-size: .78rem; color: var(--muted); line-height: 1.5; margin-bottom: .6rem; }
.tool-tags { display: flex; flex-wrap: wrap; gap: .3rem; }
.tag {
  font-family: var(--mono); font-size: .65rem;
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--muted); padding: .1rem .4rem; border-radius: 4px;
}

/* ── Search results header ────────────────────────────────────── */
.search-results-header { padding: 1.5rem 1.5rem .5rem; }
.search-results-header h2 { font-size: 1.1rem; color: var(--muted); }
.search-results-header span { color: var(--text); }
.clear-link { font-size: .85rem; color: var(--muted); text-decoration: underline; }

/* ── Tool page ───────────────────────────────────────────────── */
.tool-page-wrap {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 58px);
  max-width: 1280px; margin: 0 auto;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.tool-sidebar {
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
}
.sidebar-inner { padding: 0 1rem; position: sticky; top: 70px; max-height: calc(100vh - 80px); overflow-y: auto; }
.sidebar-cat-link {
  display: block; font-size: .75rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: 1rem;
}
.sidebar-tools { list-style: none; }
.sidebar-tools li { margin-bottom: .15rem; }
.sidebar-tools a {
  display: block; font-size: .82rem; color: var(--muted);
  padding: .3rem .6rem; border-radius: 6px; transition: all .15s;
}
.sidebar-tools a:hover { color: var(--text); background: var(--bg3); }
.sidebar-tools li.active a {
  color: var(--accent2); background: var(--accent-dim);
  font-weight: 500;
}

/* ── Main tool area ──────────────────────────────────────────── */
.tool-main { padding: 2.5rem 2rem; max-width: 820px; }
.tool-header { margin-bottom: 2rem; }
.tool-header-meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.cat-badge {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent2); border: 1px solid var(--accent); border-radius: 4px;
  padding: .1rem .5rem;
}
.tool-page-title { font-size: 2rem; font-weight: 700; margin-bottom: .5rem; }
.tool-page-desc { color: var(--muted); font-size: .95rem; }

/* ── Input card ──────────────────────────────────────────────── */
.tool-card-box {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1.25rem;
}
.input-group { margin-bottom: 1rem; }
.input-group label {
  display: block; font-size: .78rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: .4rem;
}
.tool-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border2);
  border-radius: var(--radius); color: var(--text);
  padding: .6rem .875rem; font-family: var(--mono); font-size: .85rem;
  transition: border-color .15s; outline: none; resize: vertical;
}
.tool-input:focus { border-color: var(--accent); }
select.tool-input { appearance: none; cursor: pointer; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: .75rem; }
.checkbox-group label { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--text); text-transform: none; letter-spacing: 0; }
.form-note { font-size: .8rem; color: var(--muted); margin-bottom: 1rem; font-style: italic; }

.run-btn {
  background: var(--accent); color: #fff;
  border: none; padding: .65rem 1.75rem;
  border-radius: var(--radius); font-family: var(--mono); font-size: .85rem;
  cursor: pointer; transition: background .15s;
}
.run-btn:hover { background: var(--accent2); }

/* ── Result box ──────────────────────────────────────────────── */
.result-box { border-color: var(--accent); }
.result-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
}
.result-label {
  font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--accent2);
}
.copy-all-btn {
  background: transparent; border: 1px solid var(--border2);
  color: var(--muted); padding: .25rem .65rem; border-radius: 6px;
  font-size: .75rem; cursor: pointer; transition: all .15s;
}
.copy-all-btn:hover { border-color: var(--accent); color: var(--accent2); }

.result-row {
  display: flex; gap: 1rem; align-items: flex-start;
  padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.result-row:last-child { border-bottom: none; }
.result-row.big { flex-direction: column; gap: .4rem; }
.result-key { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); min-width: 140px; flex-shrink: 0; padding-top: .1rem; }
.result-value { font-family: var(--mono); font-size: .875rem; color: var(--text); word-break: break-all; }
.result-pre {
  font-family: var(--mono); font-size: .82rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; padding: .75rem 1rem; overflow-x: auto;
  white-space: pre-wrap; word-break: break-all;
}
.result-error {
  color: var(--red); font-family: var(--mono); font-size: .85rem;
  background: rgba(242,88,88,.08); border: 1px solid rgba(242,88,88,.2);
  border-radius: 6px; padding: .75rem 1rem;
}

/* ── Special result renderers ────────────────────────────────── */
.shift-table, .truth-table-wrap { overflow-x: auto; }
.shift-table table, .truth-table { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: .82rem; }
.shift-table th, .truth-table th { text-align: left; padding: .4rem .7rem; color: var(--muted); border-bottom: 1px solid var(--border2); font-size: .75rem; text-transform: uppercase; }
.shift-table td, .truth-table td { padding: .4rem .7rem; border-bottom: 1px solid var(--border); }
.shift-table tr.highlight td { background: var(--accent-dim); color: var(--accent2); }
.tt-true { color: var(--green); }
.tt-false { color: var(--red); }

.color-preview-box { display: flex; gap: 1.5rem; align-items: flex-start; }
.color-swatch { width: 80px; height: 80px; border-radius: var(--radius); border: 1px solid var(--border); flex-shrink: 0; }
.color-values { flex: 1; }

.uuid-list { display: flex; flex-direction: column; gap: .4rem; }
.uuid-item { font-family: var(--mono); font-size: .85rem; padding: .4rem .6rem; background: var(--bg); border-radius: 6px; color: var(--text); }

.word-chips { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem 0; }
.word-chip { font-family: var(--mono); font-size: .82rem; padding: .25rem .6rem; background: var(--accent-dim); border: 1px solid var(--accent); border-radius: 6px; color: var(--accent2); }

.kakuro-combos { display: flex; flex-wrap: wrap; gap: .4rem; padding: .5rem 0; }
.combo-tag { font-family: var(--mono); font-size: .8rem; padding: .2rem .55rem; background: var(--bg); border: 1px solid var(--border2); border-radius: 6px; color: var(--text); }

.element-card .result-row { padding: .5rem 0; }

/* ── API hint ─────────────────────────────────────────────────── */
.api-hint {
  margin-top: 1.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.api-hint summary {
  padding: .7rem 1rem; cursor: pointer; font-size: .8rem;
  color: var(--muted); background: var(--bg2); text-transform: uppercase; letter-spacing: .06em;
}
.api-hint summary:hover { color: var(--text); }
.code-block {
  font-family: var(--mono); font-size: .78rem; color: var(--text);
  background: var(--bg); padding: 1rem 1.25rem;
  overflow-x: auto; white-space: pre;
}

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 5rem 2rem; color: var(--muted); }
.empty-state .mono { font-size: 1.1rem; margin-bottom: 1rem; }
.empty-state a { color: var(--accent2); }

/* ── Footer ───────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem; text-align: center;
  color: var(--muted); font-size: .8rem;
}
.site-footer .container { max-width: 1280px; margin: 0 auto; }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
  .tool-page-wrap { grid-template-columns: 1fr; }
  .tool-sidebar { display: none; }
  .tool-main { padding: 1.5rem 1rem; max-width: 100%; }
}
@media (max-width: 600px) {
  .hero { padding: 3rem 1rem 2.5rem; }
  .hero-title { font-size: 2.5rem; }
  .tool-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 1.5rem 1rem 3rem; }
}
@media (max-width: 400px) {
  .tool-grid { grid-template-columns: 1fr; }
}

/* ── Breadcrumb ───────────────────────────────────────────────── */
.breadcrumb {
  padding: .6rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.breadcrumb .container { max-width: 1280px; margin: 0 auto; }
.breadcrumb ol {
  list-style: none; display: flex; flex-wrap: wrap;
  gap: .25rem; align-items: center;
  font-size: .78rem; color: var(--muted);
}
.breadcrumb li + li::before { content: '/'; margin-right: .25rem; color: var(--border2); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent2); }
.breadcrumb li[aria-current="page"] { color: var(--text); }

/* ── SEO content block ────────────────────────────────────────── */
.tool-about {
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: .875rem;
  color: var(--muted);
  line-height: 1.7;
}
.tool-about h2 {
  font-size: .85rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: .75rem; font-weight: 600;
}
.tool-about p { margin-bottom: .6rem; }
.tool-about a { color: var(--accent2); }
.tool-about strong { color: var(--text); }
.tool-keywords { font-family: var(--mono); font-size: .75rem; }

/* ── Home SEO content ─────────────────────────────────────────── */
.seo-content {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: .875rem;
  color: var(--muted);
  line-height: 1.8;
}
.seo-content h2 {
  font-size: 1.1rem; font-weight: 600; color: var(--text);
  margin-bottom: .75rem;
}
.seo-content h3 {
  font-size: .85rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin: 1.25rem 0 .5rem; font-weight: 600;
}
.seo-content ul { padding-left: 1.25rem; }
.seo-content li { margin-bottom: .35rem; }
.seo-content a { color: var(--accent2); }

/* ── Hero description ─────────────────────────────────────────── */
.hero-desc {
  margin-top: .75rem; color: var(--muted);
  font-size: .9rem; max-width: 560px;
  line-height: 1.7;
}

/* ── Category intro ───────────────────────────────────────────── */
.cat-intro {
  color: var(--muted); font-size: .9rem; margin-top: .35rem;
}

/* ── Footer nav ───────────────────────────────────────────────── */
.footer-nav {
  display: flex; flex-wrap: wrap; gap: .75rem 1.25rem;
  justify-content: center; margin-bottom: .75rem;
}
.footer-nav a {
  font-size: .8rem; color: var(--muted); text-decoration: none;
}
.footer-nav a:hover { color: var(--accent2); }
.footer-tagline { margin-top: .5rem; }

/* ── Blog ─────────────────────────────────────────────────────── */
.blog-index-header { padding: 2rem 0 1.5rem; }
.blog-index-header h1 { font-size: 1.8rem; margin-bottom: .5rem; }
.blog-index-header p { color: var(--muted); }

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem; padding: 1.5rem 0 4rem;
}
.blog-card {
  display: block; text-decoration: none;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--bg2); transition: border-color .15s, transform .15s;
}
.blog-card:hover { border-color: var(--accent); transform: translateY(-2px); color: inherit; }
.blog-card-inner { padding: 1.4rem; }
.blog-card-title { font-size: 1rem; font-weight: 600; margin: .6rem 0 .5rem; color: var(--text); }
.blog-card-desc { font-size: .82rem; color: var(--muted); line-height: 1.6; margin-bottom: .75rem; }
.blog-date { font-family: var(--mono); font-size: .72rem; color: var(--muted); }

.blog-post { max-width: 720px; margin: 2rem auto 4rem; }
.blog-post-header { margin-bottom: 2rem; }
.blog-post-header h1 { font-size: 1.8rem; margin: .6rem 0 .75rem; line-height: 1.3; }
.blog-post-desc { color: var(--muted); font-size: .95rem; margin-bottom: .75rem; }
.blog-post-body { line-height: 1.8; color: var(--text); }
.blog-post-body h2 { font-size: 1.2rem; margin: 2rem 0 .75rem; }
.blog-post-body h3 { font-size: 1rem; margin: 1.5rem 0 .5rem; color: var(--accent2); }
.blog-post-body p { margin-bottom: 1rem; color: var(--muted); }
.blog-post-body ul { padding-left: 1.5rem; margin-bottom: 1rem; }
.blog-post-body li { margin-bottom: .4rem; color: var(--muted); }
.blog-post-body a { color: var(--accent2); }
.blog-post-body code { font-family: var(--mono); font-size: .82rem; background: var(--bg3); padding: .1rem .4rem; border-radius: 4px; }
.blog-post-body strong { color: var(--text); }
.blog-post-footer { margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: .85rem; }
.blog-post-footer a { color: var(--accent2); }

/* ── Blog nav link ────────────────────────────────────────────── */
.nav-blog-link {
  font-size: .85rem; color: var(--muted); text-decoration: none;
  white-space: nowrap; padding: .3rem .6rem;
  border: 1px solid var(--border2); border-radius: var(--radius);
  transition: all .15s;
}
.nav-blog-link:hover { color: var(--accent2); border-color: var(--accent); }
