/* The row that centers [terminal-stack, player] as a pair -- player.css
   defines #player's own share of this row. Using flex here (rather than
   position:fixed on the player) is what actually guarantees no overlap:
   the terminal shrinks to make room instead of the two fighting over the
   same fixed-viewport coordinates. */
#layout-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  /* nowrap is load-bearing: #terminal-stack's max-width (900) + #player's
     basis (260) + gap exceeds this row's own max-width (1200) once padding
     is subtracted, so `wrap` here silently pushed the player onto an
     invisible second line that overflowed past the row's fixed height on
     EVERY desktop viewport -- not just narrow ones. Both children can
     shrink (min-width:0 / min-width:200px), so nowrap just lets them share
     the space instead of wrapping. The mobile column-stack is handled
     explicitly by the max-width:780px query in player.css. */
  flex-wrap: nowrap;
  gap: 1.25rem;
  height: calc(100vh - 3rem);
  margin: 1.5rem auto;
  max-width: 1560px;
  padding: 0 1.5rem;
}

/* An invisible mirror of #player's width (see player.css -- same flex
   shorthand, kept in sync deliberately) sitting on the opposite side of
   #terminal-stack. Because it's an equal-width sibling rather than a
   plain justify-content:center, #terminal-stack's flex-grow naturally
   lands it centered on the page instead of centered-within-the-pair
   (which visibly skews left once the player's width is added on the
   right only). */
#layout-spacer {
  flex: 0 1 260px;
  min-width: 200px;
}

#terminal-stack {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 900px;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

#terminal {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.75rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(3px) saturate(140%);
  -webkit-backdrop-filter: blur(3px) saturate(140%);
  box-shadow: 0 0 70px rgba(168, 85, 247, 0.08), 0 20px 50px rgba(0, 0, 0, 0.45);
}

#mode-toggle-btn {
  flex: 0 0 auto;
  align-self: flex-start;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

#scrollback {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
  font-weight: 300;
  line-height: 1.6;
  padding-bottom: 1rem;
}

#scrollback .line {
  min-height: 1.4em;
}

#scrollback .line.logo {
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(129, 140, 248, 0.4);
  /* The vw term is load-bearing, not just a mobile nicety -- confirmed
     live (screenshot from an iPhone) that the fixed 0.8rem/media-query
     sizing below let the box's right border render off the edge of the
     screen, clipped by the panel. The box is a fixed 28 monospace
     characters wide regardless of viewport, and box-drawing glyphs
     (═ ║ ╔ █ etc.) don't reliably measure at the same width as a plain
     ASCII character across every mobile font-fallback stack -- so a size
     picked to fit the DECLARED character count can still overflow in
     practice. Scaling part of the font-size directly off 100vw instead
     means the box's rendered width stays a roughly constant fraction of
     the viewport no matter how wide any individual glyph actually turns
     out to be, which a fixed rem/breakpoint value can't guarantee.
     min() keeps it from getting oversized on wide desktop windows. */
  font-size: min(0.8rem, 3.2vw);
  line-height: 1.35;
}

/* These aren't scoped to .line -- they're used both as whole-line classes
   (e.g. <div class="line sys">) and as inline span classes within a line
   built by printSegments(), for actual in-line syntax-highlighting instead
   of every line being one flat color. */
#scrollback .sys {
  color: var(--fg-dim);
}

#scrollback .accent {
  color: var(--accent);
}

#scrollback .accent2 {
  color: var(--accent-2);
}

#scrollback .warn {
  color: var(--accent-3);
}

#scrollback .prompt-user {
  color: var(--accent);
  font-weight: 400;
}

#scrollback .line.welcome {
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.55;
}

#scrollback .accent-name {
  color: var(--accent-2);
  font-weight: 500;
  text-shadow: 0 0 10px rgba(129, 140, 248, 0.4);
}

#scrollback .line.hint {
  font-size: 1rem;
  font-weight: 400;
}

#scrollback .hint-arrow {
  color: var(--accent);
  margin-right: 0.5em;
}

#scrollback .cmd {
  color: var(--accent);
  font-weight: 500;
  text-shadow: 0 0 10px rgba(244, 114, 182, 0.35);
}

.prompt-line {
  display: flex;
  /* Not center: the label/input's TEXT sits near the bottom of its own
     line box (close to its baseline), so a geometrically height-centered
     circle next to it reads as sitting slightly high -- flex-end lines up
     the bottom edges instead, which visually reads as "on the same line"
     the way text-baseline-aligned icons usually do. */
  align-items: flex-end;
  gap: 0.5em;
  border-top: 1px solid var(--panel-border);
  padding-top: 0.75rem;
}

/* Sized close to #cmd-input's own text line height (~20px), not the
   player card's 26-32px buttons -- at 26px the circle visibly overhung
   the text above and below despite being mathematically centered on the
   same axis, which read as misaligned rather than just bigger. */
#mic-btn {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

#mic-btn svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

/* Hidden by default -- Enter already submits reliably with a mouse and
   keyboard. Shown only for touch/coarse-pointer input (see the
   pointer:coarse query below), where tapping away from the input to
   dismiss the keyboard is a natural gesture that would otherwise just
   close the keyboard with nothing sent -- confirmed as a real, reported
   usability problem, not a hypothetical one. */
.prompt-send-btn {
  display: none;
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.prompt-send-btn svg {
  width: 13px;
  height: 13px;
}

@media (pointer: coarse) {
  .prompt-send-btn {
    display: flex;
  }
}

/* Steady glow for the whole hands-free session (on between turns too, not
   just while actively capturing) -- .listening layers its pulse on top
   only during an actual capture cycle, so the two together read as
   "voice mode is on" vs. "and it's listening right now." */
#mic-btn.handsfree {
  border-color: var(--accent-2);
  color: var(--accent-2);
  box-shadow: 0 0 8px rgba(129, 140, 248, 0.5);
}

#mic-btn.listening {
  border-color: var(--accent);
  color: var(--accent);
  animation: mic-pulse 1.1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(244, 114, 182, 0.45);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(244, 114, 182, 0);
  }
}

.prompt-label {
  color: var(--accent);
  white-space: nowrap;
  font-size: 0.92rem;
  font-weight: 400;
}

#cmd-input {
  flex: 1;
  /* Flex items default to a content-based min-width, not 0 -- for a text
     input that's tied to its font-size (roughly the classic default
     size=20 intrinsic width), so bumping the font-size for the iOS
     zoom-on-focus fix below also raised this floor. Without resetting it,
     the input refused to shrink enough on narrow phones, overflowing
     .prompt-line and pushing #mic-btn (the last flex child) out past the
     terminal's edge -- confirmed live, not theoretical. */
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: var(--font);
  font-weight: 300;
  font-size: 0.92rem;
  caret-color: var(--accent);
}

#cmd-input:disabled {
  opacity: 0.5;
}

@media (max-width: 780px) {
  #terminal {
    padding: 1.15rem 1.25rem;
  }

  /* iOS Safari auto-zooms the whole page on focus for any input under
     16px, which is what was causing the view to jump/refocus every time
     the terminal input got focus (including programmatically, e.g. from
     voice mode) -- 16px is the documented threshold that avoids it. */
  #cmd-input {
    font-size: 16px;
  }

  #scrollback {
    font-size: 0.85rem;
  }

  /* No .line.logo override here anymore -- its own min(0.8rem, 3.2vw)
     rule already scales correctly at every width, and a fixed value here
     would win over it by source order and reintroduce the overflow this
     was fixed to prevent. */

  #scrollback .line.welcome {
    font-size: 1rem;
  }
}

@media (max-width: 420px) {
  /* "guest@hypernaut:~$" is long enough that at full size on a narrow
     phone it crowds the input down to a sliver -- shrinking the label
     (not the input) keeps typing comfortable. */
  .prompt-label {
    font-size: 0.72rem;
  }

  /* Stays at 16px here too (not shrinking further like the label does) --
     see the 780px query above for why. */
  #cmd-input {
    font-size: 16px;
  }

}
