/* Cruxy Pass. Pure black dark theme, white light theme, Cruxy blue as the
   one accent, 4px corners, system fonts. */

:root {
  --bg: #ffffff;
  --bg-subtle: #f6f8fa;
  --bg-hover: #f0f2f5;
  --fg: #0b0d12;
  --muted: #59636e;
  --border: #d8dee4;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --danger: #cf222e;
  --danger-soft: rgba(207, 34, 46, 0.1);
  --ok: #1a7f37;
  --warn-soft: rgba(212, 167, 44, 0.16);
  --shadow: 0 8px 24px rgba(140, 149, 159, 0.2);
  --radius: 4px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #000000;
  --bg-subtle: #0a0a0a;
  --bg-hover: #161616;
  --fg: #f0f3f6;
  --muted: #9198a1;
  --border: #262a30;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --danger: #f85149;
  --danger-soft: rgba(248, 81, 73, 0.14);
  --ok: #3fb950;
  --warn-soft: rgba(210, 153, 34, 0.18);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 14px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.boot { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.hidden { display: none !important; }

/* Controls */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-subtle); color: var(--fg);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
button:hover, .button:hover { background: var(--bg-hover); text-decoration: none; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary, .button.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
button.primary:hover, .button.primary:hover { background: #1d4ed8; }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--bg-hover); }
button.small { height: 26px; padding: 0 8px; font-size: 12px; }
button.wide, .button.wide { width: 100%; height: 36px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

input, select, textarea {
  width: 100%; height: 32px; padding: 0 10px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg); color: var(--fg); font: inherit;
}
textarea { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
input[type="range"] { padding: 0; accent-color: var(--accent); }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.stack > * + * { margin-top: 12px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.notice { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-subtle); }
.notice.warn { background: var(--warn-soft); }
.notice.danger { background: var(--danger-soft); border-color: transparent; }

/* The single-card screens (sign in, two-factor, unlock) */
.center { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; margin-bottom: 24px; }
.brand img { width: 28px; height: 28px; }
.card { width: 100%; max-width: 400px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); padding: 24px; }
.card h1 { font-size: 20px; margin-bottom: 6px; }
.card .lede { color: var(--muted); margin-bottom: 20px; }
.card.wide { max-width: 520px; }
.foot { margin-top: 16px; font-size: 12px; color: var(--muted); text-align: center; max-width: 400px; }
.qr { display: block; width: 200px; height: 200px; margin: 0 auto 12px; background: #fff; border-radius: var(--radius); }
.secret { font-family: var(--mono); font-size: 13px; word-break: break-all; padding: 8px 10px; background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius); }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-family: var(--mono); }
.recovery { font-family: var(--mono); font-size: 15px; line-height: 1.8; letter-spacing: 0.04em; text-align: center; padding: 14px; border: 1px dashed var(--accent); border-radius: var(--radius); background: var(--accent-soft); }

/* The app: header, sidebar, list, detail */
.shell { display: grid; grid-template-rows: 56px 1fr; height: 100vh; }
.top { display: flex; align-items: center; gap: 16px; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--bg-subtle); }
.top .brand { margin: 0; font-size: 15px; }
.top .search { flex: 1; max-width: 520px; }
.top .grow { flex: 1; }
.top .who { color: var(--muted); font-size: 13px; }
.body { display: grid; grid-template-columns: 232px 360px 1fr; min-height: 0; }
.side { border-right: 1px solid var(--border); padding: 12px 8px; overflow: auto; }
.side h3 { font-size: 12px; color: var(--muted); font-weight: 600; padding: 12px 8px 6px; display: flex; justify-content: space-between; align-items: center; }
.nav { display: flex; align-items: center; gap: 8px; width: 100%; height: 32px; padding: 0 8px; border-radius: var(--radius); background: none; border: 0; color: var(--fg); font-weight: 400; justify-content: flex-start; }
.nav:hover { background: var(--bg-hover); }
.nav.on { background: var(--accent-soft); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent); }
.nav .count { margin-left: auto; color: var(--muted); font-size: 12px; }
.list { border-right: 1px solid var(--border); overflow: auto; }
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--bg); }
.entry { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 16px; border: 0; border-bottom: 1px solid var(--border); background: none; color: var(--fg); text-align: left; height: auto; border-radius: 0; justify-content: flex-start; font-weight: 400; }
.entry:hover { background: var(--bg-hover); }
.entry.on { background: var(--accent-soft); }
.entry .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry .s { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry > div { min-width: 0; }
.badge { flex: none; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius); background: var(--bg-subtle); border: 1px solid var(--border); font-size: 11px; font-weight: 700; color: var(--muted); }
.pill { display: inline-block; padding: 0 8px; height: 20px; line-height: 20px; border-radius: 10px; border: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.pill.accent { color: var(--accent); border-color: var(--accent); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.detail { overflow: auto; padding: 24px 32px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.kv { border: 1px solid var(--border); border-radius: var(--radius); }
.kv > div { display: grid; grid-template-columns: 140px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.kv > div:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-size: 13px; }
.kv .v { overflow-wrap: anywhere; }
.kv .v.pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; max-height: 240px; overflow: auto; }
.kv .acts { display: flex; gap: 4px; }
.totp { font-family: var(--mono); font-size: 18px; letter-spacing: 0.12em; }
.section { margin-top: 28px; }
.section h2 { margin-bottom: 12px; }
table { width: 100%; border-collapse: collapse; border: 1px solid var(--border); border-radius: var(--radius); }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: var(--bg-subtle); }
.fp { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* Dialogs */
.veil { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); display: grid; place-items: center; padding: 16px; z-index: 10; }
.dialog { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); overflow: auto; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.dialog > header { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog > .content { padding: 20px; }
.dialog > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg-subtle); }
.dialog.wide { max-width: 640px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: var(--radius); font-size: 13px; z-index: 20; }

@media (max-width: 1100px) {
  .body { grid-template-columns: 200px 300px 1fr; }
}
@media (max-width: 820px) {
  .body { grid-template-columns: 1fr; }
  .side { display: none; }
  .body.has-detail .list { display: none; }
  .body:not(.has-detail) .detail { display: none; }
  .top .who { display: none; }
  .kv > div { grid-template-columns: 1fr auto; }
  .kv .k { grid-column: 1 / -1; }
  .grid2 { grid-template-columns: 1fr; }
}

/* Pages, mobile navigation and small helpers used by app.js */
.body.page { grid-template-columns: 232px 1fr; }
.body.page .detail { max-width: 960px; }
.back, .menu { display: none; }
.pad { padding: 4px 8px; }
.narrow { max-width: 640px; }
.section-lede { margin: 6px 0 4px; }
.error-text { color: var(--danger); }
.pill-gap { margin-left: 8px; }
.picker { margin-top: 10px; max-height: 240px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.picker p { padding: 10px 12px; }
.grid-host { display: grid; grid-template-columns: 1fr 120px; gap: 0 12px; }
.notice.flat { border-radius: 0; border-width: 0 0 1px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
textarea.mono { font-family: var(--mono); font-size: 12px; }
.row > select { flex: none; width: auto; }
td select { width: auto; }
.list-head h3 { font-size: 14px; }
.dialog .row > input { min-width: 0; }

@media (max-width: 1100px) {
  .body.page { grid-template-columns: 200px 1fr; }
}
@media (max-width: 820px) {
  .body.page { grid-template-columns: 1fr; }
  .back, .menu { display: inline-flex; }
  .back { margin-bottom: 12px; }
  .top { gap: 8px; padding: 0 8px; }
  .top .brand-name { display: none; }
  .body.show-side .side { display: block; position: fixed; top: 56px; left: 0; bottom: 0; width: 260px; z-index: 5; background: var(--bg); box-shadow: var(--shadow); }
  .detail { padding: 16px; }
  .grid-host { grid-template-columns: 1fr 96px; }
  .detail-head { flex-direction: column; }
}
.spacer { height: 12px; }
.gap-top { margin-top: 12px; }
button.icon { width: 32px; padding: 0; }
.top .search { min-width: 0; }
@media (max-width: 820px) {
  .top .search { flex: 1 1 auto; max-width: none; }
  .top .grow { display: none; }
}
