/* 主题：默认白天；data-theme="dark" 切黑夜；颜色一律走变量 */
:root {
  --bg: #f3f5f8; --panel: #ffffff; --line: #dde3ec; --field: #f7f9fc;
  --text: #1c2330; --muted: #67728a; --accent: #2f6fed; --danger: #d43f3f;
  --badge-bg: #e3ecff; --mask: rgba(30, 38, 55, .45); --toast-bg: #ffffff;
  --danger-line: #f0c9c9; --shadow: 0 1px 3px rgba(28, 35, 48, .08);
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}
[data-theme="dark"] {
  --bg: #0f1218; --panel: #171c26; --line: #2a3140; --field: #0b0e13;
  --text: #dfe5ee; --muted: #8a94a6; --accent: #4f8cff; --danger: #ff6b6b;
  --badge-bg: #1b2a4a; --mask: rgba(0, 0, 0, .55); --toast-bg: #2a3140;
  --danger-line: #4a2a2e; --shadow: none;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 system-ui, "PingFang SC", "Microsoft YaHei", sans-serif; }
.hidden { display: none !important; }
button { cursor: pointer; font: inherit; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); padding: 7px 14px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: var(--danger-line); background: transparent; }
input, textarea, select { font: inherit; background: var(--field); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 1px solid var(--accent); }

/* 主题切换（固定右上角，鉴权页也可见） */
#btn-theme { position: fixed; top: 14px; right: 14px; z-index: 30; padding: 5px 10px; font-size: 15px; line-height: 1; box-shadow: var(--shadow); }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: min(340px, 90vw); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 6px; }
.hint { color: var(--muted); font-size: 13px; text-align: center; }
.err { color: var(--danger); min-height: 20px; font-size: 13px; text-align: center; }

/* 主界面 */
header { display: flex; justify-content: space-between; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; gap: 8px; }
header h1 { font-size: 18px; }
.head-right { display: flex; gap: 10px; align-items: center; }
#whoami { color: var(--muted); font-size: 13px; }
.toolbar { display: flex; gap: 10px; padding: 16px 22px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; }
.toolbar select { width: 150px; flex: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; padding: 0 22px 40px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow); }
.card .name { font-weight: 600; font-size: 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.badge { font-size: 12px; color: var(--accent); background: var(--badge-bg); padding: 1px 8px; border-radius: 99px; flex: none; }
.card .kv { font-size: 13px; color: var(--muted); display: grid; grid-template-columns: 42px 1fr; gap: 4px; align-items: baseline; }
.card .kv b { font-weight: normal; }
.card .val { font-family: var(--mono); font-size: 13px; color: var(--text); background: var(--field); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; word-break: break-all; max-height: 88px; overflow: auto; }
.card .val.err { color: var(--danger); }
.card .url a { color: var(--accent); text-decoration: none; font-size: 13px; }
.card .note { font-size: 13px; color: var(--muted); white-space: pre-wrap; }
.card .ops { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.card .ops button { padding: 4px 10px; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 60px 0; }

/* 弹窗 */
.mask { position: fixed; inset: 0; background: var(--mask); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal { position: relative; width: min(640px, 96vw); max-height: 92vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
#modal-resize { align-self: flex-end; margin-top: -8px; padding: 2px 8px; color: var(--muted); cursor: ew-resize; user-select: none; font-size: 14px; line-height: 1; }
#modal-resize:hover { color: var(--accent); }
.json-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
@media (max-width: 480px) { .modal { width: 100%; } #modal-resize { display: none; } }
.modal h2 { font-size: 17px; }
.modal label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
.cat-row { display: flex; gap: 8px; align-items: stretch; }
.cat-row select { flex: 1; }
.cat-row button { flex: none; padding: 0 12px; }

/* 内容类型 tab + KV 行 */
.ctype-tabs { display: flex; gap: 6px; align-items: center; }
.ctype-tab { padding: 5px 16px; border-radius: 8px 8px 0 0; border: 1px solid var(--line); border-bottom: none; background: var(--field); color: var(--muted); }
.ctype-tab.active { background: var(--panel); color: var(--accent); font-weight: 600; }
.ctype-tabs .spacer { flex: 1; }
button.sm { padding: 4px 10px; font-size: 13px; }
.ct-pane { border: 1px solid var(--line); border-radius: 0 8px 8px 8px; padding: 8px; min-height: 120px; max-height: 44vh; overflow: auto; background: var(--panel); }
.ct-pane textarea { min-height: 160px; resize: vertical; }
.mono { font-family: var(--mono); font-size: 13px; }
.kv-line { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.kv-line input.k { flex: 0 0 30%; min-width: 90px; }
.kv-line input.v { flex: 1; }
.kv-line .del { flex: none; border: none; background: transparent; color: var(--danger); font-size: 16px; padding: 2px 8px; }
.kv-empty { color: var(--muted); text-align: center; padding: 30px 0; font-size: 13px; }

/* 卡片内容展示 */
.kv-out { border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.kv-out .r { display: grid; grid-template-columns: 34% 1fr; font-size: 13px; }
.kv-out .r + .r { border-top: 1px solid var(--line); }
.kv-out .rk { background: var(--field); color: var(--muted); padding: 5px 8px; word-break: break-all; }
.kv-out .rv { padding: 5px 8px; word-break: break-all; font-family: var(--mono); }
.modal-btns { display: flex; justify-content: flex-end; gap: 10px; }
.modal-err { color: var(--danger); font-size: 13px; min-height: 18px; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: var(--toast-bg); color: var(--text); border: 1px solid var(--line); padding: 8px 18px; border-radius: 99px; font-size: 14px; z-index: 20; box-shadow: var(--shadow); }

@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; padding: 0 12px 32px; }
  .toolbar { padding: 12px; }
  header { padding: 12px; }
}
