:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #17202b;
  --muted: #5d6b7a;
  --line: #dde2e8;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --danger: #b42318;
  --ok: #157f3b;
  --warn: #9a6700;
  --warn-bg: #fff6db;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c;
    --card: #1a2129;
    --text: #e6ebf0;
    --muted: #9aa8b6;
    --line: #2c3742;
    --accent: #5b9bff;
    --accent-text: #0b1520;
    --danger: #ff7b72;
    --ok: #56d364;
    --warn: #e3b341;
    --warn-bg: #2b2412;
  }
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
p { line-height: 1.45; }
pre { background: var(--card); border: 1px solid var(--line); padding: 0.75rem; border-radius: var(--radius); overflow-x: auto; }
.boot { padding: 2rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--danger); min-height: 0; margin: 0.25rem 0; }
.error:empty { display: none; }
.ok { color: var(--ok); }
.warn-text { color: var(--warn); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  padding: 0.6rem 1rem; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; display: flex; align-items: center; gap: 0.45rem; }
.logo { color: var(--accent); }

.row { display: flex; align-items: center; gap: 0.5rem; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 1rem; }
.row.between { justify-content: space-between; }

button, .button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 0.5rem 0.9rem;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
button:disabled { opacity: 0.55; cursor: progress; }
button.secondary { background: transparent; color: var(--accent); }
button.ghost, .button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger.ghost { background: transparent; color: var(--danger); border-color: var(--line); }
button.small, .button.small { padding: 0.25rem 0.55rem; font-size: 0.85rem; }
button.icon { background: transparent; border: none; padding: 0.35rem; font-size: 1rem; color: var(--text); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 0.55rem 0.65rem; width: 100%;
}
input[type="checkbox"] { width: auto; }
input[type="range"] { flex: 1; }
label { display: block; margin: 0.6rem 0; font-weight: 600; font-size: 0.92rem; }
label > input, label > textarea, label > .row, label > select { margin-top: 0.3rem; font-weight: 400; }
label.inline { display: flex; align-items: center; gap: 0.5rem; }
label.inline select { width: auto; }
label.check { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 400; margin: 0.3rem 0.6rem 0.3rem 0; }

main.narrow { max-width: 30rem; margin: 2.5rem auto; padding: 0 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card > button[type="submit"], #unlock-key { width: 100%; margin-top: 0.5rem; }
.or { text-align: center; color: var(--muted); margin: 0.75rem 0 0.25rem; }
.hint { font-size: 0.85rem; margin-top: -0.3rem; }
.hint.bad { color: var(--danger); }
.hint.warn { color: var(--warn); }
.hint.good { color: var(--ok); }

main.vault { max-width: 70rem; margin: 0 auto; padding: 1rem; }
.split { display: grid; grid-template-columns: minmax(16rem, 22rem) 1fr; gap: 1rem; align-items: start; }
.side { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; }
.list { list-style: none; margin: 0.75rem 0 0; padding: 0; max-height: calc(100vh - 11rem); overflow-y: auto; }
.item { display: flex; align-items: center; border-radius: 8px; }
.item.active, .item:hover { background: var(--bg); }
.item-main {
  flex: 1; min-width: 0; text-align: left; background: transparent; border: none; color: var(--text);
  display: flex; flex-direction: column; align-items: flex-start; padding: 0.5rem;
}
.item-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.item-sub { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.empty { color: var(--muted); padding: 0.75rem 0.5rem; }
.pane { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; min-height: 16rem; }
.placeholder { color: var(--muted); }
.detail h2 { margin-top: 0.9rem; overflow-wrap: anywhere; }
.back { display: none; }
.field { display: grid; grid-template-columns: 7rem 1fr auto; gap: 0.5rem; align-items: center; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.field.multiline { align-items: start; }
.field .label { color: var(--muted); font-size: 0.9rem; }
.field .value { overflow-wrap: anywhere; white-space: pre-wrap; }
.field .secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.editor .row input { flex: 1; }
.conflict { display: none; border: 1px solid var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 0.75rem; margin-bottom: 0.75rem; }
.conflict.show { display: block; }
.conflict p { margin: 0.4rem 0; }
dl.remote { display: grid; grid-template-columns: 6rem 1fr; gap: 0.2rem 0.6rem; margin: 0.4rem 0; }
dl.remote dt { color: var(--muted); }
dl.remote dd { margin: 0; overflow-wrap: anywhere; }
.banner { border-radius: 8px; padding: 0.75rem; margin-bottom: 1rem; }
.banner.warn { border: 1px solid var(--warn); background: var(--warn-bg); }

main.settings { max-width: 46rem; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
.settings-section .row.wrap input[type="text"] { flex: 1; min-width: 12rem; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.hidden-file { display: none; }

.backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 45%); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 20; }
.modal { background: var(--card); border-radius: var(--radius); padding: 1.25rem; width: 100%; max-width: 28rem; border: 1px solid var(--line); }
.modal input.mono { font-size: 1.05rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%) translateY(150%);
  background: var(--text); color: var(--bg); padding: 0.65rem 1rem; border-radius: 8px; max-width: min(92vw, 34rem);
  transition: transform 0.2s ease; z-index: 30; font-size: 0.92rem;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  main.vault { padding: 0.5rem; }
  .split { grid-template-columns: 1fr; }
  .pane { display: none; }
  body.pane-open .pane { display: block; }
  body.pane-open .side { display: none; }
  .back { display: inline-flex; }
  .field { grid-template-columns: 1fr auto; }
  .field .label { grid-column: 1 / -1; }
  header.top button { padding: 0.4rem 0.6rem; }
  .list { max-height: none; }
}
