:root {
  --bg: #0d0d0c;
  --bg-2: #151513;
  --ink: #ecebe4;
  --line: #cfcdc3;
  --dim: #8b897f;
  --faint: #3b3a36;
  --accent: #f3ef7a;
  --accent-ink: #191912;
  --ok: #8fe3a0;
  --alert: #ff8a5c;
  --font: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #e6e5e1;
  --bg-2: #dddcd7;
  --ink: #121211;
  --line: #1d1d1b;
  --dim: #6c6a63;
  --faint: #c4c2bb;
  --accent: #f6ee6e;
  --accent-ink: #121211;
  --ok: #1f7a3a;
  --alert: #c2410c;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background-color .3s, color .3s;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }

.skip {
  position: absolute; left: 12px; top: -40px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: 4px 10px;
}
.skip:focus { top: 8px; }

:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 2px; }

/* ── title bar ─────────────────────────────── */
.titlebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  border-bottom: 1px solid var(--faint);
  font-size: 12px;
  color: var(--dim);
}
.titlebar p { margin: 0; }
.titlebar-path { text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titlebar-meta { text-align: right; }
.lights { display: flex; gap: 7px; }
.lights i { width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--faint); }
.lights i:first-child { background: var(--accent); border-color: transparent; }

/* ── layout ────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  min-height: 0;
}

/* ── terminal column ───────────────────────── */
.term {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 24px 24px;
  border-right: 1px solid var(--faint);
  min-width: 0;
}

.logo {
  margin: 0;
  font-size: 9.5px;
  line-height: 1;
  letter-spacing: 0;
  color: var(--ink);
  white-space: pre;
  overflow: hidden;
}
.tagline { margin: 0; color: var(--dim); font-size: 12px; }

.log {
  margin-top: 10px;
  max-height: min(52vh, 460px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 12.5px;
}
.log .ln { white-space: pre-wrap; word-break: break-word; min-height: 1.55em; }

.prompt {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: -14px;
  font-size: 12.5px;
}
.prompt label { white-space: nowrap; }
.prompt input {
  flex: 1;
  min-width: 0;
  background: none;
  border: 0;
  outline: none;
  padding: 0;
  caret-color: var(--accent);
}
.prompt input::placeholder { color: var(--faint); }

.pr-user { color: var(--ok); }
.pr-dir { color: var(--ink); }
.pr-sym, .pr { color: var(--dim); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button {
  background: none;
  border: 1px solid var(--faint);
  border-radius: 3px;
  padding: 2px 9px;
  font-size: 12px;
  color: var(--dim);
  transition: color .15s, border-color .15s, background-color .15s;
}
.chips button:hover { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }

/* text classes shared by log and cards */
.k { color: var(--dim); }
.d { color: var(--dim); }
.f { color: var(--faint); }
.hl { color: var(--accent); font-style: normal; }
[data-theme="light"] .hl { color: var(--ink); background: var(--accent); }
.ok { color: var(--ok); }
.al { color: var(--alert); font-style: normal; }
.h1 { font-weight: 700; }
.err { color: var(--alert); }
.btn-link {
  display: inline-block;
  margin-top: 2px;
  padding: 1px 8px;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
}
.btn-link:hover { background: var(--ink); color: var(--bg); }

.caret {
  display: inline-block;
  width: .62em;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: -.2em;
  background: var(--accent);
  animation: blink 1.05s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* ── drawer ────────────────────────────────── */
.drawer-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px clamp(16px, 4vw, 56px) 28px;
  min-width: 0;
}

.drawer-hint {
  margin: 0 0 6px;
  text-align: center;
  font-size: 11.5px;
  color: var(--dim);
}
.drawer-hint::before { content: "→ "; color: var(--accent); }
[data-theme="light"] .drawer-hint::before { color: var(--ink); }
.hint-touch { display: none; }
@media (hover: none) {
  .hint-mouse { display: none; }
  .hint-touch { display: inline; }
}

.drawer {
  position: relative;
  width: 100%;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.cards { position: absolute; inset: 0; }

.card {
  position: absolute;
  pointer-events: none;
  transform: translateY(0);
  transition:
    transform .62s var(--ease),
    translate .8s var(--ease),
    opacity .6s ease;
  transition-delay: 0s, var(--d, 0s), var(--d, 0s);
  will-change: transform;
}
.card.pre { translate: 0 -36px; opacity: 0; }

.card-svg { position: absolute; left: 0; top: 0; overflow: visible; }
.card-body {
  fill: var(--bg);
  stroke: var(--line);
  stroke-width: 1;
  pointer-events: visiblePainted;
  transition: fill .3s, stroke .3s;
}
.card-tab { fill: transparent; stroke: none; pointer-events: none; transition: fill .2s; }
.card.is-dir .card-tab { fill: var(--ink); }
.card.is-active .card-tab { fill: var(--accent); }

.tab {
  position: absolute;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 6px 0 4px;
  background: none;
  border: 0;
  pointer-events: auto;
  font-size: 12px;
  line-height: 1;
  color: var(--ink);
  white-space: nowrap;
}
.tab-name { overflow: hidden; text-overflow: ellipsis; }
.card.is-dir .tab { color: var(--bg); font-weight: 500; }
.card.is-active .tab { color: var(--accent-ink); }
.tab:focus-visible { outline-offset: -3px; }

/* content of an open card */
.content {
  position: absolute;
  left: 0;
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 16px 22px 14px;
  pointer-events: auto;
  user-select: text;
  -webkit-user-select: text;
  opacity: 0;
  transition: opacity .3s ease .12s;
}
.card.is-active .content { display: flex; }
.card.is-active.is-shown .content { opacity: 1; }

.c-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.c-title { margin: 0; font-size: 14px; font-weight: 500; }
.c-sub { margin: 2px 0 0; color: var(--dim); font-size: 12px; }
.c-close {
  background: none; border: 1px solid var(--faint); border-radius: 3px;
  padding: 1px 7px; font-size: 11px; color: var(--dim); white-space: nowrap;
}
.c-close:hover { color: var(--ink); border-color: var(--ink); }

.c-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 24px;
  align-items: start;
}
.c-body.single { grid-template-columns: minmax(0, 1fr); }

.c-term {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  overflow: hidden;
}
.c-term .ln { white-space: pre-wrap; min-height: 1.6em; }

.c-art {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.2;
  color: var(--ink);
  white-space: pre;
  animation: scan .7s steps(14) both;
}
.c-art i { font-style: normal; }
.c-art .sw { color: var(--ok); }
.drawer.is-narrow .c-body { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.drawer.is-narrow .c-fig { order: -1; align-items: center; }
.c-fig { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.c-fig figcaption { font-size: 10.5px; color: var(--faint); }
[data-theme="light"] .c-fig figcaption { color: var(--dim); }
@keyframes scan {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 0 0); }
}

/* run mode: terminal boots the project, browser shows the real screens */
.c-body.run { grid-template-columns: minmax(0, .78fr) minmax(0, 1.42fr); gap: 20px; }
.c-body.run .c-term { font-size: 11.5px; }
.drawer.is-narrow .c-body.run { grid-template-columns: minmax(0, 1fr); gap: 14px; }
.drawer.is-narrow .run-media { order: -1; }
.drawer.is-narrow .br-thumbs { display: none; }

.run-media { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.br-thumbs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.br-thumbs button {
  padding: 0;
  border: 1px solid var(--faint);
  border-radius: 3px;
  overflow: hidden;
  background: #0b0b12;
  aspect-ratio: 16 / 10;
  opacity: .55;
  transition: opacity .2s, border-color .2s;
}
.br-thumbs button:hover { opacity: .9; }
.br-thumbs button[aria-current="true"] { opacity: 1; border-color: var(--accent); }
[data-theme="light"] .br-thumbs button[aria-current="true"] { border-color: var(--ink); }
.br-thumbs img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top; }

.browser {
  margin: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-2);
}
.br-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 28px;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--faint);
  font-size: 11px;
  color: var(--dim);
}
.br-dots { display: flex; gap: 5px; }
.br-dots i { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--faint); }
.br-url {
  flex: 1;
  min-width: 0;
  padding: 1px 8px;
  background: var(--bg);
  border-radius: 3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.br-expand, .br-prev, .br-next, .vw-prev, .vw-next, .vw-close {
  flex: none;
  background: none;
  border: 1px solid var(--faint);
  border-radius: 3px;
  padding: 0 6px;
  height: 19px;
  font-size: 12px;
  line-height: 1;
  color: var(--dim);
  transition: color .15s, border-color .15s;
}
.br-expand:hover, .br-prev:hover, .br-next:hover, .vw-prev:hover, .vw-next:hover, .vw-close:hover { color: var(--ink); border-color: var(--ink); }
.vw-close { font-size: 11px; }

.br-load {
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}
.browser[data-state="loading"] .br-load { transform: scaleX(1); transition: transform .75s cubic-bezier(.3, .6, .2, 1); }
.browser[data-state="live"] .br-load { transform: scaleX(1); opacity: 0; transition: opacity .3s; }

.br-view {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #0b0b12;
  overflow: hidden;
}
.browser[data-state="live"] .br-view { cursor: zoom-in; animation: scan .55s steps(10) both; }
.br-wait {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  font-size: 11.5px;
  color: #8b897f;
  background: var(--bg);
}
.browser[data-state="live"] .br-wait { display: none; }
.br-shot {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  opacity: 0;
  transition: opacity .5s ease;
}
.browser[data-state="live"] .br-shot.on { opacity: 1; }

.br-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 30px;
  padding: 0 8px;
  border-top: 1px solid var(--faint);
  font-size: 11px;
}
.browser:not([data-state="live"]) .br-nav { opacity: .35; pointer-events: none; }
.br-label { flex: 1; min-width: 0; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.br-pips { display: flex; gap: 4px; }
.br-pips button { width: 14px; height: 3px; padding: 0; border: 0; background: var(--faint); }
.br-pips button[aria-current="true"] { background: var(--accent); }
[data-theme="light"] .br-pips button[aria-current="true"] { background: var(--ink); }

/* full-screen viewer */
.viewer {
  width: min(1280px, 94vw);
  max-width: none;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--font);
}
.viewer[open] { animation: pop .28s var(--ease); }
.viewer::backdrop { background: rgba(8, 8, 7, .84); }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.vw-window { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg-2); }
.vw-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 110px);
  object-fit: contain;
  background: #0b0b12;
}

/* drawer front */
.front { position: absolute; pointer-events: none; }
.front-svg { position: absolute; left: 0; top: 0; overflow: visible; }
.front-rim, .front-panel { fill: var(--bg); stroke: var(--line); stroke-width: 1; transition: fill .3s, stroke .3s; }
.front-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.front-meta { position: absolute; font-size: 11px; color: var(--dim); white-space: nowrap; }

.noscript { color: var(--dim); text-align: center; }

/* ── status bar ────────────────────────────── */
.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  height: 28px;
  padding: 0 16px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11.5px;
  white-space: nowrap;
}
.statusbar b { font-weight: 700; }
.sb-right { display: flex; gap: 14px; align-items: center; }
.sb-theme { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ── responsive ────────────────────────────── */
@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; }
  .term { border-right: 0; border-bottom: 1px solid var(--faint); padding: 22px 16px 18px; }
  .log { min-height: 0; max-height: 11.5em; }
  .drawer-wrap { padding: 20px 16px 24px; }
}

@media (max-width: 640px) {
  body { font-size: 12px; }
  .titlebar-meta, .sb-keys, .sb-session { display: none; }
  .statusbar { justify-content: flex-end; }
  .logo { font-size: 6.6px; }
  .c-art { font-size: 8.5px; }
  .c-fig figcaption, .front-meta, .br-pips { display: none; }
  .content { padding: 12px 14px; gap: 8px; }
  .c-term { font-size: 11.5px; }
  .tab { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation: none !important; }
}
