*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  font-family: "JetBrains Mono", "Cascadia Code", "Fira Code", ui-monospace, monospace;
  font-weight: 300; font-size: 14px; line-height: 1.7;
  color: var(--fg); background: var(--bg);
  display: flex; flex-direction: column; overflow: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-dim); color: var(--fg); }
.skip-link { position: absolute; top: -100%; left: 1rem; z-index: 50; padding: .4rem .8rem; background: var(--accent); color: var(--bg); font-weight: 500; }
.skip-link:focus { top: 0; }
.tt { position: absolute; opacity: 0; pointer-events: none; }

.ed { flex: 1; min-height: 0; position: relative; display: grid; grid-template-columns: 15rem minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto; }
.tt:checked ~ .ed { grid-template-columns: 0 minmax(0, 1fr); }
.tt:checked ~ .ed .tree { display: none; }

.tree { grid-column: 1; grid-row: 1 / 3; border-right: 1px solid var(--border); overflow: auto; padding: .45rem 0 2rem; font-size: 13px; }
.tree.focus { box-shadow: inset 0 0 0 1px var(--accent); }
.tree summary { list-style: none; cursor: pointer; }
.tree summary::-webkit-details-marker { display: none; }
.tree summary::before { content: "▸"; color: var(--fg-muted); width: 1ch; flex: none; text-align: center; }
.tree details[open] > summary::before { content: "▾"; }
.hd { display: flex; align-items: center; gap: .35rem; padding: .1rem .7rem; margin-top: .7rem; font-size: 11px; font-weight: 500; letter-spacing: .1em; color: var(--fg-muted); text-transform: uppercase; }
.sec:first-child > .hd { margin-top: 0; }
.row { display: flex; align-items: center; gap: .35rem; padding: .08rem .7rem; color: var(--fg-dim); white-space: nowrap; min-height: 1.6rem; }
.row > a { color: inherit; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row > a:hover { text-decoration: none; color: var(--fg); }
.row:hover, .row.cur { background: var(--accent-dim); }
.row.cur > a { color: var(--accent); }
.row.tcur { box-shadow: inset 2px 0 var(--highlight); background: var(--accent-dim); }
.row.dir > a { color: var(--teal); }
.row.off { color: var(--fg-muted); }
.row .ic { color: var(--fg-muted); width: 1ch; flex: none; text-align: center; }
.badge { color: var(--highlight); font-size: 11px; flex: none; }
.badge.off, .kb { color: var(--fg-muted); font-size: 11px; flex: none; }
.dir .kids .row { padding-left: 1.75rem; }
.js-only { display: none; }
.js .js-only { display: flex; }
.row .grow { flex: 1; }

.tabs { grid-column: 2; grid-row: 1; display: flex; align-items: stretch; border-bottom: 1px solid var(--border); font-size: 12px; min-width: 0; }
.tgl { cursor: pointer; color: var(--accent); padding: 0 .75rem; border-right: 1px solid var(--border); display: flex; align-items: center; user-select: none; }
.tgl:hover { background: var(--accent-dim); }
.tt:focus-visible ~ .ed .tgl { outline: 2px solid var(--accent); outline-offset: -2px; }
.bufs { display: flex; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tab { display: flex; align-items: center; border-right: 1px solid var(--border); white-space: nowrap; }
.tab a { padding: .3rem .75rem; color: var(--fg-muted); }
.tab a:hover { text-decoration: none; color: var(--fg); }
.tab button { all: unset; cursor: pointer; color: var(--fg-muted); padding: 0 .55rem 0 0; opacity: 0; }
.tab:hover button, .tab.on button, .tab button:focus-visible { opacity: 1; }
.tab button:hover { color: var(--error); }
.tab.on { background: var(--accent-dim); box-shadow: inset 0 -2px var(--accent); }
.tab.on a { color: var(--fg); }

.win { grid-column: 2; grid-row: 2; overflow: auto; position: relative; outline: none; }
.buf { counter-reset: ln; padding: .6rem 0 45vh; }
.buf > * { counter-increment: ln; position: relative; padding: 0 1rem 0 4.2rem; min-height: 1.7em; max-width: 54rem; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; }
.buf > *::before { content: counter(ln); position: absolute; left: 0; width: 3rem; text-align: right; color: var(--fg-muted); opacity: .6; font-size: 12px; }
.rnu .buf > *::before { content: attr(data-n); }
.nonu .buf > * { padding-left: 1rem; }
.nonu .buf > *::before { display: none; }
.nowrap .buf > * { white-space: pre; overflow-wrap: normal; max-width: none; width: max-content; min-width: 100%; }
.buf > .cl { background: var(--accent-dim); }
.buf > .cl::before { color: var(--highlight); opacity: 1; }
.buf a:focus-visible { outline: 1px solid var(--highlight); outline-offset: 1px; }
.buf mark { background: var(--highlight); color: var(--bg); }
.buf mark.now { background: var(--accent); }
.h1 { color: var(--highlight); font-weight: 500; }
.h2 { color: var(--accent); font-weight: 500; }
.mk { color: var(--fg-muted); }
.q, .dim { color: var(--fg-dim); }
.c { color: var(--fg-muted); font-style: italic; }
.k { color: var(--teal); }
.s { color: var(--accent); }
.n { color: var(--highlight); }
.code { color: var(--teal); }
.ok { color: var(--teal); } .warn { color: var(--highlight); } .err { color: var(--error); }
.tag { color: var(--highlight); }
.buf strong { font-weight: 600; }
.buf .fold > summary { list-style: none; cursor: pointer; }
.buf .fold > summary::-webkit-details-marker { display: none; }
pre.ban { color: var(--accent); font-size: 8px; line-height: 1.12; white-space: pre; overflow: hidden; }
@media (min-width: 720px) { pre.ban { font-size: 11px; } }
.sw { display: inline-flex; gap: 2px; vertical-align: -1px; }
.sw i { width: .75rem; height: .8rem; display: block; }
.sw i:nth-child(1) { background: var(--t-bg); } .sw i:nth-child(2) { background: var(--t-accent); } .sw i:nth-child(3) { background: var(--t-highlight); }
.sw i:nth-child(4) { background: var(--t-teal); } .sw i:nth-child(5) { background: var(--t-error); }
[data-theme] { cursor: pointer; }

.status { grid-column: 1 / -1; grid-row: 3; display: flex; align-items: stretch; font-size: 12px; border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; min-height: 1.75rem; }
.status > * { padding: .22rem .7rem; display: flex; align-items: center; }
.status .mode { background: var(--accent); color: var(--bg); font-weight: 500; }
.status .mode.m-cmd { background: var(--highlight); }
.status .mode.m-tree { background: var(--teal); }
.status .file label { cursor: pointer; color: var(--fg); }
.status .ro { color: var(--fg-muted); padding-left: 0; }
.status .fill { flex: 1; padding: 0; }
.status .showcmd { color: var(--highlight); min-width: 3ch; }
.status a { color: var(--fg-dim); }
.status a:hover { color: var(--accent); text-decoration: none; }
.status .chip a { color: var(--accent); }
.status .ft { color: var(--fg-dim); }
.status .ver { white-space: pre; }
.status .pos { background: var(--border); color: var(--fg); }

.cmd { grid-column: 1 / -1; grid-row: 4; position: relative; z-index: 6; display: none; align-items: center; gap: .1rem; font-size: 13px; padding: 0 .6rem; background: var(--bg); border-top: 1px solid var(--border); min-height: 1.75rem; }
.cmd.on, .ch1 .cmd { display: flex; }
.cwrap { flex: 1; min-width: 0; position: relative; display: flex; }
.cwrap[hidden] { display: none; }
.cmd input { flex: 1; min-width: 0; position: relative; background: transparent; border: 0; color: var(--fg); font: inherit; outline: none; }
.ghost { position: absolute; inset: 0; pointer-events: none; white-space: pre; overflow: hidden; color: var(--fg-muted); display: flex; align-items: center; }
.ghost .ty { color: transparent; }
.out { flex: 1; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.out.e { color: var(--error); } .out.w { color: var(--highlight); }
.pum { position: absolute; bottom: calc(100% + 1px); left: .6rem; min-width: 18rem; max-width: min(36rem, calc(100vw - 1.2rem)); max-height: 15rem; overflow: auto; list-style: none; padding: .2rem 0; background: var(--bg); border: 1px solid var(--fg-muted); display: none; z-index: 10; }
.pum.on { display: block; }
.pum li { display: flex; gap: 1.5rem; padding: 0 .7rem; cursor: pointer; white-space: nowrap; line-height: 1.6; color: var(--fg-dim); }
.pum li b { color: var(--fg); font-weight: 700; }
.pum li .d { margin-left: auto; color: var(--fg-muted); font-size: 12px; }
.pum li.on { background: var(--accent); color: var(--bg); }
.pum li.on b, .pum li.on .d { color: var(--bg); }

.more { position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; display: none; background: var(--bg); border-top: 1px solid var(--accent); max-height: 60%; overflow: auto; padding: .4rem .8rem .3rem; font-size: 13px; }
.more.on { display: block; }
.more pre { white-space: pre-wrap; }
.more p { color: var(--teal); margin-top: .3rem; }
.scrim { position: absolute; inset: 0; z-index: 7; display: none; background: #0006; }
.scrim.on { display: block; }
.float { position: absolute; left: 50%; top: 10%; transform: translateX(-50%); width: min(38rem, calc(100% - 2rem)); max-height: 72%; display: none; flex-direction: column; background: var(--bg); border: 1px solid var(--accent); z-index: 9; }
.float.on { display: flex; }
.float header { display: flex; justify-content: space-between; padding: .2rem .7rem; color: var(--accent); font-size: 12px; border-bottom: 1px solid var(--border); }
.float header button { all: unset; cursor: pointer; color: var(--fg-muted); }
.float label { display: flex; gap: .5rem; padding: .45rem .8rem; border-bottom: 1px solid var(--border); }
.float label b { color: var(--highlight); font-weight: 500; }
.float input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--fg); font: inherit; }
.float ul { list-style: none; overflow: auto; padding: .25rem 0; }
.float li { display: flex; gap: .7rem; padding: .05rem .8rem; cursor: pointer; font-size: 13px; }
.float li .d { color: var(--fg-muted); font-size: 12px; margin-left: auto; }
.float li mark { background: none; color: var(--highlight); font-weight: 500; }
.float li.on { background: var(--accent-dim); color: var(--accent); }

.buf.intro { padding: 0; height: 100%; }
.buf.intro > .splash { position: relative; display: flex; align-items: center; justify-content: center; min-height: 100%; max-width: none; padding: 2rem 1rem 2rem 3.2rem; white-space: normal; }
.buf.intro > *::before { display: none; }
.buf.intro > .cl { background: none; }
.tildes { position: absolute; left: 0; top: .6rem; bottom: 0; width: 2.4rem; overflow: hidden; color: var(--fg-muted); opacity: .6; text-align: right; }
.intro-in { text-align: center; min-width: 0; max-width: 100%; }
.intro-in pre.ban { display: inline-block; text-align: left; margin-bottom: 1rem; }
.intro-in .iv { color: var(--highlight); font-weight: 500; }
.opts { display: inline-grid; grid-template-columns: auto auto auto; gap: .1rem 1.6rem; text-align: left; margin: 1.4rem 0; }
.opts a { display: contents; color: var(--fg); }
.opts a:hover > span { color: var(--accent); }
.opts .kk { color: var(--highlight); font-weight: 500; }

@media (max-width: 760px) {
  .ed, .tt:checked ~ .ed { grid-template-columns: minmax(0, 1fr); }
  .tabs, .win { grid-column: 1; }
  .tree, .tt:checked ~ .ed .tree { display: block; position: fixed; z-index: 20; inset: 0 22% 0 0; background: var(--bg); border-right: 1px solid var(--accent); transform: translateX(-102%); transition: transform .15s; }
  .tt:checked ~ .ed .tree { transform: none; }
  .buf > * { padding-left: 3rem; padding-right: .75rem; }
  .buf > *::before { width: 2.2rem; }
  .status .ft, .status .ro, .status .showcmd, .status .ver { display: none; }
  .buf.intro > .splash { padding-left: 2rem; }
  .tildes { width: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) { .tree { transition: none; } }
