/* The admin page. Desktop first, down to a phone; light and dark. The CSP
   allows no inline styles, so every style is here. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f4f5f7;
  --surface-3: #eceef2;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eef3ff;
  --accent-text: #ffffff;
  --ok: #15803d;
  --ok-soft: #ecfdf3;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --warn-border: #fcd34d;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --code: #f3f4f6;
  --focus: rgb(37 99 235 / 35%);
  --shadow-s: 0 1px 2px rgb(17 24 39 / 5%);
  --shadow-l: 0 16px 40px rgb(17 24 39 / 20%);
  --radius: 10px;
  --radius-s: 7px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --surface: #14171c;
    --surface-2: #1a1e24;
    --surface-3: #222730;
    --text: #e7e9ee;
    --text-2: #c7ccd5;
    --muted: #8d95a3;
    --faint: #5f6877;
    --border: #262b33;
    --border-strong: #353b46;
    --accent: #6d9bff;
    --accent-hover: #8db1ff;
    --accent-soft: #16213a;
    --accent-text: #0b0d10;
    --ok: #4ade80;
    --ok-soft: #0f2418;
    --warn: #fbbf24;
    --warn-soft: #251d0c;
    --warn-border: #6b5414;
    --danger: #f87171;
    --danger-soft: #2a1213;
    --code: #1c2027;
    --focus: rgb(109 155 255 / 40%);
    --shadow-s: none;
    --shadow-l: 0 16px 48px rgb(0 0 0 / 55%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 10px; }

code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--code); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
pre {
  margin: 0;
  background: var(--code);
  padding: 10px 12px;
  border-radius: var(--radius-s);
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.noscript { padding: 24px; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack > * + * { margin-top: 16px; }
.mt { margin-top: 14px; }
.mt-s { margin-top: 8px; }
.flush { margin: 0; }

/* The header. */

.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: 1240px;
  height: 56px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
#nav { display: flex; gap: 4px; height: 100%; }
#nav a {
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
#nav a:hover { color: var(--text); text-decoration: none; }
#nav a.active { color: var(--text); border-bottom-color: var(--accent); }
.who { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--muted); white-space: nowrap; }

main { max-width: 1240px; margin: 0 auto; padding: 24px 24px 64px; }

/* Page headers and tabs. */

.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.app-head { margin-bottom: 0; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 16px 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs a {
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.tabs .count { margin-left: 6px; }

/* Cards. */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-s);
  min-width: 0;
}
.card + .card, .card + .grid, .grid + .card, .notice + .card, .toolbar + .card { margin-top: 20px; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px 18px; }
.card-body > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 20px; align-items: start; }
.grid > .card, .grid > * + .card { margin-top: 0; }
.cols-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols-main { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }

/* Pills, notices. */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 550;
  line-height: 20px;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.mono { font-family: var(--mono); font-weight: 500; font-size: 11.5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; flex: none; }

.notice {
  border: 1px solid transparent;
  border-radius: var(--radius-s);
  padding: 10px 14px;
  background: var(--accent-soft);
  color: var(--text);
}
.notice + * { margin-top: 16px; }
.notice.warn { background: var(--warn-soft); border-color: var(--warn-border); }
.notice.danger { background: var(--danger-soft); }
.notice.ok { background: var(--ok-soft); }
.notice ul { margin: 6px 0 0; padding-left: 18px; }

/* Forms. */

label { display: block; font-weight: 550; margin: 14px 0 6px; }
label:first-child { margin-top: 0; }
label .muted { font-weight: 400; }
input[type=text], input[type=password], input:not([type]), input[type=datetime-local], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-s);
  padding: 6px 10px;
  min-height: 34px;
}
textarea { resize: vertical; line-height: 1.45; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 420px; }
textarea.code.short { min-height: 110px; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--accent); }
button:focus-visible, a:focus-visible, .toggle:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input.code-input { font-family: var(--mono); letter-spacing: .2em; font-size: 16px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: middle; margin: 0; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; margin: 10px 0; }
.w-num { max-width: 12rem; }
.w-time { max-width: 15rem; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

button, .button {
  font: inherit;
  font-weight: 550;
  border-radius: var(--radius-s);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  height: 34px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  box-shadow: var(--shadow-s);
}
button:hover:not(:disabled), .button:hover { background: var(--surface-2); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { color: var(--danger); }
button.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger.solid:hover:not(:disabled) { filter: brightness(1.08); background: var(--danger); }
button.small, .button.small { height: 28px; padding: 0 9px; font-size: 12.5px; }
button.ghost { border-color: transparent; box-shadow: none; background: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
button.block { width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { border: 0; box-shadow: none; background: none; height: auto; padding: 0; color: var(--accent); font-weight: 500; }
button.link:hover:not(:disabled) { background: none; text-decoration: underline; }
svg.icon { width: 15px; height: 15px; flex: none; }

.problems { margin: 6px 0 0; padding-left: 18px; color: var(--danger); font-size: 12.5px; }
.problems li + li { margin-top: 2px; }

/* The toggle switch. */

.toggle {
  flex: none;
  position: relative;
  width: 40px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--border-strong);
  box-shadow: none;
  cursor: pointer;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 35%);
  transition: transform .15s ease;
}
.toggle[aria-checked=true] { background: var(--accent); }
.toggle[aria-checked=true]::after { transform: translateX(18px); }
.toggle:hover:not(:disabled), .toggle[aria-checked=true]:hover:not(:disabled) { filter: brightness(.95); }
.toggle.big { width: 48px; height: 26px; }
.toggle.big::after { width: 22px; height: 22px; }
.toggle.big[aria-checked=true]::after { transform: translateX(22px); }
.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle-row .state { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }

/* Apps. */

.apps { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.app-card { display: block; color: var(--text); padding: 18px; transition: border-color .12s; }
.app-card:hover { text-decoration: none; border-color: var(--accent); }
.app-card .name { display: flex; align-items: center; gap: 8px; }
.app-card .name h2 { font-size: 16px; }
.app-card .meta { color: var(--muted); margin-top: 4px; }
.app-card .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }

.empty { text-align: center; padding: 48px 24px; }
.empty h2 { font-size: 17px; margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 480px; margin: 0 auto 18px; }

.starters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

/* An app's overview. */

.switch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.switch-row:first-child { border-top: 0; }
.switch-row.alert { background: var(--warn-soft); }
.switch-row .info { flex: 1; min-width: 0; }
.switch-row .key { font: 600 13px var(--mono); }
.switch-row .desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.switch-row .state { font-weight: 600; font-size: 12.5px; text-align: right; min-width: 5.5rem; }
.switch-row.alert .state { color: var(--warn); }

.big { font-size: 30px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.kvs { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.kvs dt { color: var(--muted); }
.kvs dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.quote { border-left: 3px solid var(--border-strong); padding: 2px 0 2px 12px; color: var(--text-2); margin: 12px 0; }
.url { display: flex; align-items: center; gap: 8px; min-width: 0; }
.url code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Diffs. */

.diff { list-style: none; padding: 0; margin: 0; }
.diff li { padding: 9px 0; border-top: 1px solid var(--border); min-width: 0; }
.diff li:first-child { border-top: 0; padding-top: 0; }
.diff .k { font: 600 12.5px var(--mono); }
.diff .v { font-family: var(--mono); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; color: var(--text-2); }
.diff .old { color: var(--danger); text-decoration: line-through; text-decoration-thickness: 1px; }
.diff .new { color: var(--ok); }
.diff .arrow { color: var(--faint); margin: 0 4px; }
.diff.scroll { max-height: 42vh; overflow-y: auto; }

/* The draft editor. */

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .status { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.toolbar .status.saving { color: var(--accent); }
.toolbar .status.bad { color: var(--danger); }
.toolbar .status.saved .dot { color: var(--ok); }

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.editor > .side { position: sticky; top: 76px; }
.editor .groups > .card + .card { margin-top: 16px; }

.kv {
  position: relative;
  display: grid;
  grid-template-columns: minmax(200px, 330px) minmax(0, 1fr);
  gap: 8px 28px;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}
.kv:first-child { border-top: 0; }
.kv::before {
  content: "";
  position: absolute;
  left: 0;
  top: 12px;
  bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
}
.kv.changed::before { background: var(--accent); }
.kv.bad::before { background: var(--danger); }
.kv-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv-name code { font: 600 13px var(--mono); background: none; padding: 0; color: var(--text); }
.kv-desc {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.kv-desc.open { display: block; cursor: auto; }
.kv-control { min-width: 0; }
.kv-live { color: var(--muted); font-size: 12px; margin-top: 6px; overflow-wrap: anywhere; }
.kv-live code { font-size: 11.5px; }

.sub-rows { display: grid; gap: 6px; }
.sub-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.sub-row .lang { font: 600 12px var(--mono); color: var(--muted); padding-top: 8px; }
.sub-row textarea { min-height: 34px; height: 34px; resize: none; overflow: hidden; }
.shares { border: 1px solid var(--border); border-radius: var(--radius-s); overflow: hidden; }
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem; gap: 10px; align-items: center; padding: 6px 6px 6px 12px; border-top: 1px solid var(--border); }
.share-row:first-child { border-top: 0; }
.share-row .addr { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.share-row input { text-align: right; }
.share-total { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; border-top: 1px solid var(--border); }
.share-total.off { color: var(--danger); background: var(--danger-soft); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.time-row { display: flex; gap: 8px; align-items: center; }

.publish .count { margin-left: 2px; }
.jumpbar { display: none; }
.publish form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.publish .why { color: var(--muted); margin-top: 12px; }

/* Tables. */

.table .trow {
  display: grid;
  gap: 16px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  align-items: start;
  min-width: 0;
}
.table .trow > * { min-width: 0; }
.table .trow:first-child { border-top: 0; }
.table .trow.head {
  padding: 9px 18px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-radius: var(--radius) var(--radius) 0 0;
}
.table .trow.live { background: var(--ok-soft); }
.history .trow { grid-template-columns: 150px 190px minmax(0, 1fr) minmax(0, 1.2fr) 190px; }
.audit .trow { grid-template-columns: 150px 170px 90px 130px minmax(0, 1fr); }
.keyrows .trow { grid-template-columns: 210px minmax(0, 1fr) 230px; }
.trow .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.trow .keys { display: flex; gap: 4px; flex-wrap: wrap; }
.trow details summary { color: var(--accent); cursor: pointer; font-size: 12.5px; }
.trow details pre { margin-top: 8px; font-size: 11.5px; }
.values-table .trow { grid-template-columns: 260px minmax(0, 1fr); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; min-width: 12rem; }
.more { margin-top: 16px; }

/* Setup, sign-in, account. */

.auth { max-width: 420px; margin: 48px auto; }
.auth.wide { max-width: 860px; }
.auth .card-body { padding: 24px; }
.auth h1 { margin-bottom: 6px; }
.auth .lead { color: var(--muted); margin-bottom: 20px; }
.setup-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; }
.setup-cols h2 { margin-bottom: 12px; }
.step { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-right: 8px; }
.qr { background: #fff; padding: 8px; border-radius: var(--radius-s); border: 1px solid var(--border); width: 196px; height: 196px; display: block; }
.secret { font-family: var(--mono); font-size: 13px; letter-spacing: .06em; overflow-wrap: anywhere; }
.codes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; font-family: var(--mono); font-size: 14px; padding: 14px 18px; background: var(--code); border-radius: var(--radius-s); list-style: none; margin: 14px 0; }

/* Dialogs and toasts. */

dialog {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(480px, calc(100vw - 24px));
  box-shadow: var(--shadow-l);
}
dialog.wide { width: min(680px, calc(100vw - 24px)); }
dialog::backdrop { background: rgb(9 11 15 / 50%); }
dialog form { padding: 20px 22px; }
dialog h2 { font-size: 17px; margin-bottom: 12px; }
dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
dialog .notice { margin-top: 12px; }

#toasts {
  position: fixed;
  right: 20px;
  top: 68px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none; /* never in the way of a click */
}
#toasts .toast:nth-last-child(n+4) { display: none; }
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 9px;
  box-shadow: var(--shadow-l);
  font-size: 13.5px;
}
.toast.error { background: var(--danger); color: #fff; }

/* Narrower screens. */

@media (max-width: 1100px) {
  .editor { grid-template-columns: minmax(0, 1fr) 320px; }
  .kv { grid-template-columns: minmax(170px, 260px) minmax(0, 1fr); gap: 8px 20px; }
  .history .trow { grid-template-columns: 130px 170px minmax(0, 1fr) minmax(0, 1fr) 170px; }
}

@media (max-width: 900px) {
  .cols-2, .cols-main, .setup-cols { grid-template-columns: minmax(0, 1fr); }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor > .side { position: static; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .table .trow { grid-template-columns: minmax(0, 1fr) !important; gap: 4px; }
  .table .trow.head { display: none; }
  .trow .actions { justify-content: flex-start; margin-top: 6px; }
  .jumpbar:not([hidden]) {
    position: sticky;
    bottom: 12px;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding: 10px 12px 10px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-l);
    font-weight: 600;
  }
}

@media (max-width: 600px) {
  body { font-size: 15px; }
  input[type=text], input[type=password], input:not([type]), input[type=datetime-local], select, textarea { font-size: 16px; min-height: 40px; }
  button, .button { height: 38px; }
  .top-inner { padding: 0 14px; gap: 14px; }
  .brand span { display: none; }
  .who #whoname { display: none; }
  main { padding: 18px 14px 56px; }
  .card-head, .card-body, .kv, .switch-row { padding-left: 14px; padding-right: 14px; }
  .codes { grid-template-columns: 1fr; }
  #toasts { right: 12px; top: 64px; }
}
