/* ==========================================================================
   2FA 看码器 - 精致极简设计规范
   无外部字体依赖 · 支持深浅模式 · 响应式自适应 (375px - 桌面端)
   ========================================================================== */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;

  /* 基础光感与色彩 - 浅色模式 */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #4f46e5;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-subtle: #94a3b8;
  
  /* 品牌与主操作 */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-active: #3730a3;
  --primary-light: #eef2ff;
  --primary-ring: rgba(79, 70, 229, 0.2);

  /* 状态色 */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;

  /* 投影与层次 */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.15);
  --radius-card: 20px;
  --radius-button: 12px;
  --radius-inner: 10px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-page: #0b0f19;
    --bg-card: #131b2e;
    --bg-card-subtle: #1a243b;
    --bg-input: #0f172a;
    --border-color: #243049;
    --border-focus: #6366f1;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-active: #4338ca;
    --primary-light: rgba(99, 102, 241, 0.15);
    --primary-ring: rgba(99, 102, 241, 0.25);

    --success: #34d399;
    --success-bg: rgba(16, 185, 129, 0.15);
    --warning: #fbbf24;
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger: #f87171;
    --danger-bg: rgba(239, 68, 68, 0.15);
    --danger-border: rgba(239, 68, 68, 0.3);

    --shadow-card: 0 10px 30px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  }
}

/* 基础重置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  min-height: 100%;
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* 整体居中布局容器 */
.app-layout {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin: auto;
}

/* 顶部品牌与状态 */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.brand-logo {
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* 徽标 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 9999px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-neutral {
  background-color: var(--bg-card-subtle);
  color: var(--text-muted);
}

.badge-live {
  background-color: var(--primary-light);
  color: var(--primary);
}

/* 主卡片 */
.main-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

/* 视图面板淡入 */
.view-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 首页面板 */
.panel-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.panel-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* 表单组件 */
.secret-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
}

.text-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.text-btn:hover {
  text-decoration: underline;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.text-input {
  width: 100%;
  height: 48px;
  padding: 0 42px 0 14px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-inner);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  transition: all var(--transition-fast);
}

.text-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-ring);
  background-color: var(--bg-card);
}

.text-input::placeholder {
  font-family: var(--font-sans);
  color: var(--text-subtle);
  letter-spacing: normal;
}

.input-clear-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: color var(--transition-fast);\n}

.input-clear-btn:hover {
  color: var(--text-muted);
}

.form-error {
  font-size: 0.8rem;
  color: var(--danger);
  font-weight: 500;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 按钮规范 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-button);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  text-decoration: none;
  user-select: none;
}

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

.btn-block {
  width: 100%;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.btn-primary:active {
  background-color: var(--primary-active);
}

.btn-secondary {
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

.btn-subtle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-subtle:hover {
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
}

.btn-sm {
  height: 36px;
  padding: 0 14px;
  font-size: 0.85rem;
}

/* 隐私安全提示 */
.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background-color: var(--bg-card-subtle);
  border-radius: var(--radius-inner);
  border-left: 3px solid var(--primary);
}

.privacy-icon {
  color: var(--primary);
  flex-shrink: 0;
  margin-top: 2px;
}

.privacy-text {
  font-size: 0.775rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.privacy-text code {
  font-family: var(--font-mono);
  background: var(--bg-card);
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

/* ==========================================================================
   验证码展示页 (Code View)
   ========================================================================== */

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 4px;
}

.code-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  background-color: var(--primary-light);
  padding: 3px 10px;
  border-radius: 9999px;
  width: fit-content;
}

.indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary);
  box-shadow: 0 0 6px var(--primary);
}

.code-alias-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

/* 核心 TOTP 大卡片 */
.totp-card {
  position: relative;
  background-color: var(--bg-card-subtle);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-inner);
  padding: 26px 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: all var(--transition-base);
  user-select: none;
}

.totp-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.totp-card:focus-visible {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.totp-card:active {
  transform: scale(0.99);
}

/* 大字号动态码 */
.code-display {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.code-numbers {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.code-divider {
  width: 8px;
  height: 3px;
  background-color: var(--text-subtle);
  border-radius: 2px;
}

/* 加载/过期占位骨架 */
.code-placeholder {
  display: flex;
  align-items: center;
  gap: 16px;
}

.code-pulse-bar {
  width: 90px;
  height: 38px;
  background: linear-gradient(90deg, var(--border-color) 25%, var(--bg-card) 50%, var(--border-color) 75%);
  background-size: 200% 100%;
  border-radius: 8px;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 复制微气泡 */
.copy-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  font-size: 0.775rem;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.totp-card:hover .copy-hint {
  color: var(--primary);
}

/* 倒计时圆环区域 */
.timer-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-color);
  width: 100%;
  justify-content: center;
}

.circular-timer {
  position: relative;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.timer-ring-bg {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 3.5;
}

.timer-ring-bar {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 100.53; /* 2 * pi * 16 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.8s linear, stroke var(--transition-fast);
}

/* 即将过期时的高亮警示 */
.timer-warning .timer-ring-bar {
  stroke: var(--warning);
}

.timer-danger .timer-ring-bar {
  stroke: var(--danger);
  animation: dangerPulse 1s infinite alternate;
}

@keyframes dangerPulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

.timer-text {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.timer-caption {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* 错误横幅 */
.error-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background-color: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-inner);
}

.error-icon-wrapper {
  color: var(--danger);
  flex-shrink: 0;
}

.error-content {
  flex: 1;
}

.error-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--danger);
}

.error-desc {
  font-size: 0.775rem;
  color: var(--text-muted);
}

.btn-retry {
  background-color: var(--bg-card);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.btn-retry:hover {
  background-color: var(--danger);
  color: #fff;
}

/* 操作按钮组 */
.code-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  height: 44px;
  font-size: 0.875rem;
}

/* 书签提示条 */
.bookmark-tip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background-color: var(--bg-card-subtle);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.bookmark-icon {
  font-size: 0.9rem;
}

/* 全局 Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background-color: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
}

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

.toast-icon {
  color: #34d399;
}

/* 页脚 */
.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* 响应式优化 (适配 375px 及更窄屏手机) */
@media (max-width: 400px) {
  .main-card {
    padding: 22px 18px;
  }

  .code-numbers {
    font-size: 2.3rem;
    gap: 8px;
  }

  .code-pulse-bar {
    width: 72px;
    height: 32px;
  }

  .code-actions {
    grid-template-columns: 1fr;
  }
}

/* 记录模块与管理链接样式规范：与现有 .btn, .text-input 配合 */

[hidden] {
  display: none !important;
}

.record-section {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.saved-entry {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 1rem;
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 8px;
  background: rgba(79, 70, 229, 0.04);
  text-align: left;
  font-size: 0.85rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.record-dialog {
  width: min(460px, calc(100% - 2rem));
  max-height: calc(100dvh - 2rem);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: inherit;
  background: #fff;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
  overflow-y: auto;
}

.record-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.record-existing {
  padding: 0.75rem;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.85rem;
  line-height: 1.6;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.record-form-card {
  background: rgba(79, 70, 229, 0.04);
  border: 1px solid rgba(79, 70, 229, 0.2);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

.record-form-card .form-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.record-form-card .form-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1e1b4b;
}

.record-form-card .form-tip {
  font-size: 0.8rem;
  color: #64748b;
}

.record-form-card .form-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.record-form-card .input-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.record-form-card label {
  font-size: 0.85rem;
  font-weight: 500;
}

.record-form-card .note-textarea {
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 50px;
}

.record-form-card .error-msg {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.2);
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.record-form-card .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.admin-entry {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

.admin-nav-link {
  font-size: 0.85rem;
  color: #4f46e5;
  text-decoration: none;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  transition: background 0.15s ease;
}

.admin-nav-link:hover {
  background: rgba(79, 70, 229, 0.08);
  text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
  .record-form-card {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.3);
  }

  .record-form-card .form-title {
    color: #e0e7ff;
  }

  .record-form-card .form-tip {
    color: #94a3b8;
  }

  .admin-nav-link {
    color: #818cf8;
  }

  .admin-nav-link:hover {
    background: rgba(129, 140, 248, 0.15);
  }
}

.record-field-tags .field-hint {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-muted, #888);
  overflow-wrap: anywhere;
}

/* 账号库状态与解锁提示 */
.info-card.warning {
  padding: 16px;
  background-color: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-inner);
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.prompt-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-main);
}

.prompt-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.unlock-card {
  padding: 16px;
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-inner);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
}

.monospace {
  font-family: var(--font-mono);
}

.required {
  color: var(--danger);
}
