/* cyphrix theme — shared by the shell and any page that wants the look */
:root {
  --bg: #0a0b0f;
  --bg-2: #0d0f15;
  --panel: #11131b;
  --panel-2: #161925;
  --line: #222738;
  --fg: #e6e8ee;
  --muted: #8b93a7;
  --dim: #5b6275;
  --green: #00e5a0;
  --blue: #00b3ff;
  --purple: #9b5cff;
  --red: #ff5c7a;
  --yellow: #ffd166;
  --grad: linear-gradient(90deg, var(--green), var(--blue), var(--purple));
  --mono: ui-monospace, "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.65;
}
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
::selection { background: rgba(0, 229, 160, .28); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.ok { color: var(--green); }
.warn { color: var(--yellow); }
.err { color: var(--red); }
.cursor::after { content: "_"; color: var(--green); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- page shell for themed pages ---------- */
.wrap { max-width: 880px; margin: 0 auto; padding: 28px 16px 72px; }

/* shown only when a page is opened directly (not inside the cyphrix shell) */
.standalone-bar {
  display: flex; align-items: baseline; gap: .5em;
  max-width: 880px; margin: 0 auto; padding: 16px 16px 0;
  font-size: .9rem;
}
.standalone-bar .brand { font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em; }
html.framed .standalone-bar { display: none; }

.page-title {
  font-size: clamp(1.9rem, 7vw, 3rem);
  line-height: 1.1;
  letter-spacing: -.03em;
  margin: .4em 0 .2em;
}
.lede { color: var(--muted); margin: 0 0 1.6em; }

/* ---------- terminal window ---------- */
.term {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.term + .term, .term + .grid, .grid + .term { margin-top: 18px; }
.term-bar {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-size: .78rem; color: var(--muted);
}
.term-bar i { width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--red); }
.term-bar i:nth-of-type(2) { background: var(--yellow); }
.term-bar i:nth-of-type(3) { background: var(--green); }
.term-bar .title { margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.term-body { padding: 16px 18px; overflow-wrap: anywhere; }
.term-body > :first-child { margin-top: 0; }
.term-body > :last-child { margin-bottom: 0; }

.line { white-space: pre-wrap; }
.ps1 { color: var(--green); }
.cwd { color: var(--blue); }
.cmd { color: var(--fg); }
.out { color: var(--muted); margin: 2px 0 12px; white-space: pre-wrap; }
.out b { color: var(--fg); font-weight: 600; }

/* ---------- grid / cards ---------- */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
}
.card h3 { margin: 0 0 .4em; font-size: 1rem; color: var(--fg); }

.btn {
  font: inherit; font-size: .88rem;
  color: var(--green);
  background: rgba(0, 229, 160, .08);
  border: 1px solid rgba(0, 229, 160, .35);
  border-radius: 6px;
  padding: 6px 14px;
  cursor: pointer;
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.btn:hover { background: rgba(0, 229, 160, .16); border-color: var(--green); box-shadow: 0 0 18px rgba(0, 229, 160, .2); }

.tag {
  display: inline-block;
  font-size: .75rem;
  color: var(--purple);
  border: 1px solid rgba(155, 92, 255, .35);
  border-radius: 999px;
  padding: 0 9px;
  margin: 0 4px 4px 0;
}

/* ---------- blog listing ---------- */
.posts { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 14px; }
.post-card a {
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  color: inherit;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.post-card a:hover {
  text-decoration: none;
  border-color: rgba(0, 179, 255, .55);
  box-shadow: 0 0 0 1px rgba(0, 179, 255, .15), 0 10px 30px rgba(0, 0, 0, .35);
  transform: translateY(-1px);
}
.post-card h2 { margin: .15em 0 .3em; font-size: 1.2rem; line-height: 1.3; color: var(--fg); }
.post-card a:hover h2 { color: var(--green); }
.post-card p { margin: 0 0 .5em; color: var(--muted); font-size: .9rem; }
.meta { font-size: .78rem; color: var(--dim); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.meta time { color: var(--muted); }
.meta .edited { color: var(--yellow); }

/* ---------- single post ---------- */
.back { display: inline-block; margin-bottom: 16px; font-size: .88rem; }
.post-title { font-size: clamp(1.6rem, 6vw, 2.5rem); line-height: 1.15; letter-spacing: -.02em; margin: .3em 0 .35em; }
.post-head .meta { font-size: .8rem; }
.md { margin-top: 26px; }

/* ---------- markdown (GitHub-flavoured) ---------- */
.md { overflow-wrap: break-word; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { position: relative; line-height: 1.3; margin: 1.6em 0 .6em; scroll-margin-top: 16px; }
.md h1 { font-size: 1.75rem; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.md h2 { font-size: 1.4rem; padding-bottom: .3em; border-bottom: 1px solid var(--line); color: var(--green); }
.md h3 { font-size: 1.15rem; color: var(--blue); }
.md h4 { font-size: 1rem; color: var(--purple); }
.md h5 { font-size: .92rem; }
.md h6 { font-size: .85rem; color: var(--muted); }
.md .anchor { position: absolute; left: -1.1em; color: var(--dim); opacity: 0; text-decoration: none; padding-right: .3em; }
.md h1:hover .anchor, .md h2:hover .anchor, .md h3:hover .anchor,
.md h4:hover .anchor, .md h5:hover .anchor, .md h6:hover .anchor { opacity: 1; }
.md p, .md ul, .md ol, .md blockquote, .md table, .md pre, .md details, .md dl { margin: 0 0 1em; }
.md ul, .md ol { padding-left: 1.6em; }
.md li + li { margin-top: .25em; }
.md li > ul, .md li > ol { margin: .25em 0 0; }
.md ul { list-style: none; }
.md ul > li::before { content: "▸"; color: var(--green); position: absolute; margin-left: -1.2em; }
.md ul > li { position: relative; }
.md ol > li::marker { color: var(--blue); }
.md li.task-list-item::before, .md ul:has(> li > input[type=checkbox]) > li::before { content: none; }
.md li > input[type=checkbox] { accent-color: var(--green); margin: 0 .5em 0 -1.3em; vertical-align: middle; }
.md strong { color: #fff; }
.md em { color: #d6d9e4; }
.md del { color: var(--dim); }
.md hr { border: 0; height: 1px; background: var(--grad); opacity: .45; margin: 2em 0; }
.md img, .md video { max-width: 100%; height: auto; border-radius: 8px; }
.md video { display: block; background: #000; border: 1px solid var(--line); }
.md audio { width: 100%; max-width: 520px; display: block; }
.md blockquote {
  margin-left: 0; padding: .2em 1em;
  color: var(--muted);
  border-left: 3px solid var(--purple);
  background: rgba(155, 92, 255, .05);
  border-radius: 0 6px 6px 0;
}
.md blockquote > :last-child { margin-bottom: 0; }
.md code, .md kbd, .md samp { font-family: var(--mono); font-size: .88em; }
.md :not(pre) > code {
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; padding: .1em .38em; color: var(--green);
}
.md kbd {
  display: inline-block; padding: .05em .45em;
  background: var(--panel-2); color: var(--fg);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
}
.md pre {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.5;
}
.md pre code { background: none; border: 0; padding: 0; color: var(--fg); font-size: .86rem; }
.md pre .copy {
  position: absolute; top: 6px; right: 6px;
  font: inherit; font-size: .7rem; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 2px 8px; cursor: pointer; opacity: 0; transition: opacity .2s;
}
.md pre:hover .copy, .md pre .copy:focus { opacity: 1; }
.md pre.mermaid { background: var(--panel); text-align: center; }
.md .table-wrap { overflow-x: auto; margin: 0 0 1em; }
.md table { border-collapse: collapse; margin: 0; min-width: 50%; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 13px; }
.md th { background: var(--panel-2); color: var(--blue); font-weight: 600; }
.md tr:nth-child(even) td { background: rgba(255, 255, 255, .02); }
.md details { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5em 1em; }
.md summary { cursor: pointer; color: var(--blue); }
.md details[open] summary { margin-bottom: .6em; }
.md .math-display { overflow-x: auto; margin: 0 0 1em; text-align: center; }
.md .footnotes { font-size: .85rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 2.5em; padding-top: 1em; }
.md sup a, .md .footnote-backref { text-decoration: none; }

/* GitHub alerts */
.md .markdown-alert { padding: .5em 1em; margin: 0 0 1em; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 7%, transparent); border-radius: 0 6px 6px 0; }
.md .markdown-alert > :last-child { margin-bottom: 0; }
.md .markdown-alert-title { color: var(--c); font-weight: 700; display: flex; align-items: center; gap: .5em; margin-bottom: .3em; }
.md .markdown-alert-note { --c: var(--blue); }
.md .markdown-alert-tip { --c: var(--green); }
.md .markdown-alert-important { --c: var(--purple); }
.md .markdown-alert-warning { --c: var(--yellow); }
.md .markdown-alert-caution { --c: var(--red); }

/* highlight.js tokens in cyphrix colours */
.hljs-comment, .hljs-quote { color: var(--dim); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag { color: var(--purple); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-attribute, .hljs-meta .hljs-string { color: var(--green); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-link { color: var(--yellow); }
.hljs-title, .hljs-section, .hljs-title.function_, .hljs-name { color: var(--blue); }
.hljs-type, .hljs-built_in, .hljs-class .hljs-title, .hljs-title.class_ { color: #4dd8ff; }
.hljs-variable, .hljs-template-variable, .hljs-attr, .hljs-params { color: #c9b6ff; }
.hljs-meta, .hljs-selector-id, .hljs-selector-class { color: var(--muted); }
.hljs-deletion { color: var(--red); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

@media (max-width: 520px) {
  body { font-size: 14px; }
  .term-body, .card, .post-card a { padding: 14px; }
  .md .anchor { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- forms ---------- */
.field {
  display: block; width: 100%;
  font: inherit; color: var(--fg); caret-color: var(--green);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
  transition: border-color .2s, box-shadow .2s;
}
.field:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(0, 229, 160, .12); }
textarea.field { resize: vertical; min-height: 6em; line-height: 1.5; }
.q { display: block; margin: 0 0 8px; color: var(--fg); }
.q .ps1 { margin-right: .5ch; }
.qblock + .qblock { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.choices { display: grid; gap: 6px; }
.choice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg-2);
  cursor: pointer; transition: border-color .2s, background .2s;
}
.choice:hover { border-color: rgba(0, 179, 255, .5); }
.choice:has(input:checked) { border-color: var(--green); background: rgba(0, 229, 160, .07); }
.choice input { accent-color: var(--green); margin: .3em 0 0; flex: none; }
.hint { font-size: .75rem; color: var(--dim); margin-top: 4px; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---------- surveys ---------- */
.survey { margin: 2em 0; text-align: left; }
.survey .survey-title { font-size: 1.15rem; font-weight: 700; color: var(--fg); margin: 0 0 .3em; }
.survey .survey-msg { margin: 0 0 .8em; }
.survey .survey-status { margin: 0 0 .8em; font-size: .85rem; }
.survey form { margin: 0; }
.md .survey .choices, .md .survey .qblock { margin: 0; }
.md .survey label { font-weight: normal; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin: 0 0 18px; }
.tabs a { padding: 7px 14px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0; color: var(--muted); }
.tabs a:hover { color: var(--green); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--green); background: var(--panel); border-color: var(--line); margin-bottom: -1px; }
.flag { display: inline-block; font-size: .7rem; padding: 0 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); margin-right: 4px; }
.flag.on { color: var(--green); border-color: rgba(0, 229, 160, .45); }
.flag.warnf { color: var(--yellow); border-color: rgba(255, 209, 102, .45); }
.user-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.user-card + .user-card { margin-top: 12px; }
.user-card .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.user-card .head b { color: var(--green); font-size: 1.05rem; }
.user-card .what { color: var(--muted); font-size: .85rem; white-space: pre-wrap; margin: 6px 0; }
.inline { display: inline; margin: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .field { flex: 1; min-width: 12ch; width: auto; }
select.field { appearance: auto; }
.logline { font-size: .8rem; padding: 6px 0; border-bottom: 1px dashed var(--line); overflow-wrap: anywhere; }
.logline .src { display: inline-block; min-width: 5ch; }
.flash { padding: 8px 12px; border-radius: 6px; margin: 0 0 16px; border: 1px solid; }
.flash.ok { border-color: rgba(0, 229, 160, .4); background: rgba(0, 229, 160, .06); }
.flash.err { border-color: rgba(255, 92, 122, .4); background: rgba(255, 92, 122, .06); }
details.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; margin-top: 12px; }
details.panel summary { cursor: pointer; color: var(--blue); }
.btn.mini { font-size: .75rem; padding: 4px 10px; color: var(--muted); border-color: var(--line); background: var(--panel-2); }
.btn.mini:hover { color: var(--green); }
.savecode { word-break: break-all; color: var(--green); background: var(--bg-2); border: 1px dashed var(--line); border-radius: 6px; padding: 8px 10px; }
.coderow { display: flex; gap: 8px; }
.coderow .field { flex: 1; min-width: 0; }
