/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: "Trebuchet MS", Helvetica, sans-serif;
  background-color: #161616;
  color: #d8d8d8;
  font-size: 13px;
}

a {
  color: #7ec8e3;
  text-decoration: none;
}
a:hover { color: #b0dfee; text-decoration: underline; }

hr { border: none; border-top: 1px solid #444; margin: 12px 0; }

/* ── Layout shell ── */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 170px;
  min-width: 170px;
  flex-shrink: 0;
  height: 100vh;
  overflow-y: auto;
  position: sticky;
  top: 0;
  background: #0f0f0f;
  border-right: 1px solid #3c3c3c;
  display: flex;
  flex-direction: column;
  padding: 0;
  transition: width .2s ease, min-width .2s ease;
}

.sidebar-row {
  width: 100%;
  height: 50px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid #3c3c3c;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 4px;
  padding: 0 12px;
  font-size: 15px;
  font-weight: bold;
  color: #fff;
  letter-spacing: 0.5px;
  white-space: nowrap; overflow: hidden;
}

.sidebar-logo-img {
  width: 20px; height: 20px; vertical-align: -3px;
  filter: brightness(0) invert(1); /* white logo on dark bg */
  opacity: 0.85;
}

html.light-theme .sidebar-logo-img { filter: brightness(0) invert(0); /* dark logo on light bg */ }

.sidebar-logo span {
  color: #7ec8e3;
}

/* ── Desktop collapse toggle button ── */
.sidebar-collapse-btn {
  display: none;
}
@media (min-width: 768px) {
  .sidebar-collapse-btn {
    display: flex; align-items: center; justify-content: flex-end;
    padding: 5px 10px;
    background: none; border: none;
    color: #b0b0b0; cursor: pointer; transition: background .15s, color .15s;
    flex-shrink: 0;
  }
  .sidebar-collapse-btn:hover { background: #1e1e1e; color: #d0d0d0; }
  .sidebar-collapse-btn svg { width: 20px; height: 20px; }
  .sidebar-collapse-closed { display: none; }

  /* Collapsed state */
  .sidebar.collapsed .sidebar-row { justify-content: center; align-items: center; }
  .sidebar.collapsed { width: 52px; min-width: 52px; }
  .sidebar.collapsed .sidebar-label { display: none; }
  .sidebar.collapsed .sidebar-logo {
    display: none;
  }
  .sidebar.collapsed .sidebar-collapse-btn { justify-content: center; padding: 5px 0; }
  .sidebar.collapsed .sidebar-collapse-open  { display: none; }
  .sidebar.collapsed .sidebar-collapse-closed { display: block; }
  .sidebar.collapsed nav a { justify-content: center; padding: 12px 0; }
  .sidebar.collapsed .sidebar-icon { margin-right: 0; }
  .sidebar.collapsed .sidebar-controls { padding: 8px 0; }
  .sidebar.collapsed .sidebar-controls-row { flex-direction: column; align-items: center; gap: 4px; }
  .sidebar.collapsed .sidebar-lang-form { display: none; }

  html[dir="rtl"] .sidebar-collapse-btn { justify-content: flex-start; }
  html[dir="rtl"] .sidebar.collapsed nav a { justify-content: center; }
}

.sidebar nav {
  flex: 1;
  padding: 10px 0;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  color: #c0c0c0;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover {
  background: #1e1e1e;
  color: #e0e0e0;
  text-decoration: none;
}

.sidebar nav a.active {
  background: #1a1a1a;
  color: #7ec8e3;
  border-left-color: #7ec8e3;
}

.sidebar-footer {
  padding: 12px 16px;
  font-size: 11px;
  color: #888;
  border-top: 1px solid #383838;
}

/* ── Sidebar nav icons ── */
.sidebar-icon {
  width: 16px; height: 16px; vertical-align: -3px; margin-right: 8px;
  flex-shrink: 0;
  
}
html[dir="rtl"] .sidebar-icon { margin-right: 0; margin-left: 8px; }
html[dir="rtl"] .sidebar.collapsed .sidebar-icon { margin-right: 0; margin-left: 0; }

/* ── Sidebar controls (bottom bar) ── */
.sidebar-controls {
  margin-top: auto;
  padding: 10px 12px;
  border-top: 1px solid #383838;
}
.sidebar-controls-row {
  display: flex; align-items: center; gap: 6px;
}
.sidebar-ctrl-btn {
  background: #1a1a1a; border: 1px solid #3c3c3c; color: #c0c0c0;
  border-radius: 6px; padding: 6px 8px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.sidebar-ctrl-btn:hover { background: #282828; color: #e0e0e0; }
.sidebar-ctrl-icon { width: 15px; height: 15px; }
.theme-icon-dark  { display: none; }
html.light-theme .theme-icon-light { display: none; }
html.light-theme .theme-icon-dark  { display: inline; }
.sidebar-lang-form { flex: 1; min-width: 0; }
.sidebar-lang-select {
  width: 100%; background: #1a1a1a; color: #d0d0d0;
  border: 1px solid #3c3c3c; border-radius: 6px;
  padding: 6px 8px; font-size: 11px; cursor: pointer;
}
.sidebar-lang-select:focus { outline: none; border-color: #7ec8e3; }
.sidebar-logout-form { margin: 0; }
.sidebar-ctrl-logout { color: #e57373; }
.sidebar-ctrl-logout:hover { background: #3a2020; color: #ef5350; }
.sidebar-player-tag {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: #c0c0c0; margin-bottom: 8px;
  padding: 4px 0; overflow: hidden;
}
.sidebar-player-tag span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #d8d8d8; font-weight: 600;
}

/* ── Main content area ── */
.main-content {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-header {
  flex-shrink: 0;
  min-height: 50px;
  width: 100%;
  background: #1a1a1a;
  border-bottom: 1px solid #3c3c3c;
  padding: 14px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.page-header h1 {
  margin: 0;
  font-size: 17px;
  color: #e0e0e0;
  font-weight: normal;
}

.page-header .header-meta {
  font-size: 12px;
  color: #999;
}

.content-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px;
}

/* ── Cards / panels ── */
.card {
  background: #1c1c1c;
  border: 1px solid #3c3c3c;
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 18px;
}

.card-title {
  font-size: 13px;
  font-weight: bold;
  color: #c0c0c0;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  margin: 0 0 12px;
}

/* ── Stat cards row ── */
.stat-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-block: 12px;
}

.stat-card {
  background: #1e2a35;
  border: 1px solid #2e4055;
  border-radius: 6px;
  padding: 14px 18px;
  min-width: 130px;
  flex: 1;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: bold;
  color: #7ec8e3;
  display: block;
}

.stat-card .stat-label {
  font-size: 11px;
  color: #a8a8a8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: block;
  margin-top: 4px;
}

/* ── Tables ── */
.table-wrap {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}

thead th {
  background: #121212;
  color: #b8b8b8;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid #3c3c3c;
  position: sticky;
  top: 0;
}

tbody tr {
  border-bottom: 1px solid #303030;
  transition: background 0.1s;
}

tbody tr:hover {
  background: #1f1f1f;
}

/* Stale VP row: PID dead + socket offline */
tbody tr.row-stale {
  opacity: 0.65;
  background: #160e0e;
}

tbody td {
  padding: 8px 10px;
  vertical-align: middle;
  color: #d0d0d0;
}

/* ── Status badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.3px;
}

.badge-online    { background: #1a3a1a; color: #4caf50; border: 1px solid #2d5a2d; }
.badge-battle    { background: #3a1a1a; color: #ef5350; border: 1px solid #5a2d2d; }
.badge-waiting   { background: #2d2d1a; color: #fdd835; border: 1px solid #4a4a20; }
.badge-offline   { background: #222; color: #909090; border: 1px solid #3c3c3c; }
.badge-bound     { background: #1a2a3a; color: #7ec8e3; border: 1px solid #2a4a5a; }
.badge-free      { background: #1c2a1c; color: #81c784; border: 1px solid #2c4a2c; }
.badge-algo      { background: #2a1a3a; color: #ce93d8; border: 1px solid #4a2a5a; }
.badge-llm       { background: #1a2a1a; color: #a5d6a7; border: 1px solid #2a4a2a; }
.badge-pending   { background: #3a2a10; color: #ffb74d; border: 1px solid #5a3a10; }
.badge-stale     { background: #3a2020; color: #e57373; border: 1px solid #5a3030; }
.badge-active    { background: #1a3a1a; color: #4caf50; border: 1px solid #2d5a2d; }
.badge-inactive  { background: #222; color: #a8a8a8;    border: 1px solid #484848; }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm { padding: 3px 8px; font-size: 11px; }

.btn-primary   { background: #1e3a4a; color: #7ec8e3; border-color: #2a5a6a; }
.btn-primary:hover { background: #2a4a5a; text-decoration: none; color: #9fd8f0; }

.btn-danger    { background: #3a1a1a; color: #ef5350; border-color: #5a2525; }
.btn-danger:hover { background: #4a2020; text-decoration: none; color: #f87171; }
.btn-activate  { background: #1a3a1a; color: #4caf50; border-color: #2d5a2d; }
.btn-activate:hover { background: #1e4a1e; text-decoration: none; color: #66bb6a; }
.btn-warn      { background: #3a2a00; color: #ffb300; border-color: #5a4000; }
.btn-warn:hover { background: #4a3600; text-decoration: none; color: #ffc933; }

.btn-warning   { background: #3a2e10; color: #fdd835; border-color: #5a4a18; }
.btn-warning:hover { background: #4a3a14; text-decoration: none; color: #ffe082; }

.btn-success   { background: #1a3a1a; color: #81c784; border-color: #2a5a2a; }
.btn-success:hover { background: #204a20; text-decoration: none; color: #a5d6a7; }

.btn-secondary { background: #222; color: #c0c0c0; border-color: #3c3c3c; }
.btn-secondary:hover { background: #2a2a2a; text-decoration: none; color: #d8d8d8; }

/* Actions cell — keep buttons on one line */
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-right: 3px; }

/* ── Free VP cap bar ── */
.cap-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 12px;
  color: #c0c0c0;
}

.cap-progress {
  flex: 1;
  max-width: 220px;
  height: 8px;
  background: #252525;
  border-radius: 4px;
  overflow: hidden;
}

.cap-progress-inner {
  height: 100%;
  background: #4caf50;
  border-radius: 4px;
  transition: width 0.3s;
}

.cap-progress-inner.cap-warn  { background: #fdd835; }
.cap-progress-inner.cap-full  { background: #ef5350; }

/* ── Detail page live status grid ── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.status-item {
  background: #141414;
  border: 1px solid #383838;
  border-radius: 5px;
  padding: 10px 12px;
}

.status-item .si-label {
  font-size: 10px;
  color: #909090;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.status-item .si-value {
  font-size: 14px;
  color: #e4e4e4;
  font-weight: bold;
  word-break: break-all;
}

/* ── Timeline ── */
.timeline-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid #282828;
  font-size: 12px;
}

.timeline-list li:last-child { border-bottom: none; }

.tl-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.tl-dot-start   { background: #4caf50; }
.tl-dot-stop    { background: #ef5350; }
.tl-dot-bind    { background: #7ec8e3; }
.tl-dot-expired { background: #fdd835; }
.tl-dot-cmd     { background: #666; }

.tl-ts   { color: #909090; min-width: 140px; font-size: 11px; }
.tl-text { color: #d0d0d0; }
.tl-ok-true  { color: #4caf50; font-weight: bold; }
.tl-ok-false { color: #ef5350; font-weight: bold; }

/* ── Charts wrapper ── */
.chart-wrap {
  position: relative;
  height: 220px;
}

/* ── Date picker / filter row ── */
.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-row label { font-size: 12px; color: #a8a8a8; }

.filter-row input[type="date"],
.filter-row select {
  background: #141414;
  border: 1px solid #484848;
  border-radius: 4px;
  color: #d0d0d0;
  padding: 5px 8px;
  font-size: 12px;
  outline: none;
}

.filter-row input[type="date"]:focus,
.filter-row select:focus {
  border-color: #7ec8e3;
}

/* ── Alert / notice boxes ── */
.notice {
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 12px;
  margin-bottom: 12px;
}

.notice-info    { background: #1a2a3a; border: 1px solid #2a4a5a; color: #7ec8e3; }
.notice-warn    { background: #3a2d10; border: 1px solid #5a4a18; color: #fdd835; }
.notice-error   { background: #3a1a1a; border: 1px solid #5a2525; color: #ef5350; }
.notice-pending { background: #2a2a1a; border: 1px solid #4a4a28; color: #ffb74d; }

/* ── Loading spinner ── */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #333;
  border-top-color: #7ec8e3;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ── */
.text-muted   { color: #909090; }
.text-success { color: #4caf50; }
.text-danger  { color: #ef5350; }
.text-warn    { color: #fdd835; }
.text-info    { color: #7ec8e3; }
.monospace    { font-family: monospace; font-size: 11px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-12 { margin-bottom: 12px; }
.flex-gap { display: flex; gap: 8px; align-items: center; }
.auto-refresh-indicator { font-size: 11px; color: #808080; }

/* ═══════════════════════════════════════════════════════════════
   Monitor panel styles (.mon-* namespace)
   Scoped to .mon-root so they don't affect existing dashboard UI.
   Colors match the legacy log-monitor color scheme.
   ═══════════════════════════════════════════════════════════════ */
.mon-root {
  --mon-bg:    #0d1117; --mon-bg2: #161b22; --mon-bg3: #21262d; --mon-bg4: #30363d;
  --mon-border:#30363d; --mon-text:#c9d1d9; --mon-dim:#6e7681;  --mon-bright:#f0f6fc;
  --mon-green: #3fb950; --mon-blue:#58a6ff; --mon-yellow:#d29922; --mon-orange:#f0883e;
  --mon-red:   #f85149; --mon-purple:#bc8cff; --mon-teal:#39d353; --mon-pink:#f778ba;
  --mon-gold:  #e3b341; --mon-gray:#8b949e;
  font-family: 'Cascadia Code','JetBrains Mono','Fira Code',monospace;
  font-size: 13px;
  background: var(--mon-bg);
  color: var(--mon-text);
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* toolbar */
.mon-toolbar {
  display:flex; align-items:center; gap:10px; padding:7px 14px;
  background:var(--mon-bg2); border-bottom:1px solid var(--mon-border);
  flex-shrink:0; flex-wrap:wrap;
}
.mon-toolbar h2 { font-size:13px; font-weight:700; color:var(--mon-bright); margin:0; white-space:nowrap; }
.mon-dot { width:8px;height:8px;border-radius:50%;background:var(--mon-dim);flex-shrink:0; }
.mon-dot.live { background:var(--mon-green);box-shadow:0 0 6px var(--mon-green); }
.mon-status { font-size:11px; color:var(--mon-dim); white-space:nowrap; }
.mon-sep { width:1px;height:18px;background:var(--mon-border);flex-shrink:0; }

/* filter buttons */
.mon-filters { display:flex;gap:4px;flex-wrap:wrap; }
.mon-btn {
  padding:3px 10px; border-radius:4px; border:1px solid var(--mon-border);
  background:transparent; color:var(--mon-dim); cursor:pointer; font-size:11px;
  font-family:inherit; transition:all .15s; white-space:nowrap;
}
.mon-btn:hover { background:var(--mon-bg3); color:var(--mon-text); }
.mon-btn.active { border-color:var(--mon-blue); background:rgba(88,166,255,.15); color:var(--mon-blue); }
.mon-btn.active.f-error  { border-color:var(--mon-red);    background:rgba(248,81,73,.15);    color:var(--mon-red); }
.mon-btn.active.f-battle { border-color:var(--mon-orange); background:rgba(240,136,62,.15);   color:var(--mon-orange); }
.mon-btn.active.f-chat   { border-color:var(--mon-teal);   background:rgba(57,211,83,.12);    color:var(--mon-teal); }
.mon-btn.active.f-key    { border-color:var(--mon-gold);   background:rgba(227,179,65,.12);   color:var(--mon-gold); }
.mon-ml-auto { margin-left:auto; }

/* panels area */
.mon-main {
  display:flex; flex:1; overflow:hidden; gap:1px; background:var(--mon-border);
  min-height:0;
}
.mon-main.stacked { flex-direction:column; }

/* single panel */
.mon-panel {
  display:flex; flex-direction:column; flex:1; background:var(--mon-bg); overflow:hidden; min-width:0;
}
.mon-panel-header {
  display:flex; align-items:center; gap:8px; padding:6px 12px;
  background:var(--mon-bg2); border-bottom:1px solid var(--mon-border); flex-shrink:0;
}
.mon-pname   { font-weight:700; font-size:13px; color:var(--mon-bright); }
.mon-psub    { font-size:10px; color:var(--mon-dim); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mon-pengine {
  font-size:10px; padding:1px 7px; border-radius:10px; font-weight:700;
  background:rgba(88,166,255,.12); color:var(--mon-blue); white-space:nowrap; flex-shrink:0;
}
.mon-pengine.algo { background:rgba(63,185,80,.12); color:var(--mon-green); }
.mon-pengine.llm  { background:rgba(188,140,255,.12); color:var(--mon-purple); }
.mon-pmodel {
  font-size:10px; padding:1px 7px; border-radius:10px;
  background:var(--mon-bg4); color:var(--mon-dim); white-space:nowrap; flex-shrink:0;
}
.mon-pbadge { margin-left:auto; font-size:10px; padding:1px 7px; border-radius:10px; background:var(--mon-bg3); color:var(--mon-dim); }

/* HUD */
.mon-hud {
  display:flex; gap:12px; padding:5px 12px; background:var(--mon-bg2);
  border-bottom:1px solid var(--mon-border); flex-shrink:0; flex-wrap:wrap;
}
.mon-hud-block { display:flex; flex-direction:column; gap:1px; }
.mon-hud-lbl { font-size:9px; color:var(--mon-dim); text-transform:uppercase; letter-spacing:.5px; }
.mon-hud-val { font-size:13px; font-weight:700; color:var(--mon-bright); }
.mon-hud-val.hp { color:var(--mon-green); }
.mon-hud-val.hp.low { color:var(--mon-red); }
.mon-hud-val.ap { color:var(--mon-blue); }
.mon-hud-val.turn { color:var(--mon-purple); }
.mon-hud-val.phase { color:var(--mon-orange); font-size:11px; font-weight:600; }
.mon-hud-val.gold { color:var(--mon-gold); }
.mon-hud-val.red  { color:var(--mon-red); }

/* phase bar */
.mon-phase-bar {
  display:flex; padding:4px 10px; background:var(--mon-bg3);
  border-bottom:1px solid var(--mon-border); flex-shrink:0; gap:0; overflow:hidden;
}
.mon-phase-step {
  flex:1; text-align:center; font-size:10px; padding:2px 4px;
  color:var(--mon-dim); border-radius:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.mon-phase-step.done   { color:var(--mon-green);  background:rgba(63,185,80,.08); }
.mon-phase-step.active { color:var(--mon-orange); background:rgba(240,136,62,.15); font-weight:700; }

/* log body */
.mon-log-body { flex:1; overflow-y:auto; padding:4px 0; }
.mon-log-body::-webkit-scrollbar { width:6px; }
.mon-log-body::-webkit-scrollbar-thumb { background:var(--mon-bg4); border-radius:3px; }

/* log line — compact 2-row layout */
.mon-line {
  display:flex; flex-direction:column; padding:2px 10px; line-height:1.4;
  border-left:2px solid transparent; font-size:12px;
}
.mon-line:hover { background:var(--mon-bg3); }
.mon-line-head { display:flex; gap:6px; align-items:center; }
.mon-line-ts    { color:var(--mon-dim); flex-shrink:0; font-size:10px; }
.mon-line-badge {
  flex-shrink:0; font-size:10px; padding:1px 6px; border-radius:3px;
  max-width:200px; text-overflow:ellipsis; overflow:hidden; white-space:nowrap;
}
.mon-line-msg  { color:var(--mon-dim); word-break:break-all; font-size:11px; padding-left:2px; }
.mon-line.expanded .mon-line-msg { color:var(--mon-text); white-space:pre-wrap; }
.mon-line-expand {
  flex-shrink:0; cursor:pointer; color:var(--mon-dim); font-size:10px;
  padding:1px 4px; border-radius:2px; align-self:flex-start; margin-top:1px; user-select:none;
}
.mon-line-expand:hover { color:var(--mon-text); background:var(--mon-bg4); }

/* line category colours — same as monitor index.html */
.mon-line.noise,.mon-line.stats { display:none; }
.mon-line.startup    { border-color:var(--mon-gray); }
.mon-line.startup .mon-line-badge { background:rgba(139,148,158,.15); color:var(--mon-gray); }
.mon-line.login      { border-color:var(--mon-blue); }
.mon-line.login .mon-line-badge  { background:rgba(88,166,255,.1);   color:var(--mon-blue); }
.mon-line.login_ok   { border-color:var(--mon-green); background:rgba(63,185,80,.05); }
.mon-line.login_ok .mon-line-badge { background:rgba(63,185,80,.2); color:var(--mon-green); }
.mon-line.login_ok .mon-line-msg   { color:var(--mon-green); }
.mon-line.lobby      { border-color:var(--mon-blue); }
.mon-line.lobby .mon-line-badge  { background:rgba(88,166,255,.12); color:var(--mon-blue); }
.mon-line.lobby_prompt { border-color:var(--mon-gold); background:rgba(227,179,65,.05); }
.mon-line.lobby_prompt .mon-line-badge { background:rgba(227,179,65,.2);  color:var(--mon-gold); }
.mon-line.lobby_prompt .mon-line-msg   { color:var(--mon-gold); }
.mon-line.room       { border-color:var(--mon-blue); }
.mon-line.room .mon-line-badge   { background:rgba(88,166,255,.1);   color:var(--mon-blue); }
.mon-line.room_ok    { border-color:var(--mon-green); background:rgba(63,185,80,.06); }
.mon-line.room_ok .mon-line-badge  { background:rgba(63,185,80,.2);  color:var(--mon-green); }
.mon-line.room_ok .mon-line-msg    { color:var(--mon-green); }
.mon-line.room_ready { border-color:var(--mon-yellow); background:rgba(210,153,34,.08); }
.mon-line.room_ready .mon-line-badge { background:rgba(210,153,34,.25); color:var(--mon-yellow); }
.mon-line.room_ready .mon-line-msg   { color:var(--mon-yellow); }
.mon-line.battle_start { border-color:var(--mon-orange); background:rgba(240,136,62,.08); }
.mon-line.battle_start .mon-line-badge { background:rgba(240,136,62,.25); color:var(--mon-orange); }
.mon-line.battle_start .mon-line-msg   { color:var(--mon-orange); font-weight:600; }
.mon-line.turn       { border-color:#58a6ff88; }
.mon-line.turn .mon-line-badge   { background:rgba(88,166,255,.12); color:var(--mon-blue); }
.mon-line.turn_end   { border-color:transparent; }
.mon-line.turn_end .mon-line-badge { background:rgba(88,166,255,.08); color:#58a6ff66; }
.mon-line.decision   { border-color:var(--mon-purple); background:rgba(188,140,255,.04); }
.mon-line.decision .mon-line-badge { background:rgba(188,140,255,.18); color:var(--mon-purple); }
.mon-line.decision .mon-line-msg   { color:var(--mon-purple); }
.mon-line.decision_q { border-color:transparent; }
.mon-line.decision_q .mon-line-badge { background:rgba(188,140,255,.1); color:#bc8cff88; }
.mon-line.action_us  { border-color:var(--mon-green); }
.mon-line.action_us .mon-line-badge  { background:rgba(63,185,80,.2);   color:var(--mon-green); }
.mon-line.action_opp { border-color:#f0883e88; }
.mon-line.action_opp .mon-line-badge { background:rgba(240,136,62,.18); color:var(--mon-orange); }
.mon-line.combat     { border-color:var(--mon-orange); }
.mon-line.combat .mon-line-badge     { background:rgba(240,136,62,.18); color:var(--mon-orange); }
.mon-line.combat_us  { border-color:var(--mon-orange); background:rgba(240,136,62,.06); }
.mon-line.combat_us .mon-line-badge  { background:rgba(240,136,62,.25); color:var(--mon-orange); }
.mon-line.combat_us .mon-line-msg    { color:var(--mon-orange); }
.mon-line.combat_warn { border-color:var(--mon-red); background:rgba(248,81,73,.08); }
.mon-line.combat_warn .mon-line-badge { background:rgba(248,81,73,.3);  color:var(--mon-red); }
.mon-line.combat_warn .mon-line-msg   { color:var(--mon-red); }
.mon-line.combat_hit  { border-color:var(--mon-red); background:rgba(248,81,73,.1); }
.mon-line.combat_hit .mon-line-badge  { background:rgba(248,81,73,.35); color:var(--mon-red); }
.mon-line.combat_hit .mon-line-msg    { color:var(--mon-red); font-weight:700; }
.mon-line.combat_kill { border-color:#b71c1c; background:rgba(183,28,28,.15); }
.mon-line.combat_kill .mon-line-badge { background:rgba(183,28,28,.4);  color:#ff5252; }
.mon-line.combat_kill .mon-line-msg   { color:#ff5252; font-weight:700; }
.mon-line.trap  { border-color:var(--mon-pink); }
.mon-line.trap .mon-line-badge  { background:rgba(247,120,186,.18); color:var(--mon-pink); }
.mon-line.magic { border-color:#a371f7; }
.mon-line.magic .mon-line-badge { background:rgba(163,113,247,.18); color:#a371f7; }
.mon-line.chat_in  { border-color:var(--mon-teal); }
.mon-line.chat_in .mon-line-badge  { background:rgba(57,211,83,.12); color:var(--mon-teal); }
.mon-line.chat_out { border-color:#2ea04380; }
.mon-line.chat_out .mon-line-badge { background:rgba(46,160,67,.1);  color:#56d364; }
.mon-line.dashboard_in { border-color:#ff9800; }
.mon-line.dashboard_in .mon-line-badge { background:rgba(255,152,0,.12); color:#ff9800; }
.mon-line.win  { border-color:var(--mon-gold); background:rgba(227,179,65,.12); }
.mon-line.win .mon-line-badge  { background:rgba(227,179,65,.35); color:var(--mon-gold); }
.mon-line.win .mon-line-msg    { color:var(--mon-gold); font-weight:700; font-size:13px; }
.mon-line.loss { border-color:var(--mon-red); background:rgba(248,81,73,.08); }
.mon-line.loss .mon-line-badge { background:rgba(248,81,73,.3); color:var(--mon-red); }
.mon-line.game_over  { border-color:var(--mon-orange); }
.mon-line.game_over .mon-line-badge { background:rgba(240,136,62,.2); color:var(--mon-orange); }
.mon-line.error   { border-color:var(--mon-red); background:rgba(248,81,73,.1); }
.mon-line.error .mon-line-badge   { background:rgba(248,81,73,.35); color:var(--mon-red); }
.mon-line.error .mon-line-msg     { color:var(--mon-red); }
.mon-line.warning { border-color:var(--mon-yellow); background:rgba(210,153,34,.08); }
.mon-line.warning .mon-line-badge { background:rgba(210,153,34,.25); color:var(--mon-yellow); }
.mon-line.warning .mon-line-msg   { color:var(--mon-yellow); }
.mon-line.proto   { display:none; }
.mon-match-sep {
  display:flex !important; justify-content:center; align-items:center;
  padding:8px 0; border:none; margin:4px 0;
  background:linear-gradient(90deg, transparent, rgba(227,179,65,.15), transparent);
}
.mon-match-sep-text {
  font-size:11px; font-weight:700; color:var(--mon-gold); letter-spacing:1px;
  text-transform:uppercase;
}

/* filter mode body classes */
.mon-root.show-proto .mon-line.proto { display:flex; }
.mon-root.filter-key .mon-line:not(.login_ok,.lobby_prompt,.room_ok,.room_ready,
  .battle_start,.turn,.decision,.action_us,.action_opp,.combat,.combat_us,
  .combat_warn,.combat_hit,.combat_kill,.trap,.magic,.chat_in,.chat_out,.dashboard_in,
  .win,.loss,.game_over,.error,.warning,.mon-match-sep) { display:none !important; }
.mon-root.filter-battle .mon-line:not(.battle_start,.turn,.turn_end,.decision,.decision_q,
  .action_us,.action_opp,.combat,.combat_us,.combat_warn,.combat_hit,.combat_kill,
  .trap,.magic,.win,.loss,.game_over,.error,.warning,.mon-match-sep) { display:none !important; }
.mon-root.filter-error .mon-line:not(.error,.warning,.mon-match-sep) { display:none !important; }
.mon-root.filter-chat  .mon-line:not(.chat_in,.chat_out,.dashboard_in,.mon-match-sep) { display:none !important; }

/* stats bar */
.mon-statsbar { display:flex; gap:1px; background:var(--mon-border); border-top:1px solid var(--mon-border); flex-shrink:0; }
.mon-stat-panel { flex:1; display:flex; gap:16px; padding:6px 14px; background:var(--mon-bg2); align-items:center; overflow:hidden; flex-wrap:wrap; }
.mon-stat-item  { display:flex; flex-direction:column; gap:1px; min-width:60px; }
.mon-stat-lbl   { font-size:9px; color:var(--mon-dim); text-transform:uppercase; letter-spacing:.5px; }
.mon-stat-val   { font-size:12px; font-weight:700; color:var(--mon-bright); }
.mon-stat-val.green  { color:var(--mon-green);  }
.mon-stat-val.red    { color:var(--mon-red);    }
.mon-stat-val.blue   { color:var(--mon-blue);   }
.mon-stat-val.purple { color:var(--mon-purple); }
.mon-stat-val.orange { color:var(--mon-orange); }
.mon-stat-val.gold   { color:var(--mon-gold);   }

/* send message bar */
.mon-msgbar { display:flex; align-items:center; gap:8px; padding:6px 12px; background:var(--mon-bg2); border-top:1px solid var(--mon-border); flex-shrink:0; }
.mon-msg-target { background:var(--mon-bg); color:var(--mon-bright); border:1px solid var(--mon-border); border-radius:4px; padding:4px 8px; font-size:12px; }
.mon-msg-input { flex:1; background:var(--mon-bg); color:var(--mon-bright); border:1px solid var(--mon-border); border-radius:4px; padding:5px 10px; font-size:13px; }
.mon-msg-input::placeholder { color:var(--mon-dim); }
.mon-msg-status { font-size:12px; color:var(--mon-dim); min-width:40px; }

/* companion banner */
.mon-companion-banner {
  display:flex; align-items:center; gap:10px; padding:6px 14px;
  background:rgba(227,179,65,.12); border-bottom:1px solid var(--mon-gold);
  font-size:12px; color:var(--mon-gold); flex-shrink:0;
}
.mon-companion-banner button {
  padding:3px 10px; border-radius:4px; border:1px solid var(--mon-gold);
  background:transparent; color:var(--mon-gold); cursor:pointer; font-size:11px; font-family:inherit;
}
.mon-companion-banner button:hover { background:rgba(227,179,65,.2); }
.mon-companion-dismiss { margin-left:auto; cursor:pointer; opacity:.6; }
.mon-companion-dismiss:hover { opacity:1; }

/* ── Sync timeline ─────────────────────────────────────────────────────── */
.mon-sync-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  border-top: 1px solid var(--mon-sep);
  background: var(--mon-bg);
  font-size: 11px;
  font-family: var(--mono);
}

/* Header row */
.sync-header {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--mon-panel-bg);
  border-bottom: 1px solid var(--mon-sep);
  font-size: 10px;
  font-weight: 600;
  color: var(--mon-dim);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* Data rows */
.sync-row {
  display: flex;
  border-bottom: 1px solid rgba(255,255,255,.03);
  min-height: 20px;
}
.sync-row:hover { background: rgba(255,255,255,.03); }

/* Gap indicator row */
.sync-gap {
  display: flex;
  background: rgba(100,100,100,.08);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.sync-gap-cell {
  color: var(--mon-dim);
  font-style: italic;
  opacity: .6;
  font-size: 10px;
}

/* Timestamp column */
.sync-ts-col {
  flex: 0 0 68px;
  padding: 3px 6px;
  color: var(--mon-dim);
  border-right: 1px solid var(--mon-sep);
  white-space: nowrap;
  font-size: 10px;
}

/* Bot data column — one per bot, equal width */
.sync-bot-col {
  flex: 1;
  padding: 2px 6px;
  border-right: 1px solid rgba(255,255,255,.04);
  overflow: hidden;
  min-width: 0;
}
.sync-bot-col:last-child { border-right: none; }

/* Individual line inside a cell */
.sync-cell-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1px 0;
  color: var(--mon-text);
}

/* Inherit line colour rules from main log */
.sync-cell-line.startup    { color: var(--mon-dim); }
.sync-cell-line.key        { color: var(--mon-gold); font-weight: 600; }
.sync-cell-line.decision   { color: var(--mon-purple); }
.sync-cell-line.action_us  { color: var(--mon-green); }
.sync-cell-line.combat_us  { color: var(--mon-orange); font-weight: 600; }
.sync-cell-line.combat_them { color: var(--mon-red); }
.sync-cell-line.win        { color: var(--mon-gold); font-weight: 700; }
.sync-cell-line.loss       { color: var(--mon-red); font-weight: 700; }
.sync-cell-line.error      { color: var(--mon-red); }
.sync-cell-line.chat       { color: var(--mon-blue); }
.sync-cell-line.proto      { color: var(--mon-dim); opacity: .7; }

/* ── Sidebar language switcher (lower section of sidebar) ── */
/* (sidebar-lang replaced by sidebar-controls) */

/* ── RTL layout (Arabic) ──────────────────────────────────────────────────────
   Mirrors the shell so the sidebar sits on the right and content flows
   right-to-left. This is layout-level mirroring of directional properties only —
   colors, sizing, and component internals are unchanged. */
html[dir="rtl"] .shell {
  flex-direction: row-reverse;
}

html[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid #3a3a3a;
}

html[dir="rtl"] .sidebar nav a {
  border-left: none;
  border-right: 3px solid transparent;
}

html[dir="rtl"] .sidebar nav a.active {
  border-left-color: transparent;
  border-right-color: #7ec8e3;
}

html[dir="rtl"] .sidebar-controls {
  text-align: right;
}

html[dir="rtl"] thead th {
  text-align: right;
}

html[dir="rtl"] .spinner {
  margin-right: 0;
  margin-left: 6px;
}

html[dir="rtl"] .actions-cell .btn {
  margin-right: 0;
  margin-left: 3px;
}

html[dir="rtl"] .mon-ml-auto,
html[dir="rtl"] .mon-pbadge,
html[dir="rtl"] .mon-companion-dismiss {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] .mon-line-badge {
  text-align: left;
}

html[dir="rtl"] .sync-bot-col {
  border-right: none;
  border-left: 1px solid var(--mon-sep);
}

html[dir="rtl"] .sync-bot-col:last-child {
  border-left: none;
}
/* -- Light Theme -- */
html.light-theme body {
  background-color: #f5f5f5;
  color: #333;
}
html.light-theme .shell { background: #f5f5f5; }
html.light-theme .sidebar {
  background: #eaeaea;
  border-right: 1px solid #ccc;
}
html.light-theme .sidebar-logo {
  color: #222;
}
html.light-theme .sidebar-row { border-bottom: 1px solid #ccc; }
html.light-theme .sidebar-logo span { color: #0066cc; }
html.light-theme .sidebar nav a { color: #555; }
html.light-theme .sidebar nav a:hover { background: #d5d5d5; color: #111; }
html.light-theme .sidebar nav a.active { background: #d0d0d0; color: #0066cc; border-left-color: #0066cc; }
html.light-theme .sidebar-footer { border-top: 1px solid #ccc; color: #666; }
html.light-theme .sidebar-controls { border-top-color: #ddd; }
html.light-theme .sidebar-ctrl-btn { background: #fff; border-color: #ccc; color: #555; }
html.light-theme .sidebar-ctrl-btn:hover { background: #eee; color: #222; }
html.light-theme .sidebar-collapse-btn { border-bottom-color: #ccc; color: #aaa; }
html.light-theme .sidebar-collapse-btn:hover { background: #d5d5d5; color: #555; }
html.light-theme .sidebar-ctrl-logout { color: #c62828; }
html.light-theme .sidebar-ctrl-logout:hover { background: #ffebee; }
html.light-theme .sidebar-lang-select { background: #fff; color: #333; border-color: #ccc; }
html.light-theme .sidebar-player-tag { color: #666; }
html.light-theme .sidebar-player-tag span { color: #222; }

html.light-theme .main-content { background-color: #f5f5f5; }
html.light-theme .page-header { background: #fff; border-bottom: 1px solid #ddd; }
html.light-theme .page-header h1 { color: #222; }

html.light-theme .card { background: #fff; border: 1px solid #ddd; }
html.light-theme .card-title { color: #555; }
html.light-theme .stat-card { background: #f0f7fa; border: 1px solid #cce5eb; }
html.light-theme .stat-card .stat-value { color: #0066cc; }
html.light-theme .stat-card .stat-label { color: #555; }

html.light-theme thead th { background: #eaeaea; color: #444; border-bottom: 1px solid #ccc; }
html.light-theme tbody tr { border-bottom: 1px solid #ddd; }
html.light-theme tbody tr:hover { background: #f9f9f9; }
html.light-theme tbody tr.row-stale { background: #fff0f0; }
html.light-theme tbody td { color: #333; }

html.light-theme .status-item { background: #f9f9f9; border: 1px solid #e0e0e0; }
html.light-theme .status-item .si-value { color: #222; }

html.light-theme .filter-row input, html.light-theme .filter-row select { background: #fff; border: 1px solid #ccc; color: #333; }
html.light-theme .filter-row input:focus, html.light-theme .filter-row select:focus { border-color: #0066cc; outline:none; }

html.light-theme .timeline-list li { border-bottom: 1px solid #eee; }
html.light-theme .tl-text { color: #444; }

html.light-theme .cap-progress { background: #dde; }
html.light-theme .cap-bar { color: #555; }

html.light-theme, html.light-theme .mon-root {
  --mon-bg: #fff;
  --mon-bg2: #f6f8fa;
  --mon-bg3: #f3f4f6;
  --mon-bg4: #ebf0f4;
  --mon-border: #d0d7de;
  --mon-text: #24292f;
  --mon-dim: #57606a;
  --mon-bright: #0f1419;
  --mon-gray: #57606a;
  --mon-blue: #0969da;
  --mon-green: #1a7f37;
  --mon-red: #d1242f;
  --mon-orange: #9a6700;
  --mon-gold: #9a6700;
  --mon-purple: #8250df;
  --mon-pink: #bf3989;
  --mon-yellow: #9a6700;
  --mon-teal: #117865;
  --mon-sep: #d0d7de;
  --mon-panel-bg: #f6f8fa;
}

.sidebar-breadcrumb {
  margin-top: 8px; border-top: 1px solid #3a3a3a; padding-top: 10px;
}
html.light-theme .sidebar-breadcrumb { border-top-color: #ccc; }

/* Click-to-copy cells */
.copyable { cursor: pointer; }
.copyable:hover { text-decoration: underline dotted; }

/* theme toggle button */
html.light-theme #theme-toggle { background: #fff !important; color: #333 !important; border: 1px solid #ccc !important; }
html.light-theme .badge-online    { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
html.light-theme .badge-battle    { background: #ffebee; color: #c62828; border-color: #ffcdd2; }
html.light-theme .badge-waiting   { background: #fffde7; color: #f57f17; border-color: #fff9c4; }
html.light-theme .badge-offline   { background: #f5f5f5; color: #616161; border-color: #e0e0e0; }
html.light-theme .badge-bound     { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }
html.light-theme .badge-free      { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
html.light-theme .badge-algo      { background: #f3e5f5; color: #6a1b9a; border-color: #e1bee7; }
html.light-theme .badge-llm       { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
html.light-theme .badge-pending   { background: #fff8e1; color: #f57f17; border-color: #ffecb3; }
html.light-theme .badge-stale     { background: #ffebee; color: #c62828; border-color: #ffcdd2; }
html.light-theme .badge-active   { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
html.light-theme .badge-inactive { background: #f5f5f5; color: #757575; border-color: #e0e0e0; }

html.light-theme .btn-primary   { background: #e3f2fd; color: #1565c0; border-color: #bbdefb; }
html.light-theme .btn-primary:hover { background: #bbdefb; color: #0d47a1; }
html.light-theme .btn-danger    { background: #ffebee; color: #c62828; border-color: #ffcdd2; }
html.light-theme .btn-danger:hover { background: #ffcdd2; color: #b71c1c; }
html.light-theme .btn-activate  { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
html.light-theme .btn-activate:hover { background: #c8e6c9; color: #1b5e20; }
html.light-theme .btn-warn      { background: #fff8e1; color: #f57f17; border-color: #ffecb3; }
html.light-theme .btn-warn:hover { background: #ffecb3; color: #e65100; }
html.light-theme .btn-warning   { background: #fffde7; color: #f57f17; border-color: #fff9c4; }
html.light-theme .btn-warning:hover { background: #fff9c4; color: #f57f17; }
html.light-theme .btn-success   { background: #e8f5e9; color: #2e7d32; border-color: #c8e6c9; }
html.light-theme .btn-success:hover { background: #c8e6c9; color: #1b5e20; }
html.light-theme .btn-secondary { background: #f5f5f5; color: #424242; border-color: #e0e0e0; }
html.light-theme .btn-secondary:hover { background: #e0e0e0; color: #212121; }

/* ── Shared form styles (used by launch_vp, settings, player/launch_vp) ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 24px; }
.form-grid .full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; color: #a8a8a8; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea {
  background: #202020; border: 1px solid #484848; border-radius: 4px;
  color: #e0e0e0; padding: 6px 9px; font-size: 13px; font-family: inherit;
  outline: none; transition: border-color 0.15s;
  max-width: 100%; min-width: 0;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #7ec8e3; }
.form-group .hint { font-size: 11px; color: #909090; margin-top: 2px; }
.form-group select option { background: #202020; }
.section-header {
  font-size: 11px; font-weight: bold; color: #7ec8e3; text-transform: uppercase;
  letter-spacing: 0.7px; margin: 18px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid #383838; grid-column: 1 / -1;
}

/* -- Light Theme: form inputs (launch_vp.php) -- */
html.light-theme .form-group input,
html.light-theme .form-group select,
html.light-theme .form-group textarea {
  background: #fff; border: 1px solid #ccc; color: #333;
}
html.light-theme .form-group select option { background: #fff; color: #333; }
html.light-theme .form-group input:focus,
html.light-theme .form-group select:focus,
html.light-theme .form-group textarea:focus { border-color: #0066cc; }
html.light-theme .form-group label { color: #555; }
html.light-theme .form-group .hint { color: #777; }
html.light-theme .section-header { color: #1565c0; border-bottom-color: #ddd; }
html.light-theme .radio-group label { color: #333; }

/* -- Light Theme: notice boxes -- */
html.light-theme .notice-info    { background: #e3f2fd; border: 1px solid #bbdefb; color: #0d47a1; }
html.light-theme .notice-warn    { background: #fff8e1; border: 1px solid #ffecb3; color: #8d6e00; }
html.light-theme .notice-error   { background: #ffebee; border: 1px solid #ffcdd2; color: #b71c1c; }
html.light-theme .notice-pending { background: #fff3e0; border: 1px solid #ffe0b2; color: #a15c00; }

/* ── Messenger-style chat bubbles (chat filter only) ── */
.mon-root.filter-chat .mon-log-body {
  display: flex; flex-direction: column;
}
.mon-root.filter-chat .mon-line.chat_in,
.mon-root.filter-chat .mon-line.chat_out {
  display: flex; flex-direction: column; gap: 2px;
  border-left: none; border-radius: 14px;
  padding: 6px 12px; margin: 4px 8px; max-width: 70%;
}
.mon-root.filter-chat .mon-line.chat_out {
  align-self: flex-end; align-items: flex-end;
  background: rgba(46,160,67,.18);
}
.mon-root.filter-chat .mon-line.chat_in {
  align-self: flex-start; align-items: flex-start;
  background: var(--mon-bg3);
}
.mon-root.filter-chat .mon-line-head {
  order: -1; display: flex; gap: 6px; align-items: center;
}
.mon-root.filter-chat .mon-line-badge {
  width: auto; text-align: inherit; background: transparent !important;
  font-size: 10px; font-weight: 600; padding: 0; align-self: inherit;
}
.mon-root.filter-chat .mon-line-ts {
  font-size: 9px; opacity: .6; min-width: auto; padding: 0;
}
.mon-root.filter-chat .mon-line-msg {
  color: var(--mon-text); white-space: normal; word-break: break-word; flex: initial;
}
.mon-root.filter-chat .mon-line-expand { display: none; }

/* ── Battlefield — shared cell styles ── */
.bf-grid { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0; }
.bf-section { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bf-row { display: flex; gap: 6px; justify-content: center; }

.bf-cell {
  width: 84px; min-height: 44px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  font-size: 10px; padding: 4px 3px 3px; border-radius: 5px;
  background: #1c2128; border: 1px solid #30363d; color: #c9d1d9;
  position: relative; transition: border-color .15s, box-shadow .15s;
  gap: 2px;
}
.bf-cell.empty { opacity: 0.28; border-style: dashed; }
.bf-card-name { font-size: 10px; font-weight: 600; line-height: 1.2; word-break: break-word; }
.bf-stats { display: flex; gap: 2px; align-items: center; font-size: 9px; font-weight: 700; }
.bf-hp-stat  { color: #3fb950; }
.bf-atk-stat { color: #f0883e; }
.bf-def-stat { color: #6e7681; }
.bf-hp-bar { width: 76%; height: 3px; background: #2d333b; border-radius: 2px; overflow: hidden; margin-top: 1px; }
.bf-hp-fill { height: 100%; border-radius: 2px; transition: width .3s ease; }
.bf-hp-fill.hp-high { background: #3fb950; }
.bf-hp-fill.hp-mid  { background: #f0883e; }
.bf-hp-fill.hp-low  { background: #f85149; }
.bf-def-badge {
  position: absolute; top: 2px; right: 3px; font-size: 7px; font-weight: 700;
  color: #58a6ff; letter-spacing: .4px; line-height: 1;
}
.bf-cell.bf-defending { border-color: #388bfd; background: rgba(56,139,253,.06); }

.bf-label { font-size: 10px; color: #6e7681; text-transform: uppercase; letter-spacing: .5px; }
.bf-divider {
  width: 100%; max-width: 340px; background: transparent; margin: 4px 0;
  display: flex; align-items: center; gap: 8px;
}
.bf-divider::before, .bf-divider::after { content: ''; flex: 1; height: 1px; background: #30363d; }
.bf-move-label {
  font-size: 10px; color: var(--mon-orange, #f0883e); font-weight: 600;
  white-space: nowrap; padding: 2px 8px; background: rgba(240,136,62,.1);
  border-radius: 3px; border: 1px solid rgba(240,136,62,.22);
}

/* ── Highlights + animations ── */
.bf-cell.bf-highlight-put {
  border-color: #3fb950; box-shadow: 0 0 8px rgba(63,185,80,.5);
  animation: bfCardPlace .4s cubic-bezier(.34,1.56,.64,1);
}
.bf-cell.bf-highlight-move-from { border-color: #58a6ff; border-style: dashed; opacity: .5; }
.bf-cell.bf-highlight-move-to {
  border-color: #58a6ff; box-shadow: 0 0 8px rgba(88,166,255,.45);
  animation: bfSlideIn .3s ease-out;
}
.bf-cell.bf-highlight-atk-src {
  border-color: #f85149; box-shadow: 0 0 8px rgba(248,81,73,.5);
  animation: bfAtkSrc .5s ease-out;
}
.bf-cell.bf-highlight-atk-dst {
  border-color: #f85149; box-shadow: 0 0 12px rgba(248,81,73,.65);
  background: rgba(248,81,73,.1);
  animation: bfAtkDst .6s ease-out;
}
.bf-cell.bf-highlight-magic-src {
  border-color: #a371f7; box-shadow: 0 0 8px rgba(163,113,247,.5);
  animation: bfMagicSrc .6s ease-out;
}
.bf-cell.bf-highlight-magic-dst {
  border-color: #d2a8ff; box-shadow: 0 0 14px rgba(163,113,247,.7);
  animation: bfMagicDst .8s ease-out;
}
.bf-cell.bf-highlight-damage {
  border-color: #f85149; box-shadow: 0 0 10px rgba(248,81,73,.5);
  animation: bfDamage .45s ease-out;
}
.bf-cell.bf-highlight-heal {
  border-color: #3fb950; box-shadow: 0 0 8px rgba(63,185,80,.45);
}
.bf-cell.bf-highlight-death {
  border-color: #f85149; opacity: .5;
  animation: bfDeath .5s ease-out forwards;
}

/* ── Animated overlays ── */
.bf-overlay-svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; overflow: visible; }
.bf-effect-label { position: absolute; pointer-events: none; z-index: 41; transform: translateX(-50%); white-space: nowrap; }
.bf-magic-label {
  font-size: 10px; font-weight: 700; color: #d2a8ff;
  text-shadow: 0 0 6px rgba(163,113,247,.8);
  animation: bfFloatUp 1.3s ease-out forwards;
}
.bf-damage-label {
  font-size: 13px; font-weight: 900; color: #f85149;
  text-shadow: 0 0 6px rgba(248,81,73,.7);
  animation: bfFloatUp .8s ease-out forwards;
}

/* ── Keyframes ── */
@keyframes bfCardPlace {
  from { transform: scale(.25) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes bfSlideIn {
  from { transform: scale(.7) translateY(-8px); opacity: .5; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes bfAtkSrc {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.12); box-shadow: 0 0 16px rgba(248,81,73,.7); }
  100% { transform: scale(1); }
}
@keyframes bfAtkDst {
  0%   { transform: scale(1); }
  25%  { transform: scale(.88); background: rgba(248,81,73,.25); }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}
@keyframes bfMagicSrc {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); box-shadow: 0 0 18px rgba(163,113,247,.8); }
  100% { transform: scale(1); }
}
@keyframes bfMagicDst {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.08); box-shadow: 0 0 22px rgba(163,113,247,.9); }
  65%  { transform: scale(.97); }
  100% { transform: scale(1); }
}
@keyframes bfDamage {
  0%   { transform: translateX(0); }
  25%  { transform: translateX(-5px); }
  50%  { transform: translateX(5px); }
  75%  { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}
@keyframes bfDeath {
  from { transform: scale(1); opacity: .5; filter: brightness(1); }
  to   { transform: scale(.7); opacity: 0; filter: brightness(2) saturate(0); }
}
@keyframes bfFloatUp {
  0%   { transform: translateX(-50%) translateY(0); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-30px); opacity: 0; }
}
@keyframes bfArrowDraw {
  to { stroke-dashoffset: 0; }
}
@keyframes bfArrowFade {
  to { opacity: 0; }
}
@keyframes bfPulse {
  0%   { r: 6; opacity: .8; }
  100% { r: 18; opacity: 0; }
}
@keyframes bfImpactRing {
  0%   { r: 4; opacity: .9; }
  100% { r: 28; opacity: 0; }
}
@keyframes bfMagicCore {
  0%   { r: 2; opacity: 1; }
  60%  { r: 8; opacity: .6; }
  100% { r: 14; opacity: 0; }
}
@keyframes bfSpark {
  0%   { transform: translate(0,0); opacity: 1; }
  100% { transform: translate(var(--tx),var(--ty)); opacity: 0; }
}
@keyframes bfTurnPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: .5; transform: scale(.75); }
}

/* ── Turn dot ── */
.bf-turn-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #58a6ff; vertical-align: middle;
  animation: bfTurnPulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
}

/* ── Unified board — mobile first (vertical) ── */
.bf-board {
  display: flex; flex-direction: column;
  gap: 0; position: relative; width: 100%; box-sizing: border-box;
}
.bf-board-status {
  min-height: 26px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-muted, #6e7681); padding: 3px 14px;
  border-bottom: 1px solid #30363d; flex-shrink: 0; text-align: center;
}
.bf-board-body {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; padding: 10px 8px;
}
.bf-board-half {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 8px 6px; border-radius: 6px; width: 100%;
  transition: background .25s, box-shadow .25s;
}
.bf-board-half.bf-active-turn {
  background: rgba(88,166,255,.04);
  box-shadow: inset 0 0 0 1px rgba(88,166,255,.2);
}
.bf-board-pname {
  font-size: 11px; font-weight: 700; color: #6e7681;
  text-transform: uppercase; letter-spacing: .6px;
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}
.bf-pstats { display: flex; gap: 6px; margin-left: auto; }
.bf-pstat-hp {
  font-size: 11px; font-weight: 700; color: #f85149;
  background: rgba(248,81,73,.1); border: 1px solid rgba(248,81,73,.25);
  border-radius: 4px; padding: 1px 5px; line-height: 1.4;
}
.bf-pstat-ap {
  font-size: 11px; font-weight: 700; color: #58a6ff;
  background: rgba(88,166,255,.1); border: 1px solid rgba(88,166,255,.25);
  border-radius: 4px; padding: 1px 5px; line-height: 1.4;
}
.bf-winner-banner {
  font-size: 13px; font-weight: 700; color: #ffd700;
  letter-spacing: .5px;
}
.bf-board-status-winner {
  background: rgba(255,215,0,.07); border-bottom-color: rgba(255,215,0,.3);
}
.bf-board-field {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
/* In mobile: each col is a horizontal row of cells */
.bf-board-col { display: flex; flex-direction: row; gap: 5px; justify-content: center; align-items: center; }
.bf-board-traps {
  display: flex; flex-direction: row; gap: 5px; align-items: center;
}
/* Mobile: push traps to the far/outer edge of each half */
.bf-board-other .bf-board-traps { order: -1; }
.bf-board-self  .bf-board-traps { order: 1; }
.bf-trap-label {
  font-size: 9px; color: #6e7681; text-transform: uppercase;
  letter-spacing: .4px; padding-right: 3px;
}
.bf-board-divider {
  width: 100%; max-width: 380px; display: flex; align-items: center;
  gap: 8px; padding: 3px 0; flex-shrink: 0;
}
.bf-board-divider::before, .bf-board-divider::after {
  content: ''; flex: 1; height: 1px; background: #30363d;
}

/* ── Desktop (≥ 768px): rotate to horizontal ── */
@media (min-width: 768px) {
  .bf-board-body {
    flex-direction: row; align-items: stretch;
    justify-content: center; padding: 12px 8px;
  }
  .bf-board-half { flex-direction: column; width: auto; flex: 1; max-width: 280px; }
  /* cols become side-by-side visual columns */
  .bf-board-field { flex-direction: row; align-items: center; justify-content: center; gap: 4px; }
  /* cells in each col stack vertically */
  .bf-board-col { flex-direction: column; align-items: center; min-width: 78px; gap: 4px; }
  /* divider becomes a vertical line */
  .bf-board-divider {
    width: auto; min-height: 100%; flex-direction: column;
    padding: 0 10px; max-width: unset; align-items: center; align-self: stretch;
  }
  .bf-board-divider::before, .bf-board-divider::after {
    height: auto; flex: 1; width: 1px;
  }
  .bf-board-traps { justify-content: center; }
  .bf-board-status { border-bottom-color: #30363d; }
  /* Desktop: restore traps to inner position (default HTML order) */
  .bf-board-other .bf-board-traps { order: 0; }
  .bf-board-self  .bf-board-traps { order: 0; }
}

/* ── Large screens (≥ 1200px): scale battlefield up 1.3× ── */
@media (min-width: 1200px) {
  .bf-cell { width: 108px; min-height: 57px; font-size: 13px; padding: 5px 4px 4px; }
  .bf-card-name { font-size: 13px; }
  .bf-stats { font-size: 11px; }
  .bf-def-badge { font-size: 9px; }
  .bf-hp-bar { height: 4px; }
  .bf-board-col { min-width: 100px; gap: 6px; }
  .bf-board-half { max-width: 360px; }
  .bf-board-body { padding: 16px 12px; }
  .bf-board-divider { padding: 0 14px; }
  .bf-board-field { gap: 6px; }
}

/* ── Unified BF wrap (filter-board shows this instead of per-panel containers) ── */
.bf-unified-wrap { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.bf-unified-ctrl-row {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px 10px; flex-shrink: 0;
  border-top: 1px solid #30363d;
}
.bf-unified-ctrl-row input[type="range"] { flex: 1; min-width: 0; }
.bf-ctrl-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex-shrink: 0;
  background: transparent; border: 1px solid #30363d; border-radius: 6px;
  cursor: pointer; color: #8b949e; padding: 0;
  transition: background .15s, color .15s, border-color .15s;
}
.bf-ctrl-btn:hover { background: #21262d; color: #e6edf3; border-color: #484f58; }
.bf-ctrl-btn:active { background: #30363d; }
.bf-ctrl-btn.playing { color: #58a6ff; border-color: #388bfd; }
.bf-ctrl-btn svg { width: 14px; height: 14px; stroke-width: 2; }
/* toggle icons inside play button */
.bf-ctrl-btn .bf-icon-pause { display: none; }
.bf-ctrl-btn.playing .bf-icon-play  { display: none; }
.bf-ctrl-btn.playing .bf-icon-pause { display: block; }

.mon-root.filter-board .mon-main    { display: none; }
.mon-root.filter-board .mon-log-body { display: none; }
.mon-root.filter-board .bf-container { display: none; }
.mon-root.filter-board .bf-unified-wrap { display: flex; }

/* legacy per-panel container (archive viewer single-bot) */
.bf-container { display: none; padding: 10px; overflow: auto; }
.bf-slider-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 0 10px; }
.bf-slider-row input[type="range"] { flex: 1; }
.bf-slider-label { font-size: 11px; color: var(--mon-dim); white-space: nowrap; min-width: 90px; text-align: right; }

/* ── Light theme overrides ── */
html.light-theme .bf-cell { background: #f3f4f6; border: 1px solid #d0d7de; color: #24292f; }
html.light-theme .bf-cell.empty { opacity: .4; }
html.light-theme .bf-hp-stat  { color: #1a7f37; }
html.light-theme .bf-atk-stat { color: #cf6a28; }
html.light-theme .bf-stats    { color: #24292f; }
html.light-theme .bf-label    { color: #57606a; }
html.light-theme .bf-divider::before, html.light-theme .bf-divider::after { background: #d0d7de; }
html.light-theme .bf-board-divider::before, html.light-theme .bf-board-divider::after { background: #d0d7de; }
html.light-theme .bf-move-label { color: #cf6a28; background: rgba(207,106,40,.08); border-color: rgba(207,106,40,.3); }
html.light-theme .bf-board-pname { color: #57606a; }
html.light-theme .bf-pstat-hp { color: #cf2113; background: rgba(207,33,19,.08); border-color: rgba(207,33,19,.22); }
html.light-theme .bf-pstat-ap { color: #0969da; background: rgba(9,105,218,.08); border-color: rgba(9,105,218,.22); }
html.light-theme .bf-board-status-winner { background: rgba(180,136,0,.07); }
html.light-theme .bf-board-status { border-bottom-color: #d0d7de; color: #57606a; }
html.light-theme .bf-unified-ctrl-row { border-top-color: #d0d7de; }
html.light-theme .bf-ctrl-btn { border-color: #d0d7de; color: #57606a; }
html.light-theme .bf-ctrl-btn:hover { background: #f3f4f6; color: #24292f; border-color: #adb5bd; }
html.light-theme .bf-ctrl-btn:active { background: #e9ebee; }
html.light-theme .bf-board-half.bf-active-turn { background: rgba(9,105,218,.04); box-shadow: inset 0 0 0 1px rgba(9,105,218,.18); }
html.light-theme .bf-def-badge { color: #0969da; }
html.light-theme .bf-cell.bf-defending { border-color: #0969da; background: rgba(9,105,218,.05); }
html.light-theme .bf-cell.bf-highlight-put { border-color: #2da44e; box-shadow: 0 0 6px rgba(45,164,78,.3); }
html.light-theme .bf-cell.bf-highlight-atk-src { border-color: #cf222e; box-shadow: 0 0 6px rgba(207,34,46,.3); }
html.light-theme .bf-cell.bf-highlight-atk-dst { border-color: #cf222e; box-shadow: 0 0 8px rgba(207,34,46,.4); background: rgba(207,34,46,.06); }
html.light-theme .bf-cell.bf-highlight-magic-dst { border-color: #8250df; box-shadow: 0 0 10px rgba(130,80,223,.4); }

/* ── Archive full-text search ── */
.arch-search-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 0;
}
.arch-search-input {
  flex: 1; min-width: 180px; padding: 6px 10px; font-size: 13px;
  background: #1c2128; border: 1px solid #30363d; border-radius: 6px;
  color: #e6edf3; outline: none;
}
.arch-search-input:focus { border-color: #58a6ff; }
.arch-search-input::placeholder { color: #484f58; }
.arch-search-meta {
  margin-top: 10px; font-size: 12px; color: #8b949e;
}
.arch-search-results { margin-top: 10px; }
.arch-result {
  padding: 8px 10px; border: 1px solid #21262d; border-radius: 6px; margin-bottom: 6px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.arch-result:hover { border-color: #388bfd; background: rgba(56,139,253,.06); }
.arch-result-file {
  font-size: 11px; color: #8b949e; margin-bottom: 3px; font-family: monospace;
}
.arch-result-line { color: #6e7681; margin-left: 2px; }
.arch-result-text {
  font-size: 12px; font-family: monospace; color: #c9d1d9;
  white-space: pre; overflow: hidden; text-overflow: ellipsis;
}
.arch-result-text mark { background: rgba(255,215,0,.25); color: #ffd700; border-radius: 2px; }
.arch-no-results { font-size: 13px; color: #6e7681; padding: 12px 4px; }
#search-card { margin-bottom: 20px; }
.spinner {
  display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid #30363d; border-top-color: #58a6ff; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

html.light-theme .arch-search-input { background: #fff; border-color: #d0d7de; color: #24292f; }
html.light-theme .arch-search-input:focus { border-color: #0969da; }
html.light-theme .arch-search-input::placeholder { color: #adb5bd; }
html.light-theme .arch-search-meta { color: #57606a; }
html.light-theme .arch-result { border-color: #d0d7de; }
html.light-theme .arch-result:hover { border-color: #0969da; background: rgba(9,105,218,.05); }
html.light-theme .arch-result-file { color: #57606a; }
html.light-theme .arch-result-line { color: #adb5bd; }
html.light-theme .arch-result-text { color: #24292f; }
html.light-theme .arch-result-text mark { background: rgba(255,165,0,.2); color: #953800; }
html.light-theme .spinner { border-color: #d0d7de; border-top-color: #0969da; }

/* ── Responsive: sidebar hamburger ── */
.sidebar-toggle {
  display: none;
  position: fixed; top: 10px; left: 10px; z-index: 1100;
  background: #1c1c1c; border: 1px solid #3a3a3a; border-radius: 6px;
  width: 36px; height: 36px; padding: 7px 6px;
  flex-direction: column; justify-content: space-between;
  cursor: pointer;
  transition: left .25s ease;
}
.sidebar-toggle span {
  display: block; width: 100%; height: 2px;
  background: #ccc; border-radius: 2px;
  transition: transform .25s, opacity .2s;
}
.sidebar-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.sidebar-toggle.open span:nth-child(2) { opacity: 0; }
.sidebar-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.5);
}
.sidebar-overlay.open { display: block; }

html.light-theme .sidebar-toggle { background: #fff; border-color: #d0d7de; }
html.light-theme .sidebar-toggle span { background: #24292f; }

@media (max-width: 767px) {
  .sidebar-toggle { display: flex; }
  .sidebar-toggle.open { left: 210px; }

  .sidebar {
    position: fixed; left: -220px; top: 0; z-index: 1000;
    transition: left .25s ease;
    width: 200px;
    height: 100svh; /* svh = small viewport, excludes mobile browser chrome */
  }
  .sidebar.open { left: 0; }

  .page-header { padding: 10px 14px 10px 54px; }
  .page-header h1 { font-size: 15px; }

  .content-body { padding: 14px 12px; max-width: 100vw; overflow-x: auto; padding-bottom: 60px; }

  .table-wrap,
  [id$="-table-wrap"] { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .overview-table, .settings-table, .match-table { min-width: 480px; }

  .tab-panel { overflow-x: auto; }

  .settings-tabs { overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }

  .lp-fields { grid-template-columns: 1fr; }

  .overview-table { font-size: 11px; }
  .overview-table th:nth-child(n+7),
  .overview-table td:nth-child(n+7) { display: none; }

  .card { padding: 14px; }
  .field-group { flex-direction: column; }
  .field-group > .field { width: 100% !important; }

  .form-grid { grid-template-columns: 1fr; }

  .health-grid { grid-template-columns: 1fr; }

  .status-grid { grid-template-columns: repeat(2, 1fr); }

  /* Phone nav bar safe area — env() returns 0 when no system bar exists */
  .content-body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .mon-root { padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px)); }
  .sidebar-controls { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}

/* ── Pull-to-refresh ──────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  html, body { overscroll-behavior-y: none; }
}
#ptr-indicator {
  position: fixed; top: 0; left: 50%; z-index: 9999;
  transform: translateX(-50%) translateY(-60px);
  width: 48px; height: 48px;
  background: #1c1c1c; border: 1px solid #3a3a3a; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; opacity: 0;
}
#ptr-indicator .ptr-arrow {
  width: 24px; height: 24px; stroke: #aaa; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  transition: transform .2s ease, stroke .2s ease;
}
#ptr-indicator.ptr-ready .ptr-arrow { transform: rotate(180deg); stroke: #7ec8e3; }
#ptr-indicator.ptr-refreshing .ptr-arrow { stroke: #7ec8e3; animation: ptr-spin .7s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }
html.light-theme #ptr-indicator { background: #fff; border-color: #d0d7de; }
html.light-theme #ptr-indicator .ptr-arrow { stroke: #555; }
html.light-theme #ptr-indicator.ptr-ready .ptr-arrow,
html.light-theme #ptr-indicator.ptr-refreshing .ptr-arrow { stroke: #0066cc; }

@media (max-width: 480px) {
  .page-header { flex-direction: column; align-items: flex-start; gap: 4px; }

  .overview-table th:nth-child(n+5),
  .overview-table td:nth-child(n+5) { display: none; }

  .mon-panels { flex-direction: column !important; }
  .mon-panel { width: 100% !important; min-width: 0 !important; }

  .status-grid { grid-template-columns: 1fr; }

  .stat-row { gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-card .stat-value { font-size: 20px; }
}

/* ── Log-based BattleField filter ── */
.bf-container { display: none; padding: 10px; overflow: auto; }
.mon-root.filter-board .mon-log-body { display: none; }
.mon-root.filter-board .bf-container { display: block; }
.bf-slider-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 0 10px; }
.bf-slider-row input[type="range"] { flex: 1; }
.bf-slider-label { font-size: 11px; color: var(--mon-dim); white-space: nowrap; min-width: 90px; text-align: right; }

/* ── Kill / Stop modal ── */
.kill-modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:9999; display:flex; align-items:center; justify-content:center; }
.kill-modal { background:#141414; border:1px solid #383838; border-radius:10px; padding:24px 28px; max-width:480px; width:90%; color:#d0d0d0; }
.kill-modal-title { margin:0 0 8px; font-size:1rem; color:#eee; }
.kill-modal-body { min-height:60px; }
.kill-modal-muted { color:#a0a0a0; font-size:.82rem; }
.kill-modal-actions { margin-top:16px; display:flex; gap:10px; justify-content:flex-end; }
.kill-modal-table { width:100%; font-size:.85rem; border-collapse:collapse; }
.kill-modal-table td { padding:4px 8px; color:#d0d0d0; }
.kill-modal-label { color:#a0a0a0; }

html.light-theme .kill-modal { background:#fff; border-color:#ddd; color:#333; }
html.light-theme .kill-modal-title { color:#222; }
html.light-theme .kill-modal-muted { color:#888; }
html.light-theme .kill-modal-table td { color:#333; }
html.light-theme .kill-modal-label { color:#888; }

/* ── VP picker (log monitor selector) ───────────────────────────────────── */
.vp-pick-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:12px; }
.vp-pick-card {
  display:block; padding:14px 16px; border:1px solid #383838; border-radius:8px;
  background:#141414; color:#d0d0d0; text-decoration:none; transition:border-color .15s, background .15s;
}
.vp-pick-card:hover { border-color:#58a6ff; background:#1e2a3a; }
.vp-pick-offline { opacity:.45; pointer-events:none; }
.vp-pick-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:6px; }
.vp-pick-name { font-weight:600; font-size:.95rem; color:#eee; }
.vp-pick-meta { font-size:.78rem; color:#a0a0a0; display:flex; align-items:center; gap:6px; }
.vp-pick-dot { width:3px; height:3px; border-radius:50%; background:#808080; display:inline-block; }
.vp-pick-pair { border-color:#ff980060; text-align:center; }
.vp-pick-pair:hover { border-color:#ff9800; background:#2a2010; }
.vp-pick-pair-names { display:flex; align-items:center; justify-content:center; gap:10px; margin-bottom:4px; }
.vp-pick-vs { color:#a0a0a0; font-size:.75rem; font-weight:500; }
.vp-pick-badge { font-size:.72rem; color:#a0a0a0; margin-top:6px; }

html.light-theme .vp-pick-card { background:#f8f9fa; border-color:#ddd; color:#333; }
html.light-theme .vp-pick-card:hover { border-color:#0969da; background:#e8f0fe; }
html.light-theme .vp-pick-name { color:#222; }
html.light-theme .vp-pick-meta { color:#666; }
html.light-theme .vp-pick-dot { background:#bbb; }
html.light-theme .vp-pick-pair { border-color:#ff980060; }
html.light-theme .vp-pick-pair:hover { border-color:#ff9800; background:#fff8e1; }
