:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: rgba(255, 255, 255, 0.93);
  --text: #172033;
  --muted: #5f6b7b;
  --line: #d7e0ea;
  --accent: #226fc7;
  --left: #23aeea;
  --right: #f4a12d;
  --center: #414a57;
  --contact: #1f9d55;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
}

main {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.site-title {
  min-width: 0;
}

h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: 0;
}

h2,
p {
  margin: 0;
}

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

button,
select,
.doc-link {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid #bcc8d4;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
select:hover,
.doc-link:hover {
  background: #f0f5f8;
}

.doc-link {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.header-links {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.motion-scene {
  position: relative;
  height: min(660px, calc(100vh - 150px));
  min-height: 520px;
  overflow: hidden;
  background: #f8fafc;
}

#motionCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#motionCanvas.dragging {
  cursor: grabbing;
}

.motion-toolbar {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 16px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(18, 28, 43, 0.08);
  backdrop-filter: blur(10px);
}

.motion-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
  white-space: nowrap;
}

.motion-title strong {
  font-size: 18px;
  line-height: 1.2;
}

.motion-title span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
}

.motion-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.player-controls {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 116px 220px;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(18, 28, 43, 0.08);
  backdrop-filter: blur(10px);
}

.timeline-input,
.speed-control input {
  --progress: 0%;
  width: 100%;
  min-width: 0;
  height: 26px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.timeline-input::-webkit-slider-runnable-track,
.speed-control input::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0 var(--progress), #d4dce5 var(--progress) 100%);
}

.timeline-input::-webkit-slider-thumb,
.speed-control input::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -5px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(18, 28, 43, 0.25);
}

.timeline-input::-moz-range-track,
.speed-control input::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: #d4dce5;
}

.timeline-input::-moz-range-progress,
.speed-control input::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.timeline-input::-moz-range-thumb,
.speed-control input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(18, 28, 43, 0.25);
}

.metric {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(246, 248, 251, 0.82);
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.speed-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.motion-legend {
  position: absolute;
  left: 16px;
  bottom: 76px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: -1px;
}

.swatch.left {
  background: var(--left);
}

.swatch.right {
  background: var(--right);
}

.swatch.center {
  background: var(--center);
}

.swatch.contact {
  background: var(--contact);
}

.view-gizmo {
  position: absolute;
  right: 16px;
  top: 92px;
  z-index: 3;
  width: 132px;
  height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 12px 30px rgba(18, 28, 43, 0.08);
  backdrop-filter: blur(10px);
}

.gizmo-core {
  position: absolute;
  left: 60px;
  top: 60px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #3f4856;
  box-shadow: 0 0 0 3px rgba(63, 72, 86, 0.12);
}

.gizmo-line {
  position: absolute;
  left: 30px;
  top: 65px;
  width: 72px;
  height: 2px;
  border-radius: 1px;
  opacity: 0.42;
  transform-origin: 50% 50%;
}

.gizmo-line.x {
  background: #dd5555;
  transform: rotate(35deg);
}

.gizmo-line.y {
  background: #35a853;
  transform: rotate(-35deg);
}

.gizmo-line.z {
  background: #3b82f6;
  transform: rotate(90deg);
}

.gizmo-axis {
  position: absolute;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 6px 14px rgba(18, 28, 43, 0.14);
}

.gizmo-axis:hover,
.gizmo-axis.active {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.gizmo-axis.x {
  left: 88px;
  top: 72px;
  background: #dd5555;
}

.gizmo-axis.y {
  left: 88px;
  top: 28px;
  background: #35a853;
}

.gizmo-axis.z {
  left: 50px;
  top: 6px;
  background: #3b82f6;
}

.motion-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.summary-item {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(21, 34, 52, 0.05);
}

.summary-item strong {
  font-size: 16px;
}

.summary-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.fallback {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 28px;
  background: #f7f9fb;
  color: #172033;
  text-align: center;
}

.hand-main {
  width: min(1280px, calc(100vw - 32px));
}

.hand-viewer {
  position: relative;
  height: min(720px, calc(100vh - 116px));
  min-height: 560px;
  overflow: hidden;
  background: #f8fafc;
}

#handCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#handCanvas.dragging {
  cursor: grabbing;
}

.hand-toolbar {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 4;
  display: flex;
  align-items: baseline;
  gap: 12px;
  max-width: calc(100% - 336px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(18, 28, 43, 0.08);
  backdrop-filter: blur(10px);
}

.hand-toolbar strong {
  font-size: 18px;
  line-height: 1.2;
}

.hand-toolbar span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.hand-pose-panel {
  position: absolute;
  right: 16px;
  top: 16px;
  bottom: 16px;
  z-index: 5;
  width: 292px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(18, 28, 43, 0.08);
  backdrop-filter: blur(10px);
}

.hand-pose-panel-title {
  flex: 0 0 auto;
  padding: 13px 14px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hand-pose-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.hand-pose-item {
  width: 100%;
  min-height: 42px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  padding: 7px 8px;
  text-align: left;
}

.hand-pose-item span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #edf2f7;
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.hand-pose-item strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hand-pose-item.active {
  border-color: rgba(34, 111, 199, 0.72);
  background: #eef6ff;
}

.hand-pose-item.active span {
  background: var(--accent);
  color: #ffffff;
}

@media (max-width: 760px) {
  main {
    width: min(360px, calc(100vw - 24px));
    padding-top: 24px;
  }

  .site-header,
  .motion-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .doc-link {
    justify-content: center;
  }

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

  .motion-scene {
    height: 650px;
    min-height: 650px;
  }

  .hand-main {
    width: min(420px, calc(100vw - 24px));
  }

  .hand-viewer {
    height: 760px;
    min-height: 760px;
  }

  .hand-toolbar {
    right: 16px;
    max-width: none;
    flex-direction: column;
    gap: 2px;
  }

  .hand-pose-panel {
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 16px;
    width: auto;
    height: 268px;
  }

  .motion-title {
    flex-direction: column;
    gap: 2px;
    white-space: normal;
  }

  .motion-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .motion-controls select {
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .motion-legend {
    right: 16px;
    bottom: 156px;
    flex-wrap: wrap;
  }

  .view-gizmo {
    right: 12px;
    top: 160px;
    transform: scale(0.74);
    transform-origin: top right;
  }

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