/* OpenLog — Chromos 2.x/4.x log viewer. Palette mirrors PeakFit; dark default. */
:root {
  --bg: #0d1117; --surface: #161b22; --surface2: #1c2430;
  --ink: #e6edf3; --muted: #9aa7b4; --line: #26303c; --line2: #313d4d;
  --accent: #58b0ff; --accent2: #2f81f7; --accent-ink: #fff;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 22px rgba(0,0,0,.35);
  /* level colors (dark) */
  --l-error: #ff6b6f; --l-warning: #f5a623; --l-user: #b083f0;
  --l-status: #4ac26b; --l-info: #6ba5ff; --l-telemetry: #2bc4d4;
  --l-detail: #7b8794; --l-trace: #6b7480;
  --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", "DejaVu Sans Mono", Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f4f6fa; --surface: #ffffff; --surface2: #eef1f6;
  --ink: #16202f; --muted: #52617a; --line: #dde3ec; --line2: #c8d1de;
  --accent: #1f6feb; --accent2: #1a5fd0; --accent-ink: #fff;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  /* level colors (light) */
  --l-error: #e5484d; --l-warning: #e08600; --l-user: #8957e5;
  --l-status: #2f9e44; --l-info: #2f6bd6; --l-telemetry: #0e9aa8;
  --l-detail: #8a94a3; --l-trace: #99a1ac;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; flex-direction: column;
}

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 24px; }
.title { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.subtitle { color: var(--muted); font-size: 12px; }
.tools { display: flex; align-items: center; gap: 8px; }
.btn {
  border: 1px solid var(--line); background: var(--surface2); color: var(--ink);
  border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; user-select: none;
}
.btn:hover { border-color: var(--accent); }
.file-btn { background: var(--accent2); color: var(--accent-ink); border-color: var(--accent2); font-weight: 600; }
.file-btn:hover { background: var(--accent); border-color: var(--accent); }

/* segmented language switch (RU/EN/DE) */
.lang { display: inline-flex; height: 34px; border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; }
.lang__btn { font-family: var(--mono); font-size: 11px; font-weight: 600; padding: 0 10px; border: 0;
  background: var(--surface2); color: var(--muted); cursor: pointer; }
.lang__btn + .lang__btn { border-left: 1px solid var(--line2); }
.lang__btn:hover { color: var(--accent); }
.lang__btn.is-active { background: var(--accent2); color: #fff; }

/* theme toggle (sun in dark, moon in light) */
.icon-btn { width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line2); border-radius: 8px; background: var(--surface2); color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn .i-moon { display: none; }
:root[data-theme="light"] .icon-btn .i-sun { display: none; }
:root[data-theme="light"] .icon-btn .i-moon { display: block; }

.status {
  padding: 8px 16px; font-size: 13px; background: var(--surface2);
  border-bottom: 1px solid var(--line);
}
.status.err { background: color-mix(in srgb, var(--l-error) 15%, var(--surface)); color: var(--l-error); }

/* meta bar */
.meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.meta b { color: var(--ink); }
.badge {
  padding: 2px 9px; border-radius: 20px; font-weight: 700; font-size: 12px;
  background: var(--surface2); border: 1px solid var(--line);
}
.drop-note { color: var(--l-warning); }
.badge.v2 { color: var(--l-warning); border-color: var(--l-warning); }
.badge.v4 { color: var(--l-status); border-color: var(--l-status); }

/* app / tabs */
.app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; gap: 2px; padding: 8px 16px 0; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  padding: 8px 16px; font-size: 13.5px; font-weight: 600; border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabpane { flex: 1; min-height: 0; display: none; flex-direction: column; }
.tabpane.active { display: flex; }

/* filters */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); background: var(--surface2); color: var(--muted);
  user-select: none;
}
.chip .dot { width: 9px; height: 9px; border-radius: 50%; }
.chip .cnt { font-variant-numeric: tabular-nums; opacity: .8; font-weight: 500; }
.chip.on { color: var(--ink); border-color: currentColor; }
.chip.off { opacity: .45; text-decoration: line-through; }
.spacer { flex: 1 1 12px; }
.ctl {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 6px 10px; font-size: 13px;
}
.ctl:focus { outline: none; border-color: var(--accent); }
.search { min-width: 220px; }
.count { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* log virtual list */
.logwrap { flex: 1; overflow: auto; background: var(--bg); position: relative; }
.logspace { position: relative; width: 100%; }
.logview { position: absolute; top: 0; left: 0; right: 0; }
.row {
  display: flex; align-items: flex-start; gap: 10px; padding: 2px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 45%, transparent);
  font-family: var(--mono); font-size: 12.5px; white-space: nowrap; cursor: default;
}
.row:hover { background: var(--surface2); }
.row.expanded { white-space: normal; }
.row .time { color: var(--muted); flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.row .lv { flex: 0 0 74px; font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: .3px; padding-top: 1px; }
.row .dev { flex: 0 0 auto; color: var(--muted); }
.row .msg { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; }
.row.expanded .msg { white-space: pre-wrap; word-break: break-word; }
.lv-error { color: var(--l-error); } .lv-warning { color: var(--l-warning); }
.lv-user { color: var(--l-user); } .lv-status { color: var(--l-status); }
.lv-info { color: var(--l-info); } .lv-telemetry { color: var(--l-telemetry); }
.lv-detail { color: var(--l-detail); } .lv-trace { color: var(--l-trace); }

/* telemetry */
.tele-layout { flex: 1; display: flex; min-height: 0; }
.tele-side {
  flex: 0 0 280px; border-right: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; min-height: 0;
}
.tele-side .search { margin: 10px; }
.series-list { flex: 1; overflow: auto; padding: 0 6px 10px; }
.series-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px;
  cursor: pointer; font-size: 12.5px; user-select: none;
}
.series-item:hover { background: var(--surface2); }
.series-item .sw { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; border: 1px solid rgba(0,0,0,.15); }
.series-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.series-item.on { background: var(--surface2); font-weight: 600; }
.series-group { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.series-head { padding: 9px 10px 6px; }
.sg-title { font-weight: 700; font-size: 12.5px; color: var(--ink); }
.sg-span { font-weight: 400; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.sg-row { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.sg-k { color: var(--muted); } .sg-k b { color: var(--accent); }
.sg-v { color: var(--ink); }
.sg-ch { color: var(--accent); }
.tele-main { flex: 1; position: relative; padding: 12px; min-width: 0; }
#chart { width: 100%; height: 100%; display: block; }
.tele-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px; text-align: center; padding: 24px; pointer-events: none;
}

/* timeline */
.tl-main { flex: 1; position: relative; padding: 12px; min-width: 0; }
#tlChart { width: 100%; height: 100%; display: block; cursor: crosshair; }

/* sessions */
.sess-summary {
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px 18px;
}
.sess-summary b { color: var(--ink); }
.sess-summary .ok { color: var(--l-status); }
.sess-summary .bad { color: var(--l-error); }
.sess-wrap { flex: 1; overflow: auto; }
.sess-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.sess-tbl th {
  position: sticky; top: 0; background: var(--surface); color: var(--muted);
  text-align: left; font-weight: 600; padding: 9px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; z-index: 1;
}
.sess-tbl th.sortable { cursor: pointer; user-select: none; }
.sess-tbl th.sortable:hover { color: var(--accent); }
.sess-tbl th .arrow { color: var(--accent); margin-left: 5px; font-size: 11px; }
.sess-tbl td { padding: 8px 16px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); white-space: nowrap; }
.sess-tbl tbody tr { cursor: pointer; }
.sess-tbl tbody tr:hover { background: var(--surface2); }
.sess-tbl .num { color: var(--muted); font-variant-numeric: tabular-nums; }
.sess-tbl .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sess-tbl .ver { font-family: var(--mono); color: var(--accent); }
.sess-tbl .built { color: var(--muted); }
.sess-tbl td.erate { position: relative; font-variant-numeric: tabular-nums; }
.er-bar { position: absolute; left: 0; top: 4px; bottom: 4px; background: color-mix(in srgb, var(--l-error) 26%, transparent);
  border-left: 2px solid var(--l-error); border-radius: 0 3px 3px 0; }
.er-txt { position: relative; }
.sess-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; border: 1px solid currentColor;
}
.sess-ok { color: var(--l-status); } .sess-bad { color: var(--l-error); } .sess-eof { color: var(--l-warning); }

@media (max-width: 720px) {
  .subtitle { display: none; }
  .search { min-width: 130px; }
  .tele-side { flex-basis: 200px; }
  .row .time { display: none; }
}
