html,
body {
  height: 100%;
}

body {
  box-sizing: border-box;
  min-height: 100vh;
  padding: 24px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  transition: background 300ms ease, color 300ms ease;
}

.terminal {
  width: min(900px, 95vw);
  height: min(560px, 85vh);
  overflow: hidden;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 16px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(100, 255, 218, 0.06), transparent 70%),
    var(--panel);
  box-shadow: var(--shadow);
}

.terminal::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.03),
    rgba(255, 255, 255, 0.03) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.25;
}

.titlebar {
  box-sizing: border-box;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.02));
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.terminal.js-enabled .titlebar {
  cursor: grab;
}

.dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  display: inline-block;
  border-radius: 50%;
}

.dot.red { background: #ff5f57; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #28c840; }

.titlebar .name {
  margin-left: 8px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.viewport {
  box-sizing: border-box;
  height: calc(100% - 40px);
  padding: 18px 18px 44px;
  overflow: auto;
  scrollbar-width: thin;
}

.line {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.prompt {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.prompt > .muted {
  flex: 0 0 auto;
  white-space: nowrap;
}

.prompt-input {
  min-width: 0;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  caret-color: var(--accent);
}

.terminal a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dashed rgba(100, 255, 218, 0.4);
}

.terminal a:hover {
  border-bottom-style: solid;
}

.footer {
  display: none;
  position: absolute;
  right: 34px;
  bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.terminal.js-enabled .footer {
  display: block;
}

.kbd {
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
}

.terminal.dragging .titlebar {
  cursor: grabbing;
}

.resize-handle {
  box-sizing: border-box;
  position: absolute;
  width: 20px;
  height: 20px;
  right: 6px;
  bottom: 6px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.15);
  cursor: nwse-resize;
  touch-action: none;
}

.resize-handle[hidden] {
  display: none;
}

.resize-handle::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  opacity: 0.8;
}

.titlebar[role="button"]:focus-visible,
.resize-handle:focus-visible,
.prompt-input:focus-visible,
.terminal a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.no-script {
  max-width: 620px;
  margin: 0 auto;
}

.no-script h1 {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: clamp(1.8rem, 7vw, 2.8rem);
}

.no-script ul {
  display: grid;
  gap: 8px;
  padding-left: 22px;
}

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

@media (max-width: 480px) {
  body {
    padding: 8px;
  }

  .terminal {
    border-radius: 10px;
  }

  .viewport {
    padding: 14px 14px 48px;
  }

  .footer {
    left: 14px;
    right: 34px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  body {
    transition: none;
  }

  .terminal::after {
    display: none;
  }

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