:root {
  color-scheme: dark;
  --bg: #080b0f;
  --panel: #111820;
  --panel-2: #16202a;
  --line: #26313d;
  --text: #eef4f8;
  --muted: #9fb0bf;
  --accent: #39d0ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #0d131a;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid #5de1ff;
  background:
    linear-gradient(90deg, transparent 48%, rgba(255, 255, 255, 0.65) 50%, transparent 52%),
    linear-gradient(transparent 48%, rgba(255, 255, 255, 0.65) 50%, transparent 52%),
    radial-gradient(circle at 60% 42%, #ff4fb3 0 18%, transparent 20%),
    radial-gradient(circle at 36% 62%, #39d353 0 16%, transparent 18%),
    #091016;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 17px;
  line-height: 1.2;
}

h2 {
  font-size: 13px;
  letter-spacing: 0;
  color: #d7e5ee;
}

p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

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

select,
button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
}

button {
  cursor: pointer;
}

button:hover,
select:hover {
  border-color: #3d5264;
}

.workspace {
  display: grid;
  grid-template-columns: 304px minmax(0, 1fr);
  height: calc(100vh - 73px);
  min-height: 560px;
}

.sidebar {
  overflow: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.control-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.control-section h2 {
  margin-bottom: 10px;
}

.marker-list,
.panel-list {
  display: grid;
  gap: 8px;
}

.marker-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1118;
}

.marker-group summary {
  cursor: pointer;
  padding: 8px 10px;
  color: var(--text);
  font-weight: 700;
}

.marker-group-body {
  display: grid;
  gap: 7px;
  padding: 0 8px 8px;
}

.marker-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1118;
}

.marker-row input {
  width: 16px;
  height: 16px;
}

.marker-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}

.stat-badge {
  justify-self: end;
  max-width: 92px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid #244052;
  border-radius: 4px;
  padding: 2px 5px;
  color: #b7d6e8;
  font-size: 11px;
}

.muted-badge {
  color: var(--muted);
  border-color: #38434d;
}

.solo-button {
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.toggle-row,
.slider-row {
  display: grid;
  gap: 8px;
  color: #d5e0e8;
  font-size: 13px;
}

.toggle-row {
  grid-template-columns: 18px 1fr;
  align-items: center;
  margin-bottom: 14px;
}

.slider-row {
  grid-template-columns: 1fr auto;
}

.slider-row input {
  grid-column: 1 / -1;
  width: 100%;
}

.panel-button {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 9px;
  min-height: 54px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0b1118;
  color: var(--text);
  text-align: left;
}

.panel-button img {
  width: 58px;
  height: 40px;
  object-fit: cover;
  background: #000;
}

.viewer-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 34px;
  min-width: 0;
}

.viewer {
  min-height: 0;
  background: #000;
}

.statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #0d131a;
  font-size: 12px;
}

#panelDialog {
  width: min(1200px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #070a0f;
  color: var(--text);
}

#panelDialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

#panelDialog img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 140px);
  object-fit: contain;
  margin-top: 10px;
  background: #000;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 22px;
}

.stats-summary {
  margin-bottom: 10px;
}

.stats-dialog {
  width: min(1280px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #070a0f;
  color: var(--text);
}

.stats-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.stats-dialog h2 {
  margin-right: 36px;
  margin-bottom: 8px;
}

.stats-link {
  display: inline-flex;
  align-items: center;
  height: 30px;
  margin: 10px 0;
  color: #8be7ff;
  font-size: 13px;
}

.stats-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 190px);
  border: 1px solid var(--line);
}

#statsTable {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  font-size: 12px;
}

#statsTable th,
#statsTable td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

#statsTable th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #101821;
  color: #d8e7ef;
}

#statsTable td {
  color: #c6d4de;
}

#statsTable .numeric {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#statsTable .included {
  color: #7ee787;
}

#statsTable .excluded {
  color: #ffcc66;
}

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(460px, 1fr);
    height: auto;
    min-height: calc(100vh - 73px);
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 44vh;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions select {
    flex: 1;
  }
}
