/* ---------------------------------------------------------------- tokens */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Charter", Charter, "Bitstream Charter",
    Georgia, Cambria, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --bg: #fcfbf9;
  --bg-soft: #f5f3ef;
  --surface: #ffffff;
  --ink: #1a1c20;
  --ink-soft: #3c4048;
  --muted: #6b7078;
  --border: #e6e2da;
  --border-strong: #d6d1c7;
  --accent: #2f4fd8;
  --accent-soft: #eaeefc;
  --accent-ink: #24409f;
  --shadow: 0 1px 2px rgba(20, 22, 26, .04), 0 8px 24px -16px rgba(20, 22, 26, .28);

  --wrap: 46rem;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1013;
    --bg-soft: #14171c;
    --surface: #14171c;
    --ink: #e9ebef;
    --ink-soft: #c7ccd4;
    --muted: #949aa4;
    --border: #242830;
    --border-strong: #333944;
    --accent: #91a9ff;
    --accent-soft: #1a2136;
    --accent-ink: #b9c8ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px -18px rgba(0, 0, 0, .8);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 1.5rem;
}

.muted { color: var(--muted); }

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem; top: 1rem; z-index: 10;
  background: var(--surface); padding: .5rem .75rem; border-radius: 8px;
  border: 1px solid var(--border);
}

/* ---------------------------------------------------------------- header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 60px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -.015em;
}
.brand:hover { text-decoration: none; color: var(--accent); }

.brand-mark {
  width: 11px; height: 11px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #c96a3f));
  transform: rotate(12deg);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  font-size: .93rem;
}
.site-nav a { color: var(--muted); }
.site-nav a:hover { color: var(--ink); text-decoration: none; }
.site-nav a.is-active { color: var(--ink); font-weight: 550; }
.nav-admin {
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: .15rem .6rem;
}

.search input {
  font: inherit;
  font-size: .9rem;
  width: 8.5rem;
  padding: .3rem .7rem;
  color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: width .18s ease, border-color .18s ease;
}
.search input:focus {
  outline: none;
  width: 11rem;
  border-color: var(--accent);
  background: var(--surface);
}

/* ----------------------------------------------------------------- intro */

main.wrap { padding-block: 3rem 4rem; }

.intro {
  margin: 0 0 2.75rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.intro h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -.02em;
  margin: 0 0 .6rem;
}
.intro p {
  margin: 0;
  color: var(--muted);
  font-size: 1.06rem;
  max-width: 34rem;
}

.page-head { margin: 0 0 2.25rem; }
.page-head h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 4vw, 2.1rem);
  letter-spacing: -.02em;
  margin: 0 0 .4rem;
  text-transform: none;
}
.page-head p { margin: 0; color: var(--muted); }

/* ------------------------------------------------------------------ feed */

.feed {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem 1.25rem;
  box-shadow: var(--shadow);
  transition: border-color .18s ease, transform .18s ease;
}
.card:hover { border-color: var(--border-strong); }

.card-link { border-left: 3px solid var(--accent); }

.card-meta {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .8rem;
  color: var(--muted);
  letter-spacing: .02em;
  margin-bottom: .45rem;
}

.badge {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: .1rem .5rem;
}
.badge-draft { color: #96601d; background: #fdf1dc; }
@media (prefers-color-scheme: dark) {
  .badge-draft { color: #e8bd7a; background: #33270f; }
}

.card-title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  line-height: 1.25;
  letter-spacing: -.015em;
  margin: 0 0 .35rem;
}
.card-title a { color: var(--ink); }
.card-title a:hover { color: var(--accent); text-decoration: none; }
.ext { font-size: .7em; margin-left: .25em; color: var(--muted); vertical-align: .25em; }

.card-source {
  margin: 0 0 .5rem;
  font-size: .85rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.card-summary {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: 1.02rem;
  line-height: 1.55;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.card-more { font-size: .87rem; white-space: nowrap; }

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.tags a {
  display: inline-block;
  font-size: .78rem;
  color: var(--muted);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .55rem;
}
.tags a:hover { color: var(--accent); border-color: var(--accent); text-decoration: none; }

.empty { color: var(--muted); }

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: .92rem;
}
.pager-link:last-child { margin-left: auto; }

/* ------------------------------------------------------------------ post */

.post { margin: 0; }
.post-header { margin-bottom: 2rem; }
.post-header h1 {
  font-family: var(--font-serif);
  font-size: clamp(2rem, 5.5vw, 2.75rem);
  line-height: 1.12;
  letter-spacing: -.025em;
  margin: 0 0 .5rem;
}
.post-header .tags { margin-top: .9rem; }
.post-source {
  margin: 0;
  font-family: var(--font-mono);
  font-size: .9rem;
}

.prose {
  font-family: var(--font-serif);
  font-size: 1.14rem;
  line-height: 1.72;
  color: var(--ink-soft);
}
.prose > *:first-child { margin-top: 0; }
.prose p { margin: 0 0 1.35rem; }
.prose h2, .prose h3, .prose h4 {
  font-family: var(--font-sans);
  color: var(--ink);
  letter-spacing: -.015em;
  line-height: 1.3;
  margin: 2.4rem 0 .8rem;
}
.prose h2 { font-size: 1.45rem; }
.prose h3 { font-size: 1.2rem; }
.prose h4 { font-size: 1.05rem; }
.prose ul, .prose ol { margin: 0 0 1.35rem; padding-left: 1.4rem; }
.prose li { margin-bottom: .45rem; }
.prose img, .prose video {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.prose blockquote {
  margin: 1.6rem 0;
  padding: .3rem 0 .3rem 1.2rem;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
  font-style: italic;
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}
.prose code {
  font-family: var(--font-mono);
  font-size: .86em;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: .1em .35em;
}
.prose pre {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.5rem;
  font-size: .92rem;
  line-height: 1.55;
}
.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: .95rem;
  margin: 0 0 1.5rem;
  display: block;
  overflow-x: auto;
}
.prose th, .prose td {
  border-bottom: 1px solid var(--border);
  padding: .55rem .6rem;
  text-align: left;
}

.related {
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}
.related h2 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 0 0 .9rem;
}
.related ul { list-style: none; margin: 0; padding: 0; }
.related li { margin-bottom: .5rem; display: flex; gap: .75rem; justify-content: space-between; }
.related li .muted { font-size: .85rem; white-space: nowrap; }

/* --------------------------------------------------------- archive, tags */

.archive-group { margin-bottom: 2.5rem; }
.archive-group h2 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--muted);
  margin: 0 0 .8rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li {
  display: grid;
  grid-template-columns: 6.5rem 1fr auto;
  gap: .75rem;
  align-items: baseline;
  padding: .45rem 0;
}
.archive-list time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.archive-list a { color: var(--ink); }
.archive-list a:hover { color: var(--accent); }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  list-style: none;
  padding: 0;
  margin: 0;
}
.tag-cloud a {
  display: inline-flex;
  align-items: baseline;
  gap: .4rem;
  padding: .35rem .8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
}
.tag-cloud a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.tag-cloud span { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; }

.search-big {
  display: flex;
  gap: .6rem;
  margin: 1.25rem 0 1rem;
}
.search-big input {
  flex: 1;
  font: inherit;
  padding: .6rem .9rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.search-big input:focus { outline: none; border-color: var(--accent); }
.search-big button {
  font: inherit;
  font-size: .95rem;
  padding: .6rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
@media (prefers-color-scheme: dark) {
  .search-big button { color: #0e1013; }
}

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  padding-block: 1.75rem 2.5rem;
  color: var(--muted);
  font-size: .88rem;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-inner p { margin: 0; }
.footer-links { display: flex; gap: 1rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--accent); }

/* ----------------------------------------------------------------- admin */

body.admin { background: var(--bg-soft); }

.admin-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.admin-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 56px;
  flex-wrap: wrap;
  max-width: 68rem;
}
.admin-brand a { color: var(--ink); font-weight: 600; }
.admin-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .9rem;
  flex-wrap: wrap;
}
.admin-nav a { color: var(--muted); }
.admin-nav a:hover { color: var(--accent); }

.admin-main { max-width: 68rem; padding-block: 2.25rem 4rem; }

.admin-head, .editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.admin-head h1, .editor-head h1 {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  margin: 0;
  letter-spacing: -.02em;
}

.btn {
  font: inherit;
  font-size: .92rem;
  font-weight: 550;
  padding: .5rem 1.1rem;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
.btn:hover { text-decoration: none; filter: brightness(1.06); }
@media (prefers-color-scheme: dark) { .btn { color: #0e1013; } }

.flash {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 9px;
  padding: .6rem 1rem;
  margin: 0 0 1.25rem;
  font-size: .92rem;
}
.flash-error { background: #fdeceb; color: #9b2c22; }
@media (prefers-color-scheme: dark) {
  .flash-error { background: #2e1614; color: #f0a79f; }
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .94rem;
}
.admin-table th {
  text-align: left;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
}
.admin-table td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table a { color: var(--ink); font-weight: 500; }
.admin-table a:hover { color: var(--accent); }

.pill {
  font-size: .72rem;
  padding: .1rem .55rem;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--muted);
}
.pill-live { background: #e6f5ec; border-color: #bfe3cd; color: #216c42; }
@media (prefers-color-scheme: dark) {
  .pill-live { background: #12281c; border-color: #1f4630; color: #7fd2a0; }
}

.row-actions {
  display: flex;
  gap: .9rem;
  align-items: center;
  font-size: .88rem;
}
.row-actions form { margin: 0; }
.link-danger {
  font: inherit;
  font-size: .88rem;
  background: none;
  border: 0;
  padding: 0;
  color: #b5372b;
  cursor: pointer;
}
.link-danger:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) { .link-danger { color: #ef8a7d; } }

/* ---------------------------------------------------------------- editor */

.editor { display: flex; flex-direction: column; gap: 1.1rem; }

.editor-actions { display: flex; align-items: center; gap: 1rem; }

.check { display: inline-flex; align-items: center; gap: .4rem; font-size: .92rem; color: var(--muted); }

.field-row { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.field-row .field { flex: 1 1 16rem; }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field > span, .field-label {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 600;
}
.field small { text-transform: none; letter-spacing: 0; font-weight: 400; }

.field input, .field select, .field textarea {
  font: inherit;
  width: 100%;
  padding: .6rem .8rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea {
  font-family: var(--font-mono);
  font-size: .92rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 22rem;
}

.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  align-items: start;
}
.preview-pane {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  position: sticky;
  top: 1.5rem;
}
.preview-pane .prose {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 1.1rem 1.25rem;
  min-height: 22rem;
  max-height: 34rem;
  overflow-y: auto;
  font-size: 1rem;
}

@media (max-width: 860px) {
  .editor-split { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
}

@media (max-width: 640px) {
  body { font-size: 16px; }
  .header-inner { padding-block: .6rem; }
  .site-nav { gap: .85rem; font-size: .88rem; width: 100%; }
  .search input { width: 100%; flex: 1; }
  .search { flex: 1; display: flex; }
  .card { padding: 1.2rem 1.15rem; }
  .archive-list li { grid-template-columns: 1fr; gap: .15rem; padding: .55rem 0; }
  .admin-table { font-size: .88rem; }
  .admin-table th:nth-child(2), .admin-table td:nth-child(2) { display: none; }
}
