/* ============================================================
   密码保险柜 · 样式
   配色：亮色莫兰迪紫（与 Hub 一致）
   ============================================================ */

:root {
  --bg: #f3f1fb;
  --bg2: #faf9fe;
  --panel: #fff;
  --panel2: #f4f1fb;
  --line: #e1dbf1;
  --line2: #cdc4e8;
  --text: #474061;
  --muted: #7e78a0;
  --dim: #aaa4c4;
  --accent: #c98a8f;
  --accent2: #a97bd0;
  --accent-soft: #f3edfa;
  --sage: #9daf9d;
  --blue: #8ba4d4;
  --ok: #7ba87b;
  --warn: #d4a76a;
  --danger: #c98a8f;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(110, 90, 150, 0.08);
  --font: "Varela Round", "MiSans VF", "MiSans", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(169, 123, 208, 0.06), transparent 50%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(201, 138, 143, 0.05), transparent 50%);
  color: var(--text);
  min-height: 100vh;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px;
}

/* ---------- 通用 ---------- */
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

button, .btn {
  font-family: var(--font);
  font-size: 14px;
  background: var(--accent2);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.2s;
}
button:hover:not(:disabled), .btn:hover {
  background: #9166c4;
  transform: translateY(-1px);
}
button:disabled {
  background: var(--dim);
  cursor: not-allowed;
  transform: none;
}
button.ghost, .btn.ghost {
  background: transparent;
  color: var(--accent2);
  border: 1px solid var(--line2);
}
button.ghost:hover { background: var(--accent-soft); }
button.danger { background: var(--danger); }
button.danger:hover { background: #b87580; }

input, select, textarea {
  font-family: var(--font);
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent2);
}
textarea { resize: vertical; min-height: 60px; font-family: var(--font); }

label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  border: 1px solid var(--line);
}

/* ---------- 登录 / 解锁 / 设置主密码页面 ---------- */
.center-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}
.center-stage .card {
  width: 100%;
  max-width: 440px;
}
.center-stage h1 {
  margin: 0 0 4px 0;
  font-size: 24px;
  text-align: center;
  color: var(--text);
}
.center-stage .subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.form-field { margin-bottom: 14px; }
.form-field .hint { font-size: 12px; color: var(--dim); margin-top: 4px; }
.error-msg {
  background: #faecec;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}
.warn-msg {
  background: #faecda;
  color: var(--warn);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin: 12px 0;
}

/* ---------- 强度条 ---------- */
.strength-bar {
  display: flex;
  gap: 3px;
  margin-top: 6px;
  height: 4px;
}
.strength-bar div {
  flex: 1;
  background: var(--line);
  border-radius: 2px;
  transition: background 0.2s;
}
.strength-label {
  font-size: 12px;
  margin-top: 4px;
  color: var(--muted);
}

/* ---------- 列表页 ---------- */
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.app-header h1 {
  margin: 0;
  font-size: 22px;
  color: var(--text);
}
.app-header .lock-icon { font-size: 20px; }
.app-header .status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  background: #dceedc;
  color: var(--ok);
}
.app-header .status.locked {
  background: var(--panel2);
  color: var(--muted);
}

.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-bar input { flex: 1; min-width: 200px; }
.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.chip {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  user-select: none;
}
.chip.active {
  background: var(--accent2);
  color: white;
  border-color: var(--accent2);
}
.chip:hover:not(.active) { background: var(--accent-soft); }

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.entry {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}
.entry:hover {
  border-color: var(--accent2);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.entry-icon { font-size: 22px; }
.entry-main { flex: 1; min-width: 0; }
.entry-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.entry-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-tags { display: flex; gap: 4px; margin-top: 4px; }
.entry-tag { background: var(--panel2); color: var(--muted); font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.entry-actions { display: flex; gap: 6px; }
.entry-actions button {
  padding: 5px 10px;
  font-size: 12px;
  background: var(--panel2);
  color: var(--text);
}
.entry-actions button:hover { background: var(--accent-soft); color: var(--accent2); }
.entry-actions button.danger { background: var(--panel2); color: var(--danger); }
.entry-actions button.danger:hover { background: #faecec; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* ---------- 模态框 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(60, 50, 80, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}
.modal h2 { margin: 0 0 20px 0; font-size: 18px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ---------- 模态框详情页 ---------- */
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 12px; color: var(--muted); }
.detail-value { font-size: 14px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.detail-secret {
  background: var(--panel2);
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 1px;
}

/* ---------- 顶部消息条 ---------- */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 200;
  box-shadow: var(--shadow);
  animation: toast-in 0.3s;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
@keyframes toast-in {
  from { transform: translate(-50%, -20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ---------- 密码可见切换 ---------- */
.input-with-toggle { position: relative; }
.input-with-toggle input { padding-right: 40px; }
.input-with-toggle .toggle-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  font-size: 14px;
}
.input-with-toggle .toggle-btn:hover {
  background: transparent;
  color: var(--accent2);
  transform: translateY(-50%);
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  #app { padding: 16px; }
  .card { padding: 20px; }
  .entry { flex-wrap: wrap; }
  .entry-actions { width: 100%; justify-content: flex-end; }
}
