:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #b45309;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; z-index: 100; box-shadow: var(--shadow); max-width: 90vw;
}
.toast.warn { background: var(--warn); }
.toast.error { background: var(--danger); }

/* ---------- 解锁 / 初始化 ---------- */
.gate { min-height: 100%; display: grid; place-items: center; padding: 32px 16px; }
.gate-card {
  width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border);
  border-radius: 18px; box-shadow: var(--shadow); padding: 32px 28px 28px;
}
.gate-logo { font-size: 40px; line-height: 1; }
.gate-card h1 { margin: 10px 0 4px; font-size: 26px; letter-spacing: .5px; }
.gate-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.gate-row { display: flex; gap: 10px; margin-top: 14px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; outline: none; transition: border-color .15s;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 72px; }
.hint { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin: 8px 0 0; }
.hint.error { color: var(--danger); }
.hint.ok { color: var(--ok); }
.primary, .ghost {
  border-radius: 10px; padding: 10px 16px; border: 1px solid transparent; font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-strong); }
.primary:disabled, .ghost:disabled { opacity: .55; cursor: default; }
.ghost { background: #fff; border-color: var(--border); color: var(--text); }
.ghost:hover { border-color: #cbd5e1; background: #f8fafc; }
.wide { width: 100%; }
#btn-setup, #btn-login { margin-top: 6px; }

/* ---------- 主界面 ---------- */
.shell { height: 100%; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 18px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-actions .ghost { padding: 7px 12px; font-size: 13px; }
.badge {
  font-size: 12px; padding: 5px 10px; border-radius: 999px; background: #f1f5f9; color: var(--muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.badge.syncing { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge.synced { background: #ecfdf5; color: var(--ok); border-color: #a7f3d0; }
.badge.offline { background: #fffbeb; color: var(--warn); border-color: #fde68a; }

.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 176px 320px 1fr; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 14px 10px; overflow-y: auto; }
.nav-item {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--text);
  font-size: 14px; text-align: left;
}
.nav-item:hover { background: #f1f5f9; }
.nav-item.active { background: #e0eaff; color: var(--accent-strong); font-weight: 600; }
.nav-item .count { font-size: 12px; color: var(--muted); }
.nav-title { margin: 18px 12px 6px; font-size: 11px; letter-spacing: 1px; color: var(--muted); }
.category-list { display: flex; flex-direction: column; gap: 2px; }

.list { min-width: 0; border-right: 1px solid var(--border); background: #fafbfc; display: flex; flex-direction: column; }
.list-tools { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); background: var(--panel); }
.list-tools input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; outline: none; }
.list-tools input:focus { border-color: var(--accent); }
.list-tools .primary { padding: 8px 12px; white-space: nowrap; }
.items { flex: 1; overflow-y: auto; padding: 8px; }
.item-card {
  display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--border);
  border-radius: 11px; padding: 11px 12px; margin-bottom: 8px; transition: border-color .15s, box-shadow .15s;
}
.item-card:hover { border-color: #c7d2fe; }
.item-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.item-card .item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-card .platform { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card .star { color: #f59e0b; font-size: 13px; }
.item-card .username { color: var(--muted); font-size: 12.5px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-card .meta { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.tag {
  font-size: 11px; color: #475569; background: #f1f5f9; border-radius: 6px; padding: 2px 7px;
}
.tag.cat { background: #eef2ff; color: #4338ca; }
.empty-items { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 12px; line-height: 1.8; }

.detail { min-width: 0; overflow-y: auto; background: var(--panel); }
.detail-empty { height: 100%; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.9; }
.detail-empty-icon { font-size: 40px; margin-bottom: 8px; }
.detail-form { padding: 20px 22px 40px; max-width: 720px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.detail-head h2 { margin: 0; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-head .actions { display: flex; gap: 8px; flex-shrink: 0; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.detail-grid .span2 { grid-column: 1 / -1; }
.pw-row { display: flex; gap: 8px; }
.pw-row input { flex: 1; min-width: 0; }
.pw-row .ghost { padding: 0 12px; white-space: nowrap; }
.copy-row { display: flex; gap: 8px; margin: -6px 0 14px; }
.copy-row .ghost { padding: 7px 12px; font-size: 12.5px; }
.section-title { font-size: 12px; letter-spacing: 1px; color: var(--muted); margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.questions { display: flex; flex-direction: column; gap: 8px; }
.question-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: start; }
.question-row input { padding: 8px 10px; }
.question-row .ghost { padding: 8px 10px; }
.add-question { align-self: flex-start; margin-top: 4px; }
.detail-meta { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; line-height: 1.8; }
.detail-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--panel) 30%); padding-top: 14px; display: flex; gap: 10px; }
.detail-actions .danger { color: var(--danger); border-color: #fecaca; background: #fff; }
.detail-actions .danger:hover { background: #fef2f2; }

.dialog { border: 1px solid var(--border); border-radius: 16px; padding: 24px; width: min(440px, 92vw); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(15, 23, 42, .35); }
.dialog h2 { margin: 0 0 16px; font-size: 18px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 0; margin: 18px 0 0; }
.dialog-meta { color: var(--muted); font-size: 12px; line-height: 1.8; margin-top: 12px; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .list { border-right: 0; }
  .detail { position: fixed; inset: 0; z-index: 20; transform: translateY(100%); transition: transform .2s; }
  .detail.open { transform: none; }
  .detail-form { max-width: none; }
}
/* ---------- 右键快捷菜单 ---------- */
.ctx-menu {
  position: fixed; z-index: 120; min-width: 186px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, .16), 0 2px 8px rgba(15, 23, 42, .08);
  font-size: 13px; animation: ctx-in .09s ease-out;
}
.ctx-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  width: 100%; padding: 7px 10px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text); text-align: left; cursor: pointer;
}
.ctx-item:hover:not(:disabled) { background: #eef2ff; color: var(--accent-strong); }
.ctx-item:disabled { color: #9ca3af; cursor: default; }
.ctx-hint { color: var(--muted); font-size: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-sep { height: 1px; margin: 5px 6px; background: #eef1f6; }
@keyframes ctx-in { from { opacity: 0; transform: translateY(-3px) scale(.98); } }
