/**
 * Copyright (c) 2014 The xterm.js authors. All rights reserved.
 * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
 * https://github.com/chjj/term.js
 * @license MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Originally forked from (with the author's permission):
 *   Fabrice Bellard's javascript vt100 for jslinux:
 *   http://bellard.org/jslinux/
 *   Copyright (c) 2011 Fabrice Bellard
 *   The original design remains. The terminal itself
 *   has been extended to include xterm CSI codes, among
 *   other features.
 */

/**
 *  Default styles for xterm.js
 */

.xterm {
    cursor: text;
    position: relative;
    user-select: none;
    -ms-user-select: none;
    -webkit-user-select: none;
}

.xterm.focus,
.xterm:focus {
    outline: none;
}

.xterm .xterm-helpers {
    position: absolute;
    top: 0;
    /**
     * The z-index of the helpers must be higher than the canvases in order for
     * IMEs to appear on top.
     */
    z-index: 5;
}

.xterm .xterm-helper-textarea {
    padding: 0;
    border: 0;
    margin: 0;
    /* Move textarea out of the screen to the far left, so that the cursor is not visible */
    position: absolute;
    opacity: 0;
    left: -9999em;
    top: 0;
    width: 0;
    height: 0;
    z-index: -5;
    /** Prevent wrapping so the IME appears against the textarea at the correct position */
    white-space: nowrap;
    overflow: hidden;
    resize: none;
}

.xterm .composition-view {
    /* TODO: Composition position got messed up somewhere */
    background: #000;
    color: #FFF;
    display: none;
    position: absolute;
    white-space: nowrap;
    z-index: 1;
}

.xterm .composition-view.active {
    display: block;
}

.xterm .xterm-viewport {
    /* On OS X this is required in order for the scroll bar to appear fully opaque */
    background-color: #000;
    overflow-y: scroll;
    cursor: default;
    position: absolute;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
}

.xterm .xterm-screen {
    position: relative;
}

.xterm .xterm-screen canvas {
    position: absolute;
    left: 0;
    top: 0;
}

.xterm .xterm-scroll-area {
    visibility: hidden;
}

.xterm-char-measure-element {
    display: inline-block;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: -9999em;
    line-height: normal;
}

.xterm.enable-mouse-events {
    /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */
    cursor: default;
}

.xterm.xterm-cursor-pointer,
.xterm .xterm-cursor-pointer {
    cursor: pointer;
}

.xterm.column-select.focus {
    /* Column selection mode */
    cursor: crosshair;
}

.xterm .xterm-accessibility:not(.debug),
.xterm .xterm-message {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 10;
    color: transparent;
    pointer-events: none;
}

.xterm .xterm-accessibility-tree:not(.debug) *::selection {
  color: transparent;
}

.xterm .xterm-accessibility-tree {
  user-select: text;
  white-space: pre;
}

.xterm .live-region {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.xterm-dim {
    /* Dim should not apply to background, so the opacity of the foreground color is applied
     * explicitly in the generated class and reset to 1 here */
    opacity: 1 !important;
}

.xterm-underline-1 { text-decoration: underline; }
.xterm-underline-2 { text-decoration: double underline; }
.xterm-underline-3 { text-decoration: wavy underline; }
.xterm-underline-4 { text-decoration: dotted underline; }
.xterm-underline-5 { text-decoration: dashed underline; }

.xterm-overline {
    text-decoration: overline;
}

.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }
.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }
.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }
.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }
.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }

.xterm-strikethrough {
    text-decoration: line-through;
}

.xterm-screen .xterm-decoration-container .xterm-decoration {
	z-index: 6;
	position: absolute;
}

.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {
	z-index: 7;
}

.xterm-decoration-overview-ruler {
    z-index: 8;
    position: absolute;
    top: 0;
    right: 0;
    pointer-events: none;
}

.xterm-decoration-top {
    z-index: 2;
    position: relative;
}

/* ── diginery: the scrollback scrollbar is DEAD under tmux ─────────────────
   tmux drives the ALTERNATE screen and repaints in place, so output never
   reaches xterm's scrollback buffer — the bar had nothing to scroll, ever
   (history is tmux copy-mode, C-b [; Claude Code pages its own transcript).
   A permanently inert control is removed, not styled. Appended here because
   an inline <style> in a morphed screen would need the page's CSP nonce;
   this file is already ours and already served. */
.xterm .xterm-viewport { scrollbar-width: none; -ms-overflow-style: none; }
.xterm .xterm-viewport::-webkit-scrollbar { display: none; width: 0; }

/* ── the scrollback scrollbar is DEAD under tmux ──────────────────────────
   tmux drives the ALTERNATE screen and repaints in place, so output never
   reaches xterm's scrollback buffer — the bar has nothing to scroll (history
   is tmux copy-mode C-b [; a full-screen app pages its own transcript). A
   permanently inert control is removed, not styled. */
.xterm .xterm-viewport { scrollbar-width: none; -ms-overflow-style: none; }
.xterm .xterm-viewport::-webkit-scrollbar { display: none; width: 0; }

/* ── the shell's layout paddings + system safe areas ──────────────────────
   Here and not inline: literal calc(…+ env(…)) inside an `html { }` block
   trips the block lexer (reads to EOF), and the stylesheet is where the
   framework's own safe-area handling lives (pwa_install_prompt). env() is
   0px wherever there is no system furniture — desktops are untouched; on a
   phone the strip clears the status bar / notch and the key row clears the
   gesture-navigation bar, while both backgrounds extend beneath them. */
/* Bottom stack: terminal, then TABS directly under it -- the active tab is
   a flap hanging from the terminal it belongs to (same background, bottom-
   rounded corners), which is what gives the flipped rounding its meaning --
   then the key row at the very edge, separated by a terminal-dark hairline.
   Inset roles follow the stack: the host absorbs the status-bar inset, the
   key row (bottom-most wherever it exists, i.e. touch devices) absorbs the
   gesture-bar inset, the tab strip carries the side insets. On desktop the
   keys are hidden and the strip is bottom-most, where insets are 0. */
/* [data-dterm-host], NOT #dterm-host: there is one host PER PANE now and an
   id cannot be. Both rules in this file that named the host by id went dead
   the moment the split view renamed it to dterm-host-<pane> — silently, the
   way a CSS selector that matches nothing always does. The one below is the
   one that mattered: without touch-action:none some engines run a native pan
   over the grid, which is the phone this whole app exists for. */
[data-dterm-host] { padding: calc(6px + env(safe-area-inset-top, 0px)) calc(6px + env(safe-area-inset-right, 0px)) 6px calc(6px + env(safe-area-inset-left, 0px)); }
#dterm-tabs { padding: 8px calc(8px + env(safe-area-inset-right, 0px)) 8px calc(8px + env(safe-area-inset-left, 0px)); }
#dterm-keys { padding: 0 8px calc(8px + env(safe-area-inset-bottom, 0px)) 8px; }

/* The terminal owns every touch gesture on this page. overscroll-behavior
   kills the browser's pull-to-refresh/glow at the scroll-chain root (tabs
   strip and key row included); touch-action:none on the host stops Chrome
   from running its native pan/zoom recognizer concurrently with the
   synthetic wheel translation above it. */
html, body { overscroll-behavior: none; }
[data-dterm-host] { touch-action: none; }

/* FIFTEEN PIXELS OF TERMINAL, GIVEN AWAY FOR A SCROLLBAR THAT CANNOT APPEAR.
   The page's root carries `scrollbar-gutter: stable`, which permanently
   reserves the gutter so content does not shift when a scrollbar appears.
   That is the right default for a document — and wrong for this one: the
   shell is position:fixed;inset:0 over a page that never scrolls, so the
   gutter reserves space against an event that can never happen. Measured
   2026-08-26: the shell laid out at 1265px inside a 1280px viewport, with
   documentElement.clientWidth reporting the full 1280 and no scrollbar
   anywhere — which is why it read as a mystery rather than as a gutter.
   Scoped with :has() so it only applies to a page that actually hosts the
   terminal; on a browser without :has() the rule is ignored and the old
   behaviour stands, which is a lost 15px and not a broken layout. */
html:has(#dterm-shell) { scrollbar-gutter: auto; }

/* ── DRAG-REORDER ──────────────────────────────────────────────────────
   Lives here, not in a framework widget: the framework's own lints are
   explicit that a composite Widget may not own CSS/JS (style/W001,
   style/W002) and that a `: Flutter` primitive must be a real
   Flutter-named UNIVERSAL capability (flutter/W012) -- "Reorderable" is
   neither, and the portal's deploy gate refused it. A feature package
   that already ships its own assets is the honest home until a second
   consumer justifies the framework shape (which would be
   ReorderableListView(children:, onReorder:), the name Flutter gives it). */
[data-reorder] {
  position:relative
}
/* THE LIFTED TAB IS A GHOST, AND `pointer-events:none` IS WHAT MAKES THE DROP
   TARGETS REACHABLE AT ALL.

   It tracks the cursor exactly (term.js translates it by the pointer delta) and
   sits at z-index 40, so without this it is the topmost element under the
   pointer for the whole drag — and `aimAt` decides its target with
   `document.elementFromPoint(x, y)`. Every hit test therefore returned the
   LIFTED tab, `it !== lift` refused it, and its `.closest('[data-group-box]')`
   fallback searched upward from inside the thing being dragged. Both branches
   were unreachable by construction: no `.d-reorder-onto` could ever appear, on
   any build, with any callback wired.

   Measured 2026-09-01 while fixing the OTHER half of this (term.js read
   `data-group-cb` off the wrong element): with the callback reachable and the
   drag mid-flight, `elementFromPoint` at the centre of another tab returned
   `A.` inside `data-reorder-key="claudeu/pwalt"` — the dragged tab — with
   `itemIsLifted: true`. Two independent blockers on one never-run path, and
   fixing either alone leaves a feature that still does nothing while looking
   repaired.

   Safe with the gesture as written: term.js takes `setPointerCapture` on the
   container, so pointermove/up arrive there regardless of what is under the
   cursor. `elementFromPoint` is a separate hit test that capture does not
   affect, which is exactly the one we want to see THROUGH the ghost. The caret
   two rules down has carried the same property since it was written, for the
   same reason. */
.d-reorder-lift {
  transform:scale(1.06);
  box-shadow:0 6px 18px rgba(0,0,0,.45);
  opacity:.92;
  z-index:40;
  position:relative;
  pointer-events:none;
  transition:none !important
}
[data-reorder] [data-reorder-item],
[data-reorder] [data-reorder-item] a {
  -webkit-user-drag:none
}
[data-reorder] [data-reorder-item] {
  -webkit-touch-callout:none;
  user-select:none;
  -webkit-user-select:none
}
.d-reorder-caret {
  position:absolute;
  width:3px;
  border-radius:2px;
  background:var(--primary, #6ee7a8);
  pointer-events:none;
  z-index:41
}

/* GROUP TARGETS. The caret says "it will land between"; these say "it will land
   INSIDE". Two distinct affordances for two distinct outcomes, and they are
   mutually exclusive by construction — term.js kills the caret the moment a
   target is aimed at, because a drag that shows both is a drag whose result the
   user has to guess.

   A RING, NOT A FILL. The tab under the pointer is still readable while it is a
   target: the point of dropping onto THAT tab is that you recognised it, and a
   highlight that obscures its label takes the recognition away at the moment it
   is being used. */
.d-reorder-onto {
  box-shadow:0 0 0 2px var(--primary, #6ee7a8) inset;
  border-radius:8px
}
.d-reorder-onto-box {
  box-shadow:0 0 0 2px var(--primary, #6ee7a8) inset !important
}
/* THE THIRD OUTCOME NEEDED ITS OWN MARK. A drop that takes a tab OUT of a box
   lands on the strip, not on the tab it happens to be over — ringing that tab
   would promise the join this drop specifically is not. The strip itself
   lights up, which is where the tab is going. */
.d-reorder-onto-loose {
  box-shadow:0 0 0 2px var(--primary, #6ee7a8) inset;
  border-radius:8px
}
