:root {
  color-scheme: light;
  --ink: #201b2b;
  --muted: #625d6c;
  --purple: #5b21b6;
  --purple-dark: #43158f;
  --purple-pale: #f3edff;
  --cyan: #00b8c8;
  --line: #e7e3ed;
  --surface: #ffffff;
  --wash: #faf9fc;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 130px; }
body { margin: 0; background: var(--surface); color: var(--ink); font-size: 16px; line-height: 1.65; }
a { color: var(--purple); text-decoration-thickness: .08em; text-underline-offset: .18em; }
a:hover { color: var(--purple-dark); }
:focus-visible { outline: 3px solid #006b75; outline-offset: 3px; border-radius: 4px; }
button, input, select { font: inherit; }
input, select { min-height: 48px; font-size: 16px; }
.page-width { width: min(1120px, calc(100% - 36px)); margin-inline: auto; }

.site-header { position: sticky; z-index: 10; top: 0; border-bottom: 1px solid var(--line); background: rgb(255 255 255 / 94%); backdrop-filter: blur(14px); }
.header-inner { width: min(1200px, calc(100% - 32px)); min-height: 68px; margin-inline: auto; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 20px; padding-block: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; color: var(--ink); font-size: 16px; font-weight: 760; letter-spacing: -.025em; text-decoration: none; white-space: nowrap; }
.brand-mark { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 11px; background: var(--purple); color: #fff; font-size: 13px; letter-spacing: -.04em; }
.anchor-nav { display: flex; flex: 1 1 100%; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: thin; }
.anchor-nav a { display: inline-flex; min-height: 44px; flex: 0 0 auto; align-items: center; padding-inline: 12px; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 650; text-decoration: none; }
.anchor-nav a:hover { background: var(--purple-pale); color: var(--purple); }

.hero { position: relative; overflow: hidden; margin-top: 28px; padding: 48px 24px 30px; border: 1px solid #e8e0f5; border-radius: 26px; background: linear-gradient(135deg, #fbf9ff 0%, #fff 62%, #f0fdff 100%); }
.hero::after { position: absolute; top: -90px; right: -54px; width: 210px; height: 210px; border: 26px solid rgb(0 184 200 / 12%); border-radius: 50%; content: ""; pointer-events: none; }
.eyebrow { margin: 0 0 10px; color: var(--purple); font-size: 12px; font-weight: 800; letter-spacing: .13em; line-height: 1.4; }
h1, h2, h3 { color: var(--ink); line-height: 1.16; letter-spacing: -.035em; }
h1 { max-width: 760px; margin: 0; font-size: clamp(2.5rem, 9vw, 4.8rem); }
.hero-lede { max-width: 680px; margin: 18px 0 0; color: var(--muted); font-size: clamp(1rem, 2.5vw, 1.18rem); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: 10px 18px; border: 1px solid transparent; border-radius: 12px; font-weight: 720; text-decoration: none; transition: transform .16s ease, background-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--purple); color: #fff; }
.button-primary:hover { background: var(--purple-dark); color: #fff; }
.button-secondary { border-color: #d9c9f2; background: #fff; color: var(--purple); }
.stats { display: flex; flex-wrap: wrap; gap: 12px 26px; margin-top: 34px; padding-top: 20px; border-top: 1px solid var(--line); }
.stats div { display: flex; align-items: baseline; gap: 7px; }
.stats strong { color: var(--purple); font-size: 23px; line-height: 1; }
.stats span { color: var(--muted); font-size: 14px; }

.library-section { padding-block: 66px 42px; }
#library { scroll-margin-top: 130px; }
.section-heading { max-width: 720px; }
.section-heading h2, .content-wrap h2 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.5rem); }
.section-heading > p:last-child { margin: 12px 0 0; color: var(--muted); }
.library-controls { display: grid; gap: 14px; margin-top: 26px; }
.library-controls label { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 700; }
.library-controls input, .library-controls select { width: 100%; padding: 10px 13px; border: 1px solid #d9d4e1; border-radius: 11px; background: #fff; color: var(--ink); }
.library-controls input::placeholder { color: #8a8492; }
.library-controls input:focus, .library-controls select:focus { border-color: var(--purple); outline: 3px solid rgb(91 33 182 / 15%); }
.result-count { min-height: 24px; margin: 20px 0 12px; color: var(--muted); font-size: 14px; }
.card-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; margin: 0; padding: 0; list-style: none; }
.card-grid > li, .script-card { min-width: 0; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; box-shadow: 0 5px 18px rgb(32 27 43 / 4%); }
.card-grid > li:hover, .script-card:hover { border-color: #cbb5ef; box-shadow: 0 10px 25px rgb(51 23 92 / 9%); }
.card-grid h3, .script-card h3 { margin: 0 0 8px; font-size: 18px; }
.card-grid p, .script-card p { color: var(--muted); }
.card-grid button, .script-card button { min-height: 44px; padding: 8px 13px; border: 0; border-radius: 10px; background: var(--purple-pale); color: var(--purple); cursor: pointer; font-weight: 700; }
.card-grid button:hover, .script-card button:hover { background: #e7dafa; }
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0 0; }
.card-actions a { color: var(--purple); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.bookmarklet-link { display: inline-flex; min-height: 44px; align-items: center; padding: 8px 13px; border: 2px dashed var(--purple); border-radius: 10px; background: #fff; color: var(--purple); font-weight: 700; text-decoration: none; cursor: grab; }
.bookmarklet-link:hover { background: var(--purple-pale); }
.bookmarklet-link.unavailable { border-color: #b8b2c1; color: #8a8492; cursor: not-allowed; }
.runner-note { margin: 14px 0 0; padding: 14px 16px; border: 1px solid #d9c9f2; border-radius: var(--radius); background: #f6f0ff; color: var(--ink); font-size: 14px; }
.runner-note strong { color: var(--purple); }
.run-button { background: var(--purple) !important; color: #fff !important; }
.run-button:hover { background: var(--purple-dark) !important; }
.exec-modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgb(32 27 43 / 55%); }
.exec-modal[hidden] { display: none; }
.exec-panel { display: flex; flex-direction: column; width: min(720px, 100%); max-height: 82vh; border-radius: 14px; background: #fff; box-shadow: 0 24px 60px rgb(32 27 43 / 30%); }
.exec-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.exec-head h3 { margin: 0; font-size: 17px; }
.exec-head button { min-height: 38px; padding: 6px 14px; border: 0; border-radius: 9px; background: var(--purple-pale); color: var(--purple); font-weight: 700; cursor: pointer; }
.exec-status { margin: 0; padding: 10px 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.exec-log { flex: 1; overflow: auto; padding: 12px 18px; background: #1d1a26; color: #e8e4f0; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; line-height: 1.55; min-height: 180px; }
.log-line { display: flex; gap: 10px; }
.log-time { flex: none; color: #8a8492; }
.log-warn span:last-child { color: #ffd166; }
.log-error span:last-child { color: #ff8fa3; }
.log-info span:last-child { color: #9be8ff; }
.exec-foot { margin: 0; padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.toast { position: fixed; z-index: 20; right: 16px; bottom: 16px; max-width: min(360px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: 0 8px 28px rgb(32 27 43 / 20%); }
.toast:empty { display: none; }

.content-wrap { width: min(900px, calc(100% - 36px)); margin: 0 auto; }
.content-wrap section { padding-block: 34px; border-top: 1px solid var(--line); scroll-margin-top: 130px; }
.content-wrap section > .eyebrow { margin-bottom: 9px; }
.content-wrap h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
.content-wrap p { color: var(--muted); }
.content-placeholder { min-width: 0; overflow-wrap: anywhere; }
.content-placeholder > * { max-width: 100%; }
.content-wrap table { display: block; width: 100%; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.content-wrap table:focus { outline: 3px solid #006b75; outline-offset: 2px; }
.content-wrap table { scrollbar-color: var(--purple) var(--purple-pale); }
.content-wrap caption { padding: 0 0 8px; color: var(--muted); text-align: left; font-size: 14px; font-weight: 650; }
.content-wrap caption::after { content: " · Scroll horizontally on narrow screens"; font-weight: 500; }
.content-wrap caption { padding: 0 0 10px; color: var(--muted); text-align: left; font-weight: 650; }
.content-wrap th, .content-wrap td { min-width: 120px; padding: 11px 12px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.content-wrap th { background: var(--purple-pale); color: var(--ink); font-size: 14px; }
.content-wrap td { color: var(--muted); }
.content-wrap summary { min-height: 44px; padding-block: 10px; color: var(--ink); font-weight: 700; cursor: pointer; }
.content-wrap u { text-decoration-thickness: 2px; text-decoration-color: var(--cyan); text-underline-offset: 3px; }
.content-placeholder pre { max-width: 100%; overflow-x: auto; padding: 16px; border-radius: 12px; background: #211a2b; color: #f7f3ff; font-size: 14px; }
.content-placeholder :not(pre) > code { overflow-wrap: anywhere; padding: 2px 5px; border-radius: 5px; background: var(--wash); }
.noscript-banner { padding: 12px 18px; background: #fff4d6; color: #553b00; text-align: center; }
.site-footer { margin-top: 34px; border-top: 1px solid var(--line); background: var(--wash); }
.footer-inner { display: flex; width: min(1120px, calc(100% - 36px)); flex-wrap: wrap; justify-content: space-between; gap: 0 24px; margin-inline: auto; padding-block: 18px; }
.footer-inner p { margin: 5px 0; color: var(--muted); font-size: 14px; }
.footer-inner a { display: inline-flex; min-height: 44px; align-items: center; }
.ext-link { color: var(--purple); text-decoration: underline; cursor: pointer; }

@media (min-width: 600px) {
  html { scroll-padding-top: 90px; }
  .page-width { width: min(1120px, calc(100% - 56px)); }
  .header-inner { width: min(1200px, calc(100% - 48px)); flex-wrap: nowrap; }
  .anchor-nav { flex: 0 1 auto; justify-content: flex-end; }
  .hero { margin-top: 38px; padding: 64px 52px 36px; }
  .library-controls { grid-template-columns: minmax(0, 1.7fr) minmax(200px, .8fr); align-items: end; }
  #library { scroll-margin-top: 90px; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
  .content-wrap { width: min(900px, calc(100% - 56px)); }
  .content-wrap section { scroll-margin-top: 90px; }
}
@media (min-width: 900px) {
  .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .content-wrap table { display: block; overflow-x: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
