:root {
  --bg: #0E1013;
  --fg: #E9E7E1;
  --dim: #A9A7A0;
  --hint: #8A8880;
  --line: #2A2D33;
  --accent: #4ADE80;
  --accent-light: #047857;
  --error: #F87171;
  --prompt-size: clamp(44px, 10vw, 112px);
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: inherit; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--fg); }

#term {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
  overflow: hidden;
}

/* output log: grows above the prompt */
#log {
  flex: 1 1 0;
  width: min(760px, 100%);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding-top: 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
#log > :first-child { margin-top: auto; }
.entry { padding-bottom: 20px; }
.entry.tight { padding-bottom: 6px; }
.echo { color: var(--hint); overflow-wrap: anywhere; }
.echo b { color: var(--dim); font-weight: 400; }
.out { overflow-wrap: anywhere; }
.out p { margin: 0 0 0.6em; max-width: 64ch; }
.out h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin: 0.2em 0 0.4em; }
.out a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
.out .muted { color: var(--dim); }
.out .err { color: var(--error); }
.out table { border-collapse: collapse; }
.out td { padding: 0 2ch 0 0; vertical-align: top; }
.out ul { list-style: none; padding: 0; margin: 0 0 0.6em; }
.out li { padding-left: 2ch; text-indent: -2ch; max-width: 64ch; }
.out li::before { content: '- '; color: var(--dim); }
.grid { display: flex; flex-wrap: wrap; gap: 0 3ch; }
.echo .val { color: var(--fg); }
.ok { color: var(--accent); }

/* grep matches */
.out mark { background: var(--accent); color: var(--bg); padding: 0 1px; border-radius: 2px; }

/* contact --vim: vim-style TUI overlay that covers the whole terminal */
#vimtui {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  flex-direction: column;
  padding: max(24px, env(safe-area-inset-top, 0px)) 20px max(12px, env(safe-area-inset-bottom, 0px));
}
#vimtui.open { display: flex; }
#vt-buffer {
  flex: 1 1 auto;
  width: min(760px, 100%);
  margin: 0 auto;
  overflow-y: auto;
  padding-top: 8px;
  font-size: 16px;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.vt-field { overflow-wrap: anywhere; }
.vt-label { color: var(--dim); margin-right: 1ch; }
.vt-field.cur .vt-label { color: var(--accent); }
.vt-cursor { display: inline-block; width: 0.6em; height: 1em; background: var(--accent); vertical-align: -0.15em; animation: blink 1.1s steps(1) infinite; }
.vt-cursor.ins { width: 2px; }
.vt-tilde { color: var(--hint); }
#vt-status {
  flex: none;
  width: min(760px, 100%);
  margin: 8px auto 0;
  display: flex;
  justify-content: space-between;
  gap: 1ch;
  background: var(--line);
  color: var(--dim);
  font-size: 14px;
  padding: 2px 8px;
}
#vt-mode { background: var(--accent); color: var(--bg); font-weight: 700; padding: 0 0.6ch; }
#vt-file { color: var(--dim); }
#vt-cmd {
  flex: none;
  width: min(760px, 100%);
  margin: 0 auto;
  padding-top: 4px;
  min-height: 1.6em;
  overflow-wrap: anywhere;
}
#vt-cmd .err { color: var(--error); }
#vt-cmd .hintline { color: var(--hint); font-size: 13px; }
.vt-prompt { color: var(--accent); }

/* ---------- start gate + classic website ---------- */
#gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 24px;
  text-align: center;
}
#gate.open { display: flex; }
#gate .gate-logo { display: block; width: min(520px, 88vw); height: auto; }
#gate .gate-lead { color: var(--hint); }
#gate .tiles { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
#gate .tile {
  width: min(300px, 86vw);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 20px;
  text-align: left;
  font: inherit;
  color: var(--fg);
  background: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}
#gate .tile b { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
#gate .tile span { color: var(--hint); font-size: 14px; }
#gate .tile:hover, #gate .tile:focus-visible { border-color: var(--accent); }
#gate .gate-hint { color: var(--hint); font-size: 14px; }

#classic {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 15;
  background: var(--bg);
  color: var(--fg);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
#classic.open { display: block; }
#classic .cls-wrap { max-width: 90ch; margin: 0 auto; padding: 40px 20px 80px; }
#classic header { display: flex; flex-wrap: wrap; gap: 6px 20px; align-items: center; justify-content: space-between; margin-bottom: 40px; }
#classic .brand { display: block; flex: none; line-height: 0; }
#classic .brand img { display: block; width: 270px; max-width: 48vw; height: auto; }
#classic nav { display: flex; flex-wrap: wrap; gap: 4px 22px; align-items: center; }
#classic nav a { color: var(--accent); text-decoration: none; }
#classic nav > a, #classic nav > button[data-lang] { position: relative; }
#classic nav > a::before, #classic nav > button[data-lang]::before {
  content: '>';
  position: absolute;
  right: 100%;
  margin-right: 0.3ch;
  color: var(--accent);
  visibility: hidden;
}
#classic nav > a:hover::before, #classic nav > a:focus-visible::before,
#classic nav > button[data-lang]:hover::before, #classic nav > button[data-lang]:focus-visible::before { visibility: visible; }
#classic nav > a:hover, #classic nav > a:focus-visible { text-decoration: none; }
#classic button[data-lang] { font: inherit; color: var(--hint); background: none; border: 0; padding: 0; cursor: pointer; }
#classic button[data-lang].on { color: var(--accent); }
#classic button[data-lang].on:not(:hover):not(:focus-visible) { text-decoration: underline; text-underline-offset: 3px; }
#classic .nav-actions { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
#classic a { color: var(--accent); }
#classic h2 { font-size: 18px; font-weight: 800; margin: 1.2em 0 0.4em; }
#classic footer { margin-top: 56px; font-size: 14px; }

/* ---------- light/dark look (gate + classic; the terminal stays dark) ---------- */
#classic.light, #gate.light {
  --bg: #FBFAF7;
  --fg: #1A1C20;
  --dim: #565B63;
  --hint: #8A8E95;
  --line: #DFDCD4;
  --error: #B91C1C;
  --accent: var(--accent-light);
}

/* gate: kbd chip, brand cursor and the two view miniatures */
#gate .tile { position: relative; }
#gate .tile kbd {
  position: absolute;
  top: 12px;
  right: 12px;
  font: 11px/1 var(--mono);
  color: var(--hint);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 7px;
}

#gate .mini {
  width: 100%;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font: 12px/1.55 var(--mono);
}
#gate .mini.w { background: #FFFFFF; color: #8A8E96; border: 1px solid #E4E2DB; }
#gate .mini.w .ln { display: block; height: 5px; border-radius: 3px; background: #E8E6DF; margin: 7px 0; }
#gate .mini.t { background: #0E1013; color: #A9A7A0; border: 1px solid #2A2D33; }
#gate .mini.t span { display: block; }
#gate .mini.t .a, #gate .mini.t .p { color: #E9E7E1; }
#gate .mini.t .a { color: #4ADE80; }
#gate .mini.t .cur {
  display: inline-block;
  width: 0.5em;
  height: 0.9em;
  background: #4ADE80;
  vertical-align: -0.1em;
  animation: blink 1.1s steps(1) infinite;
}

/* classic: sticky header, skip link, action chips, home hero, project cards */
#classic header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--line);
}
#classic nav a.on:not(:hover):not(:focus-visible) { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 2px; }
#classic .skip {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 40;
  transform: translateY(-3em);
  font: inherit;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  transition: transform 0.15s ease;
}
#classic .skip:focus-visible { transform: none; }
#classic button.cmd, #classic button[data-skin] {
  display: inline-block;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: none;
  border-radius: 8px;
  padding: 3px 10px;
  font: 13px/1.6 var(--mono);
  text-decoration: none;
  cursor: pointer;
}

#classic button.cmd:hover, #classic button[data-skin]:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
#classic main[data-page="home"] { display: flex; align-items: center; justify-content: center; }
#classic .cls-wrap.landing {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-top: 0;
  padding-bottom: 20px;
}
#classic .cls-wrap.landing header { display: none; }
#classic .cls-wrap.landing main { flex: 1; }
#classic .cls-wrap.landing footer {
  margin-top: 32px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  justify-content: center;
}
#classic .home-hero {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
}
#classic .home-logo { display: block; width: min(880px, 100%); height: auto; }
#classic .home-contact { font-size: 16px; text-underline-offset: 4px; }
#classic main > h1::after {
  content: '────';
  display: block;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: -1px;
  margin-top: 0.35em;
}
#classic main[data-page="projects"] table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
#classic main[data-page="projects"] tr {
  display: block;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 0;
}
#classic main[data-page="projects"] tr:has(a:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
#classic main[data-page="projects"] tr:hover { border-color: var(--accent); }
#classic main[data-page="projects"] td { display: block; padding: 0; }
#classic main[data-page="projects"] td:last-child { margin-top: 4px; font-size: 14px; }
#classic main[data-page="projects"] a::before { content: ''; position: absolute; inset: 0; }

@media (max-width: 520px) {
  #classic main[data-page="projects"] table { grid-template-columns: 1fr; }
}

/* neofetch */
.fetch { display: flex; flex-wrap: wrap; gap: 1em 4ch; align-items: flex-start; }
.fetch pre { margin: 0.2em 0 0; color: var(--accent); font: inherit; line-height: 1.1; }
.fetch .k { color: var(--accent); font-weight: 700; }
.fetch .rule { color: var(--dim); }
.swatches { display: flex; margin-top: 0.6em; }
.swatches span { width: 3ch; height: 1.2em; }

button.cmd {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
button.cmd:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* the prompt: the logo is the command line */
#promptwrap {
  flex: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
}
#path { color: var(--hint); font-size: 14px; min-height: 1.6em; }
#prompt {
  display: flex;
  align-items: center;
  max-width: 100%;
  font-size: var(--prompt-size);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  cursor: text;
  transition: font-size 0.45s ease;
}
#prompt svg { width: 0.75em; height: 0.75em; flex: none; margin-right: 0.25em; }
#prompt polyline { stroke: var(--accent); }
#cmd {
  font: inherit;
  letter-spacing: inherit;
  color: var(--fg);
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  height: 1.25em;
  line-height: 1.25;
  min-width: 1ch;
  max-width: calc(100vw - 2.2em - 40px);
  caret-color: transparent;
  outline: none;
}
#cmd::placeholder { color: var(--fg); opacity: 1; }
#cmd:focus::placeholder { color: var(--fg); }
.cursor {
  flex: none;
  align-self: flex-end;
  width: 0.54em;
  height: 0.125em;
  margin: 0 0 0.285em 0.09em;
  background: var(--accent);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
#hint { color: var(--hint); margin-top: 18px; text-align: center; padding: 0 12px; }

#spacer { flex: 1 1 0; transition: flex-grow 0.45s ease; }

/* once there is output, the prompt settles lower and smaller */
#term.active { --prompt-size: clamp(30px, 6vw, 60px); }
#term.active #spacer { flex-grow: 0.28; }
#term.active #hint { display: none; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* noscript fallback, shown when JavaScript is off */
.noscript { max-width: 64ch; margin: 0 auto; padding: 24px; }
.noscript a { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .cursor, .vt-cursor, .tcur { animation: none; }
  #prompt, #spacer { transition: none; }
}
@media (max-width: 520px) {
  body { font-size: 14px; }
  .out td { display: block; padding: 0; }
  .out tr { display: block; margin-bottom: 0.5em; }
}
