:root {
  color-scheme: dark;
  --bg: #020402;
  --panel: rgba(0, 0, 0, 0.62);
  --panel-solid: rgba(0, 0, 0, 0.82);
  --ink: #e9ffe9;
  --muted: rgba(233, 255, 233, 0.64);
  --line: rgba(84, 255, 138, 0.2);
  --line-strong: rgba(84, 255, 138, 0.48);
  --green: #54ff8a;
  --cyan: #63ddff;
  --amber: #ffcf5a;
  --coral: #ff6f61;
  --shadow: rgba(0, 0, 0, 0.68);
  --font-pixel: "Jersey 25", "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(105, 255, 0, 0.72) rgba(255, 255, 255, 0.04);
  overflow-x: hidden;
  background: var(--bg);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.04);
}

::-webkit-scrollbar-thumb {
  background: rgba(105, 255, 0, 0.72);
  border-radius: 999px;
  border: 2px solid rgba(0, 0, 0, 0.6);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--green);
}

body {
  width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: 0;
  position: relative;
  z-index: 0;
}

body.layout-terminal {
  min-height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

body.layout-content {
  height: auto;
  min-height: 100dvh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  background: #020402 url("media/background-duck.webp") top left / auto repeat;
  opacity: 0;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 35%, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.54) 78%),
    linear-gradient(rgba(0, 0, 0, 0.16) 50%, rgba(0, 0, 0, 0.28) 50%);
  background-size: auto, 100% 4px;
}

a {
  color: var(--cyan);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.17em;
}

a:hover,
a:focus-visible {
  color: var(--green);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.agent-canary {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.site-shell {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr;
  margin: 0;
  padding: 0;
  padding-top: 49px; /* Desktop navbar height */
}

@media (max-width: 768px) {
  .site-shell {
    padding-top: 61px; /* Mobile navbar height */
  }
}

.terminal-stage {
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4rem 1.25rem 2rem;
  width: 100%;
}

.terminal-window {
  width: 100%;
  max-width: 1140px;
  height: 100%;
  max-height: 85vh;
  min-height: 600px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(105, 255, 0, 0.2);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.1);
  box-shadow: 0 24px 90px var(--shadow), 0 0 0 1px rgba(105, 255, 0, 0.1);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.terminal-titlebar {
  min-height: 40px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.6);
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.window-dots {
  display: flex;
  gap: 7px;
}

.window-dots span {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--coral);
}

.window-dots span:nth-child(2) {
  background: var(--amber);
}

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

.title-copy {
  min-width: 0;
}

.title-copy strong,
.title-copy span {
  display: inline;
}

.title-copy strong {
  margin-right: 10px;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 400;
}

.title-copy span {
  color: var(--muted);
  font-size: 0.82rem;
}

.title-copy .powered-by {
  margin-left: 10px;
  color: var(--green);
}

.node-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-size: 0.88rem;
  white-space: nowrap;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
  animation: pulse 1.8s ease-in-out infinite;
}

/* Global Custom Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.35);
  border-left: 1px solid rgba(84, 255, 138, 0.14);
}

::-webkit-scrollbar-thumb {
  background: rgba(84, 255, 138, 0.58);
  border: 2px solid rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  box-shadow: 0 0 12px rgba(84, 255, 138, 0.4);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(84, 255, 138, 0.88);
}

/* Firefox support */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(84, 255, 138, 0.58) rgba(0, 0, 0, 0.35);
}

.terminal-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 10px;
  color: var(--green);
  font-size: 1rem;
  line-height: 1.18;
  text-shadow: 0 0 16px rgba(84, 255, 138, 0.3);
}

.terminal-output pre {
  margin: 0 0 12px;
  color: var(--green);
  font: inherit;
  line-height: inherit;
  white-space: pre-wrap;
}

.terminal-output .line {
  display: table;
  margin-bottom: 7px;
  padding: 1px 5px;
  background: rgba(0, 0, 0, 0.34);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.terminal-output .typed-block {
  display: table;
  padding: 2px 5px;
  background: rgba(0, 0, 0, 0.34);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

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

.terminal-output .ok {
  color: var(--green);
}

.terminal-output .warn {
  color: var(--amber);
}

.terminal-output .hot {
  color: var(--coral);
}

.terminal-output .cyan,
.terminal-output .user-command {
  color: var(--cyan);
}

.terminal-logo {
  display: inline-block;
  margin: 4px 0 10px;
  color: var(--green);
  font-size: clamp(3rem, 6vw, 5.8rem);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 0.84;
  text-transform: none;
  text-shadow: 0 0 28px rgba(84, 255, 138, 0.48);
}

.terminal-form {
  min-height: 46px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel-solid);
}

.prompt-label {
  color: var(--green);
  white-space: nowrap;
  text-shadow: 0 0 16px rgba(84, 255, 138, 0.36);
}

#command-input {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  padding: 0 8px;
  caret-color: var(--green);
}

#command-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(84, 255, 138, 0.18), 0 0 22px rgba(84, 255, 138, 0.18);
}

.terminal-form button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  color: var(--ink);
}

.terminal-form button:hover,
.terminal-form button:focus-visible {
  border-color: var(--green);
  color: var(--green);
}

.duck-mode::before {
  opacity: 0.98;
  filter: saturate(1.25) contrast(1.08);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.72;
  }
  50% {
    transform: scale(1.35);
    opacity: 1;
  }
}

.matrix-mode {
  --bg: #000000;
  --ink: #00ff41;
  --muted: rgba(0, 255, 65, 0.6);
  --cyan: #00ff41;
  --green: #00ff41;
}

.matrix-mode body::before {
  background: #000 url("media/background-duck.webp") top left / auto repeat;
  filter: sepia(100%) hue-rotate(80deg) saturate(400%) contrast(1.5);
  opacity: 0.95;
}

.matrix-mode .terminal-window {
  background: rgba(0, 5, 0, 0.85);
  box-shadow: 0 0 30px rgba(0, 255, 65, 0.2) inset;
}

.matrix-mode .terminal-output {
  text-shadow: 0 0 5px rgba(0, 255, 65, 0.8);
}

.matrix-mode input {
  text-shadow: 0 0 5px rgba(0, 255, 65, 0.8);
}

#back-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.86);
  color: var(--green);
  font-family: var(--mono);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 150ms ease, transform 150ms ease, border-color 150ms ease;
}

#back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#back-to-top:hover {
  border-color: var(--green);
}

@media (max-width: 900px) {
  html,
  body {
    font-size: 18px;
  }

  .site-shell {
    width: 100%;
    padding: 0;
  }

  .terminal-titlebar {
    grid-template-columns: auto 1fr auto;
    min-height: 34px;
    padding: 6px 12px;
  }

  .node-state {
    grid-column: 3;
    font-size: 0.75rem;
  }

  .title-copy .guest-shell {
    display: none;
  }

  .title-copy .powered-by {
    display: inline;
    margin-left: 0;
  }

  .terminal-output {
    padding: 14px 12px 8px;
    font-size: 0.94rem;
  }

  .terminal-logo {
    font-size: clamp(3.2rem, 18vw, 5.4rem);
  }

  .terminal-form {
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: 94px;
    padding: 12px 10px max(36px, env(safe-area-inset-bottom));
  }
}
