:root {
  color-scheme: dark;
  --page: #0d1117;
  --frame: #161b22;
  --frame-edge: #30363d;
  --screen: #0d1117;
  --text: #e2e8f0;
  --muted: #878e9a;
  --dim: #718096;
  --green: #27c77e;
  --green-strong: #27c77e;
  --yellow: #e8b420;
  --orange: #f07d30;
  --red: #f0485a;
  --track: #1e2235;
  --key-bg: #1e2235;
  --key-fg: #a0aec0;
  --highlight: #1e2a40;
  --focus: #27c77e;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    monospace;
}

button,
input {
  font: inherit;
}

.demo-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(14px, 3vw, 34px);
  gap: 30px;
}

.demo-header {
  width: min(100%, 1550px);
  display: flex;
  justify-content: center;
}

.github-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  text-decoration: none;
  font-size: 20px;
  transition: color 0.15s;
}

.github-link:hover {
  color: var(--text);
}

.github-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.terminal-window {
  width: min(100%, 1550px);
  min-height: min(760px, calc(100vh - clamp(28px, 6vw, 68px)));
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid color-mix(in srgb, var(--frame-edge), transparent 12%);
  background: var(--frame);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.34),
    inset 0 1px rgba(255, 255, 255, 0.04);
}

.terminal-titlebar {
  min-height: 44px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.08);
  color: var(--muted);
}

.window-controls {
  justify-self: start;
  display: flex;
  gap: 8px;
}

.window-controls span {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--dim);
}

.window-controls span:nth-child(1) {
  background: var(--red);
}

.window-controls span:nth-child(2) {
  background: var(--yellow);
}

.window-controls span:nth-child(3) {
  background: var(--green);
}

.titlebar-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-self: center;
  gap: 1ch;
}

.terminal-subtitle {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--dim);
  font-size: 11px;
}

.view-switch {
  display: flex;
  border: 1px solid var(--frame-edge);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.view-switch-btn {
  border: 0;
  border-right: 1px solid var(--frame-edge);
  padding: 0.22em 0.8em;
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: color 0.1s, background 0.1s;
}

.view-switch-btn:last-child {
  border-right: 0;
}

.view-switch-btn.active {
  background: var(--key-bg);
  color: var(--text);
}

.view-switch-btn:not(.active):hover,
.view-switch-btn:not(.active):focus-visible {
  color: var(--muted);
  outline: none;
}

.terminal-screen {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: clamp(14px, 2.4vw, 28px);
  background:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    var(--screen);
  background-size: 100% 24px, auto;
  outline: none;
  font-size: clamp(12px, 1.28vw, 15px);
  line-height: 1.48;
  letter-spacing: 0;
}

.terminal-screen:focus-visible {
  box-shadow: inset 0 0 0 2px var(--focus);
}

.measure-probe {
  position: absolute;
  visibility: hidden;
  white-space: pre;
}

.raw-output {
  margin: 0;
  font: inherit;
  line-height: 1.48;
  white-space: pre;
  overflow: auto;
  color: var(--text);
}

.screen-block {
  min-width: 660px;
}

.screen-line {
  min-height: 1.48em;
  white-space: pre-wrap;
}

.header-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55ch 2.2ch;
  color: var(--muted);
}

.header-leader {
  color: var(--green);
  font-weight: 700;
}

.header-segment {
  white-space: pre;
}

.header-separator {
  color: var(--green);
}

.header-muted {
  color: var(--muted);
}

.header-value {
  color: var(--text);
  font-weight: 700;
}

.header-warning {
  color: var(--yellow);
  font-weight: 700;
}

.header-filter {
  color: var(--yellow);
  font-weight: 700;
}

.header-cursor {
  color: var(--muted);
}

.table-wrap {
  display: grid;
  gap: 0;
}

.demo-row {
  display: grid;
  gap: 2ch;
  align-items: baseline;
  min-height: 1.48em;
  color: var(--text);
}

.demo-row.header {
  color: var(--dim);
}

.active-sort {
  color: var(--text);
  font-weight: 700;
}

.demo-row.separator {
  color: var(--track);
  user-select: none;
}

.demo-row.selected {
  background: var(--highlight);
}

.demo-row.total {
  color: var(--dim);
}

.cell {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cell.right {
  text-align: right;
}

.cell.bar {
  white-space: pre;
  text-overflow: clip;
}

.bar-track {
  color: var(--track);
}

.sort-arrow {
  color: var(--green);
  font-weight: 400;
  margin-left: 0.4ch;
}

.pct {
  font-weight: 700;
}

.heat-green {
  color: var(--green);
}

.heat-yellow {
  color: var(--yellow);
}

.heat-orange {
  color: var(--orange);
}

.heat-red {
  color: var(--red);
}

.dim {
  color: var(--dim);
}

.key-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55ch;
  color: var(--muted);
}

.key-label {
  color: var(--text);
  font-weight: 700;
  margin-right: 0.7ch;
}

.key-separator {
  color: var(--green);
  margin: 0 1.1ch;
}

.key-button,
.restart-button {
  border: 0;
  color: var(--key-fg);
  background: var(--key-bg);
  cursor: pointer;
}

.key-button {
  padding: 0.08em 0.58em 0.12em;
  min-height: 1.6em;
}

.key-button:hover,
.key-button:focus-visible,
.restart-button:hover,
.restart-button:focus-visible {
  background: var(--green-strong);
  outline: none;
}

.key-desc {
  margin-right: 1.2ch;
}

.filter-line {
  display: flex;
  align-items: center;
}

.filter-label {
  color: var(--green);
  font-weight: 700;
  white-space: pre;
}

.filter-input {
  min-width: 0;
  border: 0;
  padding: 0;
  color: var(--text);
  font-weight: 700;
  background: transparent;
  caret-color: var(--muted);
  outline: none;
}

.filter-hint {
  color: var(--dim);
  white-space: pre;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(18px, 4vw, 54px);
  max-width: 980px;
}

.help-panel-title {
  margin-bottom: 0.65em;
}

.help-panel-marker {
  color: var(--green);
  white-space: pre;
}

.help-panel-text {
  color: var(--text);
  font-weight: 700;
}

.help-row,
.detail-row,
.metric-row {
  display: grid;
  grid-template-columns: 15ch minmax(0, 1fr);
  gap: 1ch;
}

.help-row {
  grid-template-columns: 8ch minmax(0, 1fr);
  min-height: 1.75em;
}

.help-badge {
  justify-self: start;
  padding: 0.08em 0.58em 0.12em;
  color: var(--key-fg);
  background: var(--key-bg);
}

.detail-title-leader {
  color: var(--green);
  font-weight: 700;
  white-space: pre;
}

.detail-title-text {
  color: var(--text);
  font-weight: 700;
}

.detail-section {
  display: grid;
  gap: 0.2em;
  margin-top: 1.1em;
}

.detail-label {
  color: var(--dim);
}

.detail-value {
  color: var(--text);
  font-weight: 700;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.metric-value {
  display: inline-block;
  min-width: 8ch;
}

.sparkline {
  display: inline-flex;
  gap: 0;
  white-space: nowrap;
  font-weight: 400;
}

.quit-panel {
  display: grid;
  gap: 1em;
  width: min(56ch, 100%);
}

.quit-title {
  color: var(--green);
  font-weight: 700;
}

.restart-button {
  justify-self: start;
  padding: 0.48em 0.86em;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 760px) {
  .demo-page {
    align-items: stretch;
    padding: 0;
    gap: 0;
  }

  .demo-header {
    display: none;
  }

  .terminal-window {
    min-height: 100vh;
    border-left: 0;
    border-right: 0;
  }

  .terminal-titlebar {
    grid-template-columns: 1fr;
  }

  .window-controls {
    display: none;
  }

  .terminal-screen {
    padding: 14px;
    font-size: 12px;
  }

  .help-grid {
    grid-template-columns: 1fr;
    gap: 1.2em;
  }
}