/* ============================================================
 * DeskLock 动态码 —— 移动优先样式（iPhone Safari 重点适配）
 * ============================================================ */

:root {
  --bg: #070a10;
  --bg2: #0d1420;
  --card: rgba(19, 27, 40, 0.82);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eef4ff;
  --dim: #8394ad;
  --dim2: #5d6d85;
  --accent: #3d6fe0;
  --accent2: #5b8bf5;
  --ok: #4ad48a;
  --warn: #ffb454;
  --err: #ff6b6b;
  --radius: 20px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  /* 防止 iOS 上放大后横向漂移 */
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "SF Pro Text",
    "PingFang SC", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* iOS 橡皮筋背景 */
  overscroll-behavior-y: none;
  /* 数字等宽，避免码跳动 */
  font-variant-numeric: tabular-nums;
}

/* 背景光晕 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(58% 42% at 50% 0%, rgba(61, 111, 224, 0.30), transparent 70%),
    radial-gradient(50% 40% at 85% 100%, rgba(91, 139, 245, 0.14), transparent 70%),
    linear-gradient(180deg, #080c14 0%, #06090f 60%, #04070b 100%);
}

.shell {
  min-height: 100%;
  min-height: 100dvh; /* iOS 15+ 动态视口，避开地址栏高度问题 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding:
    calc(22px + var(--safe-t))
    calc(16px + var(--safe-r))
    calc(26px + var(--safe-b))
    calc(16px + var(--safe-l));
}

/* ---------------- 卡片 ---------------- */
.card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow:
    0 24px 60px -24px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  animation: rise 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--dim);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--dim);
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.12s;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

/* ---------------- 码 ---------------- */
.code-block {
  text-align: center;
  padding: 14px 0 10px;
}

.code-prefix,
.code-suffix {
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--dim);
  font-weight: 600;
  word-break: break-all;
}

.code {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: clamp(46px, 17vw, 66px);
  font-weight: 250;
  letter-spacing: 0.1em;
  color: #f5f9ff;
  text-shadow: 0 0 34px rgba(91, 139, 245, 0.42);
  /* 码变化时轻微反馈 */
  transition: opacity 0.12s ease;
  user-select: all;
  -webkit-user-select: all;
  word-break: break-all;
  line-height: 1.1;
}

.code.flash { animation: flash 0.45s ease; }

@keyframes flash {
  0% { opacity: 0.25; transform: scale(0.985); }
  100% { opacity: 1; transform: none; }
}

/* ---------------- 倒计时环 ---------------- */
.ring-wrap {
  position: relative;
  width: 78px;
  height: 78px;
  margin: 4px auto 12px;
}

.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}

.ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 7;
}

.ring-fg {
  fill: none;
  stroke: var(--accent2);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-dasharray: 276.46;
  stroke-dashoffset: 0;
  transition: stroke 0.3s;
  filter: drop-shadow(0 0 5px rgba(91, 139, 245, 0.65));
}

.ring-fg.warn { stroke: var(--warn); filter: drop-shadow(0 0 5px rgba(255, 180, 84, 0.7)); }

.ring-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 21px;
  font-weight: 300;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ---------------- 元信息 ---------------- */
.meta {
  text-align: center;
  font-size: 12.5px;
  color: var(--dim2);
  margin-bottom: 16px;
  letter-spacing: 0.02em;
}

.meta .sep { margin: 0 7px; opacity: 0.5; }

/* ---------------- 按钮 ---------------- */
.copy-btn {
  width: 100%;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 10px 26px -10px rgba(61, 111, 224, 0.85);
  transition: transform 0.12s, filter 0.18s;
}

.copy-btn:active { transform: scale(0.975); filter: brightness(1.08); }
.copy-btn.done { background: linear-gradient(180deg, #57dfa0, #35b97c); }

.hint {
  margin: 12px 0 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--dim2);
  letter-spacing: 0.01em;
}

/* ---------------- 设置面板 ---------------- */
.panel {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px calc(18px + var(--safe-b));
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.9);
  animation: rise 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.panel h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--dim);
  margin-bottom: 7px;
  letter-spacing: 0.03em;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
select {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  background: rgba(5, 9, 15, 0.85);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px; /* 关键：>=16px 才不会被 iOS 自动放大 */
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61, 111, 224, 0.22);
}

#fSecret {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 0.08em;
  font-size: 15px;
  text-transform: uppercase;
}

#fSecret.masked {
  -webkit-text-security: disc;
  text-transform: none;
}

select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path fill='%238394ad' d='M6 8 0 0h12z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 11px;
  padding-right: 36px;
}

.row {
  display: flex;
  gap: 8px;
}

.row input { flex: 1; min-width: 0; }

.mini {
  flex: 0 0 auto;
  height: 48px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s;
}

.mini:active { background: rgba(255, 255, 255, 0.14); }

.field-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 7px;
}

.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent2);
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}

.link:active { opacity: 0.6; }

.note {
  font-size: 11.5px;
  color: var(--dim2);
  margin-left: auto;
  text-align: right;
}

.field .note {
  margin: 6px 0 0;
  text-align: left;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  flex: 1;
  height: 48px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, filter 0.16s;
}

.btn:active { transform: scale(0.98); }

.btn.primary {
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(61, 111, 224, 0.9);
}

.btn.ghost {
  flex: 0 0 40%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line-strong);
  color: var(--dim);
}

.footnote {
  margin: 16px 0 0;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--dim2);
  text-align: center;
}

[hidden] { display: none !important; }

/* ---------------- 大屏微调 ---------------- */
@media (min-width: 560px) {
  .shell { gap: 18px; }
  .card, .panel { padding: 26px 26px 24px; }
  .code { font-size: 72px; }
}

/* ---------------- 横屏矮屏 ---------------- */
@media (max-height: 520px) and (orientation: landscape) {
  .shell { justify-content: flex-start; padding-top: calc(12px + var(--safe-t)); }
  .code { font-size: 44px; }
  .ring-wrap { width: 60px; height: 60px; }
  .code-block { padding: 6px 0; }
}

/* ---------------- 深色输入框自动填充 ---------------- */
input:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #05090f inset;
}

/* 减弱动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* 选中态配色 */
::selection { background: rgba(91, 139, 245, 0.35); color: #fff; }

/* ============================================================
 * 远程控制卡片
 * ============================================================ */
.rc { gap: 12px; }

.rc-dot {
  width: 9px; height: 9px; border-radius: 50%;
  display: inline-block; margin-right: 8px;
  background: #46536b; box-shadow: 0 0 0 3px rgba(70,83,107,.18);
  transition: background .25s, box-shadow .25s;
}
.rc-dot.on { background: #37c98a; box-shadow: 0 0 0 3px rgba(55,201,138,.2); }
.rc-dot.idle { background: #e0a33a; box-shadow: 0 0 0 3px rgba(224,163,58,.2); }
.rc-dot.off { background: #5b6580; }

.rc-status {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px;
  padding: 2px 0 4px;
}
.rc-status strong { color: var(--text); font-size: 19px; font-weight: 600; }
.rc-status span { color: var(--muted); font-size: 12.5px; }
.rc-status em { color: #5d6b82; font-size: 11.5px; font-style: normal; }

.rc-gate { display: flex; flex-direction: column; gap: 10px; }
.rc-tip {
  color: var(--muted); font-size: 12px; line-height: 1.6;
  margin: 0 0 2px; padding: 9px 11px;
  background: rgba(61,111,224,.09); border-radius: 9px;
  border: 1px solid rgba(61,111,224,.18);
}
.rc-msg {
  color: #ff7b7b; font-size: 12px; min-height: 16px; margin: 0;
}

.rc-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: rgba(255,255,255,.045);
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 13px; padding: 13px 15px; margin-top: 9px;
  color: var(--text); cursor: pointer; text-align: left;
  transition: background .18s, border-color .18s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.rc-btn:active { transform: scale(.985); }
.rc-btn:hover { background: rgba(255,255,255,.085); border-color: rgba(255,255,255,.14); }
.rc-btn:disabled { opacity: .45; }
.rc-btn.danger { border-color: rgba(255,107,107,.22); }
.rc-btn.danger:hover { background: rgba(255,107,107,.09); border-color: rgba(255,107,107,.34); }

.rc-ico {
  font-size: 19px; width: 34px; height: 34px; flex: 0 0 34px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.055); border-radius: 10px;
}
.rc-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rc-txt b { font-size: 14.5px; font-weight: 600; }
.rc-txt i { font-size: 11.5px; color: var(--muted); font-style: normal; }

.rc-note {
  color: #7fd1a5; font-size: 12px; text-align: center;
  margin: 8px 0 0; min-height: 16px; opacity: 0;
  transition: opacity .22s;
}
.rc-note.show { opacity: 1; }

.btn.wide { width: 100%; }
.link.small { font-size: 11.5px; }

/* 桌面端隐藏的控件 */
#rcPanel[hidden], #rcSetupPanel[hidden], #rcGate[hidden], #rcButtons[hidden],
#rcResetPanel[hidden] { display: none !important; }

/* 启用后出现的“断开”按钮 */
#rcDisconnect { display: none; }
#rcPanel:not(.locked-ui) #rcDisconnect { display: inline; }
#rcPanel:not(.locked-ui) #rcDisconnect[hidden] { display: none !important; }
