/* GrepKit Tools — shared styles. Brand carried over from grepkit.com:
   charcoal + signal green, system UI font with a monospace companion. */

:root {
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-pill: 999px;
  --container: 1120px;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde2e8;
  --border-strong: #c3cad3;
  --text: #0d1117;
  --text-2: #2d333b;
  --muted: #57606a;
  --accent: #0b7a4b;
  --accent-hover: #08603b;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(11, 122, 75, 0.1);
  --link: #0b6b43;
  --danger: #b42318;
  --danger-bg: rgba(180, 35, 24, 0.08);
  --warn: #9a5b00;
  --warn-bg: rgba(154, 91, 0, 0.1);
  --add-bg: rgba(11, 122, 75, 0.16);
  --del-bg: rgba(180, 35, 24, 0.14);
  --focus: #1f6feb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07080a; --surface: #0e1116; --surface-2: #151a21; --border: #232a33; --border-strong: #343d48;
    --text: #e8ecf1; --text-2: #c9d1d9; --muted: #96a0ab;
    --accent: #2fd67c; --accent-hover: #5be39a; --accent-contrast: #04140b; --accent-soft: rgba(47, 214, 124, 0.12);
    --link: #5be39a; --danger: #ff7b72; --danger-bg: rgba(255, 123, 114, 0.1); --warn: #e3b341; --warn-bg: rgba(227, 179, 65, 0.12);
    --add-bg: rgba(47, 214, 124, 0.2); --del-bg: rgba(255, 123, 114, 0.2); --focus: #58a6ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07080a; --surface: #0e1116; --surface-2: #151a21; --border: #232a33; --border-strong: #343d48;
  --text: #e8ecf1; --text-2: #c9d1d9; --muted: #96a0ab;
  --accent: #2fd67c; --accent-hover: #5be39a; --accent-contrast: #04140b; --accent-soft: rgba(47, 214, 124, 0.12);
  --link: #5be39a; --danger: #ff7b72; --danger-bg: rgba(255, 123, 114, 0.1); --warn: #e3b341; --warn-bg: rgba(227, 179, 65, 0.12);
  --add-bg: rgba(47, 214, 124, 0.2); --del-bg: rgba(255, 123, 114, 0.2); --focus: #58a6ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--font-ui);
  display: flex; flex-direction: column; min-height: 100vh;
}
main { flex: 1; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: clamp(1.75rem, 1.3rem + 2vw, 2.5rem); letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; letter-spacing: -0.01em; }
h3 { font-size: 1.0625rem; }
p { margin: 0 0 1em; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.9em; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.container { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-contrast); padding: 8px 14px; border-radius: var(--r-sm); font-weight: 600; }
.skip-link:focus { top: 8px; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.site-header .container { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.125rem; }
.brand:hover { color: var(--text); }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--text); display: inline-grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; }
.brand small { font-weight: 500; color: var(--muted); font-size: 0.875rem; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a, .nav button { color: var(--text-2); text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm); font: inherit; font-size: 0.9375rem; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { color: var(--accent); font-weight: 600; }
.nav-toggle { display: none; }
.nav-panel { display: flex; align-items: center; gap: 4px; }
@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .nav-panel { display: none; position: absolute; top: 60px; left: 0; right: 0; background: var(--surface); border-bottom: 1px solid var(--border); flex-direction: column; align-items: stretch; padding: 8px 16px 16px; }
  .nav-panel.open { display: flex; }
  .nav-panel a { padding: 12px; }
}

/* Header tools dropdown */
.nav-menu { position: relative; }
.nav-menu > summary { list-style: none; cursor: pointer; padding: 8px 12px; border-radius: var(--r-sm); color: var(--text-2); font-size: 0.9375rem; }
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after { content: " \25BE"; font-size: 0.75em; }
.nav-menu > summary:hover { background: var(--surface-2); color: var(--text); }
.nav-menu .menu { position: absolute; right: 0; top: calc(100% + 6px); width: 290px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 8px; z-index: 30; display: flex; flex-direction: column; }
.nav-menu .menu a { display: block; padding: 8px 10px; }
.nav-menu .menu-h { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 10px 2px; margin: 0; }
@media (max-width: 720px) { .nav-menu .menu { position: static; width: auto; box-shadow: none; border: 0; padding: 0 0 0 8px; } }

/* Footer */
.site-footer { margin-top: 64px; background: var(--surface); border-top: 1px solid var(--border); padding: 40px 0 28px; font-size: 0.9375rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 28px; }
.footer-grid h2 { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px; }
.footer-grid ul { list-style: none; margin: 0; padding: 0; }
.footer-grid li { margin: 6px 0; }
.footer-grid a { color: var(--text-2); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); text-decoration: underline; }
.disclosure { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.8125rem; }
@media (max-width: 720px) { .footer-grid { grid-template-columns: 1fr 1fr; } .footer-grid > :first-child { grid-column: 1 / -1; } }

/* Hero / page header */
.page-head { padding: 40px 0 24px; }
.eyebrow { display: inline-block; font-size: 0.8125rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 8px; }
.lede { font-size: 1.125rem; color: var(--text-2); max-width: 64ch; }
.breadcrumbs { font-size: 0.875rem; color: var(--muted); margin-bottom: 12px; }
.breadcrumbs a { color: var(--muted); }

/* Cards & panels */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 20px; }
.section { margin-top: 40px; }
.section > h2 { margin-bottom: 12px; }
.prose { max-width: 72ch; }
.prose li { margin: 4px 0; }

.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; list-style: none; margin: 0; padding: 0; }
.tool-card { display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); text-decoration: none; color: var(--text); transition: border-color .15s, transform .15s; }
.tool-card:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }
.tool-card h3 { margin: 0; font-size: 1.0625rem; display: flex; align-items: center; gap: 10px; }
.tool-card p { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.tool-icon { width: 34px; height: 34px; flex: none; border-radius: 9px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-family: var(--font-mono); font-weight: 700; font-size: 0.8125rem; }
.badge { display: inline-block; padding: 2px 8px; border-radius: var(--r-pill); font-size: 0.75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge.adv { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.search-wrap { position: relative; max-width: 520px; margin-top: 20px; }
.search-wrap input[type="search"] { padding-left: 40px; height: 48px; font-size: 1rem; }
.search-wrap svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* Forms */
label, .label { display: block; font-weight: 600; font-size: 0.9375rem; margin-bottom: 6px; }
.hint { font-size: 0.8125rem; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="search"], input[type="number"], input[type="url"], input[type="password"], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: 10px 12px;
}
textarea { min-height: 200px; resize: vertical; font-size: 0.9375rem; line-height: 1.55; }
textarea.mono, .mono { font-family: var(--font-mono); font-size: 0.875rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: transparent; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; margin: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: 0.9375rem; margin-bottom: 6px; padding: 0; }
.field { margin-bottom: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.row.end { justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 820px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-md); overflow: hidden; flex-wrap: wrap; }
.segmented label { margin: 0; font-weight: 500; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: block; padding: 8px 14px; cursor: pointer; border-right: 1px solid var(--border); font-size: 0.9375rem; }
.segmented label:last-child span { border-right: 0; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-contrast); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: 0.9375rem; padding: 10px 16px; border-radius: var(--r-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; min-height: 42px; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 6px 10px; min-height: 34px; font-size: 0.875rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }

/* Output & states */
.output { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; min-height: 120px; overflow-wrap: anywhere; white-space: pre-wrap; font-size: 0.9375rem; }
.output.html-preview { white-space: normal; background: var(--surface); }
.output.html-preview :first-child { margin-top: 0; }
.output.html-preview pre { background: var(--surface-2); padding: 10px; border-radius: var(--r-sm); overflow-x: auto; }
.output.html-preview blockquote { margin: 0 0 1em; padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.output.html-preview table { border-collapse: collapse; }
.output.html-preview th, .output.html-preview td { border: 1px solid var(--border); padding: 4px 8px; }
.empty { color: var(--muted); font-style: italic; }
.status { min-height: 1.5em; font-size: 0.875rem; color: var(--muted); margin: 8px 0 0; }
.status.ok { color: var(--accent); }
.status.err { color: var(--danger); }
.alert { padding: 12px 14px; border-radius: var(--r-md); font-size: 0.9375rem; margin: 12px 0; border: 1px solid transparent; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: currentColor; }
.alert.err { background: var(--danger-bg); color: var(--danger); border-color: currentColor; }
.alert.info { background: var(--accent-soft); color: var(--text-2); }
.alert[hidden] { display: none; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } .tool-card { transition: none; } }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.stat { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 14px; }
.stat b { display: block; font-size: 1.625rem; font-family: var(--font-mono); line-height: 1.2; }
.stat span { font-size: 0.8125rem; color: var(--muted); }
.meter { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.meter > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s; }
.meter.over > i { background: var(--danger); }

.diff ins { background: var(--add-bg); text-decoration: none; border-radius: 3px; }
.diff del { background: var(--del-bg); text-decoration: line-through; border-radius: 3px; }

.callout { display: flex; gap: 12px; padding: 16px; border-radius: var(--r-md); background: var(--accent-soft); }
.callout svg { flex: none; color: var(--accent); margin-top: 2px; }
.callout p { margin: 0; }

.related ul { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }

/* Outline tree */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 22px; border-left: 1px dashed var(--border-strong); margin-left: 10px; }
.tree-item { display: flex; align-items: center; gap: 6px; padding: 4px 0; }
.tree-item .lvl { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); width: 26px; flex: none; }
.tree-item input { padding: 6px 8px; }
.tree-item .btn { min-height: 32px; padding: 4px 8px; }
.tree-note { margin: 0 0 4px 32px; font-size: 0.8125rem; color: var(--muted); white-space: pre-wrap; }

.preview-img { max-height: 360px; display: block; margin: 0 auto; border-radius: var(--r-sm); background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); padding: 28px; text-align: center; color: var(--muted); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
