:root {
  color-scheme: dark;
  --bg: #090f1d;
  --panel: #111a2d;
  --panel-strong: #17223a;
  --line: #2a3853;
  --text: #edf3ff;
  --muted: #adbbd4;
  --accent: #8c79ff;
  --accent-2: #54d5e8;
  --focus: #b7aaff;
  font: 16px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fc;
  --panel: #fff;
  --panel-strong: #edf2fb;
  --line: #cbd6e8;
  --text: #17233a;
  --muted: #4d5c73;
  --accent: #5745cf;
  --accent-2: #086b83;
  --focus: #5140c9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
a:hover { color: var(--accent-2); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
::selection { background: var(--accent); color: white; }
.skip-link { position: absolute; left: 1rem; top: -5rem; background: var(--panel); padding: .6rem 1rem; z-index: 5; }
.skip-link:focus { top: 1rem; }
.container { width: min(100% - 2rem, 1120px); margin-inline: auto; }
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); }
.header-inner { min-height: 76px; display: flex; align-items: center; gap: 1.5rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; text-decoration: none; font-weight: 800; letter-spacing: -.035em; font-size: 1.35rem; white-space: nowrap; }
.brand-mark { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: .65rem; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #090f1d; font-weight: 900; }
.site-nav { display: flex; gap: 1.25rem; margin-left: auto; }
.site-nav a { text-decoration: none; color: var(--muted); }
.site-nav a[aria-current="page"] { color: var(--text); }
.theme-toggle, .button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: .7rem; padding: .6rem .9rem; }
.theme-toggle { white-space: nowrap; }
.button:hover, .theme-toggle:hover { border-color: var(--accent); color: var(--text); }
.button-primary { border-color: transparent; background: linear-gradient(110deg, var(--accent), #6b5ee6); color: white; font-weight: 700; }
.button-primary:hover { filter: brightness(1.12); color: white; }
.button:disabled { opacity: .55; cursor: not-allowed; }
.eyebrow { color: var(--accent-2); font-size: .875rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 750; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.035em; }
h1 { font-size: clamp(2.1rem, 5vw, 4.3rem); margin: .75rem 0 1rem; }
h2 { font-size: clamp(1.55rem, 3vw, 2.1rem); }
p { max-width: 68ch; }
.lead { color: var(--muted); font-size: 1.125rem; }
.hero { padding: clamp(3rem, 8vw, 6.5rem) 0 3rem; }
.hero-copy { max-width: 760px; }
.hero h1 span { background: linear-gradient(100deg, var(--accent), var(--accent-2)); background-clip: text; color: transparent; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: 1.6rem; }
.section { padding: 2.5rem 0 5rem; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.5rem; }
.section-heading h2 { margin: 0; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 1.1rem; padding: 1.5rem; text-decoration: none; }
.card:hover { border-color: var(--accent); color: var(--text); transform: translateY(-2px); }
.card h3 { margin: 1.1rem 0 .45rem; font-size: 1.25rem; }
.card p { color: var(--muted); margin: 0; }
.card-icon { display: inline-grid; place-items: center; width: 2.8rem; height: 2.8rem; border-radius: .75rem; background: var(--panel-strong); color: var(--accent-2); font: 700 1rem/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.site-footer { border-top: 1px solid var(--line); padding: 2rem 0; color: var(--muted); }
.footer-inner { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .75rem; }
.footer-inner p { margin: 0; }
.footer-inner a { color: var(--text); }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: .8rem 1.2rem; }
.card-category { display: inline-block; margin-left: .65rem; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.section-heading p { color: var(--muted); margin: 0; }
.search-label { display: block; font-weight: 700; margin-bottom: .4rem; }
.search-input, .form-grid input, .form-grid select, .tree-actions input, #indent { width: 100%; min-height: 2.8rem; background: var(--panel); border: 1px solid var(--line); border-radius: .65rem; color: var(--text); padding: .55rem .8rem; }
.search-input { max-width: 500px; }
.filter-row { display: flex; gap: .55rem; flex-wrap: wrap; margin: 1rem 0 .5rem; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; color: var(--muted); padding: .4rem .85rem; }
.chip:hover, .chip.is-active { border-color: var(--accent); color: var(--text); background: var(--panel-strong); }
.result-count { color: var(--muted); margin: 0 0 1rem; }
.empty-results { padding: 2rem; border: 1px dashed var(--line); border-radius: 1rem; color: var(--muted); }
.tool-intro { padding: 2.6rem 0 1.5rem; }
.tool-intro h1 { font-size: clamp(2rem, 4vw, 3.3rem); }
.breadcrumbs { color: var(--muted); font-size: .9rem; }
.breadcrumbs a { color: var(--muted); }
.workspace { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.editor-panel { min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .7rem; }
.panel-head label, .panel-head h2 { font-size: 1rem; font-weight: 700; margin: 0; }
.panel-head small { color: var(--muted); }
textarea { display: block; width: 100%; min-height: 360px; resize: vertical; padding: .9rem; border: 1px solid var(--line); border-radius: .65rem; background: var(--bg); color: var(--text); font: .875rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; tab-size: 2; }
textarea[readonly] { color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin: 1rem 0; }
.file-input { max-width: 100%; font-size: .875rem; }
.status { min-height: 1.6em; margin: .65rem 0 0; color: var(--muted); }
.status.error { color: #ff9ba9; }
:root[data-theme="light"] .status.error { color: #b11838; }
.status.success { color: #6fe0b0; }
:root[data-theme="light"] .status.success { color: #11663d; }
.tool-surface { padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: 1.2rem; }
.tool-surface > label, .editor-panel > label, .form-grid label, .tree-actions label { display: block; font-weight: 700; margin-bottom: .5rem; }
.tool-surface textarea { min-height: 240px; margin: .5rem 0; }
.workspace .editor-panel { background: transparent; border: 0; padding: .4rem; }
.workspace .editor-panel:first-child { border-right: 1px solid var(--line); padding-right: 1.4rem; }
.workspace .editor-panel:last-child { padding-left: 1.4rem; }
.file-label { color: var(--muted); font-size: .9rem; }
.file-label input { display: block; max-width: 100%; margin-top: .35rem; }
.toolbar select { min-width: 7rem; width: auto; margin-left: .4rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 1rem; margin: .5rem 0 1rem; }
.form-grid input, .form-grid select { display: block; margin-top: .4rem; font-weight: 400; }
.second-form { margin-top: 2rem; }
.result-box { display: block; padding: 1rem; border-radius: .7rem; border: 1px solid var(--line); background: var(--bg); min-height: 3.5rem; overflow-wrap: anywhere; font: 1rem/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.warning { border-left: 3px solid #f7b457; padding: .6rem .9rem; background: var(--panel-strong); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; margin: 1rem 0; }
.metrics > div { display: grid; gap: .2rem; padding: 1rem; background: var(--panel-strong); border-radius: .8rem; }
.metrics strong { font-size: 1.7rem; line-height: 1.1; }
.metrics span { color: var(--muted); font-size: .9rem; }
.tree-actions { display: flex; align-items: end; flex-wrap: wrap; gap: .5rem; }
.tree-actions label { flex: 1 1 200px; }
.tree-actions input { display: block; margin-top: .4rem; }
.tree { min-height: 240px; max-height: 600px; overflow: auto; margin-top: 1rem; padding: .8rem; border: 1px solid var(--line); border-radius: .7rem; background: var(--bg); font: .9rem/1.6 ui-monospace, SFMono-Regular, Consolas, monospace; }
.tree details { padding-left: 1rem; border-left: 1px solid var(--line); }
.tree summary { cursor: pointer; }
.tree-leaf { display: inline-block; padding-left: 1.1rem; overflow-wrap: anywhere; }
.tree-match > .tree-leaf, .tree-match > details > summary { background: rgba(140,121,255,.28); border-radius: .2rem; }
.info-block { max-width: 830px; margin-top: 2.5rem; color: var(--muted); }
.info-block h2 { color: var(--text); }
.info-block details { border-bottom: 1px solid var(--line); padding: 1rem 0; }
.info-block summary { color: var(--text); cursor: pointer; font-weight: 700; }
.info-block details p { margin-bottom: 0; }
.related { padding-bottom: 4rem; }
.prose { max-width: 830px; padding-block: 3rem 5rem; }
.prose h1 { font-size: clamp(2.1rem, 4vw, 3.3rem); }
.prose p { color: var(--muted); }
.prose a { color: var(--accent-2); }
.content-section { padding: 2rem 0 5rem; }
.content-section p { color: var(--muted); }
.content-section code { color: var(--accent-2); }
@media (max-width: 700px) {
  .header-inner { min-height: 68px; gap: .7rem; flex-wrap: wrap; padding-block: .75rem; }
  .site-nav { margin-left: auto; }
  .workspace { grid-template-columns: 1fr; }
  .workspace .editor-panel:first-child { border-right: 0; border-bottom: 1px solid var(--line); padding: .4rem .4rem 1rem; }
  .workspace .editor-panel:last-child { padding: .4rem; }
  textarea { min-height: 270px; }
  .section-heading { display: block; }
}
@media (max-width: 400px) { .brand { font-size: 1.1rem; } .site-nav { gap: .6rem; } .theme-toggle { padding: .45rem .6rem; } }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .card:hover { transform: none; } }
