/* One theme: pure black background, dark panels. */
:root {
  --bg: #000000;
  --surface: #0e0e0e;
  --surface-2: #161616;
  --text: #ededed;
  --muted: #9a9a9a;
  --line: #262626;
  --accent: #5b8cff;
  --accent-text: #050505;
  --danger: #ff6b72;
  --focus: #5b8cff66;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.6), 0 8px 24px rgb(0 0 0 / 0.5);
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none; font-weight: 500;
}
.btn:hover { border-color: color-mix(in srgb, var(--text) 25%, var(--line)); }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- auth pages ---------- */
.center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.brand { font-weight: 700; letter-spacing: -0.02em; font-size: 20px; display: flex; align-items: center; gap: 8px; }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.card h1 { font-size: 17px; font-weight: 600; margin: 18px 0 16px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
input[type=text], input[type=password] {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
}
/* password field with a show/hide button (password.js) */
.pw { position: relative; display: block; }
.pw input { padding-right: 44px; }
.pw input::-ms-reveal { display: none; } /* Edge's own reveal button */
.pw-toggle {
  position: absolute; right: 2px; top: 2px; width: 36px; height: 36px; display: grid; place-items: center;
  padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { color: var(--text); }
.pw-toggle:focus-visible { outline: 3px solid var(--focus); }
.pw-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card .btn.primary { width: 100%; margin-top: 20px; height: 40px; }
.error { color: var(--danger); font-size: 14px; margin: 12px 0 0; min-height: 1em; }
.card .alt { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.card .btn.wide { width: 100%; height: 40px; margin-top: 10px; }
.card .note { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.card .note.done { color: var(--text); font-size: 14px; }
.card input[readonly] { color: var(--muted); }

/* ---------- library ---------- */
header.bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--bg);
}
header.bar { gap: 8px 12px; flex-wrap: wrap; }
header.bar .bar-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
main.lib { max-width: 860px; margin: 0 auto; padding: 28px 16px 60px; }
.drop {
  border: 1.5px dashed color-mix(in srgb, var(--muted) 45%, transparent);
  border-radius: 14px; padding: 34px 20px; text-align: center; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.drop p { margin: 0 0 14px; font-size: 16px; }
.drop small { display: block; margin-top: 12px; color: var(--muted); font-size: 13px; }
h2 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 32px 0 10px; text-transform: uppercase; letter-spacing: .06em; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--muted); font-size: 13px; margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .sub .bad { color: var(--danger); }
.item .actions { display: flex; gap: 6px; flex-shrink: 0; }
.meter { width: 120px; height: 5px; background: var(--line); border-radius: 3px; overflow: hidden; display: inline-block; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.pill { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.item .sub .status { display: inline-flex; align-items: center; gap: 8px; }
.item .sub .viewing { display: inline-flex; align-items: center; gap: 5px; }
.item .sub .viewing i { width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 3px rgb(61 220 132 / 0.15); }
/* a site's name: click it to rename in place */
.item .name.rename {
  display: block; max-width: 100%; margin: -2px 0 -2px -6px; padding: 2px 6px; border: 0; border-radius: 6px;
  background: none; color: inherit; font: inherit; font-weight: 600; text-align: left; cursor: text;
}
.item .name.rename:hover { background: var(--surface-2); }
.item .name.rename:focus-visible { outline: 3px solid var(--focus); }
.item input.name-edit { display: block; width: 100%; max-width: 480px; height: 28px; margin: -3px 0 -3px -7px; padding: 0 6px; font-weight: 600; }
.btn.small { height: 28px; padding: 0 8px; font-size: 13px; }
dialog input[type=text] { margin: 4px 0 0; }
@media (max-width: 600px) {
  header.bar { padding: 12px 16px; }
  header.bar .btn { padding: 0 8px; }
  .item { flex-wrap: wrap; }
  .item .actions { width: 100%; flex-wrap: wrap; }
  .item .actions .btn { flex: 1; }
}

/* ---------- your account ---------- */
main.lib.narrow { max-width: 520px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.panel label:first-of-type { margin-top: 0; }
.panel .btn.primary { margin-top: 18px; }
.panel .note { color: var(--text); font-size: 14px; margin: 12px 0 0; }
.panel .error:empty { display: none; }

/* ---------- accounts page ---------- */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 32px 0 10px; }
.head h2 { margin: 0; }
.item .name .pill { margin-left: 8px; font-weight: 500; vertical-align: 1px; }
.pill.plain { background: var(--surface-2); color: var(--muted); }
.item .name a { color: inherit; text-decoration: none; }
.item .name a:hover { text-decoration: underline; }

dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(0 0 0 / 0.7); }
dialog h3 { margin: 0 0 8px; font-size: 17px; overflow-wrap: anywhere; }
dialog p { margin: 0 0 16px; color: var(--muted); }
dialog .row { display: flex; gap: 8px; }
dialog .row input { flex: 1; min-width: 0; font-size: 13px; }
dialog p.hint { margin: 12px 0 0; font-size: 13px; }
dialog p.hint strong { color: var(--text); font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; white-space: nowrap; }
dialog .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 20px; }
dialog .foot .right { display: flex; gap: 8px; margin-left: auto; }
