/* TrenchTV public viewer page (/live) */
:root {
  --bg: #07100b;
  --panel: #0c1610;
  --panel-2: #101d15;
  --panel-3: #15261b;
  --line: rgba(124, 255, 107, 0.22);
  --line-soft: rgba(124, 255, 107, 0.12);
  --neon: #7cff6b;
  --neon-dim: #3fae36;
  --violet-text: #c9b3ff;
  --teal: #2fd4c4;
  --amber: #ffb347;
  --text: #eef5ee;
  --muted: #9fb3a3;
  --faint: #5d7363;
  --down: #ff6b78;
  --on-neon: #06110a;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display: "Archivo Black", sans-serif;
  --hdr: 60px;
  --gap: 20px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
/* clip (not hidden): the sliding panel must never make the page scroll sideways when focus moves into it */
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column;
  background-color: var(--bg); color: var(--text);
  background-image: linear-gradient(rgba(124,255,107,0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(124,255,107,0.035) 1px, transparent 1px);
  background-size: 64px 64px;
  font: 500 15px/1.45 Inter, system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
  overflow-x: clip;
}
[hidden] { display: none !important; }
a { color: var(--neon); }
code { font-family: var(--mono); font-size: 0.92em; color: var(--text); }
h2 { margin: 0 0 6px; font-size: 18px; font-weight: 800; letter-spacing: 0.2px; }
h3 { margin: 0 0 10px; font: 700 12px var(--mono); letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.lead { margin: 0 0 14px; color: var(--muted); font-size: 14px; }
:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: 700 14px Inter, system-ui, sans-serif; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--neon); }
.btn.primary { background: var(--neon); border-color: var(--neon); color: var(--on-neon); }
.btn.primary:hover { background: #9dff8f; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.5; cursor: not-allowed; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20; height: var(--hdr);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  background: rgba(7, 16, 11, 0.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.logo { display: block; flex: none; line-height: 0; }
/* the antennas make the image taller above the lettering: its text sits at 61.7% of the height,
   so lift it by 11.7% to put the lettering (not the image box) on the header's centre line */
.logo img { display: block; height: 40px; width: auto; transform: translateY(-11.7%); }
.live-pill { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px; border-radius: 5px; background: #d0202f; color: #fff; font: 800 12px/1 Inter, sans-serif; letter-spacing: 1.5px; }
.live-pill.off { background: #26332b; color: #9fb3a6; }
.live-pill.off i { background: #9fb3a6; animation: none; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.top-tag { font: 700 12px var(--mono); letter-spacing: 1px; color: var(--muted); padding: 5px 10px; border: 1px solid var(--line-soft); border-radius: 5px; white-space: nowrap; }
.sp { flex: 1; }
.admin-link { flex: none; text-decoration: none; border-color: var(--neon); color: var(--neon); }
.admin-link:hover { background: rgba(124, 255, 107, 0.1); }
.wallet { position: relative; min-width: 0; max-width: 220px; flex: 0 1 auto; }
#wallet-btn { max-width: 100%; transition: none; }
#wallet-btn.signed { background: var(--panel-2); color: var(--text); border-color: var(--line); }
#wallet-btn .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#wallet-btn .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--neon); box-shadow: 0 0 8px var(--neon); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  display: grid; gap: 2px;
}
.menu-addr { margin: 0; padding: 8px 10px 10px; font: 500 12px var(--mono); color: var(--muted); border-bottom: 1px solid var(--line-soft); margin-bottom: 4px; }
.menu button { text-align: left; padding: 10px; border: 0; border-radius: 8px; background: none; color: var(--text); font: 600 14px Inter, sans-serif; cursor: pointer; }
.menu button:hover, .menu button:focus-visible { background: var(--panel-3); }

/* ---------- layout ---------- */
.layout {
  flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: var(--gap) 24px;
  display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start;
}
/* the interaction panel is a drawer: closed = the stream gets the whole width */
.layout.open { max-width: 1560px; grid-template-columns: minmax(0, 1fr) 390px; column-gap: 48px; /* room for the side tab */ }
/* closed: keep the stream clear of the side tab on the right edge */
.layout:not(.open) { padding-left: 60px; padding-right: 60px; }
.player { min-width: 0; }
.frame { position: relative; aspect-ratio: 16 / 9; width: 100%; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: #000; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45); }
.frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
.about { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
/* side tab of the drawer: vertical, glued to the right edge (closed) or to the panel's left edge (open) */
.panel-toggle {
  --tab-w: 36px;
  position: fixed; z-index: 41; top: 50%; right: var(--tab-right, 0px); transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: var(--tab-w); padding: 14px 0; border-radius: 12px 0 0 12px; cursor: pointer;
  border: 1px solid var(--neon); border-right: 0; background: var(--neon); color: var(--on-neon);
  font: 800 12.5px Inter, sans-serif; letter-spacing: 1px; text-transform: uppercase;
  box-shadow: -6px 0 24px rgba(0, 0, 0, 0.45); transition: right 0.22s ease-out, background 0.15s;
}
.panel-toggle:hover { background: #9dff8f; }
.panel-toggle[aria-expanded="true"] { background: var(--panel); color: var(--neon); border-color: var(--line); }
.panel-toggle[aria-expanded="true"]:hover { background: var(--panel-3); }
.panel-toggle:focus-visible, .panel-close:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; }
.pt-label { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.pt-arrow { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; }
.panel-toggle[aria-expanded="true"] .pt-arrow { transform: rotate(180deg); }
.dock-badge { min-width: 22px; padding: 1px 5px; border-radius: 999px; background: var(--on-neon); color: var(--neon); font: 800 11px/1.5 Inter, sans-serif; letter-spacing: 0; text-align: center; }
.panel-toggle[aria-expanded="true"] .dock-badge { background: var(--neon); color: var(--on-neon); }
.panel-close { flex: none; width: 48px; border: 0; background: none; color: var(--muted); font-size: 26px; line-height: 1; cursor: pointer; }
.panel-close:hover { color: var(--text); }
.scrim { display: none; }

.panel {
  position: sticky; top: calc(var(--hdr) + var(--gap));
  height: calc(100vh - var(--hdr) - 2 * var(--gap)); height: calc(100dvh - var(--hdr) - 2 * var(--gap));
  min-height: 520px; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  animation: panel-in 0.2s ease-out;
}
@keyframes panel-in { from { transform: translateX(32px); opacity: 0; } }
.tabs { flex: none; display: flex; border-bottom: 1px solid var(--line-soft); background: rgba(0, 0, 0, 0.15); }
.tab {
  flex: 1; min-height: 48px; padding: 12px 6px; border: 0; border-bottom: 2px solid transparent; background: none; cursor: pointer;
  color: var(--muted); font: 700 12.5px var(--mono); letter-spacing: 1.5px; text-transform: uppercase;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--neon); border-bottom-color: var(--neon); }
.tabpanel { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; overscroll-behavior: contain; }

/* ---------- chat ---------- */
.tabpanel.chat { position: relative; display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.conn { margin: 0; padding: 6px 14px; font: 600 12px var(--mono); color: var(--amber); background: rgba(255, 179, 71, 0.08); border-bottom: 1px solid rgba(255, 179, 71, 0.2); }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 7px; overscroll-behavior: contain; }
.chat-empty { margin: auto; color: var(--faint); font-size: 13px; text-align: center; }
.ln { font-size: 14px; line-height: 1.42; overflow-wrap: anywhere; }
.ln .nm { font-weight: 700; color: var(--neon); margin-right: 6px; }
.ln.mine .nm { color: #b6ffad; }
.ln.pump .nm { color: var(--teal); }
.ln .tx { color: var(--text); }
.tag { display: inline-block; margin-right: 6px; padding: 1px 5px; border-radius: 4px; border: 1px solid rgba(47, 212, 196, 0.5); color: var(--teal); font: 700 10px/1.4 var(--mono); letter-spacing: 0.5px; vertical-align: 1px; }
.ln.sys { color: var(--muted); font-size: 13px; font-style: italic; }
.ln.greet { padding: 9px 12px; border-radius: 10px; background: rgba(124, 255, 107, 0.07); border: 1px solid rgba(124, 255, 107, 0.4); }
.ln.greet .gh { font: 700 11.5px var(--mono); letter-spacing: 1px; color: var(--neon); margin-bottom: 3px; }
.ln.greet.mid { border-color: var(--neon); background: rgba(124, 255, 107, 0.11); }
.ln.greet.big { border: 2px solid var(--neon); background: linear-gradient(135deg, rgba(124, 255, 107, 0.18), rgba(47, 212, 196, 0.08)); box-shadow: 0 0 24px rgba(124, 255, 107, 0.16); font-size: 15px; font-weight: 600; }
.ln.greet.big .gh { font-size: 12.5px; }
.jump { position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%); padding: 7px 14px; border-radius: 999px; border: 1px solid var(--neon); background: var(--panel); color: var(--neon); font: 700 12px var(--mono); cursor: pointer; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
.composer { flex: none; padding: 12px 14px 14px; border-top: 1px solid var(--line-soft); display: grid; gap: 6px; background: var(--panel); }
.composer form { display: flex; gap: 8px; }
.composer input { flex: 1; min-width: 0; }
.composer .hint { margin: 0; font-size: 12px; color: var(--faint); }
.composer .hint code { color: var(--muted); }

/* ---------- forms ---------- */
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 14px; }
.form { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); min-width: 0; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; color: var(--text); }
.field small { color: var(--faint); font-size: 12px; }
.count { font: 500 11.5px var(--mono); color: var(--faint); font-weight: 500; }
.count.over { color: var(--down); }
input, textarea, select {
  width: 100%; min-height: 42px; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: 500 15px Inter, system-ui, sans-serif;
}
input.mono { font-family: var(--mono); font-size: 13.5px; }
textarea { resize: vertical; min-height: 78px; line-height: 1.4; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:disabled, textarea:disabled, select:disabled { opacity: 0.55; cursor: not-allowed; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--neon); outline-offset: 0; border-color: transparent; }
.checks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.chk { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 7px 10px; border-radius: 8px; border: 1px solid var(--line-soft); background: var(--panel-2); color: var(--text); font-size: 13px; cursor: pointer; }
.chk input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: var(--neon); flex: none; }
.chk:has(input:checked) { border-color: var(--neon); background: rgba(124, 255, 107, 0.08); }
.chk:has(input:disabled) { opacity: 0.45; cursor: not-allowed; }
.price { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 12px; border-radius: 9px; background: rgba(124, 255, 107, 0.06); border: 1px dashed var(--line); }
.price span { font: 700 12px var(--mono); letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.price b { font: 700 20px var(--mono); color: var(--neon); }
.note { margin: 0; font-size: 12.5px; color: var(--muted); padding-left: 10px; border-left: 2px solid var(--line); }
.card { padding: 16px; border-radius: 12px; border: 1px solid var(--line-soft); background: rgba(0, 0, 0, 0.18); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-bottom: 12px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line-soft); }
.seg-btn { min-height: 38px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: 700 13px Inter, sans-serif; cursor: pointer; }
.seg-btn[aria-pressed="true"] { background: var(--panel-3); color: var(--neon); box-shadow: inset 0 0 0 1px var(--line); }

.gate { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 179, 71, 0.08); border: 1px solid rgba(255, 179, 71, 0.3); color: var(--amber); font-size: 13.5px; font-weight: 600; }

/* inline status messages */
.msg { margin: 0; font-size: 13.5px; color: var(--muted); }
.msg.err { color: var(--down); }
.msg.ok { color: var(--neon); }
.msg.busy::before { content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 8px; vertical-align: -1px; border: 2px solid var(--neon); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- my orders ---------- */
.orders { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); display: grid; gap: 10px; }
.orders h3 { margin: 0; }
#o-list { display: grid; gap: 8px; }
.empty { margin: 0; color: var(--faint); font-size: 13px; }
.order { display: grid; gap: 6px; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line-soft); background: var(--panel-2); font-size: 13.5px; min-width: 0; }
.order-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.order-head b { font-weight: 700; }
.order-head .amt { margin-left: auto; font: 700 13px var(--mono); color: var(--text); }
.order .sum { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.order .meta { margin: 0; font: 500 11.5px var(--mono); color: var(--faint); }
.order .note-line { margin: 0; color: var(--amber); font-size: 13px; }
.order .pay-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.badge { padding: 3px 7px; border-radius: 5px; font: 700 10.5px/1.3 var(--mono); letter-spacing: 0.8px; text-transform: uppercase; background: var(--panel-3); color: var(--muted); }
.badge.warn { background: rgba(255, 179, 71, 0.14); color: var(--amber); }
.badge.info { background: rgba(47, 212, 196, 0.14); color: var(--teal); }
.badge.ok { background: rgba(124, 255, 107, 0.15); color: var(--neon); }
.badge.bad { background: rgba(255, 107, 120, 0.15); color: var(--down); }

/* ---------- footer ---------- */
.foot { padding: 18px 24px 22px; text-align: center; font: 500 12px var(--mono); letter-spacing: 0.5px; color: var(--faint); border-top: 1px solid var(--line-soft); }

/* ---------- dialog ---------- */
dialog {
  width: min(420px, calc(100vw - 32px)); padding: 22px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
}
dialog::backdrop { background: rgba(2, 6, 4, 0.72); backdrop-filter: blur(3px); }
dialog h2 { padding-right: 36px; }
dialog > form:not(.dlg-close) { display: grid; gap: 14px; }
.dlg-close { position: absolute; top: 12px; right: 12px; margin: 0; }
.x { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line-soft); background: none; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.x:hover { color: var(--text); border-color: var(--line); }
.wallet-list { display: grid; gap: 8px; }
.wallet-opt { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: 700 15px Inter, sans-serif; cursor: pointer; }
.wallet-opt:hover { border-color: var(--neon); background: var(--panel-3); }
.wallet-opt small { font: 500 11px var(--mono); color: var(--neon); letter-spacing: 1px; }
.wo-name { display: inline-flex; align-items: center; gap: 10px; }
.wo-name img { width: 24px; height: 24px; border-radius: 6px; flex: none; }
.nowallet p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.nowallet .links { display: flex; gap: 10px; flex-wrap: wrap; }
.nowallet .links a { padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line); text-decoration: none; font-weight: 700; }
.nowallet .links a:hover { border-color: var(--neon); }
#dlg-msg { margin-top: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .layout.open { grid-template-columns: minmax(0, 1fr) 350px; }
  .top-tag { display: none; }
}
@media (max-width: 900px) {
  :root { --hdr: 56px; --gap: 12px; }
  .top { padding: 0 16px; gap: 10px; }
  .layout, .layout:not(.open) { grid-template-columns: minmax(0, 1fr); padding: 0 0 var(--gap); }
  .frame { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; box-shadow: none; }
  .layout.open { grid-template-columns: minmax(0, 1fr); }
  .about { padding: 0 16px; }
  .panel-toggle { --tab-w: 34px; font-size: 12px; }
  /* phones and tablets: the panel slides in from the right, over the stream */
  .panel {
    position: fixed; top: 0; right: 0; bottom: 0; left: auto; z-index: 40; margin: 0;
    width: min(420px, calc(100vw - 46px)); /* leaves room for the side tab on its left edge */ height: 100vh; height: 100dvh; min-height: 0; border-radius: 18px 0 0 18px; border-right: 0;
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.6); animation: drawer-in 0.22s ease-out;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  }
  .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, 0.55); }
  .scrim[hidden] { display: none; }
  .tabpanel { padding: 16px; }
  .jump { bottom: 120px; }
  @keyframes drawer-in { from { transform: translateX(48px); opacity: 0.4; } }
}
@media (max-width: 480px) {
  .logo img { height: 32px; }
  .live-pill { padding: 4px 7px; font-size: 11px; }
  .top { gap: 8px; }
  #wallet-btn { padding: 8px 12px; font-size: 13px; }
  .tab { letter-spacing: 1px; font-size: 12px; }
}
@media (max-width: 370px) {
  .chk { padding: 7px 8px; font-size: 12.5px; }
}
@media (max-width: 340px) {
  .checks { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .live-pill i, .msg.busy::before, .panel { animation: none; }
  .panel-toggle { transition: none; }
}
