:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --fg: #e6e9ef;
  --fg-dim: #97a0b0;
  --accent: #4f9cf9;
  --warn: #f0b429;
  --crit: #f2545b;
  --ok: #3ecf8e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 "Pretendard", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.2px;
}

.brand .last-refresh {
  color: var(--fg-dim);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1.3;
}

.brand .sub {
  display: block;
  color: var(--fg-dim);
  font-size: 12px;
}

.auth-box {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  font-size: 12px;
  flex-shrink: 0;
  align-self: center;
}
.auth-box.hidden { display: none; }
.auth-user {
  color: var(--fg-dim);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid rgba(242, 84, 91, 0.55);
  background: rgba(242, 84, 91, 0.14);
  color: #ffb4b8;
  text-decoration: none;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.logout-btn:hover {
  background: rgba(242, 84, 91, 0.28);
  border-color: var(--crit);
  color: #fff;
  text-decoration: none;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.controls label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-dim);
  font-size: 12px;
}

.controls select,
.controls button {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.controls button:hover { border-color: var(--accent); }

.controls .chk { cursor: pointer; }
.controls input[type="checkbox"] { accent-color: var(--accent); }

.controls .refresh-interval {
  gap: 5px;
}

.controls .refresh-interval input[type="range"] {
  width: 88px;
  accent-color: var(--accent);
  cursor: pointer;
}

.controls .refresh-interval input[type="number"] {
  width: 52px;
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.controls .refresh-interval .unit {
  color: var(--fg-dim);
  font-size: 12px;
}

.controls .range-search {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
}

.controls .range-search input[type="datetime-local"] {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
}

.controls .live-btn {
  border-color: var(--ok);
  color: var(--ok);
}

.controls .live-btn:hover { border-color: var(--ok); }

.mode-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  border: 1px solid var(--line);
}

.mode-badge.live {
  color: var(--ok);
  border-color: rgba(62, 207, 142, 0.45);
  background: rgba(62, 207, 142, 0.12);
}

.mode-badge.history {
  color: var(--warn);
  border-color: rgba(240, 180, 41, 0.45);
  background: rgba(240, 180, 41, 0.12);
}

.controls .server-label select {
  min-width: 140px;
  border-color: var(--accent);
  font-weight: 600;
}

.server-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

.server-tag:empty { display: none; }

/* ---------- banner ---------- */

.banner {
  padding: 9px 20px;
  background: #3a2a12;
  color: var(--warn);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.hidden { display: none !important; }

/* ---------- PerfGuard panel ---------- */

.perf-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 20px 10px;
  background: var(--panel);
  overflow: auto;
}

.perf-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.perf-head h2 {
  margin: 0;
  font-size: 13px;
  color: var(--fg-dim);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.perf-status {
  color: var(--fg-dim);
  font-size: 11.5px;
}

.perf-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.perf-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 12px;
  min-width: 110px;
}

.perf-card .label {
  display: block;
  color: var(--fg-dim);
  font-size: 11px;
  margin-bottom: 2px;
}

.perf-card .value {
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.2px;
}

.perf-card.lvl-0 .value { color: var(--ok); }
.perf-card.lvl-1 .value { color: var(--warn); }
.perf-card.lvl-2 .value,
.perf-card.lvl-3 .value { color: var(--crit); }
.perf-card.warn .value { color: var(--warn); }
.perf-card.crit .value { color: var(--crit); }

.perf-chart-host {
  position: relative;
  flex: 1;
  min-height: 280px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

#perfChart {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
}

#perfChart.dragging { cursor: grabbing; }

.chart-scroll {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  min-height: 18px;
}

.chart-scroll-track {
  position: relative;
  flex: 1;
  height: 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}

.chart-scroll-thumb {
  position: absolute;
  top: 1px;
  height: 6px;
  min-width: 24px;
  background: var(--accent);
  border-radius: 999px;
  opacity: 0.75;
  cursor: grab;
}

.chart-scroll-thumb:hover { opacity: 1; }
.chart-scroll-thumb.dragging { cursor: grabbing; opacity: 1; }

.chart-scroll-hint {
  flex: none;
  color: var(--fg-dim);
  font-size: 10.5px;
  white-space: nowrap;
}

.perf-note {
  margin-top: 6px;
  color: var(--fg-dim);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.perf-note b { color: var(--fg); font-weight: 600; }
.perf-note .crit { color: var(--crit); }
.perf-note .warn { color: var(--warn); }
.perf-note .ok { color: var(--ok); }

.annot-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
  color: var(--fg-dim);
  font-size: 11px;
}

.annot-legend .al-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.annot-legend .al-item i {
  display: inline-block;
  width: 12px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(255,255,255,0.15);
}

.annot-legend .al-item.stage i {
  background: transparent;
  border-left: 2px solid #b07cf7;
  width: 8px;
}

.annot-legend .al-item.lag i {
  background: rgba(240, 180, 41, 0.35);
}

.annot-legend .al-item.crash i {
  background: rgba(242, 84, 91, 0.40);
}

.annot-legend .al-item.guides i {
  background: transparent;
  border: none;
  border-radius: 0;
  width: 14px;
  height: 0;
  border-bottom: 2px dashed rgba(240, 180, 41, 0.85);
  box-shadow: 0 3px 0 -1px rgba(242, 84, 91, 0.75);
}

/* ---------- crash log panel ---------- */

.crash-log-panel {
  margin-top: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  /* Do not flex-shrink inside .perf-panel: shrink + overflow:hidden
     collapses the crash list to 0 height with nothing to scroll to
     (especially on short/narrow viewports after mobile topbar growth). */
  flex: none;
}

.crash-log-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.crash-tab {
  background: transparent;
  color: var(--fg-dim);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 14px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.crash-tab:hover { color: var(--fg); }

.crash-tab.active {
  color: var(--fg);
  border-bottom-color: var(--crit);
  font-weight: 600;
}

.crash-log-list {
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 0;
}

.crash-log-empty {
  padding: 12px 14px;
  color: var(--fg-dim);
  font-size: 12px;
}

.crash-log-item {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) minmax(70px, 0.6fr) minmax(120px, 1.1fr) minmax(80px, 0.7fr) minmax(70px, 0.6fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.crash-log-item:hover { background: rgba(242, 84, 91, 0.08); }
.crash-log-item.active {
  background: rgba(242, 84, 91, 0.14);
  box-shadow: inset 3px 0 0 var(--crit);
}

.crash-log-item .cl-when { color: var(--fg); }
.crash-log-item .cl-dur { color: var(--crit); font-weight: 600; }
.crash-log-item .cl-srv { color: var(--fg-dim); }
.crash-log-item .cl-acc-wrap {
  min-width: 0;
  overflow: hidden;
}
.crash-log-item .cl-acc {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.02em;
}
.crash-log-item .cl-acc.unknown {
  color: var(--fg-dim);
  font-family: inherit;
  letter-spacing: 0;
}
.crash-log-item .cl-acc-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(79, 156, 249, 0.35);
  white-space: nowrap;
}
.crash-log-item .cl-acc-link:hover {
  color: #7eb6ff;
  border-bottom-color: rgba(126, 182, 255, 0.7);
}
.crash-log-item .cl-src {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(242, 84, 91, 0.18);
  color: #f7a0a4;
  font-size: 11px;
}
.crash-log-item .cl-src.gap { background: rgba(240, 180, 41, 0.15); color: var(--warn); }
.crash-log-item .cl-src.event { background: rgba(242, 84, 91, 0.22); color: #ffb4b8; }
.crash-log-item .cl-detail {
  color: var(--fg-dim);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crash-log-detail {
  max-height: none;
  overflow: visible;
  padding: 10px 14px 14px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 320px;
}

.crash-log-detail.hidden { display: none; }
.crash-log-list.hidden { display: none; }

.crash-detail-empty {
  color: var(--fg-dim);
}

.crash-detail-summary {
  margin: 0;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--fg);
  line-height: 1.45;
  flex: none;
}

.crash-detail-summary a { color: var(--accent); }

.crash-detail-hints {
  margin: 0;
  padding: 0;
  flex: none;
}

.crash-hint {
  margin: 0 0 6px;
  padding: 6px 9px;
  border-left: 3px solid var(--line);
  background: var(--panel);
  border-radius: 0 6px 6px 0;
}

.crash-hint.accelerator { border-left-color: var(--crit); }
.crash-hint.sm_error { border-left-color: var(--warn); }
.crash-hint.dump_meta { border-left-color: var(--accent); }

.crash-hint .ch-meta {
  color: var(--fg-dim);
  font-size: 11px;
  margin-bottom: 3px;
  font-variant-numeric: tabular-nums;
}

.crash-hint .ch-text { word-break: break-word; }
.crash-hint .ch-text a { color: var(--accent); }

.crash-log-browser {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 10px;
  min-height: 360px;
  flex: 1;
  min-width: 0;
}

.crash-log-picker {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 55vh;
}

.crash-log-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  color: var(--fg-dim);
  flex: none;
}

.crash-log-picker-head button {
  font: inherit;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--fg);
  cursor: pointer;
}

.crash-log-picker-head button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.crash-log-picker-list {
  overflow-y: auto;
  padding: 6px 8px 10px;
  flex: 1;
  min-height: 0;
}

.crash-log-pick {
  display: grid;
  grid-template-columns: 16px 1fr;
  gap: 6px 8px;
  align-items: start;
  padding: 5px 4px;
  border-radius: 4px;
  cursor: pointer;
}

.crash-log-pick:hover { background: rgba(255,255,255,0.04); }
.crash-log-pick input { margin-top: 2px; }
.crash-log-pick .pick-label {
  color: var(--fg);
  font-size: 12px;
  line-height: 1.3;
  word-break: break-word;
}
.crash-log-pick .pick-meta {
  grid-column: 2;
  color: var(--fg-dim);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}
.crash-log-pick.unreadable .pick-label { color: var(--fg-dim); text-decoration: line-through; }

.crash-log-combined {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d1117;
  color: #c9d1d9;
  overflow: hidden;
  max-height: 55vh;
  min-height: 360px;
  padding: 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  min-width: 0;
}

/* Meta stays outside the scrollport so it never overlays log lines. */
.crash-log-combined-meta {
  flex: none;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: var(--fg-dim);
  font-size: 11px;
  font-family: inherit;
  background: #161b22;
  position: static;
  z-index: auto;
}

.crash-log-combined-pre {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 10px 12px 14px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}

.crash-log-combined .clog-sep {
  color: #79c0ff;
  font-weight: 600;
}

.crash-log-combined .clog-ts {
  color: #8b949e;
}

.crash-detail-notes {
  margin: 0;
  color: var(--fg-dim);
  font-size: 11px;
  flex: none;
}
.crash-detail-notes li { margin: 2px 0; }

@media (max-width: 900px) {
  .crash-log-browser {
    grid-template-columns: 1fr;
  }
  .crash-log-picker { max-height: 180px; }
  .crash-log-combined { min-height: 280px; }
}

@media (max-width: 860px) {
  .crash-log-item {
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
  }
}

/* ---------- tooltip (PerfGuard chart) ---------- */

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(10, 12, 16, 0.96);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  z-index: 5;
  box-shadow: 0 6px 20px rgba(0,0,0,0.45);
}

.tooltip .tt-head {
  color: var(--fg-dim);
  margin-bottom: 5px;
  font-size: 11px;
}

.tooltip .tt-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.tooltip .tt-row .swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ---------- footer ---------- */

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 20px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  color: var(--fg-dim);
  font-size: 11.5px;
  flex: none;
}

footer code {
  background: var(--panel-2);
  padding: 1px 4px;
  border-radius: 3px;
}

/* ---------- nav / chat / ops ---------- */

.nav-link {
  color: var(--accent);
  font-size: 12px;
  text-decoration: none;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  white-space: nowrap;
}
.nav-link:hover { border-color: var(--accent); }

.chat-log-panel,
.ops-panel {
  display: flex;
  flex-direction: column;
  min-height: 220px;
  max-height: min(48vh, 520px);
}

.chat-log-panel.hidden,
.ops-panel.hidden { display: none; }

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  flex: none;
}

.chat-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-dim);
  font-size: 12px;
}

.chat-toolbar select,
.chat-toolbar input[type="search"],
.chat-toolbar input[type="datetime-local"],
.chat-toolbar button {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
}

.chat-toolbar input[type="datetime-local"] {
  font-variant-numeric: tabular-nums;
  color-scheme: dark;
  min-width: 14.5rem;
}

.chat-toolbar button { cursor: pointer; }

.chat-meta {
  color: var(--fg-dim);
  font-size: 11.5px;
  margin-left: auto;
}

.chat-log-view {
  flex: 1;
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.45 ui-monospace, Consolas, monospace;
  background: var(--bg);
}

.chat-log-view .chat-match-line {
  display: block;
  background: rgba(79, 156, 249, 0.22);
  outline: 1px solid rgba(79, 156, 249, 0.45);
  border-radius: 3px;
  margin: 0 -4px;
  padding: 0 4px;
}

.ops-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px;
}

@media (max-width: 900px) {
  .ops-grid { grid-template-columns: 1fr; }
}

.ops-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ops-card h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
}

.ops-hint {
  margin: 0;
  color: var(--fg-dim);
  font-size: 11.5px;
  line-height: 1.4;
}

.ops-card textarea,
.ops-card input[type="text"],
.ops-card select {
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font: inherit;
  font-size: 12.5px;
  resize: vertical;
}

.ops-send {
  align-self: flex-start;
  background: var(--accent);
  color: #0b1220;
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  cursor: pointer;
}
.ops-send:hover { filter: brightness(1.08); }

.ops-out-head {
  padding: 6px 12px 0;
  color: var(--fg-dim);
  font-size: 11.5px;
}

.ops-output {
  margin: 6px 12px 12px;
  padding: 10px 12px;
  min-height: 100px;
  max-height: 220px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.45 ui-monospace, Consolas, monospace;
  flex: 1;
}

.ops-output.ops-err { border-color: var(--crit); color: #ffc4c7; }

/* ---------- mobile / narrow viewports ---------- */

@media (max-width: 720px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 12px;
  }

  .brand h1 { font-size: 16px; }
  .brand .last-refresh { font-size: 11px; }
  .brand .sub { font-size: 11.5px; }

  .auth-box {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
    box-sizing: border-box;
  }

  .controls {
    gap: 8px;
  }

  .controls label {
    flex-wrap: wrap;
    font-size: 12.5px;
  }

  .controls select,
  .controls button,
  .nav-link,
  .chat-toolbar select,
  .chat-toolbar input[type="search"],
  .chat-toolbar input[type="datetime-local"],
  .chat-toolbar button,
  .crash-tab,
  .ops-send,
  .crash-log-picker-head button {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .controls .server-label,
  .controls .server-label select {
    width: 100%;
    min-width: 0;
  }

  .controls .range-search {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px;
  }

  .controls .range-search label {
    width: 100%;
    justify-content: space-between;
  }

  .controls .range-search input[type="datetime-local"] {
    flex: 1;
    min-width: 0;
    width: 100%;
    min-height: 44px;
    font-size: 14px;
  }

  .controls .range-search > button,
  .controls > button#reloadBtn {
    width: 100%;
  }

  .controls .refresh-interval {
    width: 100%;
    flex-wrap: wrap;
  }

  .controls .refresh-interval input[type="range"] {
    flex: 1;
    width: auto;
    min-width: 120px;
    height: 32px;
  }

  .controls .refresh-interval input[type="number"] {
    min-height: 44px;
    width: 64px;
    font-size: 14px;
  }

  .controls .chk {
    min-height: 40px;
    padding: 6px 4px;
  }

  .controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  .mode-badge {
    align-self: flex-start;
    padding: 6px 10px;
    font-size: 11px;
  }

  .banner {
    padding: 10px 12px;
    font-size: 13px;
    word-break: break-word;
  }

  .perf-panel {
    padding: 10px 12px 8px;
    gap: 6px;
  }

  .perf-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 6px;
  }

  .perf-cards {
    gap: 6px;
  }

  .perf-card {
    min-width: calc(50% - 6px);
    flex: 1 1 calc(50% - 6px);
    padding: 10px 12px;
  }

  .perf-card .value { font-size: 15px; }

  .perf-chart-host {
    flex: none;
    height: min(42vh, 280px);
    min-height: 200px;
    max-height: 320px;
  }

  .chart-scroll {
    flex-wrap: wrap;
    gap: 6px;
  }

  .chart-scroll-track {
    height: 14px;
    min-width: 0;
    flex: 1 1 100%;
  }

  .chart-scroll-thumb {
    height: 10px;
    top: 1px;
    min-width: 36px;
  }

  .chart-scroll-hint {
    white-space: normal;
    font-size: 10px;
    line-height: 1.35;
  }

  /* Keep chart + crash list at natural size so .perf-panel scrolls
     instead of crushing tab panels below the fold. */
  .perf-head,
  .perf-cards,
  .chart-scroll,
  .perf-note,
  .annot-legend {
    flex-shrink: 0;
  }

  .crash-log-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  .crash-tab {
    flex: 0 0 auto;
    white-space: nowrap;
    border-bottom-width: 3px;
  }

  .crash-log-list {
    max-height: min(40vh, 280px);
    min-height: 96px;
    -webkit-overflow-scrolling: touch;
  }

  .crash-log-item {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 10px 12px;
    min-height: 44px;
  }

  .crash-log-item .cl-detail {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    word-break: break-word;
  }

  .crash-log-detail {
    min-height: 0;
    padding: 10px 12px 12px;
  }

  .crash-log-browser {
    min-height: 0;
  }

  .crash-log-combined {
    min-height: 220px;
    max-height: 50vh;
  }

  .chat-log-panel,
  .ops-panel {
    max-height: none;
    min-height: 180px;
  }

  .chat-toolbar {
    gap: 8px;
    padding: 10px;
  }

  .chat-toolbar label {
    width: 100%;
    justify-content: space-between;
  }

  .chat-toolbar select,
  .chat-toolbar input[type="search"],
  .chat-toolbar input[type="datetime-local"] {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .chat-toolbar .datetime-jump-wrap,
  .chat-toolbar .search-wrap {
    width: 100%;
  }

  .chat-toolbar input[type="datetime-local"] {
    min-width: 0;
    width: 100%;
  }

  .chat-meta {
    margin-left: 0;
    width: 100%;
    word-break: break-word;
  }

  .chat-log-view {
    max-height: min(55vh, 480px);
    font-size: 13px;
    -webkit-overflow-scrolling: touch;
  }

  .ops-grid {
    padding: 10px;
    gap: 10px;
  }

  .ops-card textarea,
  .ops-card input[type="text"],
  .ops-card select {
    min-height: 44px;
    font-size: 14px;
  }

  .ops-card textarea { min-height: 88px; }

  .ops-send {
    width: 100%;
    align-self: stretch;
  }

  .ops-output {
    max-height: min(40vh, 280px);
    font-size: 13px;
    -webkit-overflow-scrolling: touch;
  }

  .tooltip {
    white-space: normal;
    max-width: min(280px, 85vw);
    font-size: 11.5px;
  }

  footer {
    flex-direction: column;
    gap: 4px;
    padding: 8px 12px;
  }

  .foot-note { word-break: break-word; }
}

@media (max-width: 390px) {
  .brand h1 { font-size: 15px; }
  .brand .last-refresh {
    font-size: 10.5px;
    white-space: normal;
  }

  .perf-card {
    min-width: 100%;
    flex: 1 1 100%;
  }

  .perf-chart-host {
    height: min(38vh, 240px);
    min-height: 180px;
  }

  .crash-tab {
    padding-left: 10px;
    padding-right: 10px;
    font-size: 13px;
  }
}
