:root {
  color-scheme: dark;
  --page-bg: #06100f;
  --window-bg: rgba(6, 15, 16, 0.9);
  --window-border: rgba(135, 238, 208, 0.2);
  --header-bg: rgba(18, 32, 33, 0.92);
  --text: #cde6dd;
  --muted: #77968e;
  --accent: #7fffd4;
  --accent-soft: #91cbb9;
  --path: #f4bf75;
  --heading: var(--accent);
  --link: #a8c7ff;
  --prompt-user: var(--accent);
  --error: #ff8f8f;
  --shadow: rgba(0, 0, 0, 0.5);
  --glow: rgba(94, 255, 210, 0.1);
  --terminal-line-height: 1.55rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

body[data-terminal-theme="matrix"] {
  --page-bg: #020802;
  --window-bg: rgba(0, 12, 2, 0.94);
  --window-border: rgba(61, 255, 103, 0.24);
  --header-bg: rgba(2, 24, 7, 0.92);
  --text: #d4ffd6;
  --muted: #6aaa76;
  --accent: #48ff70;
  --accent-soft: #a7ffb4;
  --path: #b8ff57;
  --error: #ff7b7b;
  --glow: rgba(72, 255, 112, 0.15);
}

body[data-terminal-theme="amber"] {
  --page-bg: #120e09;
  --window-bg: rgba(21, 16, 10, 0.94);
  --window-border: rgba(205, 157, 96, 0.2);
  --header-bg: rgba(34, 26, 17, 0.92);
  --text: #e8d8be;
  --muted: #9f8b6b;
  --accent: #d8ad70;
  --accent-soft: #c9a982;
  --path: #d2bd86;
  --error: #d89078;
  --glow: rgba(205, 157, 96, 0.09);
}

body[data-terminal-theme="glacier"] {
  --page-bg: #08111f;
  --window-bg: rgba(8, 17, 31, 0.94);
  --window-border: rgba(111, 177, 255, 0.26);
  --header-bg: rgba(13, 28, 50, 0.94);
  --text: #d8e9ff;
  --muted: #7f99b8;
  --accent: #85c7ff;
  --accent-soft: #adc7e5;
  --path: #78f0ff;
  --heading: #d9ecff;
  --link: #9bc6ff;
  --prompt-user: #6ea8ff;
  --error: #ff98a9;
  --glow: rgba(78, 150, 255, 0.13);
}

body[data-terminal-theme="light"] {
  color-scheme: light;
  --page-bg: #e6f4f1;
  --window-bg: rgba(247, 255, 252, 0.93);
  --window-border: rgba(45, 102, 95, 0.2);
  --header-bg: rgba(225, 243, 239, 0.94);
  --text: #173430;
  --muted: #637b75;
  --accent: #087c6c;
  --accent-soft: #285d55;
  --path: #9a5f00;
  --error: #b00020;
  --shadow: rgba(36, 65, 60, 0.22);
  --glow: rgba(20, 126, 108, 0.08);
}

* {
  box-sizing: border-box;
}

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

body[data-terminal-theme="matrix"] {
  background: linear-gradient(145deg, #020a03, var(--page-bg) 62%, #000300);
}

body[data-terminal-theme="amber"] {
  background: linear-gradient(145deg, #19120b, var(--page-bg) 60%, #080604);
}

body[data-terminal-theme="glacier"] {
  background: linear-gradient(145deg, #0d1b2f, var(--page-bg) 60%, #030814);
}

body[data-terminal-theme="light"] {
  background: linear-gradient(145deg, #f5fffc, var(--page-bg) 60%, #d4ebe6);
}

body {
  background: linear-gradient(145deg, #071312, var(--page-bg) 60%, #040a0b);
  color: var(--text);
}

body::before {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(142, 255, 221, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(142, 255, 221, 0.025) 1px, transparent 1px);
  background-size: 42px 42px;
  content: "";
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 92%);
  pointer-events: none;
}

.terminal-page {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3.4rem clamp(1rem, 4vw, 4rem) 2rem;
}

.return-link,
.page-note {
  width: min(100%, 1080px);
}

.return-link {
  color: var(--accent-soft);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  opacity: 0.78;
  text-decoration: none;
  transition: color 160ms ease, opacity 160ms ease;
}

.return-link:hover,
.return-link:focus-visible {
  color: var(--accent);
  opacity: 1;
}

.terminal-window {
  width: min(100%, 1080px);
  min-height: min(710px, 76vh);
  overflow: hidden;
  border: 1px solid var(--window-border);
  border-radius: 12px;
  background: var(--window-bg);
  box-shadow:
    0 24px 64px var(--shadow),
    0 0 70px var(--glow),
    inset 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(18px);
}

.terminal-header {
  display: grid;
  min-height: 42px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid rgba(144, 218, 201, 0.1);
  background: var(--header-bg);
  padding: 0 0.85rem;
}

.window-controls {
  display: flex;
  gap: 0.52rem;
}

.window-control {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.2);
}

.window-control-close {
  background: #ff5f57;
}

.window-control-minimize {
  background: #febc2e;
}

.window-control-expand {
  background: #28c840;
}

.terminal-title {
  margin: 0;
  color: #8ca49f;
  font-size: 0.71rem;
  letter-spacing: 0.02em;
  text-align: center;
}

.terminal-body {
  min-height: calc(min(710px, 76vh) - 42px);
  max-height: calc(88vh - 42px);
  overflow-y: auto;
  padding: clamp(1rem, 2.5vw, 1.8rem);
  cursor: text;
  scrollbar-color: rgba(127, 255, 212, 0.28) transparent;
  scrollbar-width: thin;
}

.terminal-output {
  line-height: 1.55;
}

.output-block {
  margin: 0 0 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.output-echo {
  margin-bottom: 0.4rem;
  color: var(--muted);
}

.output-accent {
  color: var(--heading);
}

.output-directory {
  color: var(--path);
}

.output-link {
  color: var(--link);
}

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

.help-command {
  color: var(--accent);
}

.help-description {
  color: var(--accent-soft);
}

.output-error {
  color: var(--error);
}

.output-ascii {
  color: var(--accent);
  font-size: clamp(0.56rem, 1.3vw, 0.88rem);
  line-height: 1.12;
  text-shadow: 0 0 14px rgba(127, 255, 212, 0.2);
}

.prompt-line {
  display: flex;
  align-items: center;
  gap: 0.58rem;
  min-height: var(--terminal-line-height);
  line-height: var(--terminal-line-height);
}

.prompt-label {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  line-height: var(--terminal-line-height);
}

.prompt-user {
  color: var(--prompt-user);
}

.prompt-path {
  color: var(--path);
}

.terminal-input {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  height: var(--terminal-line-height);
  flex: 1;
  border: 0;
  border-radius: 0;
  margin: 0;
  outline: 0;
  padding: 0;
  background: transparent;
  caret-color: var(--accent);
  color: var(--text);
  font: inherit;
  line-height: var(--terminal-line-height);
}

.terminal-input:disabled {
  opacity: 0;
}

.is-hidden {
  display: none;
}

.rain-frame {
  min-height: 12.4rem;
  color: rgba(127, 255, 212, 0.86);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  line-height: 1.08;
  text-shadow: 0 0 12px rgba(127, 255, 212, 0.28);
}

.page-note {
  margin: 0;
  color: rgba(142, 182, 172, 0.55);
  font-size: 0.67rem;
  letter-spacing: 0.12em;
  text-align: right;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .terminal-page {
    justify-content: flex-start;
    gap: 0.72rem;
    padding: 1rem 0.7rem;
  }

  .return-link {
    font-size: 0.68rem;
  }

  .terminal-window {
    min-height: calc(100vh - 5.2rem);
    border-radius: 9px;
  }

  .terminal-body {
    min-height: calc(100vh - 7.85rem);
    max-height: calc(100vh - 7.85rem);
    padding: 0.88rem;
    font-size: 0.76rem;
  }

  .terminal-header {
    min-height: 36px;
    padding: 0 0.68rem;
  }

  .window-controls {
    gap: 0.36rem;
  }

  .window-control {
    width: 10px;
    height: 10px;
  }

  .terminal-title {
    font-size: 0.6rem;
  }

  .prompt-line {
    gap: 0.36rem;
  }

  .prompt-user {
    display: none;
  }

  .rain-frame {
    min-height: 10rem;
    overflow: hidden;
    font-size: 0.61rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
