/* Shared panel chrome — the SPA-style hash-routed panel system.
 * Each panel is a `<section class="panel" data-panel="…">` and the JS
 * router toggles `.active` on exactly one at a time. Keeping all
 * panels mounted (just hidden) is what lets the ttyd iframe survive a
 * tab swap with its WebSocket and scrollback intact.
 */

.panel { display: none; }
.panel.active { display: block; }

/* The play panel hosts a fullscreen iframe under a thin always-on
   "your sandbox" bar. The bar reserves real estate (iframe is offset
   by --play-info-bar-h); when the bar is expanded, the extra body
   floats over the iframe rather than reflowing it (ttyd does not
   respond gracefully to mid-session resize). */
#panel-play.active {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  display: block;
  --play-info-bar-h: 38px;
  --play-rail-w: 30px;
  --play-preview-bar-h: 42px;
}

/* Below the info bar: a slim vertical icon rail + the stage beside it. */
.play-shell {
  position: absolute;
  top: var(--play-info-bar-h);
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
}

/* Slim, icon-only view rail down the left edge. */
.play-rail {
  flex: 0 0 var(--play-rail-w);
  width: var(--play-rail-w);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 4;
  border-right: 1px solid rgba(var(--accent-rgb), 0.14);
  background: rgba(6, 11, 8, 0.96);
}
.play-rail-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(209, 255, 218, 0.5);
  font: inherit;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.play-rail-btn:hover { color: rgb(225, 255, 230); background: rgba(var(--accent-rgb), 0.10); }
.play-rail-btn.active {
  color: rgb(230, 255, 235);
  background: rgba(var(--accent-rgb), 0.16);
}
/* Active selector reads as a flat "__" underline — a squared accent bar
   along the bottom edge, no rounded corners anywhere. */
.play-rail-btn.active::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}
/* CSS tooltip on hover — cleaner than the native one, appears beside. */
.play-rail-btn::after {
  content: attr(aria-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 9px;
  border: 1px solid rgba(var(--accent-rgb), 0.30);
  border-radius: 6px;
  background: #0a120d;
  color: rgb(225, 255, 230);
  font: 600 11px/1 var(--font-mono);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 100ms ease;
  z-index: 6;
}
/* Reveal the tooltip on hover AND keyboard focus — the rail has no text
   labels, so focus-visible is the only affordance a keyboard user gets. */
.play-rail-btn:hover::after,
.play-rail-btn:focus-visible::after { opacity: 1; }
.play-rail-ico { font: 600 15px/1 var(--font-mono); }

/* card.css applies global margins to every <input>/<button>/<label>
   (button { margin-top: 16px }, input { margin-top: 6px }). Inside the
   fixed-height preview bar that would shove the controls around, so
   zero it for everything living in the bar. (Same defensive reset the
   rail buttons already carry.) */
.play-preview-bar :is(input, button, label, a) { margin: 0; }

/* Port form. */
.play-port-form {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
}
.play-port-prefix {
  padding: 0 2px 0 9px;
  color: var(--text-soft);
  font: 500 12px/1 var(--font-mono);
  user-select: none;
}
.play-port-input {
  width: 58px;
  padding: 5px 6px;
  border: 0;
  background: transparent;
  color: rgb(225, 255, 230);
  font: 600 12px/1 var(--font-mono);
}
.play-port-input:focus { outline: none; }
.play-port-input::-webkit-outer-spin-button,
.play-port-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.play-port-go {
  padding: 5px 11px;
  border: 0;
  border-left: 1px solid rgba(var(--accent-rgb), 0.22);
  background: rgba(var(--accent-rgb), 0.16);
  color: rgb(225, 255, 230);
  font: 600 12px/1 var(--font-mono);
  cursor: pointer;
  transition: background 120ms ease;
}
.play-port-go:hover { background: rgba(var(--accent-rgb), 0.30); }

.play-preview-open,
.play-preview-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-soft);
  font: 600 14px/1 var(--font-mono);
  cursor: pointer;
  text-decoration: none;
  transition: color 120ms ease, border-color 120ms ease;
}
.play-preview-open:hover,
.play-preview-refresh:hover { color: var(--text); border-color: rgba(var(--accent-rgb), 0.5); }
.play-preview-open[hidden],
.play-preview-refresh[hidden] { display: none; }

/* The stage holds both panes (terminal iframe + preview pane), each
   filling it. Switching views toggles `hidden` on the panes — the
   terminal iframe's WebSocket survives because it stays in the DOM. */
.play-stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.play-pane {
  position: absolute;
  inset: 0;
  border: 0;
  display: block;
}
.play-pane[hidden] { display: none; }

/* Preview pane: a compact control bar on top, iframe (or empty-state)
   filling the body below it. */
.play-preview {
  display: flex;
  flex-direction: column;
  background: #05080699;
}
.play-preview-bar {
  flex: 0 0 var(--play-preview-bar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.16);
  background: linear-gradient(180deg, rgba(8, 14, 10, 0.96), rgba(4, 8, 6, 0.92));
}
.play-preview-bar-spacer { flex: 1 1 auto; }
.play-preview-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

/* Bulletproof the preview iframe ELEMENT: our page never styles the
   doc inside (cross-document, can't), but make sure none of our own
   chrome (borders, color-scheme, bg) touches the frame box either. */
.play-preview-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: #fff;
  color-scheme: normal;
}
.play-preview-frame[hidden] { display: none; }
.play-preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.play-preview-empty[hidden] { display: none; }
.play-preview-empty-card {
  max-width: 460px;
  text-align: center;
  color: rgba(209, 255, 218, 0.82);
  font-family: var(--font-mono);
}
.play-preview-empty-ico {
  font-size: 34px;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(var(--accent-rgb), 0.4);
  margin-bottom: 10px;
}
.play-preview-empty-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 650;
  color: rgb(225, 255, 230);
}
.play-preview-empty-detail { margin: 0 0 14px; line-height: 1.5; font-size: 13px; }
.play-preview-empty-fine {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: rgba(209, 255, 218, 0.6);
}
.play-preview-empty code {
  background: rgba(var(--accent-rgb), 0.12);
  border-radius: 4px;
  padding: 1px 5px;
  color: rgb(225, 255, 230);
}
.play-status {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  width: min(420px, calc(100vw - 28px));
  color: rgb(209, 255, 218);
  pointer-events: none;
}
.play-status[hidden] { display: none; }
.play-status-card {
  padding: 12px 14px 13px;
  border: 1px solid rgba(var(--accent-rgb), 0.55);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(8, 14, 10, 0.96), rgba(0, 0, 0, 0.94)),
    #020403;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.75),
    0 18px 48px rgba(0, 0, 0, 0.52),
    0 0 28px rgba(var(--accent-rgb), 0.16);
  font-family: var(--font-mono);
  text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.36);
}
.play-status-topline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(var(--accent-rgb), 0.22);
  color: rgba(209, 255, 218, 0.70);
  font-size: 11px;
  letter-spacing: 0.04em;
}
.play-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.9);
  animation: play-pulse 1100ms ease-in-out infinite;
}
.play-status-prompt { text-transform: uppercase; }
.play-status-title {
  margin: 0;
  color: rgb(225, 255, 230);
  font-weight: 650;
  font-size: 13px;
}
.play-status-caret { color: var(--accent); }
.play-status-detail {
  margin: 7px 0 0;
  color: rgba(209, 255, 218, 0.76);
  line-height: 1.45;
  font-size: 12px;
}
@keyframes play-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.88); }
  50% { opacity: 1; transform: scale(1); }
}

/* Always-on header. The closed-state bar is the only persistent
   footprint; when expanded, .play-info-body absolute-positions itself
   below the bar and overlays the iframe. */
.play-info {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
}
.play-info-bar {
  height: var(--play-info-bar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
  /* Override the inherited summary defaults — keep alignment and
     padding consistent across browsers. */
  padding: 0 16px;
}
/* Expanded body lifts off — does NOT push the bar down or shrink the
   iframe. Translucent so the eye sees "this is an overlay over your
   terminal, not chrome." */
.play-info[open] .play-info-body {
  position: absolute;
  top: var(--play-info-bar-h);
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px) saturate(1.1);
  -webkit-backdrop-filter: blur(8px) saturate(1.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}
.play-info-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}
/* Hide the default disclosure triangle. */
.play-info-bar::-webkit-details-marker { display: none; }
.play-info-bar::marker { content: ""; }
.play-info-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 8px 1px 7px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-soft);
  font-weight: 500;
  letter-spacing: 0.01em;
  font-size: 11px;
}
.play-info-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgb(var(--accent-rgb, 80 200 120));
  /* No glow — the bar should sit quietly. */
}
.play-info-summary { color: var(--text-soft); }
.play-info-summary code {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 400;
  background: transparent;
}
.play-info-reset {
  margin-left: auto;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  vertical-align: middle;
  box-sizing: border-box;
  height: 18px;
  margin-top: 0;
  margin-bottom: 0;
  appearance: none;
  background: rgba(220, 70, 70, 0.08);
  border: 1px solid rgba(220, 70, 70, 0.45);
  color: rgb(225, 110, 110);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  padding: 0 7px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.play-info-reset-ico {
  font-size: 10px;
  line-height: 1;
  color: rgb(255, 180, 90);
}
.play-info-reset:hover {
  background: rgba(220, 70, 70, 0.12);
  color: rgb(255, 130, 130);
  border-color: rgba(220, 70, 70, 0.7);
}
.play-info-chevron {
  transition: transform 120ms ease;
  color: var(--text-soft);
}
.play-info[open] .play-info-chevron { transform: rotate(180deg); }
.play-info-body {
  padding: 4px 16px 14px;
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}
.play-info-blurb { margin: 0 0 10px; max-width: 760px; }
.play-info-blurb strong { color: var(--text); }
.play-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 4px 24px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.play-info-grid > div { display: flex; gap: 8px; align-items: baseline; }
.play-info-grid dt {
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10.5px;
  min-width: 78px;
}
.play-info-grid dd { margin: 0; color: var(--text); }
.play-info-grid code {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Mobile: drop the pill entirely — too much for a small bar. Keep
   just the green dot + summary + chevron. The dot is the whole
   security signal needed at a glance; the expanded body has the
   "your own crate · sticky · nobody else inside" copy when the user
   wants the detail. */
@media (max-width: 700px) {
  #panel-play.active { --play-info-bar-h: 36px; }
  .play-info-bar { padding: 0 12px; gap: 10px; font-size: 12px; }
  /* Tighten the rail + preview bar on narrow screens. */
  #panel-play.active { --play-rail-w: 32px; }
  .play-preview-bar { gap: 6px; padding: 0 8px; }
  .play-port-prefix { display: none; }
  .play-info-pill {
    /* Strip the pill chrome; just keep the dot. */
    border: 0;
    padding: 0;
    gap: 0;
    font-size: 0;
  }
  .play-info-pill-text { display: none; }
  .play-info-summary {
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
  }
  .play-info-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .play-info-grid dt { min-width: 70px; }
  .play-info-blurb { font-size: 12.5px; }
}

/* Generic panel-frame fallback for any future iframe-hosting panel. */
.panel-frame {
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  border: 0;
  width: 100%;
  height: calc(100vh - var(--topbar-h));
  background: #000;
  z-index: 1;
}
/* Play panel: the ttyd iframe is a .play-pane inside .play-stage, so it
   just fills the stage (inset:0). The stage already sits below the info
   bar + beside the rail, so NO extra top offset here — otherwise the
   terminal gets pushed down and a dark gap opens above it. */
#panel-play .panel-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Page wrapper used inside non-iframe panels (home, tokens, future
   dochouse/marketplace). 1200px wide for the hero page; .narrow flips
   it to 1100px for secondary panels so headings + stat grids don't
   span a 27" monitor while still giving wide tables (e.g. the 7-column
   marketplace) room to breathe. */
.page {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}
.page.narrow {
  max-width: 1100px;
  padding-top: 5vh;
  padding-bottom: 6vh;
}

/* Panel head shared by tokens (and future): icon tile + title + sub.
   Lives here because every secondary panel will follow this shape. */
.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  padding: 0 0 22px;
  margin: 0 0 28px;
  border-bottom: 1px solid var(--line);
}
.panel-icon {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.10);
  border: 1px solid rgba(var(--accent-rgb), 0.32);
  border-radius: 12px;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.5);
}
.panel-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.panel-sub {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}
.panel-attribution {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}
.panel-attribution strong { font-weight: 600; }
.panel-attribution .dim { color: var(--text-soft); }

/* Compact avatar variant for inline attribution chips. */
.avatar.sm {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  flex: 0 0 auto;
}

@media (max-width: 700px) {
  .panel-head { gap: 14px; }
  .panel-icon { width: 38px; height: 38px; font-size: 18px; }
  .panel-title { font-size: 19px; }
}
