/* ── 绑定设备 · 暮光暖巢 ── */

.layout-device-bind .screen-content {
  overflow: hidden;
  background:
    radial-gradient(ellipse 110% 50% at 50% -8%, rgba(232, 168, 124, 0.12), transparent 52%),
    radial-gradient(ellipse 70% 40% at 100% 12%, rgba(123, 167, 188, 0.08), transparent 50%),
    var(--screen-bg);
}

.layout-device-bind .app-shell.device-bind-shell {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  height: 100%;
  padding: 4px 0 10px;
  overflow: hidden;
}

.device-bind-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  gap: 10px;
}

/* ── 引导 ── */
.device-bind-lead {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
  background: rgba(255, 252, 248, 0.72);
  border: 1px solid rgba(232, 168, 124, 0.16);
}

.device-bind-lead i {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--worth);
}

/* ── 主面板：扫码 + 输入 ── */
.device-bind-panel {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  border-radius: var(--radius-lg);
  background: linear-gradient(168deg, #fffcf8 0%, #f8f0e6 100%);
  border: 1px solid rgba(232, 168, 124, 0.2);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.device-bind-panel-section {
  padding: 14px 14px 12px;
}

.device-bind-panel-section--manual {
  padding-top: 12px;
  padding-bottom: 14px;
}

.device-bind-panel-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  color: var(--text-tertiary);
  font-size: 11px;
  letter-spacing: 0.02em;
}

.device-bind-panel-divider::before,
.device-bind-panel-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(232, 168, 124, 0.28), transparent);
}

/* ── 扫码取景 ── */
.device-scan-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 148px;
  border-radius: 16px;
  background:
    radial-gradient(ellipse 80% 70% at 50% 40%, rgba(123, 167, 188, 0.08), transparent 60%),
    linear-gradient(155deg, rgba(36, 42, 44, 0.96) 0%, rgba(22, 26, 28, 0.98) 100%);
  border: 1px solid rgba(123, 167, 188, 0.2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.device-scan-frame.is-live .device-scan-idle {
  opacity: 0;
  pointer-events: none;
}

.device-scan-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.35s var(--ease-soft);
}

.device-scan-frame.is-live .device-scan-video {
  opacity: 1;
}

.device-scan-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.35);
  z-index: 1;
}

.device-scan-idle {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(123, 167, 188, 0.55);
  transition: opacity 0.25s var(--ease-soft);
}

.device-scan-idle i {
  font-size: 32px;
}

.device-scan-idle span {
  font-size: 12px;
  letter-spacing: 0.06em;
}

.device-scan-overlay {
  position: absolute;
  inset: 16% 12%;
  z-index: 3;
  pointer-events: none;
}

.device-scan-corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: rgba(232, 168, 124, 0.9);
  border-style: solid;
}

.device-scan-corner--tl {
  top: 0;
  left: 0;
  border-width: 2px 0 0 2px;
  border-radius: 3px 0 0 0;
}

.device-scan-corner--tr {
  top: 0;
  right: 0;
  border-width: 2px 2px 0 0;
  border-radius: 0 3px 0 0;
}

.device-scan-corner--bl {
  bottom: 0;
  left: 0;
  border-width: 0 0 2px 2px;
  border-radius: 0 0 0 3px;
}

.device-scan-corner--br {
  bottom: 0;
  right: 0;
  border-width: 0 2px 2px 0;
  border-radius: 0 0 3px 0;
}

.device-scan-line {
  position: absolute;
  left: 6%;
  right: 6%;
  height: 2px;
  top: 20%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(123, 167, 188, 0.2) 20%,
    rgba(123, 167, 188, 0.85) 50%,
    rgba(123, 167, 188, 0.2) 80%,
    transparent
  );
  box-shadow: 0 0 10px rgba(123, 167, 188, 0.4);
  animation: device-scan-sweep 2.6s ease-in-out infinite;
}

.device-scan-frame.is-live .device-scan-line {
  animation-duration: 2s;
}

@keyframes device-scan-sweep {
  0%,
  100% {
    top: 18%;
    opacity: 0.4;
  }
  50% {
    top: 76%;
    opacity: 1;
  }
}

.device-scan-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
}

/* ── 手动输入 ── */
.device-serial-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  margin-bottom: 10px;
}

.device-serial-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.device-serial-field input {
  box-sizing: border-box;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(232, 168, 124, 0.22);
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-primary);
  font-family: var(--font-family-data);
  font-size: 14px;
  letter-spacing: 0.05em;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.device-serial-field input::placeholder {
  color: var(--text-tertiary);
  opacity: 0.55;
  letter-spacing: 0.02em;
}

.device-serial-field input:focus {
  outline: none;
  background: #fff;
  border-color: rgba(123, 167, 188, 0.5);
  box-shadow: 0 0 0 3px rgba(123, 167, 188, 0.1);
}

.device-bind-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  padding: 0 18px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(165deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: var(--brand-on);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(196, 112, 75, 0.22);
  transition: transform 0.15s var(--ease-soft), opacity 0.15s, box-shadow 0.15s;
}

.device-bind-btn i {
  font-size: 13px;
  opacity: 0.92;
}

.device-bind-btn:active:not(:disabled) {
  transform: scale(0.99);
  box-shadow: 0 2px 8px rgba(196, 112, 75, 0.18);
}

.device-bind-btn:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* ── 已绑定列表 ── */
.device-bound-card {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  min-height: 0;
  padding: 12px 14px 10px;
  border-radius: var(--radius-lg);
  background: linear-gradient(168deg, #fffcf8 0%, #f8f0e6 100%);
  border: 1px solid rgba(232, 168, 124, 0.18);
  box-shadow: 0 2px 8px rgba(196, 112, 75, 0.05);
}

.device-bound-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.device-bound-title {
  margin: 0;
  font-family: var(--font-family-display);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--text-primary);
}

.device-bound-count {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--worth);
  background: rgba(123, 167, 188, 0.12);
  letter-spacing: 0.02em;
}

.device-bound-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.device-bound-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-bound-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 20px 12px;
  border-radius: var(--radius-md);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-tertiary);
  text-align: center;
  background: rgba(255, 255, 255, 0.45);
  border: 1px dashed rgba(232, 168, 124, 0.22);
}

.device-bound-empty i {
  font-size: 22px;
  color: rgba(123, 167, 188, 0.45);
}

.device-bound-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(232, 168, 124, 0.14);
  transition: background 0.15s;
}

.device-bound-item:active {
  background: rgba(255, 255, 255, 0.85);
}

.device-bound-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--worth);
  background: linear-gradient(145deg, rgba(123, 167, 188, 0.16), rgba(123, 167, 188, 0.06));
  border: 1px solid rgba(123, 167, 188, 0.12);
}

.device-bound-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-bound-main strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.device-bound-serial {
  font-family: var(--font-family-data);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.device-bound-sync {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.device-bound-sync::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-tertiary);
  opacity: 0.45;
}

.device-bound-sync.is-active::before {
  background: var(--grow);
  opacity: 1;
  box-shadow: 0 0 6px rgba(107, 144, 128, 0.45);
}

.device-unbind-btn {
  flex-shrink: 0;
  padding: 6px 10px;
  border: 1px solid rgba(210, 140, 100, 0.25);
  border-radius: var(--radius-full);
  background: rgba(255, 248, 240, 0.9);
  color: var(--notice);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
}

.device-unbind-btn:active {
  opacity: 0.8;
  background: rgba(255, 240, 230, 1);
}

.device-toast {
  position: absolute;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  padding: 10px 18px;
  border-radius: var(--radius-full);
  background: rgba(44, 54, 57, 0.92);
  color: var(--brand-on);
  font-size: 13px;
  white-space: nowrap;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease-soft), transform 0.25s var(--ease-soft);
  box-shadow: 0 4px 16px rgba(44, 54, 57, 0.2);
}

.device-toast.hidden {
  display: block;
}

.device-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 480px) {
  .device-scan-frame {
    height: 132px;
  }

  .device-bind-panel-section {
    padding-left: 12px;
    padding-right: 12px;
  }
}
