.pane {
  position: absolute;
  inset: 0;
  padding: 10px 12px 12px;
  display: none;
}
.pane.is-active { display: block; }

.pane__inner {
  width: 100%;
  height: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: var(--shadow-1);
  overflow: hidden;
  position: relative;
}

.pane__grid {
  display: grid;
  width: 100%;
  height: 100%;
  /* gap is 0: the 6 px CSS-grid tracks interleaved between cells (in
   * .pane__gutter elements) provide the visual separation and ARE the
   * drag handles. Adding `gap` here would double-space everything. */
  gap: 0;
}

.shell-cell {
  position: relative;
  background: #07090d;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  padding: 8px;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.shell-cell:focus-within {
  border-color: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

/* Active during drag-over-with-files. Overlays a dashed border + a
 * faint label so the user sees the drop target without losing the
 * underlying terminal contents. pointer-events: none on the ::after
 * pseudo so the drop event still reaches the cell handler. */
.shell-cell--drop-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.shell-cell--drop-active::after {
  content: "Drop to upload";
  position: absolute;
  inset: 8px;
  z-index: 5;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(124, 140, 255, 0.08);
  border: 1.5px dashed var(--accent);
  border-radius: var(--radius-sm);
  pointer-events: none;
}

.shell-cell__host {
  width: 100%;
  height: 100%;
}

/* User-assigned pane label. Sits on top of the terminal at the top edge,
 * faint by default and a little more visible on hover so the user can scan
 * a grid of nine panes and find the one they need. pointer-events: none so
 * it never steals a mouse-drag from xterm's selection. */
.shell-cell__name {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 20px);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--fg);
  opacity: 0.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  user-select: none;
  z-index: 3;
  text-shadow: 0 0 6px rgba(7, 9, 13, 0.85), 0 0 2px rgba(7, 9, 13, 0.85);
  transition: opacity var(--t-fast) var(--ease);
}
.shell-cell:hover .shell-cell__name { opacity: 0.7; }
.shell-cell__name[hidden] { display: none; }

/* Hover-revealed "+ pane" button. Top-right corner of each shell-cell;
 * clicking appends a new pane to the same tab. Stays subtle so it
 * doesn't compete with terminal content, but reaches full opacity on
 * direct hover so it's easy to land on. */
.shell-cell__add-pane {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(7, 9, 13, 0.78);
  color: var(--fg-muted);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.shell-cell:hover .shell-cell__add-pane { opacity: 0.55; }
.shell-cell__add-pane:hover {
  opacity: 1;
  color: var(--accent-strong);
  border-color: var(--accent);
  background: rgba(7, 9, 13, 0.95);
}

/* Hover-revealed close (×) button. Top-left corner so it can't be
 * confused with the + button at top-right, and so the muscle memory
 * for "add another pane" stays put. Same hover-fade pattern as +; on
 * direct hover it goes red so destructive intent reads clearly. */
.shell-cell__close-pane {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 4;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(7, 9, 13, 0.78);
  color: var(--fg-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition:
    opacity var(--t-fast) var(--ease),
    color var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease),
    background var(--t-fast) var(--ease);
}
.shell-cell:hover .shell-cell__close-pane { opacity: 0.55; }
.shell-cell__close-pane:hover {
  opacity: 1;
  color: #ff97a4;
  border-color: #ff7a8a;
  background: rgba(40, 12, 18, 0.95);
}

/* Touch devices have no hover — without this the add/close pane buttons
   are invisible and effectively undiscoverable. Show them dimly by
   default so users know the controls exist; activation still requires
   a deliberate tap. */
body.is-touch .shell-cell__add-pane,
body.is-touch .shell-cell__close-pane { opacity: 0.4; }

/* iOS Safari auto-zooms the page when an input/textarea with computed
   font-size < 16px gains focus. The xterm helper textarea (offscreen,
   used for IME + keyboard capture) inherits the terminal's smaller
   font, so every tap on a pane re-zoomed the chrome on iPhone. Pinning
   the helper to 16px disables that path; the visible terminal text is
   rendered by xterm's renderer, not the textarea, so this has zero
   visual impact. Covers MOBILE_SMOKE A8 / K9 / usability M2. */
.xterm-helper-textarea { font-size: 16px !important; }

/* Resize gutters between panes. Sit on the 6 px CSS-grid tracks
 * interleaved between cells and own a pointer cursor matching their
 * axis. Subtle by default; glow on hover/drag so it's clear the user
 * can grab them. */
.pane__gutter {
  position: relative;
  background: transparent;
  z-index: 2;
  transition: background var(--t-fast) var(--ease);
}
.pane__gutter--col { cursor: col-resize; }
.pane__gutter--row { cursor: row-resize; }
.pane__gutter:hover,
.pane__gutter.is-dragging {
  background: var(--accent-soft);
}
.pane__gutter.is-dragging { background: var(--accent); }

/* Inline rename input, centered over the pane like a small modal. */
.shell-cell__name-input {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: min(70%, 360px);
  background: rgba(7, 9, 13, 0.92);
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.03em;
  text-align: center;
  padding: 8px 12px;
  outline: none;
  box-shadow:
    0 0 0 1px rgba(124, 140, 255, 0.25),
    0 12px 32px rgba(0, 0, 0, 0.55);
}

.shell-cell__overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  background: rgba(7, 9, 13, 0.92);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-med) var(--ease);
  z-index: 2;
  border-radius: inherit;
}
.shell-cell__overlay.is-visible { opacity: 1; pointer-events: auto; }
.shell-cell__overlay > * { display: grid; place-items: center; }
.shell-cell__overlay-text { margin-top: 8px; letter-spacing: 0.02em; }

.spinner {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid var(--surface-3);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.xterm-viewport { background-color: transparent !important; }
.xterm .xterm-cursor-layer { z-index: 3; }

/* ──────────────────────────────────────────────────────────────────
 * Anti-rAF-throttling: keep the compositor firing frames.
 *
 * This was the root cause behind months of "type 10 chars, see 7" /
 * "chars coming from behind" complaints — NOT network latency.
 * xterm.js's renderer is rAF-driven, and Chromium-based browsers
 * (Opera GX is especially aggressive) suspend requestAnimationFrame
 * when the page "looks idle": no animations, no scroll, no input.
 * When rAF stalls, xterm's write-queue drains ~one chunk per stalled
 * frame, so the visible screen lags N writes behind reality. Each
 * keystroke transiently wakes rAF, which is why screens "catch up"
 * a bit on every press, then fall behind again.
 *
 * A perpetual sub-pixel animation forces the compositor into
 * continuous paint mode, so rAF stays awake at 60Hz and xterm's
 * renderer drains writes immediately. The transform is invisible
 * (stationary at both endpoints) but the animation system can't
 * optimize it away because the property is non-discrete.
 * ────────────────────────────────────────────────────────────────── */
.xterm { animation: terman-keepalive 1s linear infinite; }
@keyframes terman-keepalive {
  0%, 100% { transform: translateZ(0); }
  50%      { transform: translateZ(0.001px); }
}
