:root {
  color-scheme: dark;
  --bg: #101216;
  --panel: #171b22;
  --panel-strong: #202632;
  --text: #f4f7fb;
  --muted: #9ca8b8;
  --line: #2b3442;
  --accent: #f3c64e;
  --accent-2: #57b9ff;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

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

body {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent-2);
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

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

.mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 3px solid #111;
  border-radius: 50%;
  background: linear-gradient(#e84040 0 48%, #111 48% 55%, #fff 55%);
  box-shadow: inset 0 0 0 3px #f6f6f6;
}

h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.15;
}

p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  word-break: break-word;
}

.search {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.search input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #0f1319;
  color: var(--text);
}

.dropzone {
  position: relative;
  display: grid;
  gap: 5px;
  padding: 16px;
  border: 1px dashed #4a596f;
  border-radius: 8px;
  background: #121720;
  color: var(--muted);
}

.dropzone strong {
  color: var(--text);
  font-size: 14px;
}

.dropzone span {
  font-size: 12px;
  line-height: 1.4;
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone.is-over {
  border-color: var(--accent);
  background: #201c13;
}

.model-list {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  gap: 10px;
}

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.list-head button {
  min-height: 30px;
  padding: 0 10px;
}

.model-scroll {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
}

.model-item {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121720;
  color: var(--text);
  text-align: left;
}

.model-item small {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-item.is-active {
  border-color: var(--accent);
}

.viewer {
  position: relative;
  min-width: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 45%, #242a35, #0d1015 60%);
  background-size: 32px 32px, 32px 32px, 100% 100%;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.toolbar {
  position: absolute;
  z-index: 2;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toolbar button,
.toolbar label {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(23, 27, 34, 0.86);
  color: var(--text);
  backdrop-filter: blur(12px);
}

.toolbar input[type="range"] {
  width: 110px;
}

.toolbar select {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #10141b;
  color: var(--text);
}

.status {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 2;
  width: fit-content;
  max-width: min(760px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(15, 19, 25, 0.86);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  backdrop-filter: blur(12px);
}

.gesture-panel {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 3;
  width: min(240px, calc(100% - 32px));
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b10;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.32);
}

.gesture-panel.is-hidden {
  display: none;
}

.gesture-panel video,
.gesture-panel canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.gesture-panel video {
  object-fit: cover;
  transform: scaleX(-1);
}

.gesture-panel canvas {
  pointer-events: none;
}

.gesture-label {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  overflow: hidden;
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(8, 11, 16, 0.74);
  color: var(--text);
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

#gestureButton.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 760px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 1fr;
  }

  .sidebar {
    order: 2;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .viewer {
    order: 1;
  }
}
