body.device-page {
  min-height: 100svh;
  background:
    radial-gradient(circle at 1px 1px, rgba(22, 35, 29, 0.06) 1px, transparent 1.2px)
      0 0 / 24px 24px,
    #e6ebe4;
}

.device-app {
  display: flex;
  width: min(100%, 470px);
  min-height: 100svh;
  flex-direction: column;
  margin: 0 auto;
  border-right: 1px solid rgba(220, 226, 218, 0.8);
  border-left: 1px solid rgba(220, 226, 218, 0.8);
  background: var(--paper);
}

.device-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: max(23px, env(safe-area-inset-top)) 22px 18px;
}

.device-top .brand-mark {
  width: 36px;
  height: 36px;
}

.device-top .brand-copy strong {
  font-size: 0.98rem;
}

.device-connection {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-soft);
  font-size: 0.65rem;
  font-weight: 600;
}

.device-connection .dot-live {
  width: 6px;
  height: 6px;
  box-shadow: 0 0 0 3px rgba(88, 201, 139, 0.12);
}

.device-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 18px 22px 24px;
}

.device-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0 25px;
}

.avatar-device {
  width: 62px;
  height: 62px;
  border: 6px solid var(--paper);
  font-size: 1.15rem;
  box-shadow: 0 0 0 1px var(--line);
}

.pair-signal {
  position: relative;
  width: 78px;
  height: 1px;
  margin: 0 -8px;
  background: repeating-linear-gradient(
    90deg,
    var(--ink-muted) 0 4px,
    transparent 4px 8px
  );
}

.pair-signal::before {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mint-strong);
  box-shadow: 0 0 0 4px rgba(88, 201, 139, 0.14);
  content: "";
  transform: translateX(-50%);
}

.pair-signal i {
  position: absolute;
  top: -7px;
  left: 50%;
  width: 15px;
  height: 15px;
  border: 1px solid rgba(88, 201, 139, 0.34);
  border-radius: 50%;
  animation: device-signal 2.4s ease-out infinite;
  transform: translateX(-50%);
}

@keyframes device-signal {
  to {
    opacity: 0;
    transform: translateX(-50%) scale(2);
  }
}

.device-heading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.device-heading h1 {
  font-size: clamp(1.8rem, 8vw, 2.35rem);
  line-height: 1.15;
}

.device-heading p {
  max-width: 310px;
  font-size: 0.72rem;
  line-height: 1.65;
}

.device-status-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 29px;
  padding: 20px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 20px 50px rgba(22, 35, 29, 0.13);
}

.device-state-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 50%;
  background: rgba(191, 237, 206, 0.12);
  color: var(--mint);
}

.device-state-icon svg {
  width: 22px;
  height: 22px;
}

.device-status-card > div:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.device-state-kicker {
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.6rem;
}

.device-status-card h2 {
  font-size: 1rem;
}

.device-status-card p {
  color: rgba(255, 255, 255, 0.51);
  font-size: 0.61rem;
  line-height: 1.5;
}

.device-live-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--mint-strong);
  box-shadow: 0 0 0 5px rgba(88, 201, 139, 0.12);
}

.device-scope {
  margin-top: 18px;
  padding: 19px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
}

.device-scope-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 11px;
}

.device-scope-heading > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.device-scope-heading h2 {
  font-size: 0.86rem;
}

.device-scope-heading > svg {
  width: 18px;
  height: 18px;
  color: var(--pine);
}

.device-scope-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.device-scope-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--pine);
}

.device-scope-icon svg {
  width: 15px;
  height: 15px;
}

.device-scope-row > span:last-child {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
}

.device-scope-row strong {
  font-size: 0.72rem;
}

.device-scope-row small {
  color: var(--ink-muted);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
}

.device-location-row {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.device-location-row > span:nth-child(2) {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.device-location-button {
  min-width: 52px;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--pine);
  font-size: 0.64rem;
  font-weight: 700;
}

.device-location-button.is-active {
  border-color: rgba(28, 102, 73, 0.18);
  background: var(--green-soft);
}

.device-location-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.device-exclusions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 10px 11px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink-muted);
  font-size: 0.61rem;
  line-height: 1.45;
}

.device-exclusions svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.device-recovery {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.device-recovery-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.device-recovery-icon {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--pine);
}

.device-recovery-icon svg {
  width: 16px;
  height: 16px;
}

.device-recovery-heading > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.device-recovery-heading strong {
  color: var(--ink);
  font-size: 0.72rem;
}

.device-recovery-heading small {
  color: var(--ink-muted);
  font-size: 0.59rem;
  line-height: 1.45;
}

.device-recovery .device-password-field {
  margin-top: 10px;
}

.device-recovery-button {
  display: inline-flex;
  width: 100%;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 9px;
  border: 1px solid var(--pine);
  border-radius: 6px;
  background: var(--pine);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 680;
}

.device-recovery-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.device-recovery-button svg {
  width: 14px;
  height: 14px;
}

.device-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding-top: 26px;
}

.device-alert {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #e7cf9f;
  border-radius: 6px;
  background: var(--yellow-soft);
  color: #745318 !important;
  font-size: 0.64rem !important;
  line-height: 1.5;
  text-align: left;
}

.device-stop-button {
  display: inline-flex;
  width: 100%;
  min-height: 47px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid #e6b6aa;
  border-radius: 7px;
  background: var(--coral-soft);
  color: #a53d27;
  font-size: 0.78rem;
  font-weight: 680;
  transition:
    background-color 160ms ease,
    transform 160ms ease;
}

.device-stop-button:hover {
  background: #ffd7ce;
  transform: translateY(-1px);
}

.device-stop-button svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.device-actions p {
  color: var(--ink-muted);
  font-size: 0.62rem;
  text-align: center;
}

.device-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 22px max(17px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.6rem;
}

.device-footer span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.device-footer svg {
  width: 12px;
  height: 12px;
}

.device-footer time {
  font-variant-numeric: tabular-nums;
}

.device-dialog {
  width: min(390px, calc(100vw - 30px));
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

.device-dialog::backdrop {
  background: rgba(16, 35, 26, 0.56);
  backdrop-filter: blur(4px);
}

.device-dialog h2 {
  margin-top: 12px;
  font-size: 1.15rem;
}

.device-dialog p {
  margin-top: 7px;
  font-size: 0.72rem;
}

.device-page.is-stopped .device-status-card {
  background: var(--surface-soft);
  color: var(--ink);
  box-shadow: none;
}

.device-page.is-stopped .device-state-icon {
  background: var(--surface);
  color: var(--ink-muted);
}

.device-page.is-stopped .device-state-kicker,
.device-page.is-stopped .device-status-card p {
  color: var(--ink-muted);
}

.device-page.is-stopped .device-live-pulse {
  background: var(--ink-muted);
  box-shadow: 0 0 0 5px rgba(122, 135, 128, 0.11);
}

.device-page.is-stopped .device-scope,
.device-page.is-stopped .device-pair {
  opacity: 0.52;
}

.device-page.is-stopped .device-stop-button {
  border-color: var(--line);
  background: var(--mint);
  color: var(--pine-deep);
}

.device-page.is-pending .device-status-card {
  background: var(--blue-soft);
  color: var(--ink);
  box-shadow: none;
}

.device-page.is-pending .device-state-icon {
  background: var(--surface);
  color: var(--blue);
}

.device-page.is-pending .device-state-kicker,
.device-page.is-pending .device-status-card p {
  color: var(--ink-muted);
}

.device-page.is-pending .device-live-pulse {
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(90, 108, 224, 0.1);
}

.device-page.is-pending .device-scope {
  opacity: 0.72;
}

.device-page.is-pending .device-stop-button {
  border-color: var(--pine);
  background: var(--pine);
  color: #fff;
}

.device-monitor-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 2px 0 7px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.device-monitor-list span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border: 1px solid #c8d7cd;
  border-radius: 999px;
  background: #eef6f0;
  color: var(--pine);
  font-size: 0.63rem;
  font-weight: 650;
}

.device-monitor-list span::before {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--mint-strong);
  content: "";
}

.device-password-field {
  display: flex;
  margin-top: 14px;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.device-password-field > span {
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 650;
}

.device-password-field input {
  width: 100%;
  min-height: 43px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  outline: none;
}

.device-password-field input:focus {
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(33, 64, 48, 0.08);
}

.device-password-field small {
  color: var(--ink-muted);
  font-size: 0.59rem;
  line-height: 1.5;
}

.device-dialog .device-password-field {
  margin-top: 16px;
}

.device-connection.is-offline {
  color: #8a5d12;
  border-color: #e3c98f;
}

.device-connection.is-offline .dot-live {
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(195, 139, 36, 0.12);
}

@media (max-width: 380px) {
  .device-main {
    padding-right: 17px;
    padding-left: 17px;
  }

  .device-top,
  .device-footer {
    padding-right: 17px;
    padding-left: 17px;
  }

  .device-status-card {
    padding: 17px;
  }
}
