﻿* {
  box-sizing: border-box;
}

:root {
  --bg: #2d353f;
  --panel: #e9edf2;
  --panel-soft: #f7f9fc;
  --line: #c7ced8;
  --line-strong: #98a3af;
  --text: #1f242a;
  --muted: #5c6774;
  --accent: #505a68;
}

body {
  margin: 0;
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
}

.app-container {
  min-height: 100vh;
  padding: 18px 16px 28px;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px;
  border: 1px solid rgba(171, 181, 192, 0.45);
  border-radius: 16px;
  background: var(--panel);
  display: grid;
  gap: 14px;
  box-shadow: 0 14px 34px rgba(10, 14, 20, 0.3);
}

.header {
  position: relative;
  top: 0;
  left: 0;
  right: 0;
  background: rgb(248, 249, 255);
  border: 1px solid rgba(175, 184, 194, 0.5);
  border-top: 0;
  border-radius: 0 0 15px 15px;
  padding: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  width: 100%;
  box-sizing: border-box;
}

.header-content {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
  padding: 30px 36px 26px;
  position: relative;
  text-align: center;
}

.header-content h1 {
  font-size: 2em;
  font-weight: 800;
  color: #3c4652;
  margin-bottom: 8px;
  margin-top: 8px;
}

.subtitle {
  color: #586371;
  font-size: 1.08em;
  margin: 0;
}

.back-btn {
  position: absolute;
  top: 10px;
  left: 15px;
  z-index: 10;
  font-size: 1.08em;
  color: #546170;
  font-weight: 600;
  background: none;
  border: none;
  outline: none;
  padding: 6px 18px;
  min-width: 90px;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.18s, background 0.18s;
  box-shadow: none;
  border-radius: 50px;
  text-decoration: none;
  line-height: 1.2;
}

.back-btn:hover {
  transform: scale(1.08);
  background: #eceff3;
  text-decoration: none;
}

.sim-body {
  display: grid;
  gap: 14px;
  border: 1px solid rgba(183, 192, 203, 0.55);
  border-radius: 14px;
  background: #eef2f6;
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.top-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.side-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel-soft);
}

.toggle-btn {
  border: 0;
  background: #d4dae2;
  color: #313a45;
  padding: 8px 16px;
  cursor: pointer;
  font-weight: 600;
}

.toggle-btn.active {
  background: var(--accent);
  color: #f3f4f6;
}

.sim-view {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  min-height: 360px;
  display: grid;
  place-items: center;
}

.robot-stage {
  width: min(100%, 760px);
  height: 320px;
  display: grid;
  place-items: center;
}

.robot-stage.right .robot {
  transform: scaleX(-1);
}

.robot {
  position: relative;
  width: 420px;
  height: 260px;
  transform-origin: center center;
}

.body {
  position: absolute;
  left: 72px;
  top: 34px;
  width: 276px;
  height: 60px;
  background: #2d353f;
  border-radius: 28px;
}

.head {
  position: absolute;
  left: 332px;
  top: -2px;
  width: 62px;
  height: 96px;
  background: #252c35;
  border-radius: 10px;
}

.leg {
  position: absolute;
  top: 84px;
}

.leg.front {
  left: 316px;
}

.leg.rear {
  left: 106px;
}

.joint {
  position: absolute;
  width: 0;
  height: 0;
  transform-origin: 0 0;
}

.joint.shoulder {
  transform: rotate(0deg);
}

.pivot {
  position: absolute;
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1f242c;
  border: 2px solid #6f7783;
}

.segment.upper {
  position: absolute;
  left: calc(-33px / 2);
  top: 0;
  width: 33px;
  height: 92px;
  background: #46505d;
  border-radius: 12px;
}

.joint.elbow {
  left: calc(33px / 2);
  top: 92px;
  transform: rotate(0deg);
}

.segment.lower {
  position: absolute;
  left: calc(-33px / 2);
  top: 0;
  width: 33px;
  height: 88px;
  background: #576270;
  border-radius: 10px;
}

.bottom-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 14px;
}

.motor-group {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  padding: 12px 12px 14px;
  display: grid;
  gap: 10px;
}

.motor-group legend {
  padding: 0 6px;
  font-weight: 700;
}

.control-row {
  display: grid;
  grid-template-columns: 80px 1fr 70px;
  align-items: center;
  gap: 10px;
}

.control-row span {
  font-size: 14px;
  font-weight: 600;
}

input[type='range'] {
  width: 100%;
}

input[type='number'] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #eef1f4;
  color: var(--text);
}

@media (max-width: 768px) {
  .container {
    padding: 0 8px 12px;
  }

  .header-content {
    padding: 25px 20px 18px;
  }

  .header-content h1 {
    font-size: 1.7em;
  }

  .subtitle {
    font-size: 1em;
  }

  .back-btn {
    top: 10px;
    left: 20px;
    min-width: 90px;
    min-height: 36px;
    font-size: 1em;
    padding: 4px 10px;
  }

  .bottom-panel {
    grid-template-columns: 1fr;
  }

  .robot {
    transform: scale(0.92);
  }

  .robot-stage.right .robot {
    transform: scale(0.92) scaleX(-1);
  }
}

@media (max-width: 480px) {
  .header-content {
    padding: 25px 20px 12px;
  }

  .back-btn {
    top: 8px;
    font-size: 1em;
    padding: 4px 10px;
    min-width: 60px;
    min-height: 28px;
  }
}
