:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --text: #1d1d1f;
  --muted: #6b6b70;
  --line: #dedbd4;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --bad: #b3261e;
  --notice: #fff6dd;
  --notice-line: #ead9a6;
  --field: #ffffff;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --card: #222225;
    --text: #ececef;
    --muted: #a0a0a8;
    --line: #38383d;
    --accent: #58b89d;
    --accent-text: #0e1a16;
    --ok: #58c785;
    --bad: #ff7b72;
    --notice: #33301f;
    --notice-line: #5a5230;
    --field: #1a1a1d;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
a { color: var(--accent); }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
pre { white-space: pre-wrap; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 6px; }
.wrap { word-break: break-all; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin: 0 0 16px; }
.narrow { max-width: 420px; margin: 10vh auto 0; }
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.top-actions { display: flex; gap: 14px; align-items: center; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); margin: 2px 0; }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; }
.stack label.check { flex-direction: row; align-items: center; gap: 8px; }
.small-gap { gap: 6px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline input { flex: 1 1 200px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.notice { background: var(--notice); border: 1px solid var(--notice-line); border-radius: 8px; padding: 8px 12px; }
.error { color: var(--bad); }
.error-text { color: var(--bad); }
.ok-text { color: var(--ok); }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
textarea { width: 100%; resize: vertical; }
button, a.button {
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
a.button { display: inline-block; text-decoration: none; }
button:disabled { opacity: 0.5; cursor: default; }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
button.linklike { background: none; color: var(--accent); padding: 0; text-decoration: underline; }
button.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.example { border-left: 3px solid var(--accent); padding: 2px 0 2px 12px; font-style: italic; }
ol.steps { padding-left: 1.4em; }
ol.steps li { margin: 4px 0; }
#new-key { display: grid; gap: 10px; margin: 0 0 12px; }
#new-key .notice { margin: 0; }
.extra > details > summary { font-weight: 600; }
details summary { cursor: pointer; color: var(--accent); }
details[open] summary { margin-bottom: 8px; }

/* nudges */
.nudge { border-top: 1px solid var(--line); padding: 14px 0; }
.nudge:first-child { border-top: 0; }
.nudge-top { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.nudge-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.field { display: flex; align-items: center; gap: 6px; }
.field.prompt { display: block; }
.actions { display: flex; gap: 8px; }
.days { display: flex; gap: 3px; }
.days button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 5px 0;
  width: 2.3em;
  font-size: 0.85rem;
}
.days button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.state { font-size: 0.85rem; min-width: 1em; color: var(--muted); }
.state.ok { color: var(--ok); font-weight: 700; }
.state.bad { color: var(--bad); }
.result .message {
  white-space: pre-wrap;
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 10px;
}
#add { margin-top: 8px; }

/* admin */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; vertical-align: top; padding: 8px 6px; border-top: 1px solid var(--line); }
th { font-size: 0.8rem; color: var(--muted); font-weight: 600; border-top: 0; }
table.log td.pre { max-width: 340px; }
#wa-qr { display: block; margin: 12px 0; background: #fff; padding: 8px; border-radius: 8px; }

@media (max-width: 560px) {
  .top { flex-direction: column; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
}
