:root {
  --bg: #0a0b0d;
  --fg: #e8eaef;
  --muted: #8b919c;
  --accent: #6b9fff;
  --glow: rgba(107, 159, 255, 0.12);
  --nav-unselected: #5fb3b3;
  /* TUI frame (screenshot: thin gray borders) */
  --tui-border: #5c6068;
  /* Keys / highlights — orange-gold */
  --tui-key: #e8b060;
  --tui-gold: #e8b060;
  /* Muted URL / secondary link tone */
  --tui-link-dim: #7a8eb8;
  /* Dependency table */
  --tui-dep-lib: #c9d87c;
  --tui-dep-path: #7fd67f;
  /* KV labels in panels */
  --tui-label: #5fb3b3;
  /* Centered shell column max width */
  --tui-shell-max: 72rem;
  /* Block-art logo: smaller = tighter art; shape stays correct in monospace */
  --tui-ascii-logo-size: clamp(0.3rem, 0.75vw + 0.15rem, 0.48rem);
  /* Extra uniform shrink (layout + paint); ~1 = off. Chromium/Safari/Firefox 126+ */
  --tui-ascii-logo-zoom: 0.68;
}

html {
  height: 100%;
  overflow: hidden;
}

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

body {
  color: var(--fg);
  background: var(--bg);
  margin: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

@supports (height: 100dvh) {
  html,
  body {
    height: 100dvh;
    max-height: 100dvh;
  }
}

main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: clamp(0.5rem, 1.5vw, 1rem) clamp(0.5rem, 1.5vw, 1rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}

main-menu,
#spa-root,
.tui-keybar {
  width: min(100%, var(--tui-shell-max));
  max-width: 100%;
}

main-menu {
  flex-shrink: 0;
}

.tui-app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  align-items: center;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo,
    Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

#spa-root {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ——— Main content panel (large central box) ——— */
.tui-main-panel {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  border: 1px solid var(--tui-border);
  padding: clamp(1rem, 3vw, 1.75rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  overflow: auto;
}

.tui-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  max-width: 100%;
}

.tui-ascii-logo {
  margin: 0;
  color: var(--fg);
  font: inherit;
  font-size: var(--tui-ascii-logo-size);
  line-height: 1;
  letter-spacing: 0;
  white-space: pre;
  overflow-x: auto;
  user-select: none;
  width: max-content;
  max-width: 100%;
  margin-inline: auto;
  text-align: left;
  zoom: var(--tui-ascii-logo-zoom);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tui-hero-tagline {
  margin: 0;
  color: var(--fg);
}

.tui-hero-tagline em {
  color: var(--tui-gold);
  font-style: italic;
  font-weight: 400;
}

.tui-hero-link {
  color: var(--tui-link-dim);
  text-decoration: none;
}

.tui-hero-link:hover {
  text-decoration: underline;
  color: var(--accent);
}

.tui-hero-credit {
  margin: 0;
  color: var(--muted);
  font-size: 0.88em;
}

.tui-hero-credit .tui-heart {
  color: #6bc5e8;
}

/* ——— Nested bordered info box ——— */
.tui-filebox {
  border: 1px solid var(--tui-border);
  padding: 0.75rem 1rem;
  align-self: center;
  min-width: min(100%, 22rem);
}

.tui-kv {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 1.25rem;
}

.tui-kv dt {
  margin: 0;
  color: var(--tui-label);
  font-weight: 400;
}

.tui-kv dd {
  margin: 0;
  color: var(--fg);
}

/* ——— Titled sub-panel (|Dependencies| on top border) ——— */
.tui-titled-box {
  position: relative;
  border: 1px solid var(--tui-border);
  padding: 1rem 0.85rem 0.75rem;
  margin-top: 0.25rem;
  align-self: stretch;
  width: 100%;
  min-width: 0;
}

.tui-titled-box__label {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: baseline;
  padding: 0 0.45rem;
  background: var(--bg);
  color: var(--fg);
  font-weight: 700;
  white-space: nowrap;
  line-height: 1;
  user-select: none;
}

.tui-titled-box__label .pipe {
  color: var(--muted);
  font-weight: 400;
}

.tui-titled-box__label .name {
  font-weight: 700;
}

.tui-titled-box__body {
  overflow-x: auto;
}

.tui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88em;
}

.tui-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 0.35rem 0.75rem 0.5rem 0;
  border-bottom: 1px solid var(--tui-border);
}

.tui-table td {
  padding: 0.35rem 0.75rem 0.35rem 0;
  vertical-align: top;
}

.tui-table td.lib {
  color: var(--tui-dep-lib);
}

.tui-table td.path {
  color: var(--tui-dep-path);
  word-break: break-all;
}

/* ——— Simple inner pages (about / contact) ——— */
.tui-page-panel {
  border: 1px solid var(--tui-border);
  padding: 1.25rem 1rem;
  max-width: 42rem;
  width: 100%;
  align-self: center;
  text-align: center;
}

.tui-page-panel h1 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--fg);
}

.tui-page-panel p {
  margin: 0;
  color: var(--muted);
}

.tui-page-panel p + p {
  margin-top: 0.65rem;
}

/* ——— Bottom keybind bar ——— */
.tui-keybar {
  flex-shrink: 0;
  border: 1px solid var(--tui-border);
  border-top: none;
  margin-top: -1px;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.85rem;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo,
    Consolas, monospace;
  font-size: 0.82rem;
}

.tui-keybar kbd {
  font: inherit;
  color: var(--tui-key);
  font-weight: 600;
}

.tui-keybind {
  color: var(--fg);
  white-space: nowrap;
}

.tui-keybind .arrow {
  color: var(--muted);
  padding-inline: 0.15rem;
}

.blog-shell {
  display: grid;
  width: 100%;
  gap: 1rem;
  grid-template-columns: minmax(14rem, 18rem) minmax(0, 1fr);
  align-items: start;
}

.blog-list-panel,
.blog-view-panel {
  border: 1px solid var(--tui-border);
  padding: 1rem;
}

.blog-list-panel h1 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.blog-list-item + .blog-list-item {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--tui-border);
}

.blog-list-item h2 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.blog-list-item h2 a,
.blog-back a,
.blog-content a {
  color: var(--accent);
  text-decoration: none;
}

.blog-list-item h2 a:hover,
.blog-back a:hover,
.blog-content a:hover {
  text-decoration: underline;
}

.blog-meta {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.85em;
}

.blog-list-item p {
  margin: 0;
}

.blog-post h1 {
  margin: 0 0 0.25rem;
}

.blog-back {
  margin: 0 0 0.8rem;
}

.blog-content p,
.blog-content ul,
.blog-content pre {
  margin: 0.75rem 0;
}

.blog-content pre {
  border: 1px solid var(--tui-border);
  padding: 0.75rem;
  overflow: auto;
}

.blog-content :not(pre) > code {
  color: var(--tui-gold);
}

.blog-content pre code {
  color: inherit;
}

.blog-empty,
.blog-error {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 900px) {
  .blog-shell {
    grid-template-columns: 1fr;
  }
}
