.xp-remote {
  padding: clamp(3.25rem, 7vw, 6.5rem) clamp(1.1rem, 5vw, 6rem);
  background: #f7f2e8;
  color: #173b36;
}

.xp-remote-heading {
  max-width: 1180px;
  margin: 0 auto 1.5rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
}

.xp-remote-heading h2 {
  margin: 0.35rem 0 0.65rem;
  font-family: KaiTi, STKaiti, serif;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1.05;
  font-weight: 700;
}

.xp-remote-heading > div > p:last-child {
  margin: 0;
  color: #5d6b63;
  font-size: 1rem;
}

.xp-status {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.4rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(23, 59, 54, 0.15);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.xp-status-tools {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  justify-items: end;
  gap: 0.45rem 0.6rem;
}

.xp-status-tools small {
  grid-column: 1 / -1;
  color: #78837d;
  font-size: 0.72rem;
}

.xp-refresh-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 2.4rem;
  padding: 0.5rem 0.8rem;
  border: 1px solid rgba(23, 59, 54, 0.2);
  border-radius: 999px;
  background: #173b36;
  color: #fff;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 120ms ease, transform 120ms ease;
}

.xp-refresh-status:not(:disabled):active {
  transform: scale(0.96);
}

.xp-refresh-status:disabled {
  cursor: wait;
  opacity: 0.6;
}

.xp-refresh-status[aria-busy="true"] span:first-child {
  animation: xp-spin 700ms linear infinite;
}

@keyframes xp-spin {
  to { transform: rotate(360deg); }
}

.xp-status-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: #9b8d74;
  box-shadow: 0 0 0 4px rgba(155, 141, 116, 0.13);
}

.xp-status[data-kind="ready"] .xp-status-dot {
  background: #2f8b72;
  box-shadow: 0 0 0 4px rgba(47, 139, 114, 0.14);
}

.xp-status[data-kind="waiting"] .xp-status-dot {
  background: #d9a441;
  box-shadow: 0 0 0 4px rgba(217, 164, 65, 0.16);
}

.xp-status[data-kind="offline"] .xp-status-dot {
  background: #cf654d;
  box-shadow: 0 0 0 4px rgba(207, 101, 77, 0.14);
}

.xp-remote-card {
  max-width: 1180px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(23, 59, 54, 0.13);
  border-radius: 28px;
  background: #fffdf7;
  box-shadow: 0 24px 70px rgba(42, 55, 49, 0.1);
}

.xp-unlock {
  min-height: 300px;
  display: grid;
  grid-template-columns: auto minmax(0, 560px);
  justify-content: center;
  align-items: center;
  gap: 1.6rem;
  padding: clamp(2rem, 6vw, 4.5rem);
}

.xp-lock-icon {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: #173b36;
  color: #f7f2e8;
  font-size: 2.6rem;
  transform: rotate(-18deg);
}

.xp-unlock h3,
.xp-control-copy h3 {
  margin: 0 0 0.55rem;
  font-family: KaiTi, STKaiti, serif;
  font-size: 1.55rem;
}

.xp-unlock p {
  margin: 0 0 1.15rem;
  color: #68756e;
  line-height: 1.65;
}

.xp-unlock form label {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.xp-unlock-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.7rem;
}

.xp-unlock-row input {
  min-width: 0;
  height: 50px;
  padding: 0 0.95rem;
  border: 1px solid rgba(23, 59, 54, 0.22);
  border-radius: 13px;
  background: #fff;
  color: #173b36;
  font: inherit;
  font-size: 16px;
  outline: none;
}

.xp-unlock-row input:focus {
  border-color: #356e84;
  box-shadow: 0 0 0 4px rgba(53, 110, 132, 0.12);
}

.xp-unlock-row button {
  min-width: 94px;
  border: 0;
  border-radius: 13px;
  background: #173b36;
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.xp-unlock-row button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.xp-form-error {
  min-height: 1.25rem;
  margin: 0.45rem 0 0 !important;
  color: #b44434 !important;
  font-size: 0.85rem;
}

.xp-controls {
  display: grid;
  grid-template-columns: minmax(330px, 0.9fr) minmax(300px, 1.1fr);
  align-items: center;
  gap: clamp(2rem, 7vw, 6rem);
  padding: clamp(2rem, 6vw, 4.5rem);
  background:
    radial-gradient(circle at 18% 20%, rgba(239, 113, 79, 0.12), transparent 34%),
    linear-gradient(135deg, #fffdf7 0%, #f3eee2 100%);
}

.xp-controls[hidden],
.xp-unlock[hidden] {
  display: none !important;
}

.xp-control-surface {
  display: grid;
  justify-items: center;
  gap: 0.9rem;
  min-width: 0;
}

.xp-joystick-wrap {
  display: grid;
  grid-template-columns: auto minmax(210px, 280px) auto;
  grid-template-rows: auto minmax(210px, 280px) auto;
  align-items: center;
  justify-items: center;
  gap: 0.55rem 0.75rem;
  width: min(100%, 390px);
  user-select: none;
  -webkit-user-select: none;
}

.xp-joystick {
  --stick-x: 0px;
  --stick-y: 0px;
  position: relative;
  grid-column: 2;
  grid-row: 2;
  width: min(68vw, 280px);
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(23, 59, 54, 0.18);
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 34%, rgba(255, 255, 255, 0.96), transparent 32%),
    radial-gradient(circle, #e8eee8 0 14%, #d6e2dd 15% 43%, #c6d6cf 44% 100%);
  box-shadow:
    inset 0 0 0 9px rgba(255, 255, 255, 0.42),
    inset 0 -18px 36px rgba(23, 59, 54, 0.13),
    0 18px 38px rgba(23, 59, 54, 0.16);
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.xp-joystick:focus-visible {
  box-shadow:
    0 0 0 5px rgba(53, 110, 132, 0.17),
    inset 0 0 0 9px rgba(255, 255, 255, 0.42),
    inset 0 -18px 36px rgba(23, 59, 54, 0.13),
    0 18px 38px rgba(23, 59, 54, 0.16);
}

.xp-joystick.is-active {
  cursor: grabbing;
}

.xp-joystick[data-disabled="true"] {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.48;
}

.xp-joystick-ring {
  position: absolute;
  inset: 19%;
  border: 1px solid rgba(23, 59, 54, 0.13);
  border-radius: 50%;
  pointer-events: none;
}

.xp-joystick-cross,
.xp-joystick-cross::after {
  position: absolute;
  top: 50%;
  left: 9%;
  width: 82%;
  height: 1px;
  background: rgba(23, 59, 54, 0.11);
  content: "";
  pointer-events: none;
}

.xp-joystick-cross::after {
  top: 0;
  left: 0;
  width: 100%;
  transform: rotate(90deg);
}

.xp-joystick-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: clamp(72px, 21vw, 92px);
  aspect-ratio: 1;
  border: 1px solid rgba(23, 59, 54, 0.24);
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 28%, #527c72 0 12%, transparent 13%),
    linear-gradient(145deg, #35665c, #173b36);
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.08),
    0 10px 22px rgba(23, 59, 54, 0.32);
  transform: translate(calc(-50% + var(--stick-x)), calc(-50% + var(--stick-y)));
  transition: transform 65ms linear, box-shadow 120ms ease;
  pointer-events: none;
}

.xp-joystick.is-active .xp-joystick-thumb {
  box-shadow:
    inset 0 0 0 5px rgba(255, 255, 255, 0.09),
    0 7px 15px rgba(23, 59, 54, 0.3);
}

.xp-joystick-thumb i {
  width: 30%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
}

.xp-joystick-direction {
  color: #68756e;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.xp-direction-forward { grid-column: 2; grid-row: 1; }
.xp-direction-left { grid-column: 1; grid-row: 2; }
.xp-direction-right { grid-column: 3; grid-row: 2; }
.xp-direction-backward { grid-column: 2; grid-row: 3; }

.xp-joystick-readout {
  min-height: 2.15rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid rgba(23, 59, 54, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #356e84;
  font-size: 0.84rem;
  font-weight: 800;
  text-align: center;
}

.xp-emergency-stop {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.7rem 1.25rem;
  border: 1px solid rgba(184, 68, 52, 0.22);
  border-radius: 999px;
  background: #ef714f;
  color: #fff;
  box-shadow: 0 8px 18px rgba(207, 82, 55, 0.2);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 100ms ease, background 100ms ease;
}

.xp-emergency-stop:not(:disabled):active {
  transform: scale(0.96);
  background: #d95f40;
}

.xp-emergency-stop:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.xp-control-copy > p {
  margin: 0 0 1.2rem;
  color: #356e84;
  font-weight: 700;
}

.xp-control-copy ul {
  margin: 0;
  padding: 1.15rem 1.15rem 1.15rem 2.15rem;
  border-left: 3px solid #ef714f;
  border-radius: 0 16px 16px 0;
  background: rgba(255, 255, 255, 0.62);
  color: #5e6c65;
  line-height: 1.7;
}

.xp-voice-card {
  max-width: 1180px;
  margin: 1.25rem auto 0;
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 5rem);
  padding: clamp(2rem, 5vw, 4rem);
  overflow: hidden;
  border: 1px solid rgba(53, 110, 132, 0.15);
  border-radius: 28px;
  background:
    radial-gradient(circle at 86% 12%, rgba(108, 184, 175, 0.18), transparent 30%),
    linear-gradient(135deg, #eef7f3 0%, #fffaf0 58%, #f8eee2 100%);
  box-shadow: 0 24px 70px rgba(42, 55, 49, 0.09);
}

.xp-voice-intro h2 {
  margin: 0.35rem 0 0.7rem;
  font-family: KaiTi, STKaiti, serif;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.08;
}

.xp-voice-intro > p:not(.eyebrow) {
  margin: 0;
  color: #66756d;
  line-height: 1.7;
}

.xp-phrase-guide {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  margin: 1.3rem 0 1.15rem;
}

.xp-phrase-guide span {
  padding: 0.55rem 0.8rem;
  border: 1px solid rgba(23, 59, 54, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  color: #45625b;
  font-size: clamp(0.88rem, 2vw, 1.05rem);
  font-weight: 800;
  transition: transform 160ms ease, background 160ms ease, color 160ms ease;
}

.xp-phrase-guide span.is-current {
  transform: translateY(-3px) scale(1.04);
  border-color: #ef714f;
  background: #ef714f;
  color: #fff;
  box-shadow: 0 8px 18px rgba(239, 113, 79, 0.22);
}

.xp-phrase-guide span.is-done {
  border-color: rgba(47, 139, 114, 0.24);
  background: #dcece5;
  color: #28745f;
}

.xp-phrase-guide i {
  color: #9aa69f;
  font-style: normal;
}

.xp-voice-message {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 78px;
  padding: 1rem 1.1rem;
  border-left: 4px solid #6f9e91;
  border-radius: 0 15px 15px 0;
  background: rgba(255, 255, 255, 0.66);
}

.xp-voice-message strong {
  color: #173b36;
  font-size: 1.02rem;
}

.xp-voice-message span {
  color: #69776f;
  font-size: 0.88rem;
  line-height: 1.55;
}

.xp-voice-card[data-state="success"] .xp-voice-message { border-left-color: #2f8b72; }
.xp-voice-card[data-state="retry"] .xp-voice-message,
.xp-voice-card[data-state="error"] .xp-voice-message { border-left-color: #ef714f; }

.xp-recorder-panel {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  padding: 1.5rem;
  border: 1px solid rgba(23, 59, 54, 0.1);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 15px 36px rgba(23, 59, 54, 0.08);
}

.xp-record-visual {
  --record-progress: 0deg;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 0 58%, transparent 59%),
    conic-gradient(#ef714f var(--record-progress), #dce7e2 0);
  box-shadow: inset 0 0 0 1px rgba(23, 59, 54, 0.08);
}

.xp-record-visual span {
  width: 5px;
  height: 22px;
  border-radius: 999px;
  background: #4e8175;
  transform-origin: center;
}

.xp-record-visual span:nth-child(2),
.xp-record-visual span:nth-child(4) { height: 34px; }
.xp-record-visual span:nth-child(3) { height: 48px; }

.xp-voice-card[data-state="recording"] .xp-record-visual span {
  animation: xp-voice-wave 720ms ease-in-out infinite alternate;
}

.xp-voice-card[data-state="recording"] .xp-record-visual span:nth-child(2) { animation-delay: -160ms; }
.xp-voice-card[data-state="recording"] .xp-record-visual span:nth-child(3) { animation-delay: -320ms; }
.xp-voice-card[data-state="recording"] .xp-record-visual span:nth-child(4) { animation-delay: -480ms; }
.xp-voice-card[data-state="recording"] .xp-record-visual span:nth-child(5) { animation-delay: -640ms; }

@keyframes xp-voice-wave {
  from { transform: scaleY(0.45); opacity: 0.55; }
  to { transform: scaleY(1.1); opacity: 1; }
}

.xp-voice-card[data-state="checking"] .xp-record-visual {
  animation: xp-record-pulse 1.15s ease-in-out infinite;
}

@keyframes xp-record-pulse {
  50% { transform: scale(1.05); box-shadow: 0 0 0 13px rgba(53, 110, 132, 0.08); }
}

.xp-record-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-width: 170px;
  min-height: 48px;
  padding: 0.75rem 1.15rem;
  border: 0;
  border-radius: 999px;
  background: #173b36;
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.xp-record-button > span:first-child {
  color: #ef714f;
  font-size: 1.1rem;
}

.xp-record-button.is-recording { background: #cf5d44; }
.xp-record-button.is-recording > span:first-child { color: #fff; animation: xp-blink 800ms ease-in-out infinite; }
@keyframes xp-blink { 50% { opacity: 0.28; } }

.xp-record-button:disabled,
.xp-voice-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.xp-voice-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
}

.xp-voice-actions button {
  min-height: 40px;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(23, 59, 54, 0.16);
  border-radius: 11px;
  background: #fff;
  color: #34554e;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 750;
  cursor: pointer;
}

@media (max-width: 760px) {
  .xp-remote-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .xp-status-tools {
    justify-items: start;
  }

  .xp-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 2.25rem;
  }

  .xp-voice-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.7rem;
  }

  .xp-control-copy {
    text-align: center;
  }

  .xp-control-copy ul {
    text-align: left;
  }
}

@media (max-width: 520px) {
  .xp-remote {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .xp-remote-card {
    border-radius: 22px;
  }

  .xp-unlock {
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
    padding: 1.5rem;
  }

  .xp-lock-icon {
    width: 62px;
    height: 62px;
    border-radius: 18px;
    font-size: 2rem;
  }

  .xp-unlock-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .xp-unlock-row button {
    min-height: 48px;
  }

  .xp-controls {
    padding: 1.5rem 1rem 1.75rem;
  }

  .xp-voice-card {
    padding: 1.5rem 1rem;
    border-radius: 22px;
  }

  .xp-phrase-guide {
    gap: 0.45rem;
  }

  .xp-phrase-guide i {
    display: none;
  }

  .xp-joystick-wrap {
    grid-template-columns: 2.4rem minmax(190px, 250px) 2.4rem;
    grid-template-rows: auto minmax(190px, 250px) auto;
    gap: 0.45rem 0.35rem;
  }

  .xp-joystick {
    width: min(64vw, 250px);
  }

  .xp-joystick-thumb {
    width: clamp(68px, 20vw, 84px);
  }

  .xp-joystick-direction {
    font-size: 0.7rem;
  }
}
