@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&display=swap');

/* Fallback = matrix（防闪脚本未跑到时） */
:root,
html[data-theme="matrix"] {
  --bg: #060a08;
  --bg2: #0c1610;
  --bg3: #040604;
  --surface: #0a120e;
  --border: #0f3324;
  --border-hi: #1a5c40;
  --green: #00ff9c;
  --green2: #00cc7a;
  --green-dim: #2d6b4a;
  --green-ghost: rgba(var(--accent-rgb),  0.06);
  --pink: #ff2daa;
  --pink-dim: rgba(var(--pink-rgb),  0.15);
  --yellow: #ffd866;
  --red: #ff3355;
  --cyan: #00e5ff;
  --text: #d0ffe4;
  --text-dim: #1e4030;
  --accent-rgb: 0, 255, 156;
  --pink-rgb: 255, 45, 170;
  --cyan-rgb: 0, 229, 255;
  --banner-from: #0a2818;
  --banner-to: #122a1c;
  --swatch: #00ff9c;
  --swatch2: #ff2daa;
}

html[data-theme="amber"] {
  --bg: #0c0906;
  --bg2: #16100a;
  --bg3: #080604;
  --surface: #120e0a;
  --border: #3d2810;
  --border-hi: #6b4420;
  --green: #ffb040;
  --green2: #e08920;
  --green-dim: #8a5a28;
  --green-ghost: rgba(255, 176, 64, 0.06);
  --pink: #ff6b35;
  --pink-dim: rgba(255, 107, 53, 0.15);
  --yellow: #ffe08a;
  --red: #ff3355;
  --cyan: #ffd080;
  --text: #ffe8c8;
  --text-dim: #4a3220;
  --accent-rgb: 255, 176, 64;
  --pink-rgb: 255, 107, 53;
  --cyan-rgb: 255, 208, 128;
  --banner-from: #281808;
  --banner-to: #2a1c12;
  --swatch: #ffb040;
  --swatch2: #ff6b35;
}

html[data-theme="ocean"] {
  --bg: #060a12;
  --bg2: #0a1220;
  --bg3: #04080e;
  --surface: #0a1018;
  --border: #143050;
  --border-hi: #1e5080;
  --green: #3db8ff;
  --green2: #1a8ad4;
  --green-dim: #2a5a80;
  --green-ghost: rgba(61, 184, 255, 0.06);
  --pink: #7b6cff;
  --pink-dim: rgba(123, 108, 255, 0.15);
  --yellow: #5eead4;
  --red: #ff3355;
  --cyan: #67e8f9;
  --text: #d0e8ff;
  --text-dim: #1e3048;
  --accent-rgb: 61, 184, 255;
  --pink-rgb: 123, 108, 255;
  --cyan-rgb: 103, 232, 249;
  --banner-from: #081828;
  --banner-to: #0c1c2a;
  --swatch: #3db8ff;
  --swatch2: #7b6cff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { width: 100%; }
body { overflow: hidden; }

body {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, 'PingFang SC', 'Microsoft YaHei', monospace;
  background: var(--bg);
  color: var(--green);
  font-size: 13px;
  line-height: 1.55;
  width: 100%;
  height: 100%;
}

/* CRT scanline overlay */
body::after {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.12) 0 1px, transparent 1px 3px);
  z-index: 9999;
}

/* Ambient glow */
body::before {
  content: '';
  position: fixed; top: -40%; left: -20%; right: -20%;
  height: 60%;
  pointer-events: none;
  background: radial-gradient(ellipse, rgba(var(--accent-rgb), 0.07) 0%, transparent 70%);
  z-index: 0;
}

/* ======= LAYOUT ======= */
.app { display: flex; flex-direction: column; height: 100%; position: relative; z-index: 1; max-width: 100%; margin: 0 auto; }

/* In-extension popup (small fixed window) */
.is-popup .app { width: 380px; max-width: 380px; height: 600px; }

/* ======= SCREENS ======= */
.screen { display: none; flex-direction: column; height: 100%; min-height: 0; }
.screen.active { display: flex; }

/* ======= JOIN SCREEN ======= */
.join-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 28px 24px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(var(--accent-rgb), 0.08), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(var(--pink-rgb), 0.04), transparent 50%),
    var(--bg);
  position: relative;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Animated grid background for join screen */
.join-screen::before {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(var(--accent-rgb), 0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(var(--accent-rgb), 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
  animation: grid-drift 20s linear infinite;
}
@keyframes grid-drift {
  0% { transform: translate(0, 0); }
  100% { transform: translate(30px, 30px); }
}

.join-logo {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 8px;
  text-shadow: 0 0 30px rgba(var(--accent-rgb), 0.6), 0 0 60px rgba(var(--accent-rgb), 0.2);
  text-align: center;
  position: relative;
  z-index: 1;
}
.join-logo .mag {
  color: var(--pink);
  text-shadow: 0 0 30px rgba(var(--pink-rgb), 0.8), 0 0 60px rgba(var(--pink-rgb), 0.3);
  animation: cursor-blink 1s steps(1) infinite;
}
@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.join-tagline {
  font-size: 11px;
  color: var(--green-dim);
  letter-spacing: 3px;
  text-align: center;
  position: relative; z-index: 1;
}

.join-divider {
  width: 120px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-hi), transparent);
  position: relative; z-index: 1;
}

/* Quick join card */
.quick-join {
  width: 100%;
  max-width: 360px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.06), rgba(var(--accent-rgb), 0.02));
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative; z-index: 1;
}
.quick-join:hover {
  border-color: var(--green2);
  box-shadow: 0 0 20px rgba(var(--accent-rgb), 0.15);
  transform: translateY(-1px);
}
.quick-join:active { transform: translateY(0); }
.quick-join-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.quick-join-title { font-size: 15px; font-weight: 700; color: var(--green); letter-spacing: 1px; }
.quick-join-arrow { color: var(--green-dim); font-size: 14px; transition: transform 0.2s; }
.quick-join:hover .quick-join-arrow { transform: translateX(3px); color: var(--green); }
.quick-join-desc { font-size: 11px; color: var(--green-dim); letter-spacing: 0.5px; }
.quick-join-meta {
  display: flex; gap: 12px; margin-top: 8px;
  font-size: 10px; letter-spacing: 1px; color: var(--green-dim); opacity: 0.8;
}

.join-or {
  font-size: 10px;
  color: var(--green-dim);
  letter-spacing: 3px;
  position: relative; z-index: 1;
}

/* Theme picker on join screen */
.theme-picker {
  width: 100%;
  max-width: 360px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.theme-picker-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--green-dim);
}
.theme-picker-options {
  display: flex;
  gap: 8px;
}
.theme-swatch {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px 8px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.theme-swatch:hover {
  border-color: var(--border-hi);
  transform: translateY(-1px);
}
.theme-swatch.active {
  border-color: var(--green);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.25);
}
.theme-swatch-chip {
  width: 100%;
  height: 22px;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--chip-a), var(--chip-b));
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.theme-swatch-name {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--green-dim);
}
.theme-swatch.active .theme-swatch-name {
  color: var(--green);
  font-weight: 700;
}

.join-form {
  display: flex; flex-direction: column;
  gap: 8px; width: 100%; max-width: 360px;
  position: relative; z-index: 1;
}

.join-form .field { display: flex; flex-direction: column; gap: 4px; }

.join-form label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--green-dim);
}

.join-form input {
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--green);
  font-family: inherit;
  font-size: 14px;
  padding: 11px 12px;
  outline: none;
  width: 100%;
  transition: all 0.15s;
}
.join-form input:focus {
  border-color: var(--green2);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.2), inset 0 0 20px rgba(var(--accent-rgb), 0.03);
  background: rgba(0,0,0,0.8);
}
.join-form input::placeholder { color: var(--text-dim); }

.join-btns { display: flex; gap: 8px; margin-top: 6px; }
.join-btn, .create-btn {
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: #000;
  border: none;
  border-radius: 4px;
  padding: 13px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
}
.create-btn {
  background: rgba(0,0,0,0.5);
  color: var(--cyan);
  border: 1px solid var(--cyan);
  flex: 0.8;
  letter-spacing: 1px;
}
.join-btn:hover, .create-btn:hover {
  box-shadow: 0 0 25px rgba(var(--accent-rgb), 0.4), 0 4px 15px rgba(0,0,0,0.3);
  transform: translateY(-1px);
}
.create-btn:hover { box-shadow: 0 0 18px rgba(var(--cyan-rgb), 0.4); }

.join-footer {
  font-size: 9px;
  color: var(--green-dim);
  letter-spacing: 1.5px;
  text-align: center;
  opacity: 0.5;
  position: relative; z-index: 1;
}
.version-tag {
  margin-top: 6px;
  font-size: 10px;
  color: var(--cyan);
  opacity: 0.8;
  letter-spacing: 2px;
}
.version-tag span { color: var(--green); font-weight: 700; }
.footer-version {
  color: var(--cyan);
  opacity: 0.85;
  font-weight: 700;
}

/* ======= UPDATE BANNER ======= */
.update-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 14px;
  background: linear-gradient(90deg, var(--banner-from), var(--banner-to));
  border-bottom: 1px solid var(--green);
  box-shadow: 0 4px 24px rgba(var(--accent-rgb),  0.25);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.5px;
}
.update-banner.visible { display: flex; }
.update-banner b { color: var(--yellow); font-weight: 700; }
.update-banner-btn {
  border: 1px solid var(--green);
  background: var(--green-ghost);
  color: var(--green);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 14px;
  cursor: pointer;
  letter-spacing: 1px;
}
.update-banner-btn:hover {
  background: rgba(var(--accent-rgb),  0.18);
  box-shadow: 0 0 12px rgba(var(--accent-rgb),  0.35);
}

/* ======= CHAT SCREEN ======= */
#chat-screen { background: var(--bg); }

/* HEADER */
.header {
  background: linear-gradient(180deg, var(--bg2), var(--bg));
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.header .logo {
  font-weight: 700;
  letter-spacing: 4px;
  font-size: 14px;
  text-shadow: 0 0 12px rgba(var(--accent-rgb), 0.5);
  display: flex; align-items: center; gap: 8px;
}
.header .logo .mag { color: var(--pink); text-shadow: 0 0 12px rgba(var(--pink-rgb), 0.6); }
.owner-badge {
  background: linear-gradient(135deg, var(--cyan), var(--green2));
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 1px;
  box-shadow: 0 0 8px rgba(var(--cyan-rgb), 0.4);
}
.header .ctrl { display: flex; gap: 5px; }
.header .ctrl button {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--green);
  font-family: inherit;
  font-size: 13px;
  width: 30px; height: 30px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.header .ctrl button:hover { background: var(--border); border-color: var(--border-hi); }

/* STATUS BAR */
.status-bar {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--green-dim);
  background: var(--bg3);
  letter-spacing: 0.5px;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 4px;
}
.blink-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  margin-right: 5px;
  vertical-align: middle;
  animation: blink 1.2s infinite;
}
@keyframes blink { 50% { opacity: 0.2; } }
.status-bar .ch { color: var(--green-dim); }
.status-bar .ch b { color: var(--cyan); font-weight: 500; }

/* VIDEO TILES */
.tiles {
  display: none;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1px;
  background: var(--border);
  padding: 1px;
  max-height: 200px;
  overflow: hidden;
  flex-shrink: 0;
}
.tiles.visible { display: grid; }
.tile {
  background: #000;
  position: relative;
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile .tag {
  position: absolute; top: 4px; left: 4px;
  background: rgba(0,0,0,0.75);
  padding: 2px 6px;
  font-size: 10px;
  letter-spacing: 1px;
  border-radius: 2px;
}
.tile.self { border: 1px solid var(--pink); }
.tile.self .tag { color: var(--pink); }
.tile .rec-dot {
  position: absolute; top: 5px; right: 5px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
  animation: blink 1s infinite;
}

/* MESSAGE FEED */
.feed {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px;
  background:
    linear-gradient(180deg, rgba(var(--accent-rgb), 0.015) 0%, transparent 30%),
    var(--bg3);
  min-height: 0;
}
.feed::-webkit-scrollbar { width: 4px; }
.feed::-webkit-scrollbar-track { background: transparent; }
.feed::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.msg-line {
  margin-bottom: 8px;
  position: relative;
  padding: 3px 0;
  font-size: 13px;
}
.msg-line .ts {
  color: var(--green-dim);
  margin-right: 6px;
  font-size: 10px;
  opacity: 0.6;
}
.msg-line .who {
  color: var(--pink);
  font-weight: 500;
  margin-right: 4px;
}
.msg-line.self .who { color: var(--yellow); }
.msg-line.sys {
  color: var(--green-dim);
  font-size: 11px;
  opacity: 0.75;
  padding: 4px 8px;
  background: rgba(var(--accent-rgb), 0.03);
  border-radius: 3px;
  border-left: 2px solid var(--border);
}
.msg-line .body { color: var(--text); word-break: break-word; }

.msg-line.burn .body {
  background: var(--pink-dim);
  color: var(--pink);
  padding: 4px 8px;
  border-left: 2px solid var(--pink);
  border-radius: 0 3px 3px 0;
  cursor: pointer;
  transition: background 0.2s;
}
.msg-line.burn .body:hover { background: rgba(var(--pink-rgb), 0.25); }

.msg-line .ttl-bar {
  height: 2px;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  opacity: 0.25;
  margin-top: 3px;
  border-radius: 1px;
  animation: ttl-shrink 60s linear forwards;
}
.msg-line.burn.revealed .ttl-bar {
  background: linear-gradient(90deg, var(--pink), var(--red));
  animation: ttl-shrink 5s linear forwards;
}
@keyframes ttl-shrink { from { width: 100%; } to { width: 0%; } }

.msg-img {
  max-width: 240px;
  max-height: 180px;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-top: 4px;
  display: block;
  cursor: pointer;
  transition: border-color 0.15s;
}
.msg-img:hover { border-color: var(--green2); }

.voice-bar {
  display: inline-flex; gap: 2px; align-items: center;
  margin-left: 6px; vertical-align: middle;
}
.voice-bar i {
  display: inline-block; width: 2px; background: var(--green);
  border-radius: 1px;
  animation: vbar 0.8s infinite;
}
.voice-bar i:nth-child(1) { height: 6px; animation-delay: 0s; }
.voice-bar i:nth-child(2) { height: 10px; animation-delay: 0.1s; }
.voice-bar i:nth-child(3) { height: 14px; animation-delay: 0.2s; }
.voice-bar i:nth-child(4) { height: 8px; animation-delay: 0.3s; }
.voice-bar i:nth-child(5) { height: 12px; animation-delay: 0.4s; }
@keyframes vbar { 50% { transform: scaleY(0.3); } }

/* TOOLBAR */
.toolbar {
  border-top: 1px solid var(--border);
  background: linear-gradient(0deg, var(--bg3), var(--surface));
  padding: 7px 10px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.toolbar .spacer { flex: 1; }
.toolbar button {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--green);
  font-family: inherit;
  font-size: 14px;
  width: 36px; height: 36px;
  cursor: pointer;
  transition: all 0.12s;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
.toolbar button:hover { background: var(--border); border-color: var(--border-hi); transform: translateY(-1px); }
.toolbar button.on {
  background: rgba(var(--accent-rgb), 0.2);
  color: var(--green);
  border-color: var(--green2);
  box-shadow: 0 0 10px rgba(var(--accent-rgb), 0.2);
}
.toolbar button.burn-on {
  background: var(--pink-dim);
  color: var(--pink);
  border-color: var(--pink);
  box-shadow: 0 0 12px rgba(var(--pink-rgb), 0.3);
}
.toolbar button.live {
  background: rgba(255,51,85,0.2);
  color: var(--red);
  border-color: var(--red);
  box-shadow: 0 0 12px rgba(255,51,85,0.3);
  animation: pulse-glow 1.5s ease infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(255,51,85,0.2); }
  50% { box-shadow: 0 0 16px rgba(255,51,85,0.4); }
}

/* INPUT ROW */
.input-row {
  background: rgba(0,0,0,0.5);
  border-top: 1px solid var(--border);
  padding: 10px 10px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}
.input-row .prompt {
  color: var(--green);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.4);
}
.input-row input {
  flex: 1;
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  caret-color: var(--green);
  min-width: 0;
}
.input-row input:focus { border-color: var(--border-hi); background: rgba(var(--accent-rgb), 0.04); }
.input-row input::placeholder { color: var(--text-dim); }

.input-row button {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--green);
  font-family: inherit;
  font-size: 11px;
  padding: 8px 12px;
  cursor: pointer;
  letter-spacing: 1px;
  white-space: nowrap;
  transition: all 0.12s;
  flex-shrink: 0;
}
.input-row button:hover { border-color: var(--border-hi); background: var(--border); }
.input-row .send-btn {
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: #000;
  font-weight: 700;
  border-color: var(--green);
}
.input-row .send-btn:hover { box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.3); }

/* FOOTER */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg3);
  padding: 5px 12px;
  font-size: 9px;
  color: var(--green-dim);
  opacity: 0.5;
  display: flex;
  justify-content: space-between;
  letter-spacing: 1px;
  flex-shrink: 0;
}

/* PEER LIST PANEL */
.peer-panel {
  position: fixed;
  top: 0; right: 0;
  width: 300px;
  max-width: 90vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border-hi);
  box-shadow: -8px 0 30px rgba(0,0,0,0.5);
  z-index: 200;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
}
.peer-panel.open { transform: translateX(0); }
.peer-panel-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--green);
  letter-spacing: 2px;
  font-weight: 700;
  background: var(--bg2);
}
.peer-panel-header button {
  background: transparent;
  border: none;
  color: var(--green-dim);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.peer-panel-header button:hover { color: var(--red); }
.peer-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.peer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  font-size: 12px;
}
.peer-row.self { background: rgba(var(--cyan-rgb), 0.05); }
.peer-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green-dim);
  flex-shrink: 0;
}
.peer-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.peer-dot.pending { background: var(--yellow); animation: blink 1s infinite; }
.peer-name { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.peer-id { color: var(--green-dim); font-size: 10px; opacity: 0.7; }
.peer-owner {
  background: var(--cyan);
  color: #000;
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 2px;
  letter-spacing: 1px;
  font-weight: 700;
}
.peer-kick {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 3px;
  width: 22px; height: 22px;
  cursor: pointer;
  font-size: 11px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.peer-kick:hover { background: var(--red); color: #000; }
.peer-panel-footer {
  padding: 8px 14px;
  font-size: 10px;
  color: var(--green-dim);
  border-top: 1px solid var(--border);
  background: var(--bg3);
  text-align: center;
  letter-spacing: 1px;
}

/* CHANNEL SWITCH MODAL */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: 16px;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: var(--bg);
  border: 1px solid var(--green2);
  border-radius: 8px;
  box-shadow: 0 0 40px rgba(var(--accent-rgb), 0.2), 0 20px 40px rgba(0,0,0,0.5);
  padding: 24px;
  width: 320px;
  max-width: 100%;
}
.modal h3 {
  font-size: 13px;
  letter-spacing: 2px;
  margin-bottom: 16px;
  color: var(--green);
  text-shadow: 0 0 8px rgba(var(--accent-rgb), 0.3);
}
.modal input {
  background: rgba(0,0,0,0.6);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--green);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 10px;
  outline: none;
  width: 100%;
  margin-bottom: 10px;
  transition: border-color 0.15s;
}
.modal input:focus { border-color: var(--green2); box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.15); }
.modal .modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.modal button {
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--green);
  font-family: inherit;
  font-size: 11px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.12s;
}
.modal button:hover { border-color: var(--border-hi); }
.modal button.primary {
  background: linear-gradient(135deg, var(--green), var(--green2));
  color: #000;
  border-color: var(--green);
  font-weight: 700;
}
.modal button.primary:hover { box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.3); }

/* EXPANDED MODE & desktop wide layout */
@media (min-width: 720px) {
  .app { max-width: 100%; }
  .feed { padding: 14px 18px; font-size: 14px; }
  .msg-line { font-size: 14px; }
  .msg-img { max-width: 360px; max-height: 260px; }
  .toolbar button { width: 40px; height: 40px; font-size: 16px; }
  .input-row input { font-size: 15px; padding: 10px 12px; }
  .tiles { max-height: 320px; }
  .header .ctrl button { width: 32px; height: 32px; font-size: 14px; }
}

@media (min-width: 1100px) {
  .app { max-width: 1280px; }
  .feed { padding: 16px 24px; font-size: 15px; }
  .msg-line { font-size: 15px; }
  .msg-img { max-width: 460px; max-height: 320px; }
  .tiles { max-height: 420px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

body.expanded .tiles { max-height: 320px; }
body.expanded .feed { font-size: 14px; padding: 14px 18px; }
body.expanded .msg-img { max-width: 360px; max-height: 260px; }
body.expanded .toolbar button { width: 40px; height: 40px; font-size: 16px; }

/* MOBILE H5 — fix the missing input-row by using dynamic viewport height + safe area */
@media (max-width: 720px) {
  body { font-size: 14px; }
  html, body { height: 100%; height: 100dvh; }
  .app { height: 100%; height: 100dvh; }
  .input-row { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
  .footer { display: none; }
  .toolbar button { width: 38px; height: 38px; font-size: 16px; }
  .toolbar { gap: 8px; padding: 8px 10px; }
  .input-row input { font-size: 16px; padding: 10px 12px; }
  .input-row button { padding: 10px 12px; font-size: 12px; }
  .header .ctrl button { width: 34px; height: 34px; font-size: 14px; }
  .status-bar { font-size: 11px; }
  .msg-line { font-size: 14px; }
  .join-form input, .join-btn, .create-btn { font-size: 15px; }
  .modal { width: 100%; }
}

/* Animations */
@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.msg-line { animation: fade-in 0.2s ease; }

/* Extension popup mode forces fixed dimensions (set via class on html) */
html.popup, html.popup body { width: 380px; height: 600px; }
html.popup .footer { display: flex; }
