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

:root {
  --ivory: #f6f4f0;
  --warm-black: #1a1917;
  --gold: #c9a84c;
  --gold-muted: #b89a45;
  --stone: #8a857a;
  --light-stone: #d4d0c8;
  --parchment: #ece8e1;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Jost', sans-serif;
  font-weight: 300;
  background-color: var(--ivory);
  color: var(--warm-black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

/* Subtle grain overlay */
.ambient {
  position: fixed;
  top: -20%;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(ellipse at center, rgba(201, 168, 76, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---- Navbar (authed area only; flows in normal layout, not floating) ---- */
.navbar {
  position: relative;
  width: 100%;
  background: var(--warm-black);
  border-bottom: 1px solid #2c2a26;
  flex-shrink: 0;
}

.nav-inner {
  width: 100%;
  padding: 0.3rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Hamburger toggle — hidden on desktop, shown on narrow screens. */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--stone);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.1rem 0.3rem;
  cursor: pointer;
  transition: color 0.3s ease;
}

.nav-toggle:hover { color: var(--gold); }

.nav-menu {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-link {
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--stone);
  transition: color 0.3s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--gold);
}

/* tmux window controls */
.tmux-ctl {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.tmux-ctl button {
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--light-stone);
  background: #232118;
  border: 1px solid #3a3833;
  border-radius: 3px;
  padding: 0.22rem 0.45rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tmux-ctl button:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: #2b281f;
}

.tmux-ctl button.danger:hover {
  border-color: #a23b2c;
  color: #e07a6b;
}

.nav-logout {
  display: inline;
}

.nav-logout button {
  font-family: inherit;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--stone);
  background: none;
  border: 1px solid #3a3833;
  border-radius: 2px;
  padding: 0.22rem 0.6rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.nav-logout button:hover {
  border-color: var(--gold);
  color: var(--gold);
}

@media (max-width: 600px) {
  .nav-inner { gap: 0.5rem; }
  .nav-left, .nav-right { gap: 0.4rem; }

  /* Collapse the link menu behind the hamburger. */
  .nav-toggle { display: block; }
  .nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 1.1rem;
    min-width: 160px;
    padding: 1.1rem 1.3rem;
    background: var(--warm-black);
    border-bottom: 1px solid #2c2a26;
    border-right: 1px solid #2c2a26;
    border-bottom-right-radius: 4px;
    z-index: 50;
  }
  body.nav-open .nav-menu { display: flex; }

  .tmux-ctl { gap: 0.25rem; }
  .tmux-ctl button { font-size: 1.05rem; padding: 0.2rem 0.4rem; }
}

/* ---- Home ---- */
main.home {
  z-index: 1;
  width: 100%;
  max-width: 640px;
  padding: 0 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.logo-container {
  margin-top: clamp(3rem, 10vh, 7rem);
  margin-bottom: 2rem;
}

.logo-container img {
  display: block;
  max-width: 100%;
  height: auto;
}

.divider {
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--light-stone), transparent);
  margin-bottom: 2rem;
}

.tagline {
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--stone);
  letter-spacing: 0.08em;
  text-align: center;
  line-height: 1.7;
  margin-bottom: clamp(3rem, 8vh, 5rem);
}

.section-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--stone);
  margin-bottom: 1.5rem;
}

.products {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: clamp(3rem, 10vh, 6rem);
}

.product-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--light-stone);
  border-radius: 2px;
  text-decoration: none;
  color: var(--warm-black);
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.product-link:hover {
  border-color: var(--gold);
  background: rgba(255, 255, 255, 0.7);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(26, 25, 23, 0.06);
}

.product-link:hover .product-arrow {
  transform: translateX(4px);
  color: var(--gold);
}

.product-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.product-name {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 1.2rem;
  letter-spacing: 0.04em;
}

.product-desc {
  font-size: 0.8rem;
  color: var(--stone);
  letter-spacing: 0.02em;
}

.product-arrow {
  font-size: 1.1rem;
  color: var(--light-stone);
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
  margin-left: 1.5rem;
}

header, section {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.site-footer {
  position: relative;
  z-index: 1;
  margin-top: auto;
  padding: 2rem;
  font-size: 0.7rem;
  color: var(--light-stone);
  letter-spacing: 0.1em;
}

/* ---- Login ---- */
main.auth {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2.5rem 2rem;
  border: 1px solid var(--light-stone);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(8px);
}

.auth-card h1 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 500;
  font-size: 1.6rem;
  letter-spacing: 0.05em;
}

.auth-card form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.auth-card input {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--light-stone);
  border-radius: 2px;
  background: var(--ivory);
  color: var(--warm-black);
  outline: none;
  transition: border-color 0.3s ease;
}

.auth-card input:focus {
  border-color: var(--gold);
}

.auth-card button {
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.7rem;
  border: 1px solid var(--gold);
  border-radius: 2px;
  background: var(--gold);
  color: var(--ivory);
  cursor: pointer;
  transition: all 0.3s ease;
}

.auth-card button:hover {
  background: var(--gold-muted);
  border-color: var(--gold-muted);
}

.auth-error {
  font-size: 0.8rem;
  color: #a23b2c;
  letter-spacing: 0.02em;
}

/* ---- Code / terminal: full-bleed viewport ---- */
body.page-code {
  height: 100vh;      /* fallback for browsers without dvh */
  height: 100dvh;     /* shrinks when the mobile keyboard opens (paired with
                         interactive-widget=resizes-content in the viewport meta) */
  min-height: 0;
  align-items: stretch;
  overflow: hidden;
}

main.code {
  flex: 1;
  width: 100%;
  max-width: none;
  min-height: 0;
  padding: 0;
  display: flex;
  background: #1a1917;
}

#terminal {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.35rem 0.5rem;
  background: #1a1917;
}

/* xterm fills its container, and show a usable scrollbar */
#terminal .xterm,
#terminal .xterm-viewport {
  width: 100% !important;
  height: 100% !important;
}

.xterm-viewport {
  scrollbar-width: thin;
  scrollbar-color: #4a463f #1a1917;
}

.xterm-viewport::-webkit-scrollbar {
  width: 10px;
}

.xterm-viewport::-webkit-scrollbar-track {
  background: #1a1917;
}

.xterm-viewport::-webkit-scrollbar-thumb {
  background: #4a463f;
  border-radius: 5px;
}

.xterm-viewport::-webkit-scrollbar-thumb:hover {
  background: #6a655c;
}

/* ---- Termux-style extra-keys bar (code page) ---- */
.extra-keys {
  flex-shrink: 0;
  display: flex;
  gap: 0.3rem;
  padding: 0.3rem 0.4rem;
  background: var(--warm-black);
  border-top: 1px solid #2c2a26;
}

.extra-keys button {
  flex: 1 1 0;
  min-width: 0;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.8rem;
  line-height: 1;
  color: var(--light-stone);
  background: #232118;
  border: 1px solid #3a3833;
  border-radius: 4px;
  padding: 0.55rem 0.2rem;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.extra-keys button.wide { flex: 2 1 0; }

.extra-keys button:hover { border-color: var(--gold); color: var(--gold); }
.extra-keys button:active { background: #2b281f; }

/* Sticky CTRL while armed. */
.extra-keys button.armed {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--warm-black);
}

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

@media (max-width: 480px) {
  main.home { padding: 0 1.25rem; }
  .product-link { padding: 1rem 1.25rem; }
}
