:root {
  --bg: #0b1020; --bg2: #0f1629; --panel: #141c33; --panel2: #1a2340; --line: #243055; --line2: #2e3b66;
  --text: #e7ebf5; --muted: #8e9abb; --faint: #5f6b8c;
  --accent: #7aa2ff; --accent2: #5b84f0; --accent-ink: #0b1020; --silver: #c9d2e6;
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --bad-bg: rgba(248, 113, 113, .1);
  --radius: 12px; --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fb; --bg2: #eef1f8; --panel: #ffffff; --panel2: #f6f8fc; --line: #e2e7f1; --line2: #cfd7e8;
    --text: #141a2e; --muted: #5a6585; --faint: #8b95b0; --accent: #3b6ef5; --accent2: #2c5ae0; --accent-ink: #fff; --silver: #4a5574;
    --bad-bg: rgba(220, 38, 38, .07); --bad: #dc2626; --ok: #059669; --warn: #d97706; --shadow: 0 10px 30px rgba(20, 26, 46, .12);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f4f6fb; --bg2: #eef1f8; --panel: #ffffff; --panel2: #f6f8fc; --line: #e2e7f1; --line2: #cfd7e8;
  --text: #141a2e; --muted: #5a6585; --faint: #8b95b0; --accent: #3b6ef5; --accent2: #2c5ae0; --accent-ink: #fff; --silver: #4a5574;
  --bad-bg: rgba(220, 38, 38, .07); --bad: #dc2626; --ok: #059669; --warn: #d97706; --shadow: 0 10px 30px rgba(20, 26, 46, .12);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* buttons + inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--panel2); cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-danger { color: var(--bad); }
.btn-danger:hover { border-color: var(--bad); background: var(--bad-bg); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--panel2); border-color: var(--line); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 9px; }
.btn-discord { background: #5865f2; border-color: #5865f2; color: #fff; width: 100%; height: 44px; }
.btn-discord:hover { background: #4752c4; border-color: #4752c4; }
.btn-block { width: 100%; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input { width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg2); outline: none; transition: border-color .15s, box-shadow .15s; }
textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.input-group { display: flex; gap: 6px; }
.input-group .input { flex: 1; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--muted); margin: 6px 0 16px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.meter { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; width: 0; transition: width .2s, background .2s; }
.meter-label { font-size: 12px; margin-top: 4px; color: var(--muted); }
.alert { border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 14px; border: 1px solid; }
.alert-error { color: var(--bad); background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); font-weight: 600; }
.alert-info { color: var(--muted); background: var(--panel2); border-color: var(--line); }

/* auth screens */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 32px 16px;
  background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 30px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand-logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, var(--silver), var(--accent)); color: var(--accent-ink); }
.brand-logo svg { width: 19px; height: 19px; stroke-width: 2.4; }
.brand small { display: block; font-size: 11.5px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.auth h1 { font-size: 22px; margin: 22px 0 6px; letter-spacing: -.02em; }
.auth p.lead { margin: 0 0 22px; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.who { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); margin-bottom: 18px; }
.who img { width: 40px; height: 40px; border-radius: 50%; }
.who b { display: block; }
.auth-foot { margin-top: 18px; font-size: 12.5px; color: var(--faint); text-align: center; }

/* app shell */
.shell { display: grid; grid-template-columns: 250px 1fr; grid-template-rows: 60px 1fr; height: 100vh; }
.top { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 18px; border-bottom: 1px solid var(--line); background: var(--panel); }
.top .brand { width: 214px; }
.search { flex: 1; max-width: 560px; position: relative; }
.search svg { position: absolute; left: 12px; top: 12px; color: var(--faint); }
.search .input { padding-left: 36px; height: 40px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line2); cursor: pointer; }
.side { border-right: 1px solid var(--line); background: var(--panel); padding: 14px 10px; overflow-y: auto; display: flex; flex-direction: column; }
.nav-h { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 16px 10px 6px; }
.nav-h button { width: 24px; height: 24px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.nav-h button:hover { background: var(--panel2); color: var(--accent); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--text); font-weight: 500; cursor: pointer; text-decoration: none; }
.nav a:hover { background: var(--panel2); }
.nav a.active { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.nav a .count { margin-left: auto; font-size: 11.5px; color: var(--faint); }
.nav a .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot { margin-top: auto; padding-top: 14px; }
.main { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(340px, 1.15fr); min-height: 0; overflow: hidden; }
.list { border-right: 1px solid var(--line); overflow-y: auto; min-height: 0; }
.list-head { position: sticky; top: 0; z-index: 2; background: var(--bg); display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; border-bottom: 1px solid var(--line); }
.list-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-head .sub { font-size: 12px; color: var(--muted); }
.list-head .grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); cursor: pointer; }
.row:hover { background: var(--panel); }
.row.active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.row .meta { min-width: 0; flex: 1; }
.row .meta b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta span { display: block; font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; flex-shrink: 0; text-transform: uppercase; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.owner { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.star { color: var(--warn); }
.empty { padding: 60px 24px; text-align: center; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 10px; }
.empty h3 { color: var(--text); margin: 0 0 4px; }

/* detail */
.detail { overflow-y: auto; padding: 22px 26px; min-height: 0; }
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.detail-head .tile { width: 48px; height: 48px; font-size: 20px; border-radius: 13px; }
.detail-head h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; word-break: break-word; }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.fieldrow { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.fieldrow:last-child { border-bottom: 0; }
.fieldrow .k { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.fieldrow .v { word-break: break-all; margin-top: 2px; }
.fieldrow .grow { flex: 1; min-width: 0; }
.fieldrow .tools { display: flex; gap: 4px; opacity: .75; }
.fieldrow:hover .tools { opacity: 1; }
.totp { font-family: var(--mono); font-size: 20px; letter-spacing: .12em; font-weight: 700; color: var(--accent); }
.ring { width: 26px; height: 26px; }
.ring circle { fill: none; stroke-width: 3; }
.notes { white-space: pre-wrap; word-break: break-word; padding: 12px 14px; }
.foot-meta { font-size: 12px; color: var(--faint); margin-top: 8px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(5, 8, 18, .6); backdrop-filter: blur(2px); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 520px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.modal.wide { max-width: 640px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 16px; }
.modal-b { padding: 20px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; margin-bottom: 16px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
.gen-out { font-family: var(--mono); font-size: 18px; padding: 14px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line2); word-break: break-all; min-height: 56px; margin-bottom: 12px; }
.range { width: 100%; accent-color: var(--accent); }
.member { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.member img { width: 32px; height: 32px; border-radius: 50%; }
.member .grow { flex: 1; min-width: 0; }
.member select { height: 32px; border-radius: 8px; border: 1px solid var(--line2); background: var(--bg2); padding: 0 8px; }
.pick { border: 1px solid var(--line); border-radius: 10px; margin-top: 6px; max-height: 220px; overflow-y: auto; }
.pick div { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; }
.pick div:hover, .pick div.on { background: var(--panel2); }
.pick img { width: 26px; height: 26px; border-radius: 50%; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 6px; }
.steps code, .kbd { font-family: var(--mono); font-size: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--text); }
.ext-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ext-card { border: 1px solid var(--line); border-radius: 12px; padding: 16px; background: var(--panel2); }
.ext-card h4 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.menu { position: absolute; right: 16px; top: 54px; min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; z-index: 40; }
.menu .mh { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); cursor: pointer; text-decoration: none; }
.menu a:hover { background: var(--panel2); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow); max-width: 360px; font-weight: 500; }
.toast.err { border-left-color: var(--bad); color: var(--bad); font-weight: 600; }
.lockbar { position: fixed; left: 0; right: 0; top: 0; height: 3px; z-index: 45; pointer-events: none; }
.lockbar i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.back-btn { display: none; }

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 60px auto 1fr; }
  .top .brand { width: auto; }
  .top .brand small { display: none; }
  .side { flex-direction: row; overflow-x: auto; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); gap: 4px; }
  .side .nav-h, .side-foot { display: none; }
  .nav { display: flex; gap: 4px; }
  .nav a { white-space: nowrap; }
  .main { grid-template-columns: 1fr; }
  .main.show-detail .list { display: none; }
  .main:not(.show-detail) .detail { display: none; }
  .back-btn { display: inline-flex; }
  .ext-grid, .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .top { gap: 8px; padding: 0 12px; }
  .top .brand span.t { display: none; }
  .detail { padding: 16px; }
  .auth-card { padding: 22px; }
}
