/* ==========================================================================
   KeyVault — 深色主题样式表（零外部依赖，无 CDN 字体）
   ========================================================================== */

:root {
  --bg: #0e1014;
  --bg-soft: #14171d;
  --bg-elev: #191d24;
  --bg-elev-2: #1f242d;
  --bg-input: #12151a;
  --line: #262c36;
  --line-soft: #1e232b;
  --text: #e7ecf3;
  --text-dim: #9aa5b4;
  --text-faint: #6b7686;
  --accent: #4c8dff;
  --accent-hover: #6ba1ff;
  --accent-soft: rgba(76, 141, 255, 0.14);
  --danger: #ff5f56;
  --danger-soft: rgba(255, 95, 86, 0.14);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.14);
  --ok: #35c07d;
  --ok-soft: rgba(53, 192, 125, 0.14);
  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 14px;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
    "Noto Sans CJK SC", "WenQuanYi Micro Hei", Roboto, Helvetica, Arial,
    sans-serif;
  --sidebar-w: 264px;
  --panel-w: 440px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   启动占位
   -------------------------------------------------------------------------- */
.boot-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}
.boot-mark {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: kv-spin 0.8s linear infinite;
}
.boot-text { color: var(--text-faint); margin: 0; }
@keyframes kv-spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   基础控件
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  user-select: none;
}
.btn:hover:not(:disabled) { background: #262c37; border-color: #333b48; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger {
  background: transparent;
  border-color: rgba(255, 95, 86, 0.5);
  color: var(--danger);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-elev-2); color: var(--text); border-color: transparent; }

.btn-sm { min-height: 28px; padding: 3px 9px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px 8px; min-width: 34px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; color: var(--text-dim); font-weight: 500; }
.field-hint { font-size: 12px; color: var(--text-faint); }
.field-error { font-size: 12.5px; color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 11px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.textarea { min-height: 92px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }

.mono { font-family: var(--mono); font-size: 13px; }

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  color: var(--text-dim);
}
.checkbox input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.row { display: flex; gap: 10px; align-items: center; }
.row-between { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 12px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-accent { background: var(--accent-soft); border-color: rgba(76, 141, 255, 0.35); color: var(--accent-hover); }
.tag-warn { background: var(--warn-soft); border-color: rgba(245, 165, 36, 0.35); color: var(--warn); }
.tag-ok { background: var(--ok-soft); border-color: rgba(53, 192, 125, 0.35); color: var(--ok); }
.tag-danger { background: var(--danger-soft); border-color: rgba(255, 95, 86, 0.35); color: var(--danger); }
.tag-btn { cursor: pointer; }
.tag-btn:hover { border-color: var(--accent); color: var(--text); }

.hint-box {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.65;
}
.hint-box.warn { border-color: rgba(245, 165, 36, 0.4); background: var(--warn-soft); color: #f0c67a; }
.hint-box.danger { border-color: rgba(255, 95, 86, 0.4); background: var(--danger-soft); color: #ff9a94; }

.divider { height: 1px; background: var(--line-soft); margin: 18px 0; border: 0; }

/* --------------------------------------------------------------------------
   认证界面
   -------------------------------------------------------------------------- */
.auth-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(76, 141, 255, 0.12), transparent 60%),
    radial-gradient(700px 420px at 100% 110%, rgba(53, 192, 125, 0.07), transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 396px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 30px 28px 26px;
  margin: auto;
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.auth-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(150deg, var(--accent), #2f6fe0);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 17px;
  flex: none;
}
.auth-title { font-size: 19px; font-weight: 650; margin: 0; letter-spacing: 0.2px; }
.auth-sub { color: var(--text-dim); font-size: 13px; margin: 0 0 20px; }
.auth-footer { margin-top: 16px; font-size: 12px; color: var(--text-faint); text-align: center; }
.auth-form .btn-primary { min-height: 38px; margin-top: 4px; }

.strength { display: flex; gap: 5px; margin-top: 2px; }
.strength-bar { height: 4px; flex: 1; border-radius: 999px; background: var(--bg-elev-2); }
.strength-bar.on-weak { background: var(--danger); }
.strength-bar.on-mid { background: var(--warn); }
.strength-bar.on-good { background: #6aa9ff; }
.strength-bar.on-strong { background: var(--ok); }
.strength-text { font-size: 12px; color: var(--text-faint); margin-top: 5px; }

.totp-input {
  letter-spacing: 0.42em;
  font-family: var(--mono);
  font-size: 20px;
  text-align: center;
  padding: 10px 8px 10px 16px;
}

/* --------------------------------------------------------------------------
   主框架
   -------------------------------------------------------------------------- */
.shell { display: flex; height: 100vh; width: 100%; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  padding: 14px 14px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.sidebar-logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(150deg, var(--accent), #2f6fe0);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: 14px; flex: none;
}
.sidebar-name { font-weight: 650; letter-spacing: 0.2px; }
.sidebar-body { flex: 1 1 auto; overflow-y: auto; padding: 10px 8px 14px; min-height: 0; }
.sidebar-foot { border-top: 1px solid var(--line-soft); padding: 10px 12px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
}
.nav-item:hover { background: var(--bg-elev-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.nav-item .nav-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-count { font-size: 11.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.nav-item .nav-icon { flex: none; width: 16px; text-align: center; opacity: 0.9; }

.sidebar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 6px;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  text-transform: uppercase;
}
.tree { display: flex; flex-direction: column; gap: 1px; }
.tree-row { display: flex; align-items: center; gap: 2px; }
.tree-row .nav-item { padding-left: 6px; }
.tree-toggle {
  width: 18px; height: 22px;
  flex: none;
  border: 0; background: transparent; color: var(--text-faint);
  cursor: pointer; font-size: 10px; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.tree-toggle:hover { color: var(--text); }
.tree-toggle.leaf { visibility: hidden; }
.tree-actions { display: flex; gap: 1px; opacity: 0; transition: opacity 0.12s ease; flex: none; }
.tree-row:hover .tree-actions, .tree-row:focus-within .tree-actions { opacity: 1; }
.tree-actions .btn { min-height: 22px; padding: 0 5px; font-size: 11px; color: var(--text-faint); }
.tree-actions .btn:hover { color: var(--text); }

.main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
  min-height: 56px;
}
.search-wrap { position: relative; flex: 1 1 auto; max-width: 460px; }
.search-wrap .input { padding-left: 32px; }
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 13px; pointer-events: none;
}
.search-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--text-faint);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px;
  background: var(--bg-elev); pointer-events: none;
}
.hamburger { display: none; }
.content { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px 60px; min-height: 0; }
.content-narrow { max-width: 860px; margin: 0 auto; }

.page-head { margin-bottom: 18px; }
.page-title { font-size: 18px; font-weight: 650; margin: 0 0 4px; }
.page-desc { color: var(--text-dim); font-size: 13px; margin: 0; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card + .card { margin-top: 14px; }
.card-title { font-size: 14.5px; font-weight: 650; margin: 0 0 3px; }
.card-desc { color: var(--text-faint); font-size: 12.5px; margin: 0 0 14px; }
.card-danger { border-color: rgba(255, 95, 86, 0.3); }

/* --------------------------------------------------------------------------
   条目列表
   -------------------------------------------------------------------------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 12.5px;
}
.chip:hover { border-color: #38414f; color: var(--text); }
.chip.active { background: var(--accent-soft); border-color: rgba(76, 141, 255, 0.45); color: var(--accent-hover); }

.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.item-card:hover { border-color: #38414f; background: var(--bg-elev-2); }
.item-card.active { border-color: var(--accent); background: var(--accent-soft); }
.item-icon {
  width: 34px; height: 34px; flex: none;
  border-radius: 9px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.item-main { flex: 1 1 auto; min-width: 0; }
.item-title {
  font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.item-sub {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-faint);
}
.item-actions { display: flex; gap: 4px; flex: none; opacity: 0; transition: opacity 0.12s ease; }
.item-card:hover .item-actions, .item-card:focus-within .item-actions { opacity: 1; }
.fav-star { color: var(--warn); }

.empty-state {
  padding: 54px 20px;
  text-align: center;
  color: var(--text-faint);
}
.empty-state .empty-icon { font-size: 34px; opacity: 0.5; margin-bottom: 10px; }
.empty-state .empty-title { color: var(--text-dim); font-size: 14px; margin: 0 0 4px; }
.empty-state .empty-desc { font-size: 12.5px; margin: 0; }

.loading-line {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-faint); font-size: 13px; padding: 22px 4px;
}
.spinner {
  width: 16px; height: 16px; flex: none;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: kv-spin 0.7s linear infinite;
}
.skeleton {
  height: 58px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--bg-elev) 25%, var(--bg-elev-2) 50%, var(--bg-elev) 75%);
  background-size: 200% 100%;
  animation: kv-shimmer 1.3s linear infinite;
}
@keyframes kv-shimmer { to { background-position: -200% 0; } }

.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; }
.pager-info { font-size: 12.5px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   详情 / 编辑抽屉
   -------------------------------------------------------------------------- */
.drawer-scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  display: none;
}
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(var(--panel-w), 100%);
  background: var(--bg-soft);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 41;
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform 0.22s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.drawer-title { font-weight: 650; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; min-height: 0; }
.drawer-foot {
  border-top: 1px solid var(--line);
  padding: 11px 16px;
  display: flex; gap: 9px; align-items: center;
  background: var(--bg-soft);
}

.field-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--bg-elev);
  margin-bottom: 9px;
}
.field-editor-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.field-editor-head .input { min-height: 30px; padding: 4px 9px; font-size: 13px; }
.secret-display {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  min-height: 36px;
  display: flex; align-items: center; gap: 8px;
}
.secret-display .secret-value { flex: 1 1 auto; min-width: 0; }
.secret-display .secret-value.masked { letter-spacing: 0.12em; color: var(--text-faint); }

.readonly-value {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  white-space: pre-wrap;
  color: var(--text);
}
.detail-block { margin-bottom: 16px; }
.detail-label {
  font-size: 11.5px;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-bottom: 5px;
}
.notes-view {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text-dim);
  font-size: 13px;
  max-height: 320px;
  overflow-y: auto;
}

/* --------------------------------------------------------------------------
   弹层
   -------------------------------------------------------------------------- */
.modal-scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 60;
  overflow-y: auto;
}
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  margin: auto;
}
.modal-wide { max-width: 680px; }
.modal-head {
  padding: 15px 18px 11px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 650;
  font-size: 15px;
  display: flex; align-items: center; gap: 10px;
}
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 9px; justify-content: flex-end;
}

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast-root {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px;
  z-index: 90;
  pointer-events: none;
  width: min(440px, calc(100vw - 32px));
}
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 13.5px;
  animation: kv-toast-in 0.18s ease;
  word-break: break-word;
}
.toast.out { animation: kv-toast-out 0.18s ease forwards; }
.toast-icon { flex: none; }
.toast-success { border-color: rgba(53, 192, 125, 0.45); }
.toast-success .toast-icon { color: var(--ok); }
.toast-error { border-color: rgba(255, 95, 86, 0.45); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warn { border-color: rgba(245, 165, 36, 0.45); }
.toast-warn .toast-icon { color: var(--warn); }
.toast-info .toast-icon { color: var(--accent); }
@keyframes kv-toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes kv-toast-out { to { opacity: 0; transform: translateY(8px); } }

/* --------------------------------------------------------------------------
   表格（用户管理 / 审计日志）
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.kv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kv-table th, .kv-table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
.kv-table td.wrap { white-space: normal; word-break: break-word; min-width: 180px; }
.kv-table th {
  background: var(--bg-soft);
  color: var(--text-faint);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.03em;
  position: sticky; top: 0;
}
.kv-table tbody tr:hover { background: var(--bg-elev-2); }
.kv-table tbody tr:last-child td { border-bottom: 0; }

/* --------------------------------------------------------------------------
   密码生成器 / TOTP
   -------------------------------------------------------------------------- */
.gen-output {
  display: flex; gap: 8px; align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
.gen-output code { flex: 1 1 auto; word-break: break-all; font-family: var(--mono); font-size: 14px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.totp-layout { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.qr-box {
  background: #fff;
  padding: 10px;
  border-radius: var(--radius-sm);
  flex: none;
  line-height: 0;
}
.qr-box canvas { display: block; image-rendering: pixelated; }
.secret-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 11px;
  margin-bottom: 8px;
}
.secret-row code { flex: 1 1 auto; word-break: break-all; font-family: var(--mono); font-size: 13px; }

.kv-toggle {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 11px 0;
  border-bottom: 1px solid var(--line-soft);
}
.kv-toggle:last-child { border-bottom: 0; }
.kv-toggle-text { min-width: 0; }
.kv-toggle-title { font-size: 13.5px; }
.kv-toggle-desc { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.switch { position: relative; width: 40px; height: 23px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: background 0.16s ease;
  pointer-events: none;
}
.switch-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.16s ease, background 0.16s ease;
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(17px); background: #fff; }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */
.sidebar-scrim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 29;
  display: none;
}

@media (max-width: 900px) {
  .hamburger { display: inline-flex; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 30;
    transform: translateX(-102%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .content { padding: 14px 13px 60px; }
  .topbar { padding: 8px 11px; gap: 8px; }
  .search-kbd { display: none; }
  .drawer { width: 100%; border-left: 0; }
  .item-actions { opacity: 1; }
  .tree-actions { opacity: 1; }
  .modal { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   内容块：编辑器
   ========================================================================== */

.block-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.block-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  padding: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.block-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 拖动中的块：抬起来，并且不要跟手过渡，否则会拖影 */
.block-row.dragging {
  opacity: 0.9;
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transition: none;
  position: relative;
  z-index: 5;
}

.block-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.block-grow { flex: 1 1 auto; }

/* 拖动手柄：触摸屏必须 touch-action:none，否则会被滚动抢走手势 */
.block-handle {
  flex: 0 0 auto;
  width: 34px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-faint);
  font-size: 15px;
  line-height: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
}

.block-handle:hover { color: var(--text); border-color: var(--accent); }
.block-handle:active { cursor: grabbing; }
.drawer.is-dragging .block-handle { cursor: grabbing; }
.drawer.is-dragging { user-select: none; -webkit-user-select: none; }

.block-type-select {
  flex: 0 0 auto;
  width: auto;
  min-width: 108px;
  height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
}

.block-textarea {
  width: 100%;
  min-height: 84px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.62;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  color: var(--text);
  resize: vertical;
}

.block-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.block-add-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.block-count {
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 11px;
}

/* 编辑 / 预览 切换 */
.segmented {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-input);
}

.segmented .btn {
  border: 0;
  border-radius: 0;
  height: 28px;
  padding: 0 11px;
  font-size: 12.5px;
  background: transparent;
}

.segmented .btn + .btn { border-left: 1px solid var(--line); }

/* ==========================================================================
   内容块：只读展示
   ========================================================================== */

.block-view-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.block-view {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
}

.block-view-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--bg-elev-2);
}

.block-kind {
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
}

.block-actions {
  margin-left: auto;
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
}

.block-pre {
  margin: 0;
  padding: 11px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.62;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.block-empty {
  padding: 11px 12px;
  color: var(--text-faint);
  font-size: 12.5px;
  font-style: italic;
}

.block-preview {
  border-top: 1px dashed var(--line);
  background: var(--bg-soft);
}

/* ==========================================================================
   Markdown 排版
   ========================================================================== */

.block-markdown {
  padding: 11px 13px;
  font-size: 13.5px;
  line-height: 1.72;
  color: var(--text);
  word-break: break-word;
}

.block-markdown > *:first-child { margin-top: 0; }
.block-markdown > *:last-child { margin-bottom: 0; }

.block-markdown h1,
.block-markdown h2,
.block-markdown h3,
.block-markdown h4,
.block-markdown h5,
.block-markdown h6 {
  margin: 16px 0 8px;
  line-height: 1.35;
  font-weight: 650;
}

.block-markdown h1 { font-size: 19px; }
.block-markdown h2 { font-size: 17px; }
.block-markdown h3 { font-size: 15.5px; }
.block-markdown h4,
.block-markdown h5,
.block-markdown h6 { font-size: 14px; color: var(--text-dim); }

.block-markdown p { margin: 9px 0; }

.block-markdown ul,
.block-markdown ol { margin: 9px 0; padding-left: 22px; }
.block-markdown li { margin: 4px 0; }
.block-markdown li > ul,
.block-markdown li > ol { margin: 4px 0; }

.block-markdown blockquote {
  margin: 10px 0;
  padding: 6px 12px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
}

.block-markdown hr {
  margin: 14px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.block-markdown .md-code-block {
  margin: 10px 0;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
}

.block-markdown .md-code-block code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

.block-markdown .md-code-inline {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 12px;
}

.block-markdown .md-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.block-markdown .md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12.5px;
  display: block;
  overflow-x: auto;
}

.block-markdown .md-table th,
.block-markdown .md-table td {
  border: 1px solid var(--line);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
}

.block-markdown .md-table th {
  background: var(--bg-elev-2);
  font-weight: 600;
}

/* ==========================================================================
   列表卡片的摘要行 + 详情元信息
   ========================================================================== */

.item-preview {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.meta-chip {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
  font-size: 11.5px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

/* ==========================================================================
   移动端适配
   ========================================================================== */

@media (max-width: 900px) {
  /* iOS 上 font-size < 16px 会在聚焦输入框时自动放大页面，这里统一抬高 */
  .block-textarea,
  .input,
  .textarea,
  .select {
    font-size: 16px;
  }

  .block-markdown { font-size: 15px; padding: 12px; }
  .block-markdown h1 { font-size: 20px; }
  .block-markdown h2 { font-size: 18px; }
  .block-pre { font-size: 13px; }

  /* 触控目标至少 44px */
  .block-handle {
    width: 44px;
    height: 40px;
    font-size: 17px;
  }

  .block-type-select {
    min-width: 118px;
    height: 40px;
    font-size: 14px;
  }

  .block-head { gap: 7px; }
  .block-head .btn-sm { min-height: 36px; padding: 0 12px; }

  .segmented .btn { height: 36px; padding: 0 14px; font-size: 13.5px; }

  .block-add-row .btn {
    flex: 1 1 auto;
    min-height: 42px;
    justify-content: center;
  }

  .block-row { padding: 9px; }
  .block-actions { width: 100%; margin-left: 0; }
  .block-view-head { flex-wrap: wrap; }
}

/* ==========================================================================
   布局改版：顶栏 + 两列（左窄列表 / 右大正文）
   —— 取代原来的「分类侧栏 + 列表 + 编辑抽屉」三件套。
   下面这段在文件末尾，用于覆盖上面遗留的 .shell / .sidebar / .main / .content
   规则（那些类已经不在 DOM 里了）。
   ========================================================================== */

.shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

/* --- 顶栏 --- */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.2px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  flex: 0 0 auto;
}

.brand:hover { background: var(--bg-elev-2); }
.brand-mark { font-size: 16px; }

.topbar .search-wrap { flex: 1 1 auto; max-width: 560px; }

/* --- 两列 --- */

.workspace {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  min-width: 0;
}

.pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.pane-list {
  flex: 0 0 322px;
  width: 322px;
  border-right: 1px solid var(--line);
  background: var(--bg-soft);
}

.pane-doc {
  flex: 1 1 auto;
  background: var(--bg);
  overflow-y: auto;
}

/* 设置 / 用户 / 审计 / 回收站是整页，不显示左列 */
.workspace.single-column .pane-list { display: none; }

/* --- 左列：列表 --- */

.list-col { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.list-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px 8px;
}

.list-title { font-size: 14.5px; font-weight: 650; }
.list-count {
  font-size: 11.5px;
  color: var(--text-faint);
  background: var(--bg-elev-2);
  border-radius: 999px;
  padding: 1px 7px;
}

.list-col .filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 0 12px 9px;
  border-bottom: 1px solid var(--line-soft);
}

.filter-select {
  width: auto;
  min-width: 96px;
  max-width: 150px;
  height: 28px;
  padding: 0 6px;
  font-size: 12px;
}

.filter-newcat { display: inline-flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.filter-newcat-input { width: 120px; height: 28px; font-size: 12.5px; }

.list-scroll { flex: 1 1 auto; overflow-y: auto; padding: 10px; min-height: 0; }
.list-more { padding: 10px 0 20px; text-align: center; }

.item-title-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.item-list-wide { max-width: 760px; }

/* --- 右列：文档 --- */

.doc {
  /* 必须显式 width:100%：flex 列容器里 margin:0 auto 会让子项不再 stretch，
     否则正文会缩成内容宽度，白白浪费右侧大片空间 */
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 26px 90px;
}

.doc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  margin-bottom: 4px;
}

.doc-head-left { flex: 1 1 auto; }
.doc-head-right { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-left: auto; }

.doc-status { font-size: 12px; color: var(--text-faint); }
.doc-status-dirty { color: var(--warn); }
.doc-status-saving { color: var(--text-dim); }
.doc-status-saved { color: var(--ok); }
.doc-status-conflict { color: var(--danger); font-weight: 600; }
.doc-status-error { color: var(--danger); }

.doc-back { display: none; }

/* 标题：无边框大标题，直接在上面打字 */
.doc-title {
  width: 100%;
  border: 0;
  background: none;
  padding: 2px 0 6px;
  margin: 0;
  font-size: 25px;
  font-weight: 680;
  line-height: 1.3;
  color: var(--text);
  resize: none;
  overflow: hidden;
  font-family: var(--sans);
  /* 覆盖基础 .textarea 的 min-height，高度由 autoGrow 按内容决定 */
  min-height: 0;
}

.doc-title:focus { outline: none; box-shadow: none; }
.doc-title::placeholder { color: var(--text-faint); font-weight: 500; }

.doc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.doc-meta-select { width: auto; min-width: 104px; height: 28px; font-size: 12.5px; padding: 0 7px; }
.doc-meta-tags { width: 190px; height: 28px; font-size: 12.5px; }
.doc-meta-time { font-size: 11.5px; color: var(--text-faint); margin-left: auto; }

.doc-empty { display: flex; align-items: center; justify-content: center; min-height: 60vh; }

/* 冲突提示条：内联，不是弹窗 */
.doc-conflict {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  font-size: 13px;
}

.doc-conflict-text { flex: 1 1 220px; }

/* --- 整页视图（设置 / 用户 / 审计 / 回收站）--- */

.page { width: 100%; max-width: 880px; margin: 0 auto; padding: 20px 26px 90px; }
.page-title { font-size: 19px; font-weight: 680; margin-bottom: 4px; }

/* --- 分类管理 --- */

.cat-list { display: flex; flex-direction: column; gap: 4px; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  min-height: 38px;
}

.cat-row:hover { background: var(--bg-elev-2); }
.cat-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-count { font-size: 11.5px; color: var(--text-faint); flex: 0 0 auto; }
.cat-actions { display: inline-flex; gap: 5px; flex: 0 0 auto; }
.cat-input { flex: 1 1 auto; height: 30px; font-size: 13px; }
.cat-add { margin-top: 8px; }
.cat-add:empty { display: none; }
.cat-add .input { max-width: 220px; height: 30px; font-size: 13px; }

/* --- 用户管理：内联表单 --- */

.user-create { margin-bottom: 16px; }
.user-edit-row > td { background: var(--bg-soft); padding: 14px 12px; }
.user-edit { max-width: 420px; }

/* --- 密码生成器内联面板 --- */

.generator-panel { margin-top: 12px; }

/* ==========================================================================
   移动端：一次只显示一列（列表 / 正文），靠正文的「‹ 列表」返回
   ========================================================================== */

@media (max-width: 900px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .brand-name { display: none; }
  .topbar .search-wrap { max-width: none; }

  .workspace { position: relative; }

  .pane-list,
  .pane-doc {
    position: absolute;
    inset: 0;
    width: 100%;
    flex: 1 1 auto;
  }

  /* 单列整页（设置等）：只显示正文 */
  .workspace.single-column .pane-doc { display: flex; }

  /* 两列视图：按 mobilePane 决定显示哪一个 */
  .workspace:not(.single-column).pane-show-doc .pane-list { display: none; }
  .workspace:not(.single-column):not(.pane-show-doc) .pane-doc { display: none; }

  .doc-back { display: inline-flex; }
  .doc { padding: 14px 15px 80px; }
  .doc-title { font-size: 21px; }
  .doc-meta-time { margin-left: 0; width: 100%; }
  .doc-meta-tags { width: 100%; }

  .page { padding: 16px 15px 80px; }

  .cat-actions .btn { min-height: 34px; }
  .list-col .filter-bar { padding: 0 10px 8px; }
  .filter-select { max-width: none; flex: 1 1 110px; }
  .list-scroll { padding: 8px; }
}

