/* ============================================================
   style.css —— 浅色极简 UI（iOS16 设计规范）
   规范：背景 #F8FAFC · 主色 #2563EB · 中性灰 #64748B
        白色低阴影卡片 · 细边框 · Inter 字体 · 大量留白
        按钮最小 44px 触摸区域 · 无 3D 无多余装饰
   ============================================================ */

:root {
  --bg: #F8FAFC;            /* 页面背景 */
  --card: #FFFFFF;          /* 卡片白 */
  --primary: #2563EB;       /* 主色蓝 */
  --primary-soft: #EFF4FF;  /* 主色的 8% 淡底（徽章/选中态） */
  --text: #1E293B;          /* 主文字（比中性灰深一档，保证对比度） */
  --gray: #64748B;          /* 中性灰：次要文字 */
  --gray-light: #94A3B8;    /* 更浅灰：占位符 */
  --border: #E2E8F0;        /* 细边框 */
  --danger: #DC2626;        /* 危险红 */
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

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

body {
  margin: 0;
  font-family: "Inter", -apple-system, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
.mono { font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }
.hidden { display: none !important; }

/* ---------- 屏幕布局 ---------- */
.screen { min-height: 100vh; }
.center-screen { display: flex; align-items: center; justify-content: center; padding: 24px 0; }

.panel {
  background: var(--card);
  padding: 36px 26px;
  border-radius: 20px;
  border: 1px solid var(--border);          /* 细边框 */
  box-shadow: var(--shadow);                /* 低阴影 */
  width: min(400px, calc(100vw - 40px));
}
.panel-icon {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.panel-icon svg { width: 28px; height: 28px; }
.panel-heading { font-size: 20px; font-weight: 700; text-align: center; margin: 0 0 6px; letter-spacing: -0.01em; }
.panel-heading-sm { font-size: 18px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.panel-heading-sm.center { text-align: center; margin-bottom: 18px; }
.panel-sub { color: var(--gray); font-size: 14px; text-align: center; margin: 0 0 22px; line-height: 1.65; }
.error { color: var(--danger); font-size: 13px; text-align: center; margin: 12px 0 0; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ---------- 输入框 ---------- */
.input {
  display: block;
  width: 100%;
  padding: 13px 15px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;              /* ≥16px 防 iOS 聚焦自动放大 */
  font-family: inherit;
  min-height: 48px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: var(--gray-light); }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; line-height: 1.5; }
select.input { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }

.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  color: var(--gray); font-size: 13px;
  margin: 2px 0 16px; min-height: 32px;
}
.checkbox-row input { accent-color: var(--primary); width: 16px; height: 16px; }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray); margin: 12px 0 6px; }

/* ---------- 按钮（≥44px 触摸区，平面 2D 无渐变） ---------- */
.btn {
  min-height: 48px;
  padding: 12px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: background 0.15s, opacity 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:active { background: #1D4ED8; }
.btn-danger  { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-soft { background: #FEF2F2; border-color: #FECACA; color: var(--danger); }
.btn-block { width: 100%; }
.btn-small { min-height: 44px; padding: 8px 14px; font-size: 14px; width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }
.btn-row .btn { flex: 1; }

/* 图标按钮：44×44 触摸区，中性灰细线图标 */
.btn-icon {
  width: 44px; height: 44px;
  border: none; border-radius: 10px;
  background: transparent; color: var(--gray);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.btn-icon svg { width: 20px; height: 20px; }
.btn-icon:active { background: var(--bg); color: var(--primary); }
.btn-icon:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-icon-close { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: rgba(248, 250, 252, 0.92);       /* 半透明 + 毛玻璃，iOS 质感 */
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 17px; font-weight: 600; padding-left: 8px; letter-spacing: -0.01em; }
.topbar-actions { display: flex; }

/* ---------- 工具栏 ---------- */
.toolbar { padding: 16px 16px 4px; max-width: 720px; margin: 0 auto; }
.toolbar-row { display: flex; gap: 10px; margin-top: 10px; }
.btn-add { flex-shrink: 0; }
.btn-add svg { width: 16px; height: 16px; }

/* 分段切换（iOS 风格） */
.seg { display: flex; flex: 1; background: #EEF1F5; border-radius: 12px; padding: 3px; }
.seg-btn {
  flex: 1; min-height: 42px; border: none; border-radius: 10px;
  background: transparent; color: var(--gray);
  font-size: 14px; font-weight: 500; font-family: inherit; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.seg-btn.active { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ---------- 标签组件 ---------- */
.tag-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag-chip {
  padding: 5px 14px; min-height: 32px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--card); color: var(--gray);
  font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer;
  transition: all 0.15s;
}
.tag-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.item-tag {
  font-size: 12px; font-weight: 500; color: var(--primary);
  background: var(--primary-soft); border-radius: 6px; padding: 3px 8px;
}
.item-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 凭证卡片：白色低阴影 · 细边框 · 大留白 ---------- */
.item-list { padding: 12px 16px 100px; max-width: 720px; margin: 0 auto; }
.item-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;                        /* 点卡片开详情 */
  transition: transform 0.1s;
}
.item-card:active { transform: scale(0.99); }
.item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.item-name { font-size: 15px; font-weight: 600; }
.badge {
  font-size: 12px; font-weight: 500; padding: 3px 8px; border-radius: 6px;
  background: var(--primary-soft); color: var(--primary);
}
.item-card .item-tags { margin-bottom: 8px; }
.item-url { font-size: 13px; color: var(--gray); word-break: break-all; margin-bottom: 10px; }
.item-field { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.field-name { font-size: 13px; color: var(--gray); width: 40px; flex-shrink: 0; }
.field-value {
  flex: 1; font-size: 14px; color: var(--text);
  word-break: break-all; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.field-value.revealed { white-space: normal; }
.item-actions { display: flex; gap: 4px; margin-top: 10px; justify-content: flex-end; }

.empty { text-align: center; color: var(--gray-light); font-size: 14px; padding: 72px 0; }

/* ---------- 2FA 实时验证码 ---------- */
.totp-live {
  display: flex; align-items: center; gap: 10px;
  background: var(--primary-soft);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0;
}
.totp-live .detail-label { margin: 0; flex-shrink: 0; }
.totp-code { font-size: 22px; font-weight: 700; color: var(--primary); min-width: 96px; }
.totp-track { flex: 1; height: 3px; background: rgba(37, 99, 235, 0.15); border-radius: 2px; overflow: hidden; }
.totp-bar { height: 100%; width: 100%; background: var(--primary); border-radius: 2px; }
.totp-bar.warning { background: var(--danger); }

/* ---------- 详情弹窗 ---------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.detail-head-text { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.detail-row { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: baseline; }
.detail-field {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.detail-label { font-size: 13px; color: var(--gray); width: 64px; flex-shrink: 0; }
.detail-value { flex: 1; font-size: 15px; word-break: break-all; }
.detail-value.masked { letter-spacing: 0.2em; color: var(--gray); }
.detail-link { flex: 1; font-size: 14px; color: var(--primary); text-decoration: none; word-break: break-all; }
.detail-note { flex: 1; font-size: 14px; color: var(--text); margin: 0; line-height: 1.6; }
.modal-panel .btn-row { margin-top: 20px; }

/* ---------- 密码行 / 生成器 ---------- */
.pwd-row { display: flex; gap: 6px; align-items: center; }
.pwd-row .input { flex: 1; }
.gen-box { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; }
.gen-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.gen-row label { font-size: 13px; color: var(--gray); }
.gen-row b { color: var(--text); }
.gen-checks { justify-content: space-between; }
.gen-checks input { accent-color: var(--primary); }
#gen-len { flex: 1; accent-color: var(--primary); }

/* ---------- 健康报告 ---------- */
.health-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; line-height: 1.7; }
.health-item b.bad { color: var(--danger); }
.health-item b.good { color: #059669; }
.confirm-text { font-size: 15px; line-height: 1.7; margin: 8px 0 4px; text-align: center; white-space: pre-wrap; }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  overflow-y: auto;
  padding: 20px 0;
}
.modal-panel { max-height: calc(100vh - 40px); overflow-y: auto; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 64px; left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 41, 59, 0.92);
  color: #fff; font-size: 14px;
  padding: 12px 22px; border-radius: 999px;
  z-index: 999; max-width: 85vw; text-align: center;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
}

/* iOS 底部安全区 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .item-list { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
}
