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

body {
  background: #000;
  color: #fff;
  font-family: 'SF Mono', SFMono-Regular, ui-monospace,
    'DejaVu Sans Mono', Menlo, Consolas, monospace;
  font-size: 16px;
  line-height: 1.4;
  /* Remove scrolling - container handles it */
  overflow: hidden;
  /* Fill viewport */
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height - adjusts for keyboard */
  /* Safe area insets for mobile notches and rounded corners */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
}

/* Flexbox container - divides page into header + content */
#container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Header takes natural height, stays at top */
#header {
  flex: 0 0 auto; /* Don't grow or shrink */
  background: #000;
  padding: 20px;
  padding-bottom: 10px;
  /* Ensure rendering performance on iOS Safari */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

#header.loaded {
  border-bottom: none;
}

/* Content area fills remaining space and scrolls */
#content-area {
  flex: 1 1 auto; /* Grow to fill space */
  overflow-y: auto;
  overflow-x: hidden;
  /* Smooth scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

#terminal {
  max-width: 670px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 20px;
  /* Ensure terminal is at least as tall as content-area for proper scrolling */
  min-height: 100%;
}

#output {
  white-space: pre-wrap;
  word-wrap: break-word;
  margin-bottom: 10px;
}

#output .line {
  margin-bottom: 4px;
}

#output .command-echo {
  color: #fff;
  margin-bottom: 8px;
}

.green-prompt {
  color: #00ff00;
}

#output .response {
  color: #fff;
  margin-bottom: 16px;
}

#output .system {
  color: #4ecdc4;
}

#output .dim {
  color: #666;
}

#output a {
  color: #4ecdc4;
  text-decoration: underline;
  cursor: pointer;
}

#output a:hover {
  color: #6fe0d8;
}

#input-line {
  display: flex;
  align-items: center;
  padding-bottom: 20px;
  /* Input flows naturally after output - no sticky positioning */
}

#prompt {
  color: #00ff00;
  margin-right: 1ex;
}

#input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: inherit;
  font-size: inherit;
  caret-color: transparent;
  width: 0ch;
  padding: 0;
  margin-left: 0;
}

/* Custom blinking underscore cursor after input */
#input-line::after {
  content: '_';
  animation: blink 1s step-end infinite;
  margin-left: 0;
}

/* Cursor blink animation - underscore style */
.cursor {
  display: inline;
  animation: blink 1s step-end infinite;
}

.cursor::after {
  content: '_';
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Command links in header */
.command-link {
  color: #fff;
  cursor: pointer;
  text-decoration: none;
}

/* Header layout */
.header-grid {
  display: flex;
  flex-direction: column;
  font-family: inherit;
  /* Center header content within fixed header */
  max-width: 670px;
  margin: 0 auto;
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.header-title {
  white-space: nowrap;
}

.header-instruction {
  white-space: nowrap;
}

.header-commands {
  display: grid;
  grid-template-columns: auto auto auto auto;
  gap: 0 20px;
  text-align: left;
  margin-bottom: 10px;
}

.header-separator {
  width: 100%;
}

/* Mobile responsive */
@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  #terminal {
    padding: 10px;
    padding-bottom: 10px;
  }

  #header {
    /* Reduce padding on mobile for more content space */
    padding: 10px;
    padding-bottom: 10px;
  }

  #input-line {
    /* Extra padding for touch targets */
    padding-bottom: 40px;
  }

  #input {
    /* Prevent iOS Safari auto-zoom on focus (requires 16px minimum) */
    font-size: 16px;
  }

  .header-top-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .header-commands {
    /* 4-column grid on mobile - spread across full width */
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 4px 8px;
    width: 100%;
  }

  .header-separator {
    /* Reduce number of dashes shown on mobile */
    max-width: 200px;
    overflow: hidden;
    white-space: nowrap;
  }
}

/* Scrollbar styling - minimal terminal style */
#content-area::-webkit-scrollbar {
  width: 6px;
}

#content-area::-webkit-scrollbar-track {
  background: #000;
}

#content-area::-webkit-scrollbar-thumb {
  background: #222;
  border-radius: 0;
}

#content-area::-webkit-scrollbar-thumb:hover {
  background: #666666;
}
