:root {
  --bg: #f6f2ea;
  --paper: #fffdf8;
  --ink: #23262e;
  --muted: #6b6a66;
  --line: #e2dbcd;
  --accent: #2f4b5c;
  --accent-ink: #fffdf8;
  --seal: #a3423b;
  --warn-bg: #fbeee0;
  --warn-ink: #7a3f12;
  --ok-bg: #e9f0e6;
  --ok-ink: #2f5130;
  --shadow: 0 1px 2px rgb(40 30 10 / 6%), 0 6px 20px rgb(40 30 10 / 5%);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181b;
    --paper: #1f2024;
    --ink: #ebe7df;
    --muted: #9c988f;
    --line: #34353a;
    --accent: #8db3c7;
    --accent-ink: #14161a;
    --seal: #d0726a;
    --warn-bg: #3a2a1b;
    --warn-ink: #f0c79d;
    --ok-bg: #22301f;
    --ok-ink: #b9d8b0;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
}

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 16px 80px;
}

h1,
h2,
h3 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 0.4em;
}
h1 {
  font-size: 2.1rem;
}
h2 {
  font-size: 1.45rem;
}
h3 {
  font-size: 1.1rem;
}
p {
  margin: 0 0 0.8em;
}
a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}
.center {
  text-align: center;
}
.stack > * + * {
  margin-top: 16px;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.spread {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.narrow {
  max-width: 460px;
  margin: 6vh auto 0;
}

.seal {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--seal);
  margin: 0 auto 16px;
  box-shadow: inset 0 0 0 4px rgb(255 255 255 / 18%), inset 0 0 0 8px rgb(0 0 0 / 8%);
}
.seal.broken {
  background: transparent;
  border: 2px dashed var(--seal);
  box-shadow: none;
}

/* forms */
label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 4px;
}
input,
textarea,
select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
}
textarea {
  min-height: 90px;
  resize: vertical;
}
textarea.tall {
  min-height: 260px;
  font-family: var(--serif);
}
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.field + .field {
  margin-top: 12px;
}
.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}
.check {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 400;
}
.check input {
  width: auto;
}
.inline-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

button {
  font: inherit;
  font-weight: 500;
  border-radius: 6px;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button.quiet {
  background: transparent;
  color: var(--accent);
}
button.danger {
  background: transparent;
  color: var(--seal);
  border-color: var(--seal);
}
button.link {
  border: none;
  background: none;
  color: var(--accent);
  padding: 0;
  text-decoration: underline;
}
button:disabled {
  opacity: 0.55;
  cursor: progress;
}
.big {
  padding: 12px 20px;
  font-size: 1.05rem;
}
.full {
  width: 100%;
}

.error {
  color: var(--seal);
  font-size: 0.9rem;
  min-height: 1.2em;
  margin-top: 8px;
}

/* banners */
.banner {
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.banner.warn {
  background: var(--warn-bg);
  color: var(--warn-ink);
}
.banner.ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
}
.banner p:last-child {
  margin-bottom: 0;
}

/* header + nav */
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.top h1 {
  font-size: 1.6rem;
  margin: 0;
}
nav.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  overflow-x: auto;
}
nav.tabs a {
  padding: 8px 12px;
  text-decoration: none;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
nav.tabs a[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* status strip */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}
.stat .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stat .value {
  font-family: var(--serif);
  font-size: 1.15rem;
}

/* sections and entries */
.section {
  margin-bottom: 28px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.section-head h2 {
  margin: 0;
}
.entries {
  display: grid;
  gap: 10px;
}
.entry {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}
.entry h3 {
  margin-bottom: 6px;
}
.entry dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 14px;
  margin: 0;
  font-size: 0.94rem;
}
.entry dt {
  color: var(--muted);
}
.entry dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.entry .prose {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--serif);
  font-size: 1.02rem;
}
.entry .actions {
  margin-top: 10px;
}
.empty {
  color: var(--muted);
  font-style: italic;
  font-size: 0.94rem;
}

@media (max-width: 560px) {
  .entry dl {
    grid-template-columns: 1fr;
  }
  .entry dd {
    margin-bottom: 6px;
  }
}

/* lists */
.list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.list li:last-child {
  border-bottom: none;
}
.pill {
  display: inline-block;
  font-size: 0.78rem;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--warn-bg);
  color: var(--warn-ink);
}

.passcode {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.15rem;
  letter-spacing: 0.04em;
  padding: 12px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  overflow-wrap: anywhere;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  padding: 24px;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
}
dialog::backdrop {
  background: rgb(0 0 0 / 35%);
}

#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.94rem;
  max-width: calc(100vw - 32px);
}

/* the read-only estate */
.reader-head {
  text-align: center;
  margin: 12px 0 32px;
}
.reader-head h1 {
  font-size: 2.3rem;
}

@media print {
  body {
    background: #fff;
    color: #000;
  }
  .no-print,
  nav.tabs,
  .top button,
  .entry .actions {
    display: none !important;
  }
  .entry,
  .card,
  .stat {
    box-shadow: none;
    break-inside: avoid;
  }
  main {
    padding: 0;
  }
}

/* layout helpers (inline style attributes are blocked by the CSP) */
.choices {
  justify-content: center;
  margin: 24px 0;
}
.sublabel {
  margin: 10px 0 2px;
}
.gap-top {
  margin-top: 16px;
}
.inline-label {
  margin: 0;
}
select.auto {
  width: auto;
}
.nowrap {
  flex-wrap: nowrap;
}

/* credit: a link back to the main site, on the landing view only */
.credit {
  margin-top: 2.5rem;
}
.credit a {
  color: inherit;
}
