/* HTML hidden 属性优先级保护 — 否则 .loading {display:flex} 这种规则会
   跟 user-agent [hidden]{display:none} specificity 相同, cascade 后定义胜出
   导致 hidden 属性失效, 元素永远显示. */
[hidden] { display: none !important; }

:root {
  --bg: #1A1A2E;
  --bg-soft: #232342;
  --accent: #E89040;
  --accent-hover: #FFB86B;
  --text: #FFFFFF;
  --text-muted: rgba(255, 255, 255, 0.55);
  --text-faint: rgba(255, 255, 255, 0.3);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.18);
  --error: #EF4444;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

body {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ─── 顶部光晕 (无缝衔接 App splash 同色) ─── */
.bg-glow {
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 144, 64, 0.18) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 60px 24px 40px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ─── 品牌 ─── */
.brand {
  text-align: center;
  margin-bottom: 48px;
}

.brand-logo {
  width: 88px;
  height: 88px;
  margin-bottom: 16px;
  filter: drop-shadow(0 8px 24px rgba(232, 144, 64, 0.3));
}

.brand-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #E89040 0%, #FFB86B 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin-bottom: 6px;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── 上次进入快捷卡片 ─── */
.quick {
  margin-bottom: 24px;
}

.quick-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 4px;
}

.quick-card {
  width: 100%;
  display: flex;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 18px;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  color: var(--text);
}

.quick-card:active {
  transform: scale(0.98);
  border-color: var(--accent);
}

.quick-card .quick-code {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  font-family: "SF Mono", "Menlo", monospace;
}

.quick-card .quick-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-card .quick-arrow {
  font-size: 22px;
  color: var(--text-muted);
}

.quick-clear {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 12px;
  padding: 12px 0 0;
  cursor: pointer;
}

.quick-clear:active { color: var(--text-muted); }

/* ─── 输入表单 ─── */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

#code-input {
  width: 100%;
  height: 64px;
  padding: 0 20px;
  background: var(--bg-soft);
  border: 2px solid var(--border-strong);
  border-radius: 14px;
  color: var(--text);
  font-size: 32px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 12px;
  font-family: "SF Mono", "Menlo", monospace;
  outline: none;
  transition: border-color 0.15s;
}

#code-input:focus {
  border-color: var(--accent);
}

#code-input::placeholder {
  color: var(--text-faint);
  letter-spacing: 12px;
}

.submit {
  width: 100%;
  height: 56px;
  background: linear-gradient(135deg, #E89040 0%, #FFB86B 100%);
  border: none;
  border-radius: 14px;
  color: #1A1A2E;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 8px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
  box-shadow: 0 8px 24px rgba(232, 144, 64, 0.35);
}

.submit:active:not(:disabled) {
  transform: scale(0.98);
}

.submit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

/* ─── 错误提示 ─── */
.error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--error);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}

/* ─── 历史 ─── */
.history {
  margin-top: 24px;
}

.history-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 4px;
}

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

.history-item {
  width: 100%;
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  gap: 12px;
  cursor: pointer;
  color: var(--text);
}

.history-item:active {
  background: var(--bg-soft);
}

.history-item .history-code {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
  font-family: "SF Mono", "Menlo", monospace;
  width: 70px;
}

.history-item .history-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
  text-align: left;
}

.history-item .history-time {
  font-size: 10px;
  color: var(--text-faint);
}

/* ─── footer ─── */
.footer {
  margin-top: auto;
  text-align: center;
  padding-top: 32px;
}

.version {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 1px;
}

/* ─── loading 遮罩 ─── */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  animation: fade-in 0.2s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(232, 144, 64, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* ─── 适配安卓某些低端 WebView 的 dvh 不支持 ─── */
@supports not (height: 100dvh) {
  body, .container { min-height: 100vh; }
}
