:root {
  --bg: #0d0f14; --panel: #161a22; --panel2: #1d222c; --line: #2a3140;
  --fg: #e6e9ef; --muted: #8b94a7; --accent: #6ec1ff; --accent2: #50fa7b;
  --danger: #ff5f56; --radius: 12px;
}
* { box-sizing: border-box; }

/* scrollbars (dark, themed) */
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--danger); margin-top: 10px; min-height: 1em; white-space: pre-wrap; }
.ok { color: var(--accent2); margin-top: 10px; min-height: 1em; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; letter-spacing: 1px; color: var(--accent); font-size: 18px; }
.who { color: var(--muted); font-size: 13px; }
.spacer { flex: 1; }
.search {
  background: var(--panel2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 999px; padding: 8px 14px; min-width: 220px;
}

/* layout */
#main { max-width: 760px; margin: 0 auto; padding: 24px 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.screen { margin-top: 24px; }
.screen.card { max-width: 420px; margin-left: auto; margin-right: auto; }
h1 { margin: 0 0 6px; font-size: 22px; }
h2 { font-size: 16px; margin: 0 0 8px; }

label { display: block; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
input, textarea {
  width: 100%; margin-top: 4px; padding: 10px 12px; font-size: 15px;
  background: var(--panel2); color: var(--fg);
  border: 1px solid var(--line); border-radius: 8px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; font-family: inherit; }

.btn {
  margin-top: 14px; padding: 10px 16px; font-size: 14px; cursor: pointer;
  background: var(--panel2); color: var(--fg); border: 1px solid var(--line); border-radius: 8px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #06121d; border-color: var(--accent); font-weight: 600; width: 100%; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: rgba(255,95,86,.12); }
.btn.small { padding: 6px 10px; font-size: 13px; margin-top: 8px; }
a.btn { display: inline-block; text-decoration: none; text-align: center; }
.topbar .btn { margin-top: 0; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* strength meter */
.meter { height: 6px; background: var(--panel2); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.meter-bar { height: 100%; width: 0; background: var(--danger); transition: width .2s, background .2s; }

/* item list */
.item-list { list-style: none; margin: 0; padding: 0; }
.item-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; cursor: pointer;
}
.item-row:hover { border-color: var(--accent); }
.item-avatar {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  background: var(--panel2); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent);
}
.item-main { flex: 1; min-width: 0; }
.item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-actions { display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--fg);
  border-radius: 7px; padding: 6px 9px; cursor: pointer; font-size: 13px;
}
.icon-btn:hover { border-color: var(--accent); }
.empty { text-align: center; padding: 40px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
.modal-card { width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.modal-actions .btn { margin-top: 0; flex: 1; }
.pw-row { display: flex; gap: 6px; align-items: stretch; }
.pw-row input { flex: 1; }
.pw-row .btn { margin-top: 4px; }

.setting { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px; }
.setting:first-of-type { border-top: none; padding-top: 0; }
.setting.danger h2 { color: var(--danger); }

/* toast + overlay */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); border: 1px solid var(--line); color: var(--fg);
  padding: 10px 18px; border-radius: 999px; z-index: 30;
}
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 40; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
