:root {
  color-scheme: light;
  --paper: #f6f3eb;
  --surface: #fdfbf5;
  --ink: #222b25;
  --muted: #565f55;
  --rule: #cbcfc1;
  --green: #224d39;
  --green-hover: #173a2a;
  --accent: #85471d;
  --error: #862e23;
  font: 100%/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }
a { color: var(--green); text-decoration-thickness: .08em; text-underline-offset: .19em; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; line-height: 1.1; }
p { margin: 0 0 1em; }

.shell { width: min(100% - 2.75rem, 52rem); margin-inline: auto; }
.shell.wide { width: min(100% - 2.75rem, 70rem); }
main { flex: 1; }
.site-header { border-bottom: 1px solid var(--rule); }
.site-header nav { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 2.25rem; min-height: 4.5rem; }
.site-header a { text-decoration: none; }
.site-header a:hover { text-decoration: underline; }
.wordmark { font: bold 1.28rem Georgia, "Times New Roman", serif; letter-spacing: -.02em; }
.site-footer { border-top: 1px solid var(--rule); margin-top: 4rem; padding-block: 1.25rem 1.75rem; }
.site-footer p { max-width: 60ch; margin: 0; color: var(--muted); font-size: .875rem; }
.skip-link { position: absolute; top: 0; left: 1rem; translate: 0 -125%; padding: .5rem; background: var(--surface); z-index: 2; }
.skip-link:focus { translate: 0 0; }

.blog-heading { padding-block: clamp(3.25rem, 9vw, 7rem) 2.8rem; }
.blog-heading h1 { margin: 0 0 .85rem; color: var(--green-hover); font-size: clamp(3rem, 10vw, 7rem); font-weight: 500; letter-spacing: -.062em; }
.blog-heading p { margin: 0; color: var(--muted); font-size: clamp(1.06rem, 2.3vw, 1.25rem); }
.post-list { list-style: none; margin: 0; padding: 0; }
.empty-list, .post-list-item { padding-block: 1.5rem; border-top: 1px solid var(--rule); }
.empty-list { color: var(--muted); }
.post-list-item h2 { margin: 0 0 .4rem; font-size: clamp(1.5rem, 3vw, 2.1rem); }
.post-list-item h2 a { color: var(--ink); text-decoration: none; }
.post-list-item h2 a:hover { color: var(--green); text-decoration: underline; }
.post-list-item p { max-width: 58ch; margin: .7rem 0 0; }
.post-list-item time, .post-heading time { color: var(--muted); font-size: .925rem; }

.reading { max-width: 43rem; margin-inline: auto; padding-top: 2.4rem; }
.back-link { font-size: .9rem; }
.post-heading { padding-block: 1.5rem; border-bottom: 1px solid var(--rule); margin-bottom: 2rem; }
.post-heading h1, .message-page h1 {
  margin: 0 0 .9rem; font-size: clamp(2.45rem, 6vw, 4.4rem); letter-spacing: -.049em; overflow-wrap: anywhere;
}
.post-heading p { display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1rem; color: var(--muted); margin: 0; }
.prose { font-size: 1.07rem; line-height: 1.7; overflow-wrap: anywhere; }
.prose h1, .prose h2, .prose h3 { margin: 1.3em 0 .5em; }
.prose img:not(.mana-symbol) { display: block; max-width: 100%; height: auto; border-radius: .25rem; }
.mana-symbol { display: inline-block; width: 1.1em; height: 1.1em; vertical-align: -.16em; }
.prose pre { max-width: 100%; overflow: auto; background: var(--surface); border: 1px solid var(--rule); padding: 1rem; }
.prose blockquote { border-inline-start: 3px solid var(--rule); padding-inline-start: 1rem; margin-inline: 0; color: var(--muted); }
.prose table { display: block; width: fit-content; max-width: 100%; overflow: auto; border-collapse: collapse; }
.prose th, .prose td { padding: .45rem .75rem; border: 1px solid var(--rule); }
.card-link { text-decoration-color: color-mix(in srgb, var(--green), transparent 38%); }
.unresolved-card { color: var(--error); text-decoration: underline dotted; text-underline-offset: .18em; }
.message-page { padding-block: 3.5rem; }

.button, .format-buttons button, .card-close {
  appearance: none; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid #adb7a8; border-radius: .36rem; background: var(--surface);
  color: var(--green-hover); min-height: 2.6rem; padding: .44rem .84rem;
  font: 600 .94rem/1.35 system-ui, sans-serif; text-decoration: none; cursor: pointer;
}
.button:hover, .format-buttons button:hover, .card-close:hover { background: #e9eee4; color: var(--green-hover); }
.button.primary { background: var(--green); color: #fff; border-color: var(--green); }
.button.primary:hover { background: var(--green-hover); }
.button:disabled { cursor: progress; opacity: .63; }
.unpublish { margin-inline-start: auto; color: var(--error); }

.editor-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; padding-block: 2.3rem 1.5rem; }
.editor-heading h1 { margin: 0; font-size: clamp(2.4rem, 6vw, 3.9rem); letter-spacing: -.04em; }
.editor-heading a { flex: none; font-size: .925rem; }
.editor-layout { display: grid; grid-template-columns: minmax(9rem, 14rem) minmax(0, 1fr); gap: clamp(1rem, 4vw, 3rem); align-items: start; }
.editor-sidebar { border-top: 1px solid var(--rule); padding-top: 1rem; }
.editor-sidebar ul { list-style: none; padding: 0; margin: 1rem 0 0; }
.editor-sidebar li a { display: block; padding: .55rem .65rem; font-size: .96rem; overflow-wrap: anywhere; text-decoration: none; border-radius: .25rem; }
.editor-sidebar li a:hover, .editor-sidebar li a[aria-current] { background: #e9eee4; }
.editor-sidebar small { display: block; font-size: .82rem; color: var(--muted); }
.editor-pane { padding: clamp(1rem, 3vw, 2rem); border: 1px solid var(--rule); border-radius: .45rem; background: var(--surface); }
.editor-caption { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; }
.editor-caption h2 { margin: 0 0 .7rem; font-size: 1.8rem; }
.editor-caption a { font-size: .925rem; }
.editor-pane label { display: block; font-weight: 650; margin-block: .9rem .38rem; }
.editor-pane input, .editor-pane textarea {
  display: block; width: 100%; border: 1px solid #aab4a7; border-radius: .3rem;
  background: #fffef9; color: var(--ink); padding: .65rem .75rem; font: inherit;
}
.editor-pane textarea { min-height: 13rem; resize: vertical; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }
.format-buttons, .editor-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; }
.format-buttons button { font-size: .88rem; min-height: 2rem; padding: .25rem .55rem; }
.mana-buttons { display: flex; flex-wrap: wrap; gap: .25rem; }
.mana-buttons button { min-width: 2rem; padding: .25rem .35rem; }
.field-help, .feedback { color: var(--muted); font-size: .925rem; margin: .45rem 0; }
.editor-actions { margin-top: .95rem; }
.feedback { margin-top: .8rem; }
.feedback.error { color: var(--error); }
.feedback:empty { display: none; }
.preview { border-top: 1px solid var(--rule); margin-top: 1.25rem; padding-top: .75rem; }
.preview h3 { font-size: 1.4rem; margin: .45rem 0 .9rem; }

.card-popover {
  position: fixed; inset: auto; z-index: 10; max-width: calc(100vw - 1.25rem);
  border: 1px solid #6b776e; border-radius: .65rem; padding: .35rem;
  color: #fff; background: #1a2720; box-shadow: 0 .6rem 1.5rem #172b2350;
}
.card-images { display: flex; align-items: start; gap: .3rem; }
.card-images img { display: block; width: min(14rem, 42vw, 34vh); height: auto; aspect-ratio: 488 / 680; border-radius: .38rem; }
.card-controls { display: none; }
.card-popover[data-mode="tap"] { left: 50%; top: 50%; translate: -50% -50%; }
.card-popover[data-mode="tap"] .card-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; padding: .42rem .25rem .12rem; }
.card-popover[data-mode="tap"]:not([data-double]) .card-front { width: min(16rem, 78vw, 45vh); }
.card-external { color: #f8f5eb; font-size: .92rem; }
.card-external:hover { color: #f2c79f; }
.card-close { min-height: 2.05rem; padding-block: .25rem; }

@media (max-width: 44rem) {
  .editor-layout { grid-template-columns: minmax(0, 1fr); }
  .editor-sidebar { border-top: 0; padding-top: 0; }
  .editor-sidebar ul { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .6rem; }
  .editor-sidebar li { max-width: 100%; }
  .editor-sidebar li a { padding: .35rem .55rem; }
  .unpublish { margin-inline-start: 0; }
}
