/* ===================================================================
   BrowserTools — design tokens
   Palette:
     --bg        #EEF1F3  cool paper (not the cliché warm cream)
     --ink       #14181C  near-black text
     --ink-soft  #4A5560  secondary text
     --line      #D6DBDE  hairline borders
     --panel     #FFFFFF  card surfaces
     --brand     #2452FF  primary accent (links, primary actions)
     --led-idle  #9AA5AC  status dot at rest
     --led-live  #FFB020  status dot while processing (amber, like a
                 drive light) — never green-on-black, that's the default
     --led-done  #1FAE6E  status dot on success
   Type:
     display/utility: "IBM Plex Mono" — technical, dev-tool register
     body:            "IBM Plex Sans" — clean, humanist companion
   =================================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&display=swap');

:root {
  --bg: #EEF1F3;
  --ink: #14181C;
  --ink-soft: #4A5560;
  --line: #D6DBDE;
  --panel: #FFFFFF;
  --brand: #2452FF;
  --brand-soft: #E7ECFF;
  --led-idle: #9AA5AC;
  --led-live: #FFB020;
  --led-done: #1FAE6E;
  --radius: 6px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3, .mono {
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
}

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

/* Visible keyboard focus everywhere */
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- Layout shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
/* Mobile shell/sidenav rules handled in the mobile-responsive section below */


.sidenav {
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidenav .brand {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
}
.sidenav h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin: 20px 0 8px;
}
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav li a {
  display: block;
  padding: 6px 8px;
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 14px;
}
.sidenav li a:hover { background: var(--brand-soft); text-decoration: none; }
.sidenav li a.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }

.main { padding: 32px clamp(20px, 5vw, 56px) 80px; max-width: 920px; }

/* ---------- Status LED — the signature element ---------- */
.led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--led-idle);
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.led[data-state="live"] {
  background: var(--led-live);
  animation: pulse 0.9s ease-in-out infinite;
}
.led[data-state="done"] {
  background: var(--led-done);
  animation: none;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,176,32,0.5); }
  50% { box-shadow: 0 0 0 5px rgba(255,176,32,0); }
}
@media (prefers-reduced-motion: reduce) {
  .led[data-state="live"] { animation: none; opacity: 0.8; }
}

.led-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  text-transform: uppercase;
}
.led-row { display: flex; align-items: center; gap: 6px; }

/* ---------- Cards (homepage grid) ---------- */
.category { margin-bottom: 40px; }
.category h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 16px;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: block;
  color: var(--ink);
}
.card:hover { border-color: var(--brand); text-decoration: none; }
.card .name { font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.card .desc { font-size: 13px; color: var(--ink-soft); }

/* ---------- Tool page furniture ---------- */
.tool-header { margin-bottom: 20px; }
.tool-header h1 { font-size: 22px; margin: 0 0 6px; }
.tool-header p { color: var(--ink-soft); margin: 0; font-size: 14.5px; }

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 28px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 14px;
  cursor: pointer;
}
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); }

textarea, input[type="text"] {
  width: 100%;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13.5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel);
  color: var(--ink);
  resize: vertical;
}

.btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13.5px;
  font-weight: 500;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 10px 18px;
  cursor: pointer;
}
.btn:hover { background: #1a3fd6; }
.btn:disabled { background: var(--led-idle); cursor: not-allowed; }
.btn.secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}

/* --- Unused — re-add when a real ad network is wired in ---
.ad-slot {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.05em;
  margin: 20px 0;
}
.ad-slot.anchor {
  position: sticky;
  bottom: 0;
}
--- */

.faq { margin-top: 40px; border-top: 1px solid var(--line); padding-top: 24px; }
.faq h3 { font-size: 15px; margin-bottom: 6px; }
.faq p { color: var(--ink-soft); font-size: 14px; }

.output-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 320px;
  overflow-y: auto;
}

/* ---------- Site footer (About & Privacy links) ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 16px clamp(20px, 5vw, 56px);
  font-size: 12.5px;
  color: var(--ink-soft);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-left: 220px; /* matches sidenav width on desktop */
}
@media (max-width: 860px) {
  .site-footer { margin-left: 0; }
}
.site-footer a { color: var(--ink-soft); }
.site-footer a:hover { color: var(--brand); text-decoration: underline; }

/* Sidenav footer links (shown inside the sidenav at bottom) */
.sidenav-footer {
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 12px;
}
.sidenav-footer a { color: var(--ink-soft); }
.sidenav-footer a:hover { color: var(--brand); text-decoration: underline; }


/* ---------- Mobile header (hamburger) ---------- */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  align-items: center;
  justify-content: space-between;
}
.mobile-header .brand-mobile {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  text-decoration: none;
}
.hamburger {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
/* Overlay when nav is open */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 150;
}
.nav-overlay.open { display: block; }

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

  .mobile-header { display: flex; }

  /* Sidenav becomes a slide-in drawer */
  .sidenav {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    z-index: 160;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    overflow-y: auto;
    background: var(--bg);
  }
  .sidenav.open { transform: translateX(0); }

  .main {
    padding: 20px 16px 64px;
    min-width: 0;
    overflow-x: hidden;
  }

  /* Card grid: 2 cols on tablet */
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
  .tool-header h1 { font-size: 18px; }
}

/* Global overflow guards */
body { overflow-x: hidden; }
textarea, input[type="text"], select {
  max-width: 100%;
  box-sizing: border-box;
}
.btn { max-width: 100%; }

/* ---------- pdf-to-images thumbnail grid (responsive) ---------- */
#pages {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.page-thumb canvas { max-width: min(120px, 40vw) !important; height: auto !important; }

/* ---------- pdf-merge file-list rows (responsive) ---------- */
@media (max-width: 540px) {
  .file-row {
    flex-wrap: wrap;
    gap: 6px;
  }
}

/* ---------- regex-tester flag checkboxes row ---------- */
.flag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
}
.flag-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13.5px;
  cursor: pointer;
  white-space: nowrap;
}
