:root {
  --bg: #f6f7f9; --panel: #fff; --text: #16181d; --muted: #6b7280; --line: #e5e7eb; --hover: #f2f4f7;
  --accent: #4f46e5; --accent-ink: #fff; --accent-soft: #eef2ff;
  --ok: #059669; --ok-soft: #ecfdf5; --warn: #b45309; --warn-soft: #fffbeb; --err: #dc2626; --err-soft: #fef2f2;
  --off: #6b7280; --off-soft: #f3f4f6; --info: #2563eb; --info-soft: #eff6ff;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f13; --panel: #15181e; --text: #e7e9ee; --muted: #8b93a1; --line: #262a33; --hover: #1c2028;
    --accent: #818cf8; --accent-ink: #0d0f13; --accent-soft: #1e1b4b;
    --ok: #34d399; --ok-soft: #052e22; --warn: #fbbf24; --warn-soft: #2d2006; --err: #f87171; --err-soft: #2d0f0f;
    --off: #9ca3af; --off-soft: #1f2329; --info: #60a5fa; --info-soft: #0c1a33;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h2:not(:first-child) { margin-top: 22px; }
h3 { font-size: 13.5px; margin: 16px 0 8px; }
code, .mono, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--hover); padding: 1px 5px; border-radius: 5px; }
pre { background: var(--hover); padding: 12px 14px; border-radius: 8px; overflow-x: auto; margin: 0; white-space: pre; flex: 1; min-width: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; min-width: 0; }
.warn-text { color: var(--warn); }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 12px; border-right: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: var(--text); padding: 4px 10px 18px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand img { width: 26px; height: 26px; }
.brand.big { justify-content: center; font-size: 24px; padding: 0 0 6px; }
.brand.big img { width: 36px; height: 36px; }
.nav nav { display: flex; flex-direction: column; gap: 2px; }
.nav nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav nav a:hover { background: var(--hover); text-decoration: none; }
.nav nav a[aria-current] { background: var(--accent-soft); color: var(--accent); }
.ico { flex: none; opacity: .85; vertical-align: -3px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.me .who { flex: 1; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; flex: none; }
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
main { padding: 28px 32px 40px; max-width: 1200px; width: 100%; }
footer { color: var(--muted); font-size: 12px; margin-top: 32px; text-align: center; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head p { margin: 0; }
.crumb { margin: 0 0 4px !important; font-size: 13px; color: var(--muted); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .empty, .pad { padding: 16px 20px; margin: 0; }
h2.pad { padding-bottom: 0; }
.card.highlight { border-color: var(--ok); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.grid2.tight { gap: 12px; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .card, .card + .grid2 { margin-top: 18px; }
.empty { color: var(--muted); margin: 4px 0; }
.more { margin-left: auto; font-size: 12.5px; font-weight: 500; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 18px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); display: grid; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat .n { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.stat .l { color: var(--muted); font-weight: 500; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* steps */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.steps li { display: flex; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; }
.steps li.done { opacity: .55; border-style: solid; }
.steps .check { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; color: var(--ok); }
.steps li.done .check { border-color: var(--ok); background: var(--ok-soft); }

/* pills & dots */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--off-soft); color: var(--off); white-space: nowrap; line-height: 20px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: none; }
.pill.synced, .pill.pending, .pill.error, .pill.offline, .pill.new { }
.pill.synced { background: var(--ok-soft); color: var(--ok); }
.pill.pending { background: var(--info-soft); color: var(--info); }
.pill.error { background: var(--err-soft); color: var(--err); }
.pill.offline { background: var(--warn-soft); color: var(--warn); }
.pill.new, .pill.off { background: var(--off-soft); color: var(--off); }
.pill.synced::before, .pill.pending::before, .pill.error::before, .pill.offline::before, .pill.new::before { display: inline-block; }
.pill.pending::before { animation: pulse 1.2s infinite; }
.pill.tag { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
a.pill:hover { text-decoration: none; filter: brightness(.95); }
h1 .pill { font-size: 12.5px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot.synced { background: var(--ok); } .dot.offline { background: var(--warn); } .dot.error { background: var(--err); } .dot.pending { background: var(--info); }
@keyframes pulse { 50% { opacity: .3; } }

/* lists & tables */
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; color: var(--text); }
a.row:hover { background: var(--hover); text-decoration: none; border-radius: 6px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th:first-child, .tbl td:first-child { padding-left: 20px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 20px; }
.tbl tbody tr[data-href] { cursor: pointer; }
.tbl tbody tr:hover { background: var(--hover); }
.tbl .dim td { opacity: .55; }
.as-login { display: flex; gap: 6px; align-items: center; color: var(--muted); font-weight: 500; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 72px 1fr; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.timeline .what { min-width: 0; overflow-wrap: anywhere; }
.timeline li.login .what strong::before { content: "→ "; color: var(--ok); }

/* forms */
label { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; row-gap: 5px; font-weight: 500; font-size: 13px; }
label > input:not([type=checkbox]):not([type=radio]), label > select, label > textarea, label > .field-err, label > .key-preview { flex: 1 1 100%; }
label > .muted.small { font-weight: 400; }
input, select, textarea { min-height: 38px; font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); margin: 0; }
label.check, label.radio { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.stack { display: grid; gap: 14px; }
.stack h3 { margin: 0; }
.forms { margin-top: 16px; }
.inline { display: flex; gap: 8px; }
.rule-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.rule-form > label { flex: 1 1 180px; }
.scope { border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px 10px; display: flex; gap: 16px; flex-wrap: wrap; margin: 0; flex: 3 1 420px; }
.scope legend { font-size: 13px; font-weight: 500; padding: 0 4px; }
.sm-input { width: 150px; padding: 4px 8px; }
.row-form { display: flex; gap: 10px; align-items: center; flex: 1; flex-wrap: wrap; }
.edit-row { display: flex; gap: 10px; align-items: center; }
.edit-row .row-form input { width: auto; }
.inline-del { margin: 0; }
details.add > summary { list-style: none; cursor: pointer; display: inline-block; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary .btn { background: var(--hover); color: var(--text); border-color: var(--line); }
details.add[open] > summary .btn::after { content: " (close)"; font-weight: 400; color: var(--muted); }
details.add:not([open]) { background: none; border: 0; box-shadow: none; padding: 0; }
.copyrow { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.key-line { display: block; overflow-wrap: anywhere; word-break: break-all; padding: 8px 10px; flex: 1; }
.meta { display: grid; grid-template-columns: 100px 1fr; gap: 8px 12px; margin: 0; }
.meta dt { color: var(--muted); font-size: 13px; }
.meta dd { margin: 0; min-width: 0; }
.meta dd .btn { margin-top: 6px; }
.danger-zone { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
.row-btns { display: flex; gap: 8px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 13.5px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); }
.btn.danger.armed { background: var(--err); color: #fff; border-color: var(--err); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.wide { width: 100%; }
.btn.done { color: var(--ok); }
button.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: 12.5px; }
button.link:hover { color: var(--text); text-decoration: underline; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg a { padding: 6px 12px; color: var(--muted); font-weight: 500; font-size: 13px; }
.seg a + a { border-left: 1px solid var(--line); }
.seg a[aria-current] { background: var(--accent-soft); color: var(--accent); }
.seg a:hover { text-decoration: none; }

/* flash */
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 32px 28px; }
.login-card form { text-align: left; }
.login-card .flash { text-align: left; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* responsive */
@media (max-width: 960px) {
  .steps { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px 6px; border-right: 0; border-bottom: 1px solid var(--line); gap: 4px 8px; }
  .brand { padding: 0 6px 0 2px; }
  .nav nav { order: 3; width: 100%; flex-direction: row; flex-wrap: wrap; gap: 2px; margin: 0 -4px; }
  .nav nav a { padding: 5px 8px; font-size: 13.5px; white-space: nowrap; }
  .nav nav a .ico { display: none; }
  .actions { width: 100%; }
  .sentence > label, .sentence .logins { flex: 1 1 100%; }
  .me { order: 2; margin: 0 0 0 auto; border: 0; padding: 0 4px; }
  .me .who, .me .avatar { display: none; }
  main { padding: 18px 14px 30px; }
  .stats { grid-template-columns: 1fr; gap: 10px; }
  .steps { grid-template-columns: 1fr; }
  .hide-s { display: none; }
  .tbl th, .tbl td { padding: 10px 8px; }
  .tbl th:first-child, .tbl td:first-child { padding-left: 14px; }
  .card { padding: 16px; }
}

/* ---------- accessibility ---------- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -40px; z-index: 50; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.skip:focus { top: 12px; }
main:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: -1px; }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- layout bits ---------- */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.stack-cards { display: grid; gap: 18px; min-width: 0; }
.stack-cards > .card { margin: 0; }
.narrow { max-width: 560px; }
.inline.wrap { flex-wrap: wrap; align-items: flex-end; }
.ok-text { color: var(--ok); }
.ok-text .ico { vertical-align: -4px; }
.empty-state { text-align: center; padding: 36px 20px; }
.empty-state h2 { justify-content: center; margin-bottom: 6px; }
.empty-state .btn { margin-top: 12px; }
.btn .ico { margin-left: -2px; }
.btn.lg { padding: 11px 16px; font-size: 15px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--hover); }
.nav nav a .ico { opacity: .75; }

/* flash */
.flash { display: flex; align-items: flex-start; gap: 10px; transition: opacity .4s; }
.flash > span { flex: 1; }
.flash.gone { opacity: 0; pointer-events: none; height: 0; padding: 0; margin: 0; border: 0; overflow: hidden; }
.flash-x { background: none; border: 0; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; opacity: .6; padding: 0 2px; }
.flash-x:hover { opacity: 1; }

/* toolbar + search */
.toolbar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.search { position: relative; display: flex; align-items: center; flex: 1; max-width: 380px; }
.search .ico { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; }
.group + .group { border-top: 1px solid var(--line); }
.group-head { padding: 16px 20px 4px; margin: 0 !important; }

/* forms */
.field-err { color: var(--err); font-size: 12.5px; font-weight: 500; }
[aria-invalid="true"], .danger-field { border-color: var(--err) !important; background: var(--err-soft); }
.key-preview { display: block; line-height: 1.6; overflow-wrap: anywhere; }
.sentence { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.sentence > label { flex: 0 1 auto; }
.sentence .word { padding-bottom: 9px; color: var(--muted); font-weight: 500; }
.sentence .logins { width: 160px; }
.sentence .wide { flex-basis: 100%; margin: 0; }
.rule-preview:empty { display: none; }
details.pw-alt { margin-top: 18px; text-align: left; }
details.pw-alt summary { cursor: pointer; color: var(--muted); font-size: 13px; text-align: center; list-style: none; }
details.pw-alt summary::-webkit-details-marker { display: none; }
details.pw-alt[open] summary { margin-bottom: 12px; }
details.add[open] { padding-top: 6px; }
details.add .forms { margin-top: 0; }

/* commands */
.cmd { display: flex; align-items: flex-start; gap: 6px; background: var(--hover); border: 1px solid var(--line); border-radius: 8px; padding: 4px 4px 4px 12px; min-width: 0; }
.cmd code, .cmd pre { background: none; padding: 7px 0; flex: 1; min-width: 0; overflow-wrap: anywhere; word-break: break-all; white-space: pre-wrap; }
.cmd .btn { flex: none; }
.cmd.big code { font-size: 13.5px; }
details.snippet { margin: 12px 0; }
details.snippet summary { cursor: pointer; font-weight: 600; font-size: 13.5px; margin-bottom: 8px; }
.meta dd .cmd { margin-top: 0; }

/* problems */
.problems { display: grid; gap: 12px; margin-bottom: 18px; }
.problem { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: var(--radius); padding: 14px 16px; }
.problem-head { display: flex; align-items: center; gap: 8px; color: var(--warn); }
.problem p { margin: 6px 0 10px; overflow-wrap: anywhere; }
.problem .cmd { background: var(--panel); }

/* add host */
.stepnum { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 12.5px; flex: none; }
.seg { margin-bottom: 18px; }
.enroll-live { border: 1px dashed var(--line); border-radius: 10px; padding: 12px 16px; }
.enroll-live .waiting { margin: 0; display: flex; align-items: center; gap: 8px; }
.enroll-live .joined:not(:empty) { margin-top: 10px; border-top: 1px solid var(--line); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.explain h3 { margin-top: 18px; }
.howto { margin: 0; padding-left: 22px; display: grid; gap: 8px; }
.howto li::marker { color: var(--accent); font-weight: 700; }
.bullets { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.row-btns { margin: 16px 0 0; }
