:root {
  color-scheme: light;
  --bg: #f5f5f4;
  --panel: #ffffff;
  --soft: #f0f1f2;
  --ink: #202329;
  --muted: #8e939b;
  --faint: #c9cdd2;
  --line: #e3e5e7;
  --header-bg: rgba(245, 245, 244, 0.94);
  --card-bg: rgba(255, 255, 255, 0.86);
  --chart-bg: #ffffff;
  --grid-line: #edf0f2;
  --control-bg: #ffffff;
  --control-soft: #ebecef;
  --control-soft-hover: #dedfe3;
  --tooltip-bg: rgba(255, 255, 255, 0.94);
  --table-head: #f1f3f5;
  --table-alt: #fbfbfc;
  --table-hover: #f2f7ff;
  --mini-bg: #f8f9fa;
  --orange: #ffab00;
  --shadow: 0 16px 45px rgba(23, 29, 35, 0.10);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111418;
  --panel: #181d23;
  --soft: #222832;
  --ink: #eef2f6;
  --muted: #9ba4af;
  --faint: #59636f;
  --line: #2b333d;
  --header-bg: rgba(17, 20, 24, 0.96);
  --card-bg: rgba(28, 34, 41, 0.90);
  --chart-bg: #15191f;
  --grid-line: #252d36;
  --control-bg: #171c22;
  --control-soft: #252c35;
  --control-soft-hover: #303946;
  --tooltip-bg: rgba(28, 34, 41, 0.95);
  --table-head: #202730;
  --table-alt: #171c22;
  --table-hover: #1e2d3f;
  --mini-bg: #151a20;
  --shadow: 0 16px 45px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 0 0 26px;
}

.log-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 88px;
  padding: 14px 22px;
  background: var(--header-bg);
  box-shadow: 0 10px 42px rgba(16, 20, 24, 0.08);
}

.session-card {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 50px;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--card-bg);
}

.session-card strong {
  display: block;
  max-width: 360px;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.session-card.file-card {
  width: 250px;
}

.session-card.log-meta {
  min-width: 310px;
}

.upload-zone {
  cursor: pointer;
  outline: 0;
  transition: box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.upload-zone:hover,
.upload-zone:focus-visible,
.upload-zone.drag-over {
  box-shadow: 0 0 0 2px rgba(255, 171, 0, 0.45), var(--shadow);
  transform: translateY(-1px);
}

.upload-zone.drag-over {
  background: color-mix(in srgb, var(--card-bg) 78%, var(--orange));
}

.file-icon {
  width: 30px;
  height: 18px;
  border: 1px solid #ced3d8;
  border-radius: 2px;
  background:
    linear-gradient(90deg, #d9eefb 0 34%, transparent 34%),
    linear-gradient(#ffffff, #f0f2f4);
  box-shadow: 0 2px 6px rgba(20, 30, 40, 0.14);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 6px;
}

.header-bugreport,
.header-faq,
.header-version {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 19px;
  padding: 0 14px 0 8px;
  background: var(--control-bg);
  color: var(--ink);
  box-shadow: 0 6px 18px rgba(20, 26, 33, 0.07);
  text-decoration: none;
}

.header-bugreport span,
.header-faq span,
.header-version span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.header-bugreport strong,
.header-faq strong,
.header-version strong {
  font-size: 13px;
}

.header-bugreport:hover,
.header-faq:hover,
.header-version:hover {
  transform: translateY(-1px);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--control-bg);
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(20, 26, 33, 0.07);
}

.icon-button:hover {
  color: var(--ink);
  transform: translateY(-1px);
}

.file-input {
  display: none;
}

.language-switch,
.theme-switch,
.table-switch {
  display: inline-flex;
  align-items: center;
  height: 38px;
  cursor: pointer;
}

.language-switch input,
.theme-switch input,
.table-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.language-track,
.theme-track,
.table-track {
  position: relative;
  display: block;
  width: 58px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--control-bg);
  box-shadow: 0 6px 18px rgba(20, 26, 33, 0.07);
  transition: background 160ms ease, border-color 160ms ease;
}

.language-track {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}

.language-flag {
  position: relative;
  z-index: 2;
  font-size: 14px;
  line-height: 1;
}

.theme-track::before {
  position: absolute;
  top: 50%;
  left: 10px;
  color: #f6a400;
  content: "☀";
  font-size: 12px;
  transform: translateY(-50%);
}

.theme-track::after {
  position: absolute;
  top: 50%;
  right: 10px;
  color: #7c8795;
  content: "☾";
  font-size: 13px;
  transform: translateY(-50%);
}

.language-thumb,
.theme-thumb,
.table-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.18);
  transition: transform 180ms ease;
}

.language-thumb {
  background: #fff;
}

.language-switch input:checked + .language-track,
.theme-switch input:checked + .theme-track,
.table-switch input:checked + .table-track {
  background: #222832;
}

.language-switch input:checked + .language-track .language-thumb,
.theme-switch input:checked + .theme-track .theme-thumb,
.table-switch input:checked + .table-track .table-thumb {
  transform: translateX(26px);
}

.table-track::before {
  position: absolute;
  top: 50%;
  left: 9px;
  color: #7c8795;
  content: "▦";
  font-size: 13px;
  transform: translateY(-50%);
}

.table-track::after {
  position: absolute;
  top: 50%;
  right: 9px;
  color: #7c8795;
  content: "▤";
  font-size: 13px;
  transform: translateY(-50%);
}

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: 640px;
  transition: grid-template-columns 180ms ease;
}

.workspace.channels-collapsed {
  grid-template-columns: minmax(0, 1fr) 0;
}

.channel-toggle {
  position: absolute;
  top: 14px;
  right: 18px;
  z-index: 10;
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 7px;
  background: #ffab00;
  box-shadow: 0 12px 26px rgba(255, 171, 0, 0.26);
}

.channel-toggle:hover {
  background: #f39f00;
}

.toggle-icon {
  position: relative;
  display: grid;
  align-items: end;
  grid-template-columns: repeat(3, 4px);
  gap: 3px;
  width: 22px;
  height: 22px;
}

.toggle-icon::before {
  position: absolute;
  top: 0;
  left: 4px;
  width: 14px;
  height: 9px;
  border: 2px solid #fff;
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  content: "";
}

.toggle-icon span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: #fff;
}

.toggle-icon span:nth-child(1) {
  height: 8px;
}

.toggle-icon span:nth-child(2) {
  height: 13px;
}

.toggle-icon span:nth-child(3) {
  height: 10px;
}

.workspace.channels-collapsed .channel-toggle .toggle-icon {
  transform: scaleX(-1);
}

.plot-area {
  position: relative;
  min-width: 0;
  padding: 82px 0 30px 50px;
  background: var(--chart-bg);
}

.plot-stats {
  position: absolute;
  top: 18px;
  left: 50px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.plot-stats span {
  border-radius: 18px;
  padding: 7px 12px;
  background: var(--soft);
}

.plot-stats b {
  color: var(--ink);
}

.chart-frame {
  position: relative;
  width: 100%;
}

#chartCanvas {
  display: block;
  width: 100%;
  height: 570px;
  background: var(--chart-bg);
  cursor: crosshair;
}

.mini-map {
  display: block;
  width: calc(100% - 22px);
  height: 42px;
  margin-top: 18px;
  border: 1px solid var(--faint);
  background: var(--mini-bg);
  cursor: crosshair;
  touch-action: none;
}

.hover-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 215px;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--tooltip-bg);
  box-shadow: var(--shadow);
  pointer-events: none;
  backdrop-filter: blur(10px);
}

.hover-tooltip .time {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.hover-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  font-size: 12px;
}

.hover-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.hover-name {
  overflow: hidden;
  color: var(--ink);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hover-value {
  color: var(--ink);
  font-weight: 800;
}

.channel-panel {
  min-width: 0;
  max-height: calc(100vh - 88px);
  overflow: auto;
  border-left: 1px solid rgba(210, 214, 219, 0.68);
  padding: 78px 20px 26px;
  background: var(--card-bg);
  box-shadow: -18px 0 42px rgba(37, 43, 50, 0.06);
  transition: opacity 160ms ease, transform 180ms ease;
}

.workspace.channels-collapsed .channel-panel {
  overflow: hidden;
  border-left: 0;
  padding-right: 0;
  padding-left: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(16px);
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
  margin-bottom: 12px;
}

.filter-row button,
.pagination button {
  min-height: 40px;
  border-radius: 5px;
  background: var(--control-soft);
  color: var(--muted);
  font-weight: 700;
}

.filter-row button:hover,
.pagination button:hover {
  background: var(--control-soft-hover);
  color: var(--ink);
}

.filter-row select,
#searchInput {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 10px;
  background: var(--control-bg);
  color: var(--ink);
}

#searchInput {
  margin-bottom: 14px;
}

.channel-group {
  border-top: 1px solid #e3e5e7;
  padding: 12px 0 10px;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 17px;
  font-weight: 800;
}

.group-title input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.group-check {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #cbd0d5;
  color: #fff;
  font-size: 13px;
}

.channel-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  min-height: 24px;
  border-radius: 5px;
  padding: 3px 2px;
  color: #a8adb4;
  cursor: pointer;
}

.channel-row:hover {
  background: var(--soft);
}

.channel-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.channel-check {
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #d7dbe0;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.channel-name {
  min-width: 0;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-row.active {
  color: var(--ink);
}

.channel-row.active .channel-check {
  background: var(--channel-color);
}

.table-section {
  margin: 18px 24px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.table-section[hidden] {
  display: none;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.table-toolbar strong {
  display: block;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 10px;
}

#pageInfo {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pagination button {
  padding: 0 13px;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.table-wrap {
  max-height: none;
  overflow: auto;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px dashed var(--line);
  min-width: 92px;
  max-width: 122px;
  padding: 7px 8px;
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--table-head);
  color: var(--ink);
  font-size: 12px;
  text-align: left;
}

.table-group-header {
  top: 0;
  z-index: 3;
  height: 40px;
  border-right: 1px solid var(--faint);
  padding: 11px 8px 6px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  vertical-align: bottom;
}

.table-column-header {
  top: 40px;
  z-index: 2;
  height: 94px;
  border-right-style: dashed;
  vertical-align: bottom;
}

.table-column-header .column-label {
  display: block;
  color: var(--column-color);
  font-weight: 800;
  line-height: 1.32;
  white-space: normal;
}

.table-column-header .unit {
  display: block;
  color: var(--column-color);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  white-space: normal;
}

td {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.group-start {
  border-left: 1px solid var(--faint);
}

.group-end {
  border-right: 1px solid var(--faint);
}

tbody tr:nth-child(even) {
  background: var(--table-alt);
}

tbody tr:hover {
  background: var(--table-hover);
}

.empty-state {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 22px 16px 0;
  color: var(--muted);
  font-size: 12px;
}

.site-footer a {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--orange);
}

.bugreport-modal,
.faq-modal,
.version-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 13, 17, 0.50);
}

.bugreport-modal[hidden],
.faq-modal[hidden],
.version-modal[hidden] {
  display: none;
}

.bugreport-card,
.faq-card,
.version-card {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.bugreport-head,
.faq-head,
.version-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.bugreport-head strong,
.faq-head strong,
.version-head strong {
  display: block;
  color: var(--ink);
}

.bugreport-close,
.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--control-soft);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.faq-content,
.version-content {
  padding: 18px;
}

.faq-list,
.version-list {
  display: grid;
  gap: 10px;
}

.faq-item,
.version-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--control-bg);
  overflow: hidden;
}

.faq-item summary,
.version-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 46px;
  padding: 0 13px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  list-style: none;
}

.faq-item summary::-webkit-details-marker,
.version-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after,
.version-item summary::after {
  content: "+";
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--control-soft);
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}

.faq-item[open] summary::after,
.version-item[open] summary::after {
  content: "-";
  color: var(--orange);
}

.faq-answer,
.version-answer {
  display: grid;
  gap: 9px;
  padding: 0 13px 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.faq-answer p,
.faq-answer ul,
.faq-status,
.version-answer ul,
.version-status {
  margin: 0;
}

.faq-answer ul,
.version-answer ul {
  padding-left: 18px;
}

.faq-status,
.version-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.faq-status.error,
.version-status.error {
  color: #ff6b6b;
}

.version-summary {
  display: grid;
  gap: 2px;
}

.version-summary strong {
  color: var(--ink);
  font-size: 13px;
}

.version-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.faq-action {
  min-height: 38px;
  margin-top: 12px;
  border-radius: 6px;
  padding: 0 13px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
}

.bugreport-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.bugreport-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bugreport-form input,
.bugreport-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: var(--control-bg);
  color: var(--ink);
}

.bugreport-form textarea {
  resize: vertical;
}

.bugreport-submit {
  min-height: 42px;
  border-radius: 6px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
}

.bugreport-submit:disabled {
  opacity: 0.65;
  cursor: wait;
}

.bugreport-status {
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.bugreport-status.error {
  color: #ff6b6b;
}

.bugreport-status.success {
  color: #4cbf6b;
}

@media (max-width: 1100px) {
  .log-header {
    flex-wrap: wrap;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .workspace.channels-collapsed {
    grid-template-columns: 1fr;
  }

  .plot-area {
    padding: 74px 10px 24px 18px;
  }

  .plot-stats {
    left: 18px;
  }

  .channel-panel {
    max-height: none;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .workspace.channels-collapsed .channel-panel {
    display: none;
  }
}

@media (max-width: 640px) {
  .log-header {
    align-items: stretch;
    padding: 10px;
  }

  .session-card,
  .session-card.file-card,
  .session-card.log-meta {
    width: 100%;
    min-width: 0;
  }

  .header-actions {
    margin-left: 0;
  }

  #chartCanvas {
    height: 420px;
  }

  .filter-row,
  .table-toolbar {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
}
