:root {
  --bg: #f7f6f2; --fg: #1d1d1f; --muted: #6b6b70; --card: #ffffff; --line: #e3e1da;
  --accent: #2f6f5e; --accent-fg: #ffffff; --error: #b3261e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141416; --fg: #ececee; --muted: #a0a0a8; --card: #1e1e22; --line: #34343a;
    --accent: #6cc3a8; --accent-fg: #0b1f19; --error: #ff8a80;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.topbar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between;
  padding: max(.75rem, env(safe-area-inset-top)) 1rem .75rem; border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; }
.nav { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; }
.nav a, button.link { color: var(--fg); text-decoration: none; background: none; border: 0;
  font: inherit; cursor: pointer; padding: .25rem 0; }
.page { max-width: 56rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem; }
.narrow { max-width: 26rem; margin: 2rem auto; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
label { display: block; margin: 0 0 1rem; font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], select { display: block; width: 100%; margin-top: .35rem;
  padding: .7rem .8rem; font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; }
button, .button { min-height: 44px; padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--fg); font: inherit; cursor: pointer; display: inline-block; text-decoration: none; }
.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.error { color: var(--error); font-weight: 600; }
.muted { color: var(--muted); }
.inline { display: inline; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
main a { color: var(--accent); }
.recent button.link { color: var(--accent); text-decoration: underline; min-height: 44px; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.notice { color: var(--accent); font-weight: 600; }
.warning { color: var(--error); font-weight: 600; }
.badge { display: inline-block; padding: 0 .4rem; border: 1px solid var(--line); border-radius: 6px;
  font-size: .85rem; font-weight: 400; color: var(--muted); }
.nav a.add { font-weight: 700; }
textarea, input[type=search] { display: block; width: 100%; margin-top: .35rem; padding: .7rem .8rem;
  font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
details { margin: 0 0 1rem; }
summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 1rem; padding: .75rem 1rem; }
legend { font-weight: 600; padding: 0 .25rem; }
label.check { display: inline-flex; min-width: 44px; min-height: 44px; align-items: center; margin: 0; }
input[type=checkbox] { width: 1.15rem; height: 1.15rem; }
.direction { display: block; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  border-bottom: 1px solid var(--line); }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; }
.fields dt { font-weight: 600; margin-top: .5rem; }
.fields dd { margin: 0; }
.prewrap { white-space: pre-wrap; }
@media (min-width: 48rem) {
  .filters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
  .filters .actions, .filters label:first-child { grid-column: 1 / -1; }
  .bulk { display: grid; grid-template-columns: repeat(3, 1fr) auto; gap: 0 1rem; align-items: end; }
  .bulk button { margin-bottom: 1rem; }
}
@media (max-width: 47.99rem) {
  table.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: .75rem; padding: .25rem .5rem; }
  table.cards td { border: 0; padding: .25rem 0; }
  table.cards td:empty { display: none; }
  table.cards td[data-label]::before { content: attr(data-label); display: block; font-size: .8rem;
    color: var(--muted); font-weight: 600; }
}
.flash { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 8px; padding: .5rem 1rem; margin-bottom: 1rem; }
.flash.error { border-left-color: var(--error); }
.trash-row { display: flex; flex-wrap: wrap; gap: .5rem 1rem; justify-content: space-between; align-items: center;
  padding: .5rem 0; border-bottom: 1px solid var(--line); }
.trash-row .muted { display: block; }
