:root {
  color-scheme: light dark;
  --fg: #1d1d1f;
  --bg: #fafafa;
  --surface: #ffffff;
  --muted: #6b6b70;
  --line: #d8d8dc;
  --stripe: #f2f2f4;
  --accent: #2f5fb3;
  --on-accent: #ffffff;
  --danger: #b3261e;
  --on-danger: #ffffff;
  --warn-bg: #fff6d6;
  --warn-line: #d9b54a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #ececee;
    --bg: #18181a;
    --surface: #222225;
    --muted: #a0a0a8;
    --line: #3a3a3e;
    --stripe: #1f1f22;
    --accent: #8fb0ee;
    --on-accent: #111114;
    --danger: #f2a49c;
    --on-danger: #111114;
    --warn-bg: #3a3218;
    --warn-line: #8a7330;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.7;
}
main { max-width: 36rem; margin: 0 auto; padding: 3rem 1rem; }
body.admin main { max-width: 64rem; padding-top: 1.5rem; }
h1 { font-size: 1.5rem; line-height: 1.4; margin: 0 0 1.5rem; }
h2 { font-size: 1.15rem; line-height: 1.4; margin: 2.5rem 0 1rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
a { color: var(--accent); }
code { font-size: 0.9em; overflow-wrap: anywhere; }

ul.services { list-style: none; padding: 0; margin: 0 0 2rem; border-top: 1px solid var(--line); }
ul.services li { border-bottom: 1px solid var(--line); padding: 0.75rem 0; }

nav.admin {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0 0 2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}
nav.admin a { color: var(--muted); text-decoration: none; padding: 0.25rem 0; }
nav.admin a:hover { color: var(--fg); }
nav.admin a[aria-current="page"] {
  color: var(--fg);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}
nav.admin a.site { margin-left: auto; }

.table { overflow-x: auto; margin: 0 0 1.5rem; border-top: 1px solid var(--line); }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; vertical-align: top; padding: 0.55rem 0.75rem 0.55rem 0; border-bottom: 1px solid var(--line); }
th { font-size: 0.85rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
td { overflow-wrap: break-word; }
tbody tr:nth-child(even) td { background: var(--stripe); }
td:first-child, th:first-child { padding-left: 0.5rem; }
.nowrap, td.when { white-space: nowrap; overflow-wrap: normal; }
td.actions { white-space: nowrap; }
td.actions form { display: inline-block; margin: 0 0.25rem 0.25rem 0; }
.id { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; overflow-wrap: anywhere; }

tr.status-suspended td:first-child { box-shadow: inset 3px 0 var(--warn-line); }
tr.status-revoked td { color: var(--muted); }
.badge { display: inline-block; font-size: 0.8rem; padding: 0 0.5rem; border: 1px solid var(--line); border-radius: 999px; white-space: nowrap; }
.badge.warn { background: var(--warn-bg); border-color: var(--warn-line); }

dl.kv { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0 0.75rem; font-size: 0.85rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
dl.kv dd.raw { grid-column: 1 / -1; }
.table > table { min-width: 44rem; }
td.vals { min-width: 12rem; }
td.op { min-width: 9rem; }
td.id { min-width: 8rem; max-width: 11rem; }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0 0 1.5rem; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; overflow-wrap: anywhere; }

.warning, .notice {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 0 0 1.5rem;
}
.warning { background: var(--warn-bg); border-color: var(--warn-line); }
.warning p:last-child, .notice p:last-child { margin-bottom: 0; }

.link {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
  user-select: all;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 1rem;
}

.button, button {
  display: inline-block;
  font: inherit;
  line-height: 1.5;
  padding: 0.45rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:hover, button:hover { border-color: var(--muted); }
.button.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
button.danger.quiet { background: var(--surface); color: var(--danger); border-color: var(--danger); }
form.inline { display: inline; }
form { margin: 0 0 1rem; }
.actions-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 1.5rem 0; }
.actions-row form { margin: 0; }

label { cursor: pointer; }
input[type="text"], input[type="email"], input[type="date"] {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--muted);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  max-width: 100%;
}
input[type="text"], input[type="email"] { width: 22rem; }
input:focus-visible, button:focus-visible, .button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.field { margin: 0 0 1rem; }
.field > label:first-child, .field-label { display: block; font-size: 0.9rem; color: var(--muted); margin-bottom: 0.25rem; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 0.75rem 1rem; margin: 0 0 1rem; }
legend { padding: 0 0.25rem; font-size: 0.9rem; color: var(--muted); }
.choice { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.choice:last-of-type { border-bottom: 0; }
.choice .roles { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.25rem 0 0 1.6rem; font-size: 0.95rem; }
.choice .roles label { white-space: nowrap; }
.inline-fields { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; }

@media (max-width: 40rem) {
  main, body.admin main { padding: 1.5rem 1rem; }
  input[type="text"], input[type="email"] { width: 100%; }
  nav.admin a.site { margin-left: 0; }
}
