:root {
  --bg-top: #f6f0d8;
  --bg-bottom: #dbe5cf;
  --panel: rgba(255, 250, 238, 0.86);
  --panel-strong: rgba(255, 250, 238, 0.96);
  --line: rgba(56, 66, 54, 0.18);
  --ink: #1d2c24;
  --muted: #4d6255;
  --accent: #ff7b3c;
  --blue: #1790c8;
  --green: #2f9e44;
  --red: #d94841;
  --front-left: #e76f51;
  --front-right: #2a9d8f;
  --rear-left: #577590;
  --rear-right: #f4a261;
  --shadow: 0 18px 60px rgba(54, 60, 38, 0.18);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --knob-size: 4.6rem;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.6), transparent 28rem),
    radial-gradient(circle at bottom right, rgba(42, 157, 143, 0.16), transparent 24rem),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(18px);
  opacity: 0.5;
}

body::before {
  top: 4rem;
  right: -5rem;
  width: 14rem;
  height: 14rem;
  background: rgba(255, 123, 60, 0.22);
}

body::after {
  left: -4rem;
  bottom: 2rem;
  width: 16rem;
  height: 16rem;
  background: rgba(23, 144, 200, 0.18);
}

button,
input,
select,
output {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: calc(100% - 1rem);
  margin: 0 auto;
  padding: 0.85rem 0 2rem;
}

.page-content {
  margin-top: 0.5rem;
}

.hero {
  padding: 1.05rem 1.2rem 0.95rem;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(255, 248, 232, 0.96), rgba(235, 243, 231, 0.94)),
    linear-gradient(90deg, rgba(255, 123, 60, 0.08), rgba(23, 144, 200, 0.08));
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3.1vw, 2.7rem);
  line-height: 0.98;
  max-width: 22ch;
}

.hero-copy {
  width: min(46ch, 100%);
  margin: 0.45rem 0 0;
  font-size: 0.96rem;
  line-height: 1.4;
  color: var(--muted);
}

.hero-notes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.file-warning {
  margin-top: 1rem;
  padding: 0.95rem 1.1rem;
  border: 1px solid rgba(255, 123, 60, 0.28);
  border-radius: var(--radius-lg);
  background: rgba(255, 123, 60, 0.12);
  color: #5a2f12;
  line-height: 1.5;
  box-shadow: 0 10px 28px rgba(255, 123, 60, 0.08);
}

.file-warning code {
  padding: 0.08rem 0.34rem;
  border-radius: 0.35rem;
  background: rgba(255, 255, 255, 0.66);
}

.note-chip {
  padding: 0.4rem 0.65rem;
  border: 1px solid rgba(29, 44, 36, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 0.83rem;
}

.tab-strip {
  display: inline-flex;
  gap: 0.6rem;
  margin-top: 0;
  padding: 0.45rem;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.8);
  box-shadow: 0 10px 28px rgba(54, 60, 38, 0.14);
}

.tab-button {
  border: 0;
  padding: 0.7rem 1rem;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab-button.is-active {
  background: linear-gradient(135deg, #1d2c24, #345446);
  color: #fff;
}

.tab-panels {
  margin-top: 0.9rem;
}

.tab-panel {
  animation: panel-in 180ms ease;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sim-layout,
.curves-layout,
.settings-layout {
  display: grid;
  gap: 1rem;
}

.simulator-layout {
  display: grid;
  gap: 1rem;
}

.sim-top-grid {
  display: grid;
  gap: 1rem;
}

.sim-curves-card > .axis-picker {
  margin-top: 0;
}

.sim-curves-card .mini-head p,
.sim-curves-card .card-intro p,
.sim-curves-card .legend-row {
  font-size: 0.92rem;
}

.robot-card .joystick-row {
  gap: 0.8rem;
  margin-top: 1rem;
}

.robot-card .joystick-card {
  padding: 0.85rem;
}

.robot-card .joystick-pad {
  max-width: 14rem;
}

.robot-card .mini-head p {
  font-size: 0.92rem;
}

.sim-panel {
  min-width: 0;
}

.card {
  position: relative;
  overflow: hidden;
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.28), transparent 40%),
    linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.05));
  pointer-events: none;
}

.card-intro,
.mini-head,
.raw-readout,
.tiny-caption,
.axis-grid,
.plane-stack,
.plane-readout,
.axis-picker,
.chart-block,
.legend-row,
.settings-form {
  position: relative;
  z-index: 1;
}

.card-intro h2,
.mini-head h3,
.settings-group h3 {
  margin: 0;
}

.card-intro p,
.mini-head p,
.tiny-caption {
  color: var(--muted);
}

.card-intro p,
.mini-head p {
  margin: 0.35rem 0 0;
  line-height: 1.45;
}

.joystick-row {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.joystick-card,
.plane-card,
.settings-group {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 250, 238, 0.96);
}

.joystick-pad {
  position: relative;
  width: 100%;
  max-width: 20rem;
  aspect-ratio: 1;
  margin: 1rem auto 0;
  border: 2px solid rgba(29, 44, 36, 0.1);
  border-radius: 50%;
  background:
    linear-gradient(transparent 49%, rgba(29, 44, 36, 0.12) 49%, rgba(29, 44, 36, 0.12) 51%, transparent 51%),
    linear-gradient(90deg, transparent 49%, rgba(29, 44, 36, 0.12) 49%, rgba(29, 44, 36, 0.12) 51%, transparent 51%),
    radial-gradient(circle at center, rgba(23, 144, 200, 0.06), rgba(255, 255, 255, 0.8));
  touch-action: none;
  user-select: none;
}

.joystick-pad::before,
.joystick-pad::after {
  content: "";
  position: absolute;
  inset: 9%;
  border-radius: 50%;
  pointer-events: none;
}

.joystick-pad::before {
  border: 1px dashed rgba(29, 44, 36, 0.2);
}

.joystick-pad::after {
  inset: 26%;
  border: 1px solid rgba(29, 44, 36, 0.08);
}

.joystick-pad__knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--knob-size);
  height: var(--knob-size);
  border-radius: 50%;
  border: 0;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.95), rgba(23, 144, 200, 0.88) 65%, rgba(15, 88, 124, 0.98));
  box-shadow:
    inset 0 -0.45rem 0.8rem rgba(0, 0, 0, 0.14),
    0 0.9rem 1.4rem rgba(23, 144, 200, 0.25);
}

.joystick-pad.is-active .joystick-pad__knob {
  box-shadow:
    inset 0 -0.45rem 0.8rem rgba(0, 0, 0, 0.18),
    0 0 0 0.4rem rgba(23, 144, 200, 0.12),
    0 1rem 1.4rem rgba(23, 144, 200, 0.28);
}

.raw-readout {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  font-weight: 700;
}

.raw-readout span {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.tiny-caption {
  margin: 0.95rem 0 0;
  line-height: 1.45;
}

.robot-card {
  display: flex;
  flex-direction: column;
}

.robot-stage {
  display: grid;
  place-items: center;
  margin-top: 1rem;
}

.robot-card > .robot-stage {
  margin-top: 0;
}

.robot-body {
  position: relative;
  width: min(100%, 28rem);
  aspect-ratio: 1;
  border-radius: 2.4rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.1)),
    linear-gradient(160deg, rgba(23, 144, 200, 0.08), rgba(255, 123, 60, 0.12));
}

.robot-body::before {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 2rem;
  background: linear-gradient(145deg, #fff8eb, #e6efe2);
  box-shadow:
    inset 0 0 0 1px rgba(29, 44, 36, 0.08),
    0 1.2rem 2rem rgba(54, 60, 38, 0.12);
}

.robot-body::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 1.5rem;
  border: 2px dashed rgba(29, 44, 36, 0.14);
}

.robot-core {
  position: absolute;
  inset: 36%;
  display: grid;
  place-items: center;
  gap: 0.2rem;
  text-align: center;
  z-index: 1;
}

.robot-core__title {
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 800;
}

.robot-core__mode {
  color: var(--muted);
  font-size: 0.95rem;
}

.wheel {
  position: absolute;
  display: grid;
  place-items: center;
  gap: 0.1rem;
  width: 7rem;
  height: 7rem;
  padding: 0.4rem;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.65);
  background: radial-gradient(circle at 35% 30%, #ffffff, #cad0cb);
  box-shadow: 0 0.85rem 1.4rem rgba(54, 60, 38, 0.18);
  text-align: center;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
  z-index: 1;
}

.wheel__label {
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(29, 44, 36, 0.64);
}

.wheel__value {
  font-size: 1.25rem;
  line-height: 1;
}

.wheel.is-forward {
  background: radial-gradient(circle at 35% 30%, #f5fff7, #a8deb3 72%, #77ba87);
  box-shadow: 0 0 0 0.28rem rgba(47, 158, 68, 0.12), 0 1rem 1.6rem rgba(47, 158, 68, 0.22);
  transform: translateY(-2px);
}

.wheel.is-reverse {
  background: radial-gradient(circle at 35% 30%, #fff5f5, #efb0ac 72%, #da7b73);
  box-shadow: 0 0 0 0.28rem rgba(217, 72, 65, 0.12), 0 1rem 1.6rem rgba(217, 72, 65, 0.22);
  transform: translateY(-2px);
}

.wheel--front-left {
  top: 0.8rem;
  left: 0.8rem;
}

.wheel--front-right {
  top: 0.8rem;
  right: 0.8rem;
}

.wheel--rear-left {
  bottom: 0.8rem;
  left: 0.8rem;
}

.wheel--rear-right {
  bottom: 0.8rem;
  right: 0.8rem;
}

.plane-stack,
.settings-form {
  display: grid;
  gap: 1rem;
  margin-top: 0;
}

.plane {
  position: relative;
  width: min(100%, 24rem);
  aspect-ratio: 1;
  margin-top: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(29, 44, 36, 0.12);
  background:
    linear-gradient(transparent 49.5%, rgba(29, 44, 36, 0.12) 49.5%, rgba(29, 44, 36, 0.12) 50.5%, transparent 50.5%),
    linear-gradient(90deg, transparent 49.5%, rgba(29, 44, 36, 0.12) 49.5%, rgba(29, 44, 36, 0.12) 50.5%, transparent 50.5%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.74), rgba(236, 242, 234, 0.9));
  overflow: hidden;
}

.plane::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(29, 44, 36, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 44, 36, 0.06) 1px, transparent 1px);
  background-size: 20% 20%;
}

.plane__dot {
  position: absolute;
  width: 1rem;
  height: 1rem;
  margin: -0.5rem 0 0 -0.5rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.86);
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.12);
}

.plane__dot--raw {
  background: var(--blue);
}

.plane__dot--processed {
  background: var(--accent);
}

.plane-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.9rem;
  color: var(--muted);
}

.axis-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.axis-picker__button {
  border: 1px solid rgba(29, 44, 36, 0.08);
  border-radius: 999px;
  padding: 0.65rem 0.95rem;
  background: rgba(255, 255, 255, 0.6);
  color: var(--muted);
  font-weight: 700;
}

.axis-picker__button.is-active {
  background: linear-gradient(135deg, rgba(255, 123, 60, 0.98), rgba(244, 162, 97, 0.96));
  color: #fff;
}

.chart-block {
  margin-top: 1rem;
}

.chart-canvas {
  width: 100%;
  aspect-ratio: 1;
  min-height: 0;
  display: block;
  margin-top: 0.8rem;
  border: 1px solid rgba(29, 44, 36, 0.12);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.72);
}

.chart-axes {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.chart-axis-label strong {
  color: var(--ink);
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1rem;
}

.legend-pill {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 0;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  transition: opacity 140ms ease, transform 140ms ease, filter 140ms ease;
}

.legend-pill:hover {
  transform: translateY(-1px);
}

.legend-pill.is-off {
  opacity: 0.38;
  filter: saturate(0.35);
}

.legend-pill--front-left {
  background: var(--front-left);
}

.legend-pill--front-right {
  background: var(--front-right);
}

.legend-pill--rear-left {
  background: var(--rear-left);
}

.legend-pill--rear-right {
  background: var(--rear-right);
}

.switch-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.6rem;
}

.field-row {
  display: grid;
  gap: 0.55rem;
}

.field-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent);
}

select,
input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

output {
  min-width: 3.5rem;
  text-align: right;
  color: var(--muted);
  font-weight: 700;
}

.settings-actions {
  display: flex;
}

.reset-button {
  border: 0;
  padding: 0.9rem 1.15rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #1d2c24, #355548);
  color: #fff;
  font-weight: 700;
}

@media (min-width: 760px) {
  .joystick-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sim-top-grid {
    grid-template-columns: minmax(0, 1.02fr) minmax(20rem, 0.92fr) minmax(0, 0.9fr);
    align-items: start;
  }

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

@media (min-width: 1180px) {
  .app-shell {
    padding: 0.5rem 0 0.85rem;
  }

  .page-content {
    margin-top: 0.2rem;
  }

  .simulator-layout {
    --knob-size: 3.35rem;
  }

  .sim-top-grid {
    grid-template-columns: minmax(23rem, 1fr) minmax(23rem, 1fr) minmax(18rem, 0.9fr);
    align-items: stretch;
    gap: 0.9rem;
  }

  .card {
    padding: 0.9rem;
  }

  .sim-top-grid > .card {
    height: 100%;
  }

  .robot-body {
    width: min(100%, clamp(24rem, 27.25vw, 29.5rem));
  }

  .wheel {
    width: clamp(4.8rem, 4.8vw, 5.8rem);
    height: clamp(4.8rem, 4.8vw, 5.8rem);
    padding: 0.3rem;
  }

  .wheel--front-left,
  .wheel--front-right {
    top: 0.7rem;
  }

  .wheel--rear-left,
  .wheel--rear-right {
    bottom: 0.7rem;
  }

  .wheel--front-left,
  .wheel--rear-left {
    left: 0.7rem;
  }

  .wheel--front-right,
  .wheel--rear-right {
    right: 0.7rem;
  }

  .wheel__label {
    font-size: 0.68rem;
  }

  .wheel__value {
    font-size: 1.05rem;
  }

  .robot-core__title {
    font-size: clamp(1.25rem, 2vw, 1.85rem);
  }

  .robot-core__mode {
    font-size: 0.84rem;
  }

  .robot-card .joystick-row {
    grid-template-columns: repeat(2, minmax(12rem, 1fr));
    gap: 0.75rem;
    margin-top: 0.6rem;
  }

  .robot-card .joystick-card,
  .settings-group {
    padding: 0.8rem;
  }

  .robot-card .joystick-card {
    width: auto;
  }

  .robot-card .joystick-pad {
    max-width: clamp(6.7rem, 7.2vw, 8rem);
    margin-top: 0.4rem;
  }

  .mini-head h3,
  .settings-group h3 {
    font-size: 1rem;
  }

  .robot-card .mini-head p,
  .sim-curves-card .mini-head p,
  .sim-curves-card .legend-row {
    font-size: 0.84rem;
    line-height: 1.3;
  }

  .raw-readout {
    gap: 0.7rem;
    margin-top: 0.45rem;
    font-size: 0.86rem;
  }

  .axis-picker {
    gap: 0.45rem;
  }

  .axis-picker__button {
    padding: 0.5rem 0.72rem;
    font-size: 0.82rem;
  }

  .chart-block {
    margin-top: 0.55rem;
  }

  .robot-card {
    justify-content: space-between;
  }

  .sim-curves-card,
  .settings-card {
    display: flex;
    flex-direction: column;
  }

  .sim-curves-card .chart-block {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
  }

  .sim-curves-card .chart-canvas {
    width: min(100%, clamp(24.75rem, 28.5vw, 30.7rem));
    margin-inline: auto;
  }

  .chart-axes {
    gap: 0.25rem;
    margin-top: 0.45rem;
    font-size: 0.82rem;
  }

  .legend-row {
    gap: 0.45rem;
    margin-top: 0.7rem;
  }

  .legend-pill {
    padding: 0.36rem 0.62rem;
    font-size: 0.78rem;
  }

  .settings-card {
    font-size: 0.94rem;
  }

  .settings-form {
    height: 100%;
    gap: 0.65rem;
  }

  .settings-actions {
    margin-top: auto;
  }

  .switch-row,
  .field-row {
    gap: 0.4rem;
  }

  .field-control {
    gap: 0.55rem;
  }

  input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
  }

  output {
    min-width: 3rem;
    font-size: 0.88rem;
  }

  .reset-button {
    width: 100%;
    padding: 0.72rem 0.95rem;
    font-size: 0.88rem;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 0.5rem);
  }

  .hero {
    padding: 0.9rem 0.9rem 0.85rem;
  }

  .tab-strip {
    width: 100%;
    justify-content: space-between;
  }

  .tab-button {
    flex: 1 1 0;
    padding-inline: 0.4rem;
  }

  .card {
    padding: 1rem;
  }

  .wheel {
    width: 5.8rem;
    height: 5.8rem;
  }

  .chart-canvas {
    min-width: 0;
  }
}
