:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1c2330; --muted: #667085; --line: #d9dde5;
  --accent: #1f5fd1; --accent-text: #fff; --danger: #b42318; --hover: #eef2f9;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --panel: #1b2029; --text: #e6e9ef; --muted: #98a2b3; --line: #2e3542; --accent: #6ea0ff; --accent-text: #0b1220; --danger: #ff8a7a; --hover: #252c38; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#app { min-height: 100%; display: flex; flex-direction: column; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.1rem 0 .3rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.pad { padding: 1rem; }
.center { text-align: center; padding: 2rem; }
.error { color: var(--danger); }
.notice { background: var(--hover); border-radius: 8px; padding: .6rem .8rem; }

button, input, select, textarea { font: inherit; color: inherit; }
button { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .45rem .8rem; cursor: pointer; }
button:hover { background: var(--hover); }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { color: var(--danger); }
button.icon { border: 0; background: none; font-size: 1.3rem; line-height: 1; padding: .2rem .5rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=text], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .65rem;
}
textarea { resize: vertical; }
.field { display: block; margin: 0 0 .85rem; }
.field > span { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .25rem; }
.field small { display: block; color: var(--muted); margin-top: .2rem; }
.check { display: block; margin: .3rem 0; }
.inline { display: flex; gap: .4rem; }
.inline input { flex: 1; min-width: 0; }
.actions { display: flex; gap: .5rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1rem; }
.actions.left { justify-content: flex-start; }
.custom { display: flex; gap: .4rem; align-items: center; margin-bottom: .4rem; }
.custom label { white-space: nowrap; }

.card { width: min(26rem, calc(100% - 2rem)); margin: 8vh auto; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.5rem; }
.secret { font: 600 1.05rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; word-break: break-all; background: var(--hover); padding: .7rem; border-radius: 8px; }

.bar { display: flex; gap: .5rem; align-items: center; padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bar strong { font-size: 1.1rem; margin-right: .5rem; }
.bar input[type=search] { flex: 1; min-width: 10rem; }
.vault { flex: 1; display: grid; grid-template-columns: 14rem 20rem 1fr; min-height: 0; }
.vault > * { overflow: auto; padding: .75rem; }
nav, .list { border-right: 1px solid var(--line); }
nav button, .list li button { display: block; width: 100%; text-align: left; border: 0; background: none; border-radius: 8px; padding: .45rem .6rem; }
nav button:hover, .list li button:hover { background: var(--hover); }
nav button.active, .list li button.active { background: var(--accent); color: var(--accent-text); }
.list ul { list-style: none; margin: 0; padding: 0; }
.list li b, .list li span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li span { font-size: .85rem; opacity: .75; min-height: 1.2em; }
.detail { background: var(--panel); padding: 1.25rem !important; }
.detail .back { display: none; margin-bottom: .75rem; }
.row { display: flex; gap: .6rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row > span:first-child { width: 8.5rem; color: var(--muted); font-size: .85rem; flex-shrink: 0; }
.row .val, .row code { flex: 1; min-width: 8rem; word-break: break-word; }
.row pre { margin: 0; white-space: pre-wrap; font: inherit; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; }
details { margin: .75rem 0; }
summary { cursor: pointer; color: var(--muted); }
.generated { display: block; font-size: 1.05rem; background: var(--hover); padding: .8rem; border-radius: 8px; word-break: break-all; margin: .8rem 0 .3rem; min-height: 2.8rem; }

dialog { width: min(28rem, calc(100% - 1.5rem)); border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 1.25rem; }
dialog.wide { width: min(36rem, calc(100% - 1.5rem)); }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog > header { display: flex; justify-content: space-between; align-items: flex-start; }
#toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; max-width: calc(100% - 2rem); z-index: 10; box-shadow: 0 4px 16px rgb(0 0 0 / .25); }

.list details.group { margin: 0; border-bottom: 1px solid var(--line); }
.list details.group > summary { display: flex; justify-content: space-between; align-items: center; padding: .5rem .6rem; border-radius: 8px; color: var(--text); list-style: none; user-select: none; }
.list details.group > summary::-webkit-details-marker { display: none; }
.list details.group > summary::before { content: "▸"; width: 1.1em; color: var(--muted); }
.list details.group[open] > summary::before { content: "▾"; }
.list details.group > summary:hover { background: var(--hover); }
.list details.group > summary b { flex: 1; font-size: 1rem; }
.list details.group > summary span { color: var(--muted); font-size: .8rem; background: var(--hover); border-radius: 999px; padding: 0 .55em; }
.list details.group > ul { padding: 0 0 .4rem .6rem; }
ul.summary { padding-left: 1.2rem; }
ul.summary li { margin: .25rem 0; }
ul.preview { max-height: 14rem; overflow: auto; padding-left: 1.2rem; font-size: .9rem; }
.strength { margin: -.4rem 0 .85rem; }
.strength meter { width: 9rem; height: .8rem; vertical-align: middle; }
.strength .hints { margin: .3rem 0; padding-left: 1.2rem; color: var(--muted); font-size: .85rem; }
pre.codes { font: 600 1.05rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: .05em; background: var(--hover); padding: .8rem 1rem; border-radius: 8px; columns: 2; }
@media print {
  body > *:not(dialog.print) { display: none !important; }
  dialog.print { position: static; border: 0; width: auto; color: #000; background: #fff; }
  dialog.print .actions, dialog.print header button { display: none; }
}
button.link { border: 0; background: none; color: var(--accent); padding: .3rem .6rem; font-size: .85rem; }
input[type=file] { width: 100%; }

@media (max-width: 900px) {
  .vault { display: block; }
  .vault > * { border-right: 0; overflow: visible; }
  nav { display: flex; gap: .3rem; overflow-x: auto !important; border-bottom: 1px solid var(--line); }
  nav h3 { display: none; }
  nav button { width: auto; white-space: nowrap; border: 1px solid var(--line); }
  .vault .detail { display: none; }
  .vault.has-selection .detail { display: block; }
  .vault.has-selection .list, .vault.has-selection nav { display: none; }
  .detail .back { display: inline-block; }
  .row > span:first-child { width: 100%; }
}
