/* tech.redroomx.com: no external fonts or libraries */
:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #111722;
  --muted: #566073;
  --line: #d9dfe8;
  --accent: #b3261e;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9e7;
  --focus: #1d5fd1;
  --code-bg: #f4f6fa;
  --code-ink: #1b2330;
  --gutter: #8a94a6;
  --tok-c: #6b7587;
  --tok-s: #0b7a4f;
  --tok-n: #b45309;
  --tok-k: #6d28d9;
  --tok-f: #0a62c4;
  --tok-t: #be123c;
  --tok-v: #0f766e;
  --shadow: 0 1px 2px rgba(17, 23, 34, .06), 0 8px 24px -12px rgba(17, 23, 34, .18);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1017;
  --surface: #121923;
  --surface-2: #17202c;
  --ink: #e7ebf2;
  --muted: #98a3b6;
  --line: #243041;
  --accent: #ff6a5f;
  --accent-ink: #1a0604;
  --accent-soft: #2a1614;
  --focus: #7db0ff;
  --code-bg: #0a0e14;
  --code-ink: #dbe2ee;
  --gutter: #5c677a;
  --tok-c: #7b879b;
  --tok-s: #7fd6a4;
  --tok-n: #f2a65a;
  --tok-k: #c3a6ff;
  --tok-f: #7cb7ff;
  --tok-t: #ff8aa0;
  --tok-v: #6ad3c8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 28px -14px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 88px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 var(--sans); min-height: 100dvh;
  display: flex; flex-direction: column;
}
main { flex: 1; width: 100%; }
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 3px; }
code { font-family: var(--mono); font-size: .9em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.bar { display: grid; grid-template-columns: auto 1fr auto; gap: 12px 16px; align-items: center; padding: 10px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 650; letter-spacing: -.01em; }
.brand b { color: var(--accent); font-weight: 650; }
.logo {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font: 700 13px var(--mono);
}
.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; height: 42px; color: var(--muted);
}
.search:focus-within { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; height: 100%; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
kbd { font: 12px var(--mono); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 6px; color: var(--muted); }
.actions { display: flex; gap: 8px; align-items: center; }

/* Buttons */
.btn {
  font: inherit; font-weight: 600; font-size: .9rem; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); height: 38px; padding: 0 14px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.small { height: 30px; padding: 0 10px; font-size: .8rem; }
.btn:disabled { opacity: .55; cursor: progress; }
.icon-btn { width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--muted); }
.count { background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: .75rem; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; }

/* Home */
.hero { padding: 40px 0 20px; max-width: 720px; }
.hero h1 { font: 600 clamp(1.9rem, 4.4vw, 2.9rem)/1.12 var(--serif); letter-spacing: -.02em; margin: 0 0 12px; }
.hero p { margin: 0; color: var(--muted); font-size: 1.05rem; max-width: 60ch; }
.filters { display: grid; gap: 8px; margin: 18px 0 8px; }
.pillrow { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pl { color: var(--muted); font-size: .85rem; min-width: 74px; }
.pill {
  font: inherit; font-size: .85rem; cursor: pointer; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); border-radius: 99px; padding: 3px 12px; display: inline-flex; gap: 6px; align-items: center;
}
.pill small { color: var(--muted); }
.pill:hover { border-color: var(--muted); }
.pill[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill[aria-pressed="true"] small { color: inherit; opacity: .75; }
.bar-info { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 14px 0; color: var(--muted); font-size: .9rem; min-height: 30px; }
.link-btn { font: inherit; background: none; border: 0; color: var(--accent); text-decoration: underline; cursor: pointer; padding: 0; }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; padding-bottom: 48px; }
@media (min-width: 760px) { .grid { grid-template-columns: repeat(2, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); position: relative; }
.card.is-draft { border-style: dashed; border-color: var(--accent); }
.card-link { display: grid; grid-template-rows: auto 1fr; height: 100%; color: inherit; text-decoration: none; }
a.card-link:hover h2 { color: var(--accent); }
.thumb { width: 100%; aspect-ratio: 16 / 8.5; object-fit: cover; display: block; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.card-body { padding: 16px 18px 18px; display: grid; gap: 8px; align-content: start; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: .82rem; }
.qid { font-family: var(--mono); }
.badge { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 8px; font-size: .78rem; color: var(--ink); }
.badge.draft { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.card h2 { font: 600 1.25rem/1.3 var(--serif); margin: 0; letter-spacing: -.01em; }
.snip { margin: 0; color: var(--muted); display: grid; grid-template-columns: 20px 1fr; gap: 6px; font-size: .95rem; }
.snip::before { content: "A"; font: 700 .8rem var(--mono); color: var(--accent); padding-top: 3px; }
.snip span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font: .8rem var(--mono); color: var(--muted); background: none; border: 0; padding: 0; }
button.tag { cursor: pointer; }
button.tag:hover { color: var(--accent); }
mark { background: color-mix(in srgb, #ffd54a 70%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

.empty { grid-column: 1 / -1; border: 1px dashed var(--line); border-radius: 14px; padding: 36px; text-align: center; color: var(--muted); background: var(--surface); }

/* Detail */
.crumbs { padding: 22px 0 6px; font-size: .9rem; }
.qa { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: clamp(20px, 4vw, 40px); box-shadow: var(--shadow); margin-bottom: 28px; }
.qa h1 { font: 600 clamp(1.6rem, 3.6vw, 2.3rem)/1.2 var(--serif); letter-spacing: -.02em; margin: 10px 0 14px; max-width: 28em; }
.qa h2 { font: 600 1.15rem/1.3 var(--sans); margin: 28px 0 10px; display: flex; gap: 10px; align-items: baseline; }
.qa h2 .mk { font: 700 .85rem var(--mono); color: var(--accent); }
.qa .prose { max-width: 72ch; font-family: var(--serif); font-size: 1.08rem; line-height: 1.7; }
.prose p { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.4em; margin: 0 0 1em; }
.prose code { background: var(--code-bg); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: .85em; }
.prose h3 { font: 650 1rem var(--sans); margin: 1.4em 0 .5em; }
.qa figure { margin: 18px 0 0; }
.qa figure img { border-radius: 12px; border: 1px solid var(--line); display: block; max-height: 520px; width: auto; max-width: 100%; }
.qa-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.qa-actions .tags { flex: 1; }
.related h2 { font: 600 1.1rem var(--sans); margin: 0 0 12px; }

/* Code blocks */
.codeblock { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); margin: 0 0 1.1em; }
.cb-bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.copy { font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 3px 10px; }
.copy:hover { border-color: var(--muted); }
.copy.ok { background: var(--tok-s); border-color: var(--tok-s); color: #fff; }
:root[data-theme="dark"] .copy.ok { color: #06210f; }
.cb-body { display: grid; grid-template-columns: auto 1fr; font: 13.5px/1.65 var(--mono); }
.cb-body pre { margin: 0; padding: 14px 0; }
.cb-body .gutter { padding: 14px 12px; text-align: right; color: var(--gutter); user-select: none; border-right: 1px solid var(--line); }
.cb-pre { overflow-x: auto; padding: 14px 16px !important; color: var(--code-ink); tab-size: 2; }
.cb-pre code { font: inherit; }
.tok-c { color: var(--tok-c); font-style: italic; }
.tok-s { color: var(--tok-s); }
.tok-n { color: var(--tok-n); }
.tok-k { color: var(--tok-k); font-weight: 600; }
.tok-f { color: var(--tok-f); }
.tok-t { color: var(--tok-t); }
.tok-v { color: var(--tok-v); }

/* Dialogs */
dialog { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--ink); width: min(980px, 100vw - 24px); max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .5); }
dialog::backdrop { background: rgba(8, 11, 16, .6); }
dialog[open] { display: flex; flex-direction: column; }
dialog form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.dlg-head, .dlg-foot { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font: 650 1.1rem var(--sans); flex: 1; }
.dlg-foot { border-bottom: 0; border-top: 1px solid var(--line); justify-content: flex-end; }
.dlg-body { padding: 20px; overflow: auto; min-height: 0; flex: 1; }
.hint { margin-right: auto; color: var(--accent); font-size: .875rem; }
body:has(dialog[open]) { overflow: hidden; }
.drawer { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(580px, 100vw); border-radius: 0; }
.drawer .dlg-body section + section { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.drawer h3, .cmp-preview h3 { font: 650 1rem var(--sans); margin: 0 0 8px; display: flex; gap: 8px; align-items: center; }

.cmp-grid { display: grid; gap: 24px; }
@media (min-width: 860px) { .cmp-grid { grid-template-columns: 1.15fr 1fr; } .cmp-preview { position: sticky; top: 0; align-self: start; } }
.cmp-fields { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.opt { font-weight: 400; color: var(--muted); font-size: .8rem; }
input, textarea, select {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 11px; width: 100%; min-width: 0;
}
textarea { resize: vertical; }
textarea.mono, .log { font-family: var(--mono); font-size: .85rem; }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.row2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); cursor: pointer; display: grid; gap: 10px; justify-items: center; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.drop img { max-height: 140px; border-radius: 8px; }
.draft-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.draft-list li { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: grid; gap: 8px; background: var(--surface-2); }
.draft-list b { font-family: var(--mono); color: var(--accent); }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
details { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
summary { cursor: pointer; }
.log { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 12px 0 0; min-height: 44px; white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; max-width: calc(100vw - 32px); font-size: .9rem; box-shadow: var(--shadow); }

.static-page { padding: 32px 0; max-width: 72ch; }
.site-footer { border-top: 1px solid var(--line); padding: 22px 0 30px; color: var(--muted); font-size: .9rem; }
.site-footer p { margin: 4px 0; }

@media (max-width: 760px) {
  .bar { grid-template-columns: 1fr auto; }
  .search { grid-column: 1 / -1; grid-row: 2; }
  .search kbd { display: none; }
  .brand-name { font-size: .95rem; }
  .btn .count { margin-left: 2px; }
  #btn-add { padding: 0 10px; }
  .hero { padding-top: 24px; }
  .pl { min-width: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .card { transition: transform .15s ease, border-color .15s ease; }
  .card:hover { transform: translateY(-2px); border-color: var(--muted); }
}
@media print {
  .site-header, .site-footer, .qa-actions, .copy { display: none !important; }
  .qa { box-shadow: none; border: 0; }
}
