:root {
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101214;
  color: #eef1f3;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background:
    linear-gradient(180deg, rgba(18, 21, 24, 0.98), rgba(12, 14, 16, 1)),
    #101214;
}

#app {
  position: relative;
  display: grid;
  grid-template-columns: clamp(320px, 25vw, 390px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas:
    "panel viewer"
    "panel timeline";
  gap: 0;
  min-width: 0;
  min-height: 0;
}

#app.controls-collapsed {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "viewer"
    "timeline";
}

button,
select,
input {
  font: inherit;
}

.viewer-grid {
  position: relative;
  grid-area: viewer;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  background: #101214;
  min-width: 0;
  min-height: 0;
}

.viewer-grid.compare {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.viewer-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 50px;
  padding: 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: #151a1d;
}

#app.controls-collapsed .viewer-topbar {
  padding-left: 98px;
}

.experiment-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(108px, 1fr));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background: #182024;
}

.experiment-tabs button {
  min-height: 36px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #d6e0e6;
  cursor: pointer;
  font-weight: 750;
}

.experiment-tabs button[aria-selected="true"] {
  background: #2c7a7b;
  color: #ffffff;
}

.viewer-pane {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.viewer-pane[hidden] {
  display: none;
}

.viewer-grid.compare .compare-pane {
  border-left: 1px solid rgba(255, 255, 255, 0.14);
}

.viewer-pane canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.method-label {
  position: absolute;
  top: 12px;
  left: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: min(390px, calc(100% - 24px));
  min-height: 0;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(13, 17, 19, 0.82);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  color: #f4f7f9;
  font-size: 0.86rem;
  line-height: 1.25;
  pointer-events: none;
  z-index: 5;
  backdrop-filter: blur(10px);
}

.method-label.baseline {
  border-color: rgba(181, 196, 207, 0.42);
}

.method-label.ours {
  border-color: rgba(242, 166, 90, 0.72);
}

.method-badge {
  flex: 0 0 auto;
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 42px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0;
  white-space: nowrap;
  text-transform: none;
}

.badge-line {
  display: block;
}

.method-badge.baseline {
  background: #2a3741;
  color: #cbd6df;
}

.method-badge.ours {
  background: #f2a65a;
  color: #101214;
}

.method-label-body {
  display: grid;
  align-content: center;
  gap: 2px;
  min-width: 0;
}

.method-outcome {
  color: #d6e0e6;
  font-size: 0.86rem;
  line-height: 1.18;
  white-space: nowrap;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(16, 18, 20, 0.5);
  pointer-events: none;
  z-index: 8;
}

.loading-overlay[hidden] {
  display: none;
}

.loading-popup {
  display: inline-grid;
  min-width: 112px;
  min-height: 44px;
  place-items: center;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(21, 26, 29, 0.92);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.34);
  color: #f4f7f9;
  font-size: 0.9rem;
  font-weight: 800;
}

.loading-overlay.error .loading-popup {
  border-color: rgba(242, 166, 90, 0.62);
  color: #ffd5a6;
}

.panel {
  grid-area: panel;
  width: auto;
  max-height: none;
  overflow-y: auto;
  margin: 0;
  padding: 62px 18px 18px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 0;
  background: #151a1d;
  box-shadow: none;
  z-index: 10;
}

.panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  margin-bottom: 14px;
}

.panel-body {
  display: block;
}

.panel.collapsed {
  display: none;
}

.panel-toggle {
  position: absolute;
  top: 6px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: auto;
  height: 38px;
  padding: 0 11px 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: #1d2428;
  color: #e8eef2;
  cursor: pointer;
  z-index: 40;
}

.help-icon {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
}

.help-text {
  font-size: 0.86rem;
  font-weight: 750;
}

.close-icon {
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 0;
  padding-bottom: 1px;
}

.home-link {
  display: block;
  margin-bottom: 16px;
  padding: 10px 0 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #f2a65a;
  font-size: 0.9rem;
  font-weight: 750;
  text-decoration: none;
}

.home-link:hover {
  color: #ffd5a6;
}

.menu-intro {
  color: #d6e0e6;
  font-size: 0.86rem;
  line-height: 1.42;
}

.field-description {
  color: #aeb9c2;
  font-size: 0.82rem;
  line-height: 1.42;
}

h1 {
  margin: 0 0 5px;
  font-size: 1rem;
  font-weight: 700;
}

p {
  margin: 0;
}

#datasetMeta,
.status {
  color: #aeb9c2;
  font-size: 0.82rem;
  line-height: 1.35;
}

.control {
  display: grid;
  gap: 7px;
  margin-top: 13px;
  color: #dce3e8;
  font-size: 0.85rem;
}

.control span,
.check-row span {
  color: #c7d0d6;
}

select,
.segmented,
input[type="range"] {
  width: 100%;
}

select {
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: #1d2428;
  color: #eef1f3;
  padding: 0 10px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  overflow: hidden;
  background: #182024;
}

.segmented.triple {
  grid-template-columns: repeat(3, 1fr);
}

.segmented button,
.timeline button {
  min-height: 36px;
  border: 0;
  color: #e8eef2;
  background: transparent;
  cursor: pointer;
}

.segmented button.active {
  background: #2c7a7b;
  color: #ffffff;
}

.segmented button:disabled {
  color: #69747c;
  cursor: default;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  font-size: 0.86rem;
}

.check-row input {
  width: 16px;
  height: 16px;
  accent-color: #2c7a7b;
}

input[type="range"] {
  accent-color: #f2a65a;
}

.status {
  min-height: 36px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.timeline {
  grid-area: timeline;
  display: grid;
  grid-template-columns: 92px minmax(140px, 1fr) 78px;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 10px 18px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: #101417;
  z-index: 10;
}

.timeline button {
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 0;
  font-weight: 700;
  text-align: left;
}

.timeline output {
  color: #c7d0d6;
  font-size: 0.84rem;
  text-align: right;
}

@media (max-width: 680px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "viewer"
      "timeline";
  }

  .viewer-grid.compare {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  }

  .viewer-topbar,
  #app.controls-collapsed .viewer-topbar {
    position: relative;
    z-index: 35;
    min-height: 50px;
    padding: 6px 8px 6px 88px;
  }

  .experiment-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    max-width: none;
  }

  .experiment-tabs button {
    min-height: 34px;
    padding: 0 8px;
    font-size: 0.84rem;
  }

  .viewer-grid.compare .compare-pane {
    border-top: 8px solid #0b0e10;
    border-left: 0;
  }

  .method-label {
    top: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    padding: 8px 10px;
    font-size: 0.78rem;
  }

  .method-badge {
    min-height: 38px;
    padding: 5px 8px;
    font-size: 0.74rem;
  }

  .method-outcome {
    font-size: 0.8rem;
  }

  .panel {
    position: absolute;
    top: 50px;
    left: 0;
    width: 100%;
    max-height: min(72vh, calc(100dvh - 134px));
    margin: 0;
    padding: 13px;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    z-index: 30;
  }

  .panel.collapsed {
    display: none;
  }

  .panel-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel-toggle {
    top: 6px;
    left: 8px;
    height: 38px;
    padding: 0 8px 0 7px;
    gap: 5px;
  }

  .help-icon {
    width: 16px;
    height: 16px;
    font-size: 0.72rem;
  }

  .help-text {
    font-size: 0.8rem;
  }

  h1 {
    font-size: 0.94rem;
  }

  #datasetMeta {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .control {
    margin-top: 11px;
  }

  .timeline {
    grid-template-columns: 78px minmax(80px, 1fr) 58px;
    gap: 9px;
    padding: 9px 10px 10px;
  }
}
