
:root {
  --bg: #0a0d16;
  --bg-2: #0f1324;
  --panel: #141a2e;
  --panel-2: #1a2138;
  --line: #252d49;
  --text: #e8eaf4;
  --muted: #8f97b8;
  --amber: #ffb454;
  --amber-ink: #1a1203;
  --green: #6ee7a0;
  --red: #ff6b6b;
  --blue: #7aa2ff;
  --yellow: #ffd479;
  --radius: 14px;
  --radius-sm: 8px;
  --font-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
main { flex: 1; }
img, svg { max-width: 100%; }
a { color: var(--amber); text-underline-offset: 3px; }
a:hover { color: #ffcb85; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; letter-spacing: -0.02em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.3rem, 7vw, 4.4rem); font-weight: 800; }
h2 { font-size: clamp(1.6rem, 4vw, 2.3rem); font-weight: 700; }
h3 { font-size: 1.2rem; font-weight: 700; }
p { margin: 0 0 1em; }
code, pre, kbd { font-family: var(--font-mono); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--amber); color: var(--amber-ink); padding: .5rem 1rem; border-radius: 6px; z-index: 100; }
.skip:focus { left: 8px; }
.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 max(1.1rem, env(safe-area-inset-left)); }

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 13, 22, .88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 64px; position: relative; }
.brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--text); }
.brand-mark {
  font-family: var(--font-mono); font-weight: 700; font-size: .95rem;
  background: var(--amber); color: var(--amber-ink);
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px;
}
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 1.25rem; letter-spacing: -0.02em; }
.site-nav { display: flex; gap: .25rem; }
.site-nav a {
  color: var(--muted); text-decoration: none; padding: .5rem .9rem; border-radius: 999px; font-weight: 500; font-size: .98rem;
}
.site-nav a:hover { color: var(--text); background: var(--panel); }
.site-nav a[aria-current="page"] { color: var(--amber-ink); background: var(--amber); }
.nav-toggle {
  display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  width: 44px; height: 44px; cursor: pointer; align-items: center; justify-content: center;
}
.nav-bars, .nav-bars::before, .nav-bars::after {
  display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; position: relative; transition: transform .2s, opacity .2s;
}
.nav-bars::before, .nav-bars::after { content: ""; position: absolute; left: 0; }
.nav-bars::before { top: -6px; } .nav-bars::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-bars::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-bars::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 720px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column;
    background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem; margin: .5rem .6rem 0;
  }
  .site-nav.open { display: flex; }
  .site-nav a { padding: .9rem 1rem; border-radius: 10px; }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: .6rem 1.2rem; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font: 600 .98rem var(--font-body); text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--panel-2); border-color: #35406a; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn-primary:hover { background: #ffc577; border-color: #ffc577; color: var(--amber-ink); }
.btn-danger { color: var(--red); border-color: #5a2c36; background: #2a1520; }
.btn-danger:hover { background: #3a1b29; color: #ff8c8c; border-color: #7a3846; }
.btn-sm { min-height: 38px; padding: .35rem .85rem; font-size: .88rem; border-radius: 8px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.chip {
  display: inline-block; font: 500 .8rem var(--font-mono); color: var(--amber);
  border: 1px solid #4a3a1c; background: #231b0c; padding: .15rem .6rem; border-radius: 999px;
}
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-btn {
  font: 500 .9rem var(--font-body); color: var(--muted); background: var(--panel); border: 1px solid var(--line);
  padding: .45rem .95rem; border-radius: 999px; cursor: pointer; min-height: 40px;
}
.chip-btn:hover { color: var(--text); }
.chip-btn[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }

.hero { padding: clamp(2.5rem, 7vw, 5.5rem) 0 clamp(2rem, 5vw, 4rem); border-bottom: 1px solid var(--line);
  background: radial-gradient(900px 400px at 85% -10%, rgba(255,180,84,.08), transparent 60%); }
.hero-grid { display: grid; gap: 2.5rem; grid-template-columns: 1fr; align-items: center; }
.hero h1 { margin-bottom: .4em; }
.hero .lead { font-size: 1.2rem; color: #c3c8de; max-width: 34em; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.05fr 1fr; gap: 3.5rem; } }

.term {
  background: #070a12; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.8);
}
.term-bar {
  display: flex; align-items: center; gap: .75rem; padding: .65rem .9rem; background: var(--panel); border-bottom: 1px solid var(--line);
  font: 500 .8rem var(--font-mono); color: var(--muted);
}
.term-dots { display: flex; gap: 6px; }
.term-dots i { width: 11px; height: 11px; border-radius: 50%; background: #3a4363; display: block; }
.term-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-status { display: inline-flex; align-items: center; gap: .4rem; }
.term-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.term-status.off::before { background: var(--red); box-shadow: none; }
.term-status.busy::before { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.term-body {
  font: 400 .875rem/1.55 var(--font-mono); padding: 1rem; color: #d6dbef; min-height: 280px;
}
.demo-body { min-height: 320px; white-space: pre-wrap; word-break: break-word; }

.c-green, .t-ok { color: var(--green); }
.c-red, .t-err { color: var(--red); }
.c-yellow, .t-warn { color: var(--yellow); }
.c-blue { color: var(--blue); }
.c-cyan { color: #6fe3e3; }
.c-magenta { color: #e59bff; }
.c-bold { font-weight: 700; }
.t-dim, .c-dim { color: #6b7396; }
.t-prompt { color: var(--green); font-weight: 500; }
.t-path { color: var(--blue); font-weight: 500; }
.t-cmd { color: #fff; }
.caret { display: inline-block; width: .6em; height: 1.1em; background: var(--amber); vertical-align: text-bottom; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.section { padding: clamp(2.5rem, 6vw, 4.5rem) 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.8rem; }
.section-head h2 { margin: 0; }
.prose { max-width: 40em; color: #c3c8de; }
.split { display: grid; gap: 2rem; }
@media (min-width: 860px) { .split { grid-template-columns: 1fr 1.4fr; gap: 4rem; } }

.provide { display: grid; gap: 1.5rem; }
@media (min-width: 760px) { .provide { grid-template-columns: repeat(3, 1fr); gap: 2rem; } }
.provide > div { border-left: 2px solid var(--amber); padding-left: 1.1rem; }
.provide h3 { margin-bottom: .35em; }
.provide p { color: var(--muted); margin: 0; font-size: 1rem; }

.script-list { display: grid; gap: 1rem; margin: 0; padding: 0; list-style: none; }
.script {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.25rem 1.1rem;
  display: grid; gap: 1rem;
}
.script h3 { margin: 0 0 .25em; font-size: 1.3rem; }
.script .desc { margin: 0 0 .7rem; color: #b5bcd8; }
.script .meta { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; font-size: .85rem; color: var(--muted); }
.script .meta b { color: var(--text); font-weight: 600; }
@media (min-width: 820px) { .script { grid-template-columns: 1fr auto; align-items: center; } .script-actions { justify-content: flex-end; } .script details { grid-column: 1 / -1; } }
.script-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
details.preview summary { cursor: pointer; color: var(--muted); font-size: .9rem; padding: .35rem 0; min-height: 36px; display: flex; align-items: center; }
details.preview summary:hover { color: var(--text); }
pre.code {
  margin: .6rem 0 0; padding: 1rem; background: #070a12; border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow-x: auto; font-size: .82rem; line-height: 1.55; color: #cfd5ec; max-height: 340px; tab-size: 2;
}
.toolbar { display: grid; gap: .9rem; margin-bottom: 1.5rem; }
.search {
  width: 100%; background: var(--panel); border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  padding: .8rem 1rem; font: 400 1rem var(--font-body); min-height: 48px;
}
.search::placeholder { color: #66708f; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem 1.25rem; text-align: center; color: var(--muted); }
.page-head { padding: clamp(2rem, 5vw, 3.5rem) 0 1.5rem; }
.page-head p { color: #b5bcd8; max-width: 38em; margin-bottom: 0; }

.rt-layout { display: grid; gap: 1rem; padding-bottom: 3rem; }
.rt-controls { display: grid; gap: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.rt-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.rt-row > .field { flex: 1 1 200px; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
select, input[type="text"], input[type="password"], input[type="file"], textarea {
  width: 100%; background: #0b0f1c; border: 1px solid var(--line); color: var(--text); border-radius: 10px;
  padding: .7rem .85rem; font: 400 1rem var(--font-body); min-height: 46px;
}
textarea { font-family: var(--font-mono); font-size: .85rem; line-height: 1.5; min-height: 180px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
input[type="file"] { padding: .55rem; }
input[type="file"]::file-selector-button { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .8rem; margin-right: .8rem; font: 600 .85rem var(--font-body); cursor: pointer; }
.rt-term .term-body {
  height: min(62vh, 560px); min-height: 340px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; cursor: text;
}
.rt-term .ln { white-space: pre-wrap; word-break: break-word; min-height: 1.55em; }
.rt-input-line { display: flex; align-items: baseline; gap: .5ch; flex-wrap: nowrap; }
.rt-prompt { white-space: pre; flex: none; }
.rt-input {
  flex: 1; min-width: 0; background: transparent; border: 0; color: #fff; font: inherit; padding: 0; min-height: 0;
  outline: none; caret-color: var(--amber); border-radius: 0;
}
@media (max-width: 600px) {
  .term-body { font-size: .8rem; padding: .8rem; }
  .rt-input { font-size: 16px; } 
  .rt-term .term-body { height: 60vh; }
}

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin-bottom: 2rem; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat b { display: block; font: 800 2rem/1.1 var(--font-display); color: var(--amber); }
.stat span { color: var(--muted); font-size: .88rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.5rem; }
.panel h2 { font-size: 1.4rem; }
.form-grid { display: grid; gap: 1rem; }
@media (min-width: 760px) { .form-grid.two { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.hint { font-size: .84rem; color: var(--muted); margin: .3rem 0 0; }
.alert { padding: .8rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; font-size: .95rem; }
.alert.ok { background: #0f2a1d; border-color: #1f5a3b; color: #9bf0c0; }
.alert.err { background: #2a1520; border-color: #6a2c3a; color: #ff9d9d; }
.alert.info { background: #131f3b; border-color: #2b4177; color: #aac3ff; }
.admin-list { display: grid; gap: .8rem; }
.admin-item { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.admin-item > .row { display: grid; gap: .6rem; padding: 1rem; }
.admin-item .name { font-weight: 600; font-family: var(--font-display); font-size: 1.1rem; }
.counts { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; font-size: .88rem; color: var(--muted); }
.counts b { color: var(--text); }
@media (min-width: 860px) { .admin-item > .row { grid-template-columns: 1fr auto; align-items: center; } }
.admin-item details { border-top: 1px solid var(--line); }
.admin-item details > summary { padding: .8rem 1rem; cursor: pointer; color: var(--amber); font-weight: 600; min-height: 46px; display: flex; align-items: center; }
.admin-item .edit { padding: 0 1rem 1rem; }
.login { max-width: 440px; margin: clamp(2rem, 8vw, 5rem) auto; }
.inline { display: inline; }

.site-footer { border-top: 1px solid var(--line); background: var(--bg-2); padding: 2rem 0 calc(2rem + env(safe-area-inset-bottom)); margin-top: auto; }
.foot { display: grid; gap: 1rem; }
.foot p { margin: 0; }
@media (min-width: 700px) { .foot { grid-template-columns: 1fr auto; text-align: right; } .foot p:first-child { text-align: left; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

.folder { margin-bottom: 2rem; }
.folder-head {
  display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; background: var(--bg-2); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0;
}
.folder-head h2 { margin: 0; font-size: 1.5rem; }
.folder-head p { margin: 0; }
.folder > .script-list { border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); padding: .8rem; background: var(--bg-2); }
.folder.plain > .script-list { border: 0; padding: 0; background: transparent; }
.folder-title { font-size: 1.5rem; margin: 0 0 1rem; }
