/* 授权页样式（独立，不引 EQ 资源）
 * 视觉体系移植自《设备授权Web页面原型》：深色品牌风 + PHATEN 红 accent；
 * 布局 = 顶栏 56px + 居中卡片 480px；输入/授权中态有卡片，结果态去卡片（原型细节）。
 */
:root {
  color-scheme: dark;
  --bg: #0d1117;
  --topbar: #0a0d12;
  --panel: #10161e;
  --panel-input: #0d1117;
  --border: #1f2832;
  --border-strong: #303d49;
  --text: #e6edf3;
  --text-secondary: #a8b4c0;
  --muted: #8a97a4;
  --accent: #da003a;
  --accent-hover: #ed0045;
  --accent-active: #c50035;
  --success: #35c58a;
  --danger: #f0525f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  color: var(--text);
  font-family: "IBM Plex Sans", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

button, input { font: inherit; }
button { border: 0; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 2px;
}
button:disabled { cursor: not-allowed; }

.app-shell { min-height: 100vh; background: var(--bg); }

/* ---------- 顶栏 ---------- */
.topbar {
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
  background: var(--topbar);
}
.brand, .topbar-actions { display: flex; align-items: center; }
.brand { gap: 12px; white-space: nowrap; }
.brand strong { color: var(--text); font-size: 13px; font-weight: 650; letter-spacing: .08em; }
.brand-sub { color: var(--text-secondary); font-weight: 450; }
.brand-divider { width: 1px; height: 16px; background: var(--border-strong); }
.brand-module { color: var(--text-secondary); font-size: 12px; }

.conn-badge {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 12px;
  padding: 4px 12px; border: 1px solid var(--border); border-radius: 999px;
}
.conn-dot { width: 6px; height: 6px; border-radius: 50%; background: #596675; }
.conn-badge.on { color: var(--success); border-color: rgba(53, 197, 138, .45); }
.conn-badge.on .conn-dot { background: var(--success); }

/* ---------- 主区 ---------- */
.main-content {
  min-height: calc(100vh - 56px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px;
}

.banner.warn {
  width: min(100%, 480px); margin-bottom: 14px;
  background: rgba(250, 199, 117, .08); border: 1px solid rgba(250, 199, 117, .35);
  color: #fac775; border-radius: 8px; padding: 10px 14px; font-size: 13px;
}

/* 卡片：输入态/授权中有面板，结果态去卡片（原型 state-ready vs result-state 的处理） */
.auth-card { width: min(100%, 480px); }
.auth-card[data-state="idle"],
.auth-card[data-state="authorizing"] {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.view { display: flex; flex-direction: column; align-items: center; text-align: center; }
.view[hidden] { display: none; }

/* hero 图标：描边圆环 + 透明底（原型风格） */
.hero-icon {
  width: 64px; height: 64px;
  display: grid; place-items: center;
  margin-bottom: 22px; border-radius: 50%;
  background: transparent;
}
.idle-icon { border: 1px dashed #3a4552; color: var(--muted); }
.working-icon { border: 1px solid var(--border-strong); color: var(--accent-hover); }
.success-icon { border: 1px solid rgba(53, 197, 138, .45); color: var(--success); }
.failure-icon { border: 1px solid rgba(240, 82, 95, .45); color: var(--danger); }

h1 { color: var(--text); font-size: 20px; font-weight: 600; line-height: 1.4; margin-bottom: 0; }
.state-desc { margin: 12px 0 24px; color: var(--text-secondary); font-size: 14px; line-height: 1.7; }
.state-desc.dim { color: var(--muted); font-size: 12.5px; margin-top: -14px; }

/* ---------- 表单 ---------- */
.auth-form { width: 100%; text-align: left; }
.auth-form label { display: block; margin-bottom: 8px; color: var(--text-secondary); font-size: 12px; }

.code-input-wrap {
  height: 42px;
  display: flex; align-items: center;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--panel-input);
  transition: border-color 120ms ease;
}
.code-input-wrap:focus-within { border-color: var(--accent); }
.code-input-wrap.input-warning { border-color: rgba(240, 82, 95, .65); }
.code-input-wrap input {
  min-width: 0; flex: 1;
  border: 0; outline: 0;
  color: var(--text); background: transparent;
  font-size: 13px;
  font-family: Consolas, "Courier New", monospace;
}
.code-input-wrap input::placeholder { color: #657383; }
.code-input-wrap input:focus-visible { outline: 0; }

/* ---------- 按钮 ---------- */
.primary-btn {
  width: 100%; min-height: 38px; margin-top: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px;
  color: #fff; background: var(--accent);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-hover); }
.primary-btn:active:not(:disabled) { background: var(--accent-active); }
.primary-btn:disabled { color: #697685; background: #252d36; }

/* ---------- 进度 ---------- */
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-section { width: 100%; margin-top: 4px; }
.progress-meta { margin-bottom: 9px; color: var(--text-secondary); font-size: 12px; }
.progress-track {
  height: 4px; overflow: hidden;
  border-radius: 2px; background: #26313c;
}
.progress-track .indeterminate {
  display: block; height: 100%; width: 40%;
  border-radius: 2px; background: var(--accent);
  animation: slide 1.2s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

.banner.info {
  background: rgba(90, 156, 214, .1);
  border: 1px solid rgba(90, 156, 214, .35);
  color: #85b7eb;
}
.banner.info a { color: #85b7eb; }

/* ---------- 手动连接 ---------- */
.connect-section { width: 100%; margin-bottom: 16px; }
.connect-btn { margin-top: 0; }   /* 2026-10-30：与授权按钮同色（主色 accent） */
.connect-btn.connected { background: rgba(53, 197, 138, .12); color: var(--success); border: 1px solid rgba(53, 197, 138, .45); }
.conn-state { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.conn-state.on { color: var(--success); }
.conn-state.warn { color: var(--danger); }

/* 失败页双按钮（重试 + 返回） */
.failure-actions { display: flex; gap: 12px; width: 100%; margin-top: 20px; }
.failure-actions .primary-btn { margin-top: 0; flex: 1; }
.failure-actions .ghost-btn { flex: 1; padding: 9px 14px; }

.device-picker {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 8, 12, .7);
}
.device-picker[hidden] { display: none; }
.device-picker-card {
  width: min(92vw, 380px);
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: 10px; padding: 20px;
}
.device-picker-card h3 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 14px; text-align: center; }
.device-picker-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.device-item {
  padding: 11px 13px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-input); color: var(--text);
  text-align: left; cursor: pointer; font-size: 13px;
}
.device-item:hover { border-color: var(--accent); }
.device-item .dev-name { display: block; font-weight: 550; }
.device-item .dev-id { display: block; color: var(--muted); font-size: 11.5px; font-family: Consolas, monospace; margin-top: 2px; }
.device-item.empty { color: var(--muted); text-align: center; cursor: default; }
.device-item.empty:hover { border-color: var(--border); }

/* ---------- 响应式 ---------- */
@media (max-width: 600px) {
  .topbar { padding: 0 14px; }
  .brand { gap: 9px; }
  .brand strong { font-size: 11px; }
  .brand-module, .conn-badge { font-size: 11px; }
  .main-content { padding: 24px 16px; }
  .auth-card[data-state="idle"], .auth-card[data-state="authorizing"] { padding: 20px; }
  h1 { font-size: 19px; }
}
@media (max-width: 390px) {
  .brand-sub, .brand-divider, .brand-module, .conn-badge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
