/* ==========================================================================
   Lelushia
   Palette taken from the portrait: navy damask, a silver-grey suit and a
   cobalt tie. The one decorative idea is the "code damask" medallion.
   Change colours in the two theme blocks below.
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  --bg: #10172a;
  --bg-raise: #141d33;
  --surface: #19233c;
  --surface-2: #1f2b48;
  --line: #2b3a5c;
  --line-soft: #222e4a;
  --ink: #eef2f6;
  --ink-2: #b3bdcc;
  --ink-3: #8592a8;
  --accent: #6ea0ff;
  --accent-hover: #93b8ff;
  --accent-ink: #0c1324;
  --accent-wash: rgba(110, 160, 255, 0.14);
  --silver: #c4ccd6;
  --danger: #ff8f80;
  --ok: #7fd1a8;
  --mine: #2c4f97;
  --mine-ink: #f2f6ff;
  --shadow: 0 18px 50px -24px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef1f5;
  --bg-raise: #e6eaf0;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --line: #cdd5e1;
  --line-soft: #dde3ec;
  --ink: #121a2c;
  --ink-2: #44506a;
  --ink-3: #66728b;
  --accent: #2457c5;
  --accent-hover: #1a46a3;
  --accent-ink: #ffffff;
  --accent-wash: rgba(36, 87, 197, 0.1);
  --silver: #8a96a8;
  --danger: #b3261e;
  --ok: #1d7a4e;
  --mine: #2457c5;
  --mine-ink: #ffffff;
  --shadow: 0 18px 40px -24px rgba(18, 26, 44, 0.35);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #eef1f5;
    --bg-raise: #e6eaf0;
    --surface: #ffffff;
    --surface-2: #f4f6f9;
    --line: #cdd5e1;
    --line-soft: #dde3ec;
    --ink: #121a2c;
    --ink-2: #44506a;
    --ink-3: #66728b;
    --accent: #2457c5;
    --accent-hover: #1a46a3;
    --accent-ink: #ffffff;
    --accent-wash: rgba(36, 87, 197, 0.1);
    --silver: #8a96a8;
    --danger: #b3261e;
    --ok: #1d7a4e;
    --mine: #2457c5;
    --mine-ink: #ffffff;
    --shadow: 0 18px 40px -24px rgba(18, 26, 44, 0.35);
    color-scheme: light;
  }
}

:root {
  --serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, "Noto Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --code: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --measure: 40rem;
  --wide: 72rem;
  --gutter: 16px;
  --radius: 10px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
@media (min-width: 700px) { :root { --gutter: 32px; } }

/* Smooth cross-fade between pages in browsers that support it */
@view-transition { navigation: auto; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: .2em; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--accent-ink); }

h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.12; letter-spacing: -0.015em; margin: 0 0 .6em; text-wrap: balance; }
h1 { font-size: clamp(2.1rem, 5vw, 3rem); }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }
code, pre { font-family: var(--code); }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: .5rem .9rem; z-index: 100; }
.skip:focus { left: 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-3); }
[hidden] { display: none !important; }

/* ---- Buttons and links ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: 600 .95rem/1 var(--sans); padding: .78rem 1.2rem; min-height: 44px;
  border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn--quiet { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--quiet:hover { background: var(--surface-2); color: var(--ink); border-color: var(--ink-3); }
.btn--danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger); color: var(--bg); border-color: var(--danger); }
.btn--small { padding: .45rem .9rem; min-height: 36px; font-size: .88rem; }
.btn:disabled { opacity: .6; cursor: progress; }
.linkish { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: .2em; }
.linkish--danger { color: var(--danger); }
.text-link { font-weight: 600; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.icon-btn {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 999px;
  background: transparent; border: 1px solid transparent; color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { border-color: var(--line); color: var(--ink); }
.icon-btn svg path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root .i-sun { display: none; }
:root[data-theme="light"] .i-sun { display: block; }
:root[data-theme="light"] .i-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .i-sun { display: block; }
  :root:not([data-theme="dark"]) .i-moon { display: none; }
}

/* ---- Top bar --------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line-soft);
}
.topbar__inner {
  max-width: var(--wide); margin: 0 auto; padding: 0 var(--gutter);
  height: 64px; display: flex; align-items: center; gap: 1.5rem;
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; font: 700 1.2rem var(--serif); }
.brand:hover { color: var(--ink); }
.brand img { border-radius: 7px; }
.mainnav { display: flex; gap: .25rem; }
.mainnav a {
  position: relative; color: var(--ink-2); text-decoration: none; font-size: .95rem; font-weight: 500;
  padding: .45rem .7rem; border-radius: 8px; display: inline-flex; align-items: center; gap: .4rem;
}
.mainnav a:hover { color: var(--ink); background: var(--surface); }
.mainnav a[aria-current] { color: var(--ink); }
.mainnav a[aria-current]::after {
  content: ""; position: absolute; left: .7rem; right: .7rem; bottom: -12px; height: 2px; background: var(--accent); border-radius: 2px;
}
.topbar__end { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.topbar__link { color: var(--ink-2); text-decoration: none; font-weight: 500; padding: .45rem .6rem; }
.me { display: flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line-soft); }
.me:hover { color: var(--ink); border-color: var(--line); background: var(--surface); }
.me__name { font-size: .9rem; font-weight: 600; max-width: 10rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge-count {
  min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font: 700 .72rem/1.25rem var(--sans); text-align: center;
}
@media (max-width: 640px) {
  .topbar__inner { gap: .5rem; }
  .brand span, .me__name { display: none; }
  .mainnav a { padding: .45rem .5rem; }
  .topbar__link { padding: .45rem .3rem; }
}

/* ---- Layout ---------------------------------------------------------------- */
main { flex: 1; width: 100%; }
.page { max-width: var(--wide); margin: 0 auto; padding: 3rem var(--gutter) 5rem; }
.page--wide { max-width: var(--wide); }
.flashes { max-width: var(--wide); margin: 0 auto 1.5rem; }
.home .flashes { padding: 1.5rem var(--gutter) 0; margin-bottom: 0; }
.flash { margin: 0 0 .5rem; padding: .8rem 1rem; border-radius: var(--radius); background: var(--accent-wash); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.narrow-wide { max-width: 52rem; }

/* ---- Home: hero ------------------------------------------------------------ */
.hero {
  max-width: var(--wide); margin: 0 auto; padding: 4rem var(--gutter) 3rem;
  overflow-x: clip;
  display: grid; gap: 3rem; align-items: center;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); padding-top: 5.5rem; padding-bottom: 5rem; }
}
.hero__name {
  font-size: clamp(3.4rem, 10vw, 6.6rem);
  line-height: .92; letter-spacing: -0.035em; margin-bottom: 1.4rem;
}
.hero__tagline { font: 600 clamp(1.2rem, 2.4vw, 1.5rem)/1.35 var(--sans); color: var(--ink); max-width: 30ch; letter-spacing: -0.01em; }
.hero__intro { color: var(--ink-2); font-size: 1.1rem; max-width: 52ch; }
.hero__actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 2rem 0 1.5rem; }
.hero__where { color: var(--ink-3); font-size: .95rem; margin: 0; }

.hero__figure { position: relative; margin: 0; justify-self: center; width: min(400px, 78vw); }
@media (max-width: 899px) { .hero__figure { order: -1; width: min(300px, 70vw); } }
.arch {
  position: relative; z-index: 1;
  border-radius: 999px 999px 22px 22px; overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  aspect-ratio: 4 / 5;
  background: var(--surface);
}
.arch img { width: 100%; height: 100%; object-fit: cover; }

/* The code-damask medallion */
.damask { overflow: visible; }
.damask .dm-a, .damask .dm-b, .damask .dm-ring { fill: none; stroke-width: .8; vector-effect: non-scaling-stroke; }
.damask .dm-a { stroke: var(--accent); }
.damask .dm-b { stroke: var(--silver); opacity: .7; }
.damask .dm-ring { stroke: var(--silver); opacity: .5; stroke-dasharray: 2 6; }
.damask .dm-g, .damask .dm-c { font: 600 9px var(--code); fill: var(--silver); text-anchor: middle; opacity: .8; }
.damask .dm-c { fill: var(--accent); font-size: 12px; opacity: 1; }
.hero .damask {
  position: absolute; z-index: 0; width: 158%; max-width: none; left: 50%; top: 40%;
  transform: translate(-50%, -50%);
  opacity: .55; pointer-events: none;
}

/* One orchestrated entrance: the medallion draws itself, then the portrait and name settle in. */
@media (prefers-reduced-motion: no-preference) {
  .dm-draw path, .dm-draw circle { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.4s var(--ease) forwards; }
  .dm-draw path:nth-of-type(4n+2) { animation-delay: .15s; }
  .dm-draw path:nth-of-type(4n+3) { animation-delay: .3s; }
  .dm-draw path:nth-of-type(4n) { animation-delay: .45s; }
  .dm-draw circle.dm-ring { stroke-dasharray: 2 6; stroke-dashoffset: 0; opacity: 0; animation: fade .8s 1.2s forwards; }
  .dm-draw text { opacity: 0; animation: fade 1s 1s forwards; }
  .home .arch { opacity: 0; transform: translateY(14px) scale(.985); animation: settle 1s .35s var(--ease) forwards; }
  .home .hero__text > * { opacity: 0; animation: settle .9s var(--ease) forwards; }
  .home .hero__text > :nth-child(1) { animation-delay: .1s; }
  .home .hero__text > :nth-child(2) { animation-delay: .25s; }
  .home .hero__text > :nth-child(3) { animation-delay: .35s; }
  .home .hero__text > :nth-child(n+4) { animation-delay: .45s; }
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: .8; } }
@keyframes settle { to { opacity: 1; transform: none; } }

/* ---- Home: lower section --------------------------------------------------- */
.home-grid {
  max-width: var(--wide); margin: 0 auto; padding: 3rem var(--gutter) 5rem;
  display: grid; gap: 3rem; border-top: 1px solid var(--line-soft);
}
@media (min-width: 800px) { .home-grid { grid-template-columns: 1fr 1.4fr; gap: 5rem; } }
.home-grid h2 { font-size: 1.35rem; }
.now-list { list-style: none; margin: 0; padding: 0; }
.now-list li { position: relative; padding: .7rem 0 .7rem 1.6rem; border-bottom: 1px solid var(--line-soft); color: var(--ink-2); }
.now-list li::before { content: "›"; position: absolute; left: 0; top: .62rem; font: 700 1.1rem var(--code); color: var(--accent); }
.mini-posts { list-style: none; margin: 0 0 1.2rem; padding: 0; }
.mini-post { display: flex; gap: 1rem; align-items: center; padding: .6rem; margin: 0 -.6rem; border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.mini-post:hover { background: var(--surface); color: var(--ink); }
.mini-post img { width: 112px; height: 59px; object-fit: cover; border-radius: 7px; flex: none; border: 1px solid var(--line-soft); }
.mini-post__text { display: grid; gap: .15rem; }
.mini-post__title { font: 700 1.1rem/1.3 var(--serif); }
.mini-post time { color: var(--ink-3); font-size: .88rem; }

/* ---- About ----------------------------------------------------------------- */
.about { display: grid; gap: 3rem; align-items: start; }
@media (min-width: 900px) { .about { grid-template-columns: minmax(0, 1fr) minmax(0, 26rem); gap: 5rem; } }
.about__text { max-width: var(--measure); }
.prose .link-list, .link-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; }
.codecard {
  position: sticky; top: 96px;
  background: #0b1222; color: #d6deeb; border: 1px solid #263556; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow);
}
.codecard__bar { display: flex; align-items: center; gap: .4rem; padding: .7rem 1rem; border-bottom: 1px solid #1f2c48; background: #0f182c; }
.codecard__bar span { width: 10px; height: 10px; border-radius: 50%; background: #2b3a5c; }
.codecard__bar em { margin-left: .6rem; font: 500 .8rem var(--code); color: #8592a8; font-style: normal; }
.codecard pre { margin: 0; padding: 1.2rem 1.3rem 1.4rem; font-size: .86rem; line-height: 1.7; overflow-x: auto; }
.codecard .k { color: #82aaff; }
.codecard .t { color: #ffcb8b; }
.codecard .f { color: #a6e3ff; }
.codecard .v { color: #d6deeb; }
.codecard .s { color: #a3d9a5; }

/* ---- Posts list ------------------------------------------------------------ */
.post-rows { list-style: none; margin: 2rem 0 0; padding: 0; }
.post-row { display: grid; gap: 1.25rem; padding: 1.6rem 0; border-top: 1px solid var(--line-soft); }
.post-row:last-child { border-bottom: 1px solid var(--line-soft); }
@media (min-width: 640px) { .post-row { grid-template-columns: 220px 1fr; gap: 1.75rem; align-items: start; } }
.post-row__cover img { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line-soft); transition: transform .4s var(--ease); }
.post-row__cover:hover img { transform: scale(1.02); }
.post-row h2 { font-size: 1.45rem; margin: 0 0 .4rem; }
.post-row h2 a { color: var(--ink); text-decoration: none; }
.post-row h2 a:hover { color: var(--accent); }
.post-row p { color: var(--ink-2); margin: 0 0 .5rem; }
.meta { display: flex; flex-wrap: wrap; gap: .25rem 1.1rem; color: var(--ink-3); font-size: .9rem; margin: 0; }
.meta a { color: inherit; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 2rem; }

/* ---- Article --------------------------------------------------------------- */
.article { max-width: 46rem; margin: 0 auto; }
.article__cover { width: 100%; aspect-ratio: 1200 / 630; object-fit: cover; border-radius: 16px; border: 1px solid var(--line-soft); margin-bottom: 2.2rem; }
.article h1 { font-size: clamp(2.2rem, 5.5vw, 3.4rem); margin-bottom: .5rem; }
.article__summary { font-size: 1.2rem; color: var(--ink-2); margin-bottom: 1rem; }
.article__head { margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line-soft); }
.draft-note { display: inline-block; padding: .3rem .7rem; border-radius: 999px; border: 1px dashed var(--silver); color: var(--ink-2); font-size: .88rem; }
.article__actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 3rem 0; padding: 1.25rem 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }

.prose { font-size: 1.125rem; line-height: 1.75; overflow-wrap: break-word; }
.prose > * { margin-top: 0; margin-bottom: 0; }
.prose > * + * { margin-top: 1.1em; }
.prose h2 { margin-top: 2em; }
.prose h3 { margin-top: 1.6em; }
.prose img { border-radius: var(--radius); }
.prose blockquote { margin: 1.6em 0; padding: .2em 0 .2em 1.3em; border-left: 3px solid var(--accent); color: var(--ink-2); font: italic 1.2rem/1.6 var(--serif); }
.prose :not(pre) > code { font-size: .88em; background: var(--surface-2); border: 1px solid var(--line-soft); padding: .1em .35em; border-radius: 5px; }
.prose pre { background: #0b1222; color: #d6deeb; border: 1px solid #263556; border-radius: 12px; padding: 1.1rem 1.25rem; overflow-x: auto; font-size: .9rem; line-height: 1.6; }
.prose table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: 1rem; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: .5rem .75rem; text-align: left; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5em 0; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .3em; }

/* Like button */
.like {
  display: inline-flex; align-items: center; gap: .55rem; min-height: 44px; padding: .55rem 1rem;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); font: 600 .95rem var(--sans); cursor: pointer;
}
.like:hover { border-color: var(--accent); }
.like svg path { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.like.is-liked { border-color: var(--accent); color: var(--accent); background: var(--accent-wash); }
.like.is-liked svg path { fill: currentColor; }
.like__count { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.like.pop svg { animation: pop .45s var(--ease); }
@keyframes pop { 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* Comments */
.comments h2 { font-size: 1.4rem; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { display: flex; gap: .9rem; padding: 1.1rem 0; border-bottom: 1px solid var(--line-soft); }
.comment__main { min-width: 0; flex: 1; }
.comment__head { display: flex; gap: .7rem; align-items: baseline; margin: 0 0 .25rem; }
.comment__head a { color: var(--ink); font-weight: 700; text-decoration: none; }
.comment__head time { color: var(--ink-3); font-size: .85rem; }
.comment__body { margin: 0 0 .35rem; color: var(--ink-2); overflow-wrap: anywhere; }
.comment__body--live, .msg__live { white-space: pre-wrap; }
.comment form { display: inline; font-size: .85rem; }
.comment-form { display: grid; gap: .6rem; margin-top: 1.5rem; }
.comment-form label { font-weight: 600; }
.comment-form .btn { justify-self: start; }
.signin-prompt { margin-top: 1.5rem; padding: 1rem 1.2rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line-soft); }
@media (prefers-reduced-motion: no-preference) {
  .is-new { animation: arrive .45s var(--ease); }
}
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }

/* ---- Avatars --------------------------------------------------------------- */
.avatar { flex: none; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.avatar--blank { display: grid; place-items: center; background: var(--surface-2); color: var(--accent); font: 700 1rem var(--serif); border: 1px solid var(--line); }
.avatar--sm { width: 32px; height: 32px; font-size: .9rem; }
.avatar--md { width: 44px; height: 44px; font-size: 1.1rem; }
.avatar--xl { width: 112px; height: 112px; font-size: 2.6rem; }

/* ---- Forms ----------------------------------------------------------------- */
.form { display: grid; gap: 1.15rem; }
.form label, .comment-form label { display: grid; gap: .4rem; font-weight: 600; font-size: .93rem; }
.form small, .hint { font-weight: 400; color: var(--ink-3); font-size: .85rem; }
input, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; width: 100%; min-height: 44px;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--accent); flex: none; margin: 2px 0 0; }
.check { display: flex !important; grid-template-columns: none; align-items: flex-start; gap: .65rem; font-weight: 500 !important; }
.form .btn, .form button.btn { justify-self: start; }
.form-grid { display: grid; gap: 1.15rem; align-items: start; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.form-errors { list-style: none; margin: 0 0 1rem; padding: .85rem 1rem; border-radius: var(--radius); border: 1px solid var(--danger); color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, transparent); }
.form-errors li + li { margin-top: .3rem; }
.form-error { color: var(--danger); margin: 0; font-size: .9rem; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }

.auth { max-width: 26rem; margin: 2rem auto 0; }
.auth__lead { color: var(--ink-2); }
.auth__alt { margin-top: 1.5rem; color: var(--ink-2); }
.error-code { font: 700 4rem/1 var(--code); color: var(--accent); margin-bottom: .5rem; }

/* ---- Member profile -------------------------------------------------------- */
.member { max-width: 46rem; }
.member__head { display: flex; gap: 1.75rem; align-items: flex-start; flex-wrap: wrap; padding-bottom: 2rem; border-bottom: 1px solid var(--line-soft); }
.member__head h1 { margin-bottom: .1rem; }
.member__handle { color: var(--ink-3); }
.member__section { padding: 1.75rem 0; border-bottom: 1px solid var(--line-soft); }
.member__section h2 { font-size: 1.15rem; }
.member__bio { color: var(--ink-2); max-width: 60ch; }
.facts { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0 0 1.25rem; }
.facts dt { color: var(--ink-3); font-size: .85rem; }
.facts dd { margin: 0; font-weight: 600; }
.tag { display: inline-block; padding: .12rem .55rem; border-radius: 999px; border: 1px solid var(--line); font-size: .78rem; font-weight: 600; color: var(--ink-2); vertical-align: middle; }
.tag--live { border-color: var(--accent); color: var(--accent); }
.tag--danger { border-color: var(--danger); color: var(--danger); }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem; }
.chips li { padding: .35rem .8rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--line-soft); font-size: .92rem; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { padding: .8rem 0; border-bottom: 1px solid var(--line-soft); }
.activity p { margin: .2rem 0; color: var(--ink-2); }
.activity time { color: var(--ink-3); font-size: .85rem; }

/* ---- Account settings ------------------------------------------------------ */
.settings { max-width: 48rem; }
.settings__head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: 1rem; }
.panel { padding: 1.75rem 0; border-top: 1px solid var(--line-soft); }
.panel h2 { font-size: 1.25rem; margin-bottom: 1rem; }
.panel__sub { margin-top: 1rem; }
.photo-row { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.photo-row .hint { margin: .6rem 0; }
.file-pick { position: relative; display: inline-block; cursor: pointer; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.file-pick:focus-within .btn { outline: 2px solid var(--accent); outline-offset: 3px; }
.toggles { display: grid; gap: .8rem; align-content: center; }

/* ---- Chat ------------------------------------------------------------------ */
.chat {
  display: grid; gap: 0; border: 1px solid var(--line-soft); border-radius: 16px; overflow: hidden;
  background: var(--bg-raise); height: calc(100vh - 64px - 6rem); min-height: 480px;
}
@media (min-width: 860px) { .chat { grid-template-columns: 20rem 1fr; } }
.chat__side { border-right: 1px solid var(--line-soft); padding: 1.25rem 1rem; overflow-y: auto; background: var(--bg); }
.chat__side h1 { font-size: 1.6rem; padding: 0 .4rem; }
.chat__side h1 a { color: var(--ink); text-decoration: none; }
.chat__empty { padding: 0 .4rem; }
.search { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search input { min-height: 40px; padding: .5rem .75rem; }
.search .btn { min-height: 40px; padding: .5rem .9rem; }
.search-results { margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--line-soft); }
.people { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.people li { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.people li > a:first-child { display: flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; min-width: 0; }
.people small, .who small { color: var(--ink-3); font-weight: 400; }
.convos { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.convo { display: flex; gap: .75rem; align-items: center; padding: .65rem .6rem; border-radius: 10px; text-decoration: none; color: var(--ink); }
.convo:hover { background: var(--surface); color: var(--ink); }
.convo.is-active { background: var(--surface-2); }
.convo__text { display: grid; min-width: 0; flex: 1; }
.convo__name { font-weight: 700; font-size: .95rem; }
.convo__last { color: var(--ink-3); font-size: .87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo__side { display: grid; justify-items: end; gap: .25rem; }
.convo__side time { color: var(--ink-3); font-size: .75rem; white-space: nowrap; }
.chat__main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat__placeholder { align-items: center; justify-content: center; gap: 1.5rem; color: var(--ink-3); padding: 2rem; text-align: center; }
.chat__placeholder .damask { width: 180px; opacity: .45; }
@media (max-width: 859px) {
  .chat--inbox .chat__main { display: none; }
  .chat--thread .chat__side { display: none; }
  .chat__side { border-right: 0; }
}
.thread__head { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line-soft); background: var(--bg); }
.thread__back { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--ink-2); }
.thread__back svg path { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 860px) { .thread__back { display: none; } }
.thread__who { display: flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; }
.thread__who span { display: grid; line-height: 1.25; }
.thread__who small { color: var(--ink-3); }
.messages { list-style: none; margin: 0; padding: 1.25rem; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; }
.messages__empty { padding: 1.25rem; margin: 0; }
.msg { max-width: min(34rem, 82%); padding: .6rem .9rem .45rem; border-radius: 16px; overflow-wrap: anywhere; }
.msg p { margin: 0; }
.msg time { display: block; font-size: .72rem; opacity: .7; margin-top: .15rem; }
.msg--theirs { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 5px; }
.msg--mine { align-self: flex-end; background: var(--mine); color: var(--mine-ink); border-bottom-right-radius: 5px; }
.msg--mine time { text-align: right; }
.composer { display: grid; grid-template-columns: 1fr auto; gap: .6rem; align-items: end; padding: .85rem 1rem; border-top: 1px solid var(--line-soft); background: var(--bg); margin: 0; }
.composer textarea { resize: none; max-height: 180px; border-radius: 22px; padding: .65rem 1rem; }
.composer .form-error { grid-column: 1 / -1; }
.composer--off { display: block; color: var(--ink-3); }

/* ---- Admin ----------------------------------------------------------------- */
.subnav { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: 2rem; padding: .3rem; border-radius: 12px; background: var(--bg-raise); border: 1px solid var(--line-soft); width: fit-content; max-width: 100%; }
.subnav a { padding: .45rem .9rem; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .92rem; }
.subnav a:hover { color: var(--ink); }
.subnav a[aria-current] { background: var(--surface-2); color: var(--ink); }
.admin-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.admin-head h1 { margin: 0; }
.admin-head p { margin: 0; }
.segmented { display: flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented a { padding: .35rem .85rem; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-size: .88rem; font-weight: 600; }
.segmented a[aria-current] { background: var(--accent); color: var(--accent-ink); }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  border-top: 1px solid var(--line-soft); border-left: 1px solid var(--line-soft); margin-bottom: 2.5rem;
}
.stat { padding: 1.1rem 1.2rem 1.2rem; border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.stat__label { margin: 0 0 .35rem; color: var(--ink-2); font-size: .88rem; }
.stat__value { margin: 0; font: 700 2rem/1.1 var(--sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat--lead { background: var(--bg-raise); }
.stat--lead .stat__value { font-size: 2.6rem; color: var(--ink); }
.stat__note, .delta { display: block; margin-top: .3rem; color: var(--ink-3); font-size: .82rem; }
.delta--up { color: var(--ok); }
.delta--down { color: var(--danger); }

.chart-card { margin-bottom: 3rem; }
.chart-card h2 { font-size: 1.25rem; }
.chart { position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart__grid { stroke: var(--line-soft); stroke-width: 1; }
.chart__base { stroke: var(--line); }
.chart__tick { fill: var(--ink-3); font: 11px var(--sans); text-anchor: end; font-variant-numeric: tabular-nums; }
.chart__xlabel { fill: var(--ink-3); font: 11px var(--sans); text-anchor: middle; }
.chart__bar { fill: var(--accent); }
.chart__hit { fill: transparent; cursor: default; outline: none; }
.chart__hit.is-hover, .chart__hit:focus-visible { fill: var(--accent-wash); }
.chart__tip {
  position: absolute; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .35rem .6rem; font-size: .85rem; box-shadow: var(--shadow); color: var(--ink-2);
}
.chart__tip strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.chart-table { margin-top: 1rem; }
.chart-table summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: .92rem; }
.admin-tables { display: grid; gap: 2.5rem; }
@media (min-width: 1000px) { .admin-tables { grid-template-columns: 1.4fr 1fr 1fr; } }
.admin-tables h2 { font-size: 1.15rem; }
.footnote { margin-top: 2.5rem; color: var(--ink-3); font-size: .88rem; max-width: 70ch; }

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; color: var(--ink-3); font-weight: 600; font-size: .82rem; padding: .55rem .75rem .55rem 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .7rem .75rem .7rem 0; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions > * { display: inline; margin-left: .9rem; }
.table tr.is-banned td { opacity: .6; }
.who { display: inline-flex; align-items: center; gap: .6rem; color: var(--ink); text-decoration: none; margin-right: .4rem; }

.editor { display: grid; gap: 1.15rem; }
@media (min-width: 1000px) { .editor { grid-template-columns: 1fr 1fr; } }
.code-input { font-family: var(--code); font-size: .92rem; }
.editor__preview { display: grid; gap: .4rem; align-content: start; }
.editor__preview .label { font-weight: 600; font-size: .93rem; }
.preview { border: 1px dashed var(--line); border-radius: 8px; padding: 1rem 1.2rem; min-height: 14rem; max-height: 40rem; overflow: auto; font-size: 1rem; }
.slug-field { display: flex; align-items: center; gap: .3rem; font-weight: 400; color: var(--ink-3); }
.mod-list { list-style: none; padding: 0; margin: 0; max-width: 52rem; }
.mod-list li { padding: 1rem 0; border-bottom: 1px solid var(--line-soft); }
.mod-list__head { color: var(--ink-3); font-size: .9rem; margin-bottom: .3rem; }
.mod-list__head time { margin-left: .5rem; }

/* ---- Legal pages ----------------------------------------------------------- */
.legal { max-width: var(--measure); font-size: 1.05rem; }
.legal h2 { font-size: 1.35rem; }
.legal h3 { font-size: 1.1rem; font-family: var(--sans); }
.legal table { display: table; font-size: .95rem; }
.legal td, .legal th { vertical-align: top; }

/* ---- Footer ---------------------------------------------------------------- */
.footer { border-top: 1px solid var(--line-soft); color: var(--ink-3); font-size: .9rem; }
.footer__inner { max-width: var(--wide); margin: 0 auto; padding: 1.75rem var(--gutter); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.footer p { margin: 0; }
.footer__who { display: flex; gap: 1rem; flex-wrap: wrap; }
.footer a, .footer .linkish { color: var(--ink-2); }
.footer nav { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; }
.footer form { display: inline; }

/* ---- Toasts ---------------------------------------------------------------- */
.toasts { position: fixed; left: 16px; bottom: 16px; z-index: 50; display: grid; gap: .6rem; width: min(24rem, calc(100vw - 32px)); }
.toast {
  position: relative; display: grid; gap: .15rem; padding: .9rem 2.6rem .9rem 1.1rem; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  color: var(--ink-2); text-decoration: none; box-shadow: var(--shadow);
}
a.toast:hover { color: var(--ink-2); border-color: var(--accent); }
.toast strong { color: var(--ink); }
.toast span { overflow-wrap: anywhere; }
.toast__close { position: absolute; top: .5rem; right: .5rem; width: 28px; height: 28px; border: 0; border-radius: 50%; background: none; color: var(--ink-3); font-size: 1.2rem; cursor: pointer; }
.toast__close:hover { background: var(--surface-2); color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in .4s var(--ease); }
  .toast.is-leaving { transition: opacity .25s, transform .25s; opacity: 0; transform: translateY(8px); }
}
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  @view-transition { navigation: none; }
}

/* ==========================================================================
   Post content styles (used by the editor and on published posts)
   ========================================================================== */
:root, :root[data-theme="dark"] {
  --c-red: #ff8f80; --c-orange: #ffb070; --c-gold: #e8c468; --c-green: #7fd1a8; --c-purple: #c3a6ff;
  --h-yellow: rgba(255, 214, 10, .28); --h-blue: rgba(110, 160, 255, .3); --h-green: rgba(127, 209, 168, .28); --h-pink: rgba(255, 128, 191, .3);
}
:root[data-theme="light"] {
  --c-red: #b3261e; --c-orange: #b45309; --c-gold: #8a6d00; --c-green: #1d7a4e; --c-purple: #6d3fc4;
  --h-yellow: #fff1a8; --h-blue: #d6e4ff; --h-green: #cdeedd; --h-pink: #ffd6ea;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --c-red: #b3261e; --c-orange: #b45309; --c-gold: #8a6d00; --c-green: #1d7a4e; --c-purple: #6d3fc4;
    --h-yellow: #fff1a8; --h-blue: #d6e4ff; --h-green: #cdeedd; --h-pink: #ffd6ea;
  }
}
.fs-sm { font-size: .875rem; }
.fs-md { font-size: 1.125rem; }
.fs-lg { font-size: 1.4rem; line-height: 1.5; }
.fs-xl { font-size: 1.95rem; line-height: 1.3; font-weight: 600; }
.ff-sans { font-family: var(--sans); }
.ff-serif { font-family: var(--serif); }
.ff-mono { font-family: var(--code); font-size: .92em; }
.tc-default { color: var(--ink); }
.tc-accent { color: var(--accent); }
.tc-silver { color: var(--silver); }
.tc-red { color: var(--c-red); }
.tc-orange { color: var(--c-orange); }
.tc-gold { color: var(--c-gold); }
.tc-green { color: var(--c-green); }
.tc-purple { color: var(--c-purple); }
.hl-yellow, .hl-blue, .hl-green, .hl-pink { border-radius: 3px; padding: 0 .12em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.hl-yellow { background: var(--h-yellow); }
.hl-blue { background: var(--h-blue); }
.hl-green { background: var(--h-green); }
.hl-pink { background: var(--h-pink); }
.ta-left { text-align: left; }
.ta-center { text-align: center; }
.ta-right { text-align: right; }
.ta-justify { text-align: justify; hyphens: auto; }

/* Images */
main { overflow-x: clip; }
.prose figure.img { margin-left: auto; margin-right: auto; }
.prose figure.img img { width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line-soft); }
.prose figure.img figcaption { margin-top: .6rem; color: var(--ink-3); font-size: .92rem; text-align: center; line-height: 1.5; }
.img--small { width: min(20rem, 100%); }
.img--medium { width: 100%; }
.img--wide { width: min(64rem, 100vw - 32px); position: relative; left: 50%; transform: translateX(-50%); }
.img--full { width: 100vw; position: relative; left: 50%; transform: translateX(-50%); }
.prose .img--full img { border-radius: 0; border-left: 0; border-right: 0; }
@media (min-width: 700px) {
  .img--left.img--small, .img--left.img--medium { float: left; margin: .3em 1.75rem 1rem 0 !important; }
  .img--right.img--small, .img--right.img--medium { float: right; margin: .3em 0 1rem 1.75rem !important; }
  .img--left.img--medium, .img--right.img--medium { width: 50%; }
  .img--left.img--small, .img--right.img--small { width: min(17rem, 42%); }
}
.prose h2, .prose h3, .prose h4, .prose hr, .prose .cols, .prose .callout { clear: both; }

/* Dividers */
.prose hr.div-line, .prose hr:not([class]) { border: 0; border-top: 1px solid var(--line); margin: 2.6em 0; }
.prose hr.div-dots, .prose hr.div-ornament { border: 0; margin: 2.4em 0; height: auto; overflow: visible; text-align: center; }
.prose hr.div-dots::after { content: "·   ·   ·"; white-space: pre; color: var(--ink-3); font-size: 1.6rem; line-height: 1; letter-spacing: .1em; }
.prose hr.div-ornament::after { content: "{ ✦ }"; color: var(--accent); font: 600 1.05rem var(--code); letter-spacing: .3em; }

/* Columns */
.cols { display: grid; gap: 1.5rem 2.25rem; }
.cols > .col > :first-child { margin-top: 0; }
.cols > .col > * + * { margin-top: 1em; }
@media (min-width: 700px) {
  .cols-2 { grid-template-columns: 1fr 1fr; }
  .cols-3 { grid-template-columns: 1fr 1fr 1fr; }
}

/* Callout boxes */
.callout { padding: 1rem 1.25rem 1.05rem 1.15rem; border-radius: 10px; border: 1px solid var(--line-soft); border-left: 4px solid var(--accent); background: var(--accent-wash); }
.callout::before { display: block; font: 700 .9rem var(--sans); margin-bottom: .3rem; color: var(--accent); }
.callout > * + * { margin-top: .7em; }
.callout--note::before { content: "Note"; }
.callout--tip { border-left-color: var(--c-green); background: color-mix(in srgb, var(--c-green) 12%, transparent); }
.callout--tip::before { content: "Tip"; color: var(--c-green); }
.callout--warning { border-left-color: var(--c-orange); background: color-mix(in srgb, var(--c-orange) 12%, transparent); }
.callout--warning::before { content: "Warning"; color: var(--c-orange); }

/* Button links */
.prose a.btn-link {
  display: inline-flex; align-items: center; min-height: 44px; padding: .7rem 1.3rem; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font: 600 .98rem var(--sans); text-decoration: none;
}
.prose a.btn-link:hover { background: var(--accent-hover); color: var(--accent-ink); }

/* ==========================================================================
   Editor
   ========================================================================== */
.rte { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.rte__bar {
  position: sticky; top: 64px; z-index: 5;
  display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: center;
  padding: .5rem .6rem; border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px);
  border-radius: 14px 14px 0 0;
}
.rte__group { display: flex; align-items: center; gap: 2px; padding-right: .5rem; border-right: 1px solid var(--line-soft); }
.rte__group:last-child { border-right: 0; }
.rte-btn {
  display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 .4rem; border-radius: 8px;
  border: 1px solid transparent; background: none; color: var(--ink-2); cursor: pointer; font: 600 .9rem var(--sans);
  list-style: none;
}
.rte-btn::-webkit-details-marker { display: none; }
.rte-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rte-btn:hover { background: var(--surface-2); color: var(--ink); }
.rte-btn[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.rte-btn__text { font-size: 1rem; line-height: 1; }
.rte-btn--wide { padding: 0 .7rem; }
.rte-swatch-a { border-bottom: 3px solid var(--accent); padding: 0 2px 1px; }
.rte__bar select { width: auto; min-height: 36px; height: 36px; padding: 0 1.8rem 0 .6rem; border-radius: 8px; font-size: .9rem; background-color: var(--surface); cursor: pointer; }
.rte-menu { position: relative; }
.rte-menu[open] > summary { background: var(--surface-2); color: var(--ink); }
.rte-menu__panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 10; min-width: 12rem;
  padding: .5rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.rte-swatches { display: grid; grid-template-columns: repeat(4, 38px); gap: 6px; min-width: 0; }
.swatch { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--line-soft); background: var(--bg); font: 700 1rem var(--serif); cursor: pointer; color: var(--ink); }
.swatch:hover { border-color: var(--ink-3); }
.rte-insert { display: grid; min-width: 14rem; }
.rte-insert button { display: flex; align-items: center; gap: .7rem; padding: .45rem .5rem; border: 0; border-radius: 8px; background: none; color: var(--ink); font: 500 .92rem var(--sans); cursor: pointer; text-align: left; }
.rte-insert button:hover { background: var(--surface-2); }
.rte-menu__label { margin: .5rem .5rem .2rem; color: var(--ink-3); font-size: .78rem; font-weight: 600; }
.rte-menu__label:first-child { margin-top: .1rem; }
.ins-prev { display: inline-grid; place-items: center; width: 44px; height: 26px; border-radius: 5px; border: 1px solid var(--line-soft); color: var(--accent); font: 600 .75rem var(--code); flex: none; }
.ins-line::after { content: ""; width: 28px; border-top: 1px solid var(--ink-3); }
.ins-cols { grid-auto-flow: column; gap: 3px; padding: 4px; }
.ins-cols i { display: block; width: 100%; height: 100%; border-radius: 2px; background: var(--line); }
.ins-note { background: var(--accent-wash); border-left: 3px solid var(--accent); }
.ins-tip { background: color-mix(in srgb, var(--c-green) 15%, transparent); border-left: 3px solid var(--c-green); }
.ins-warning { background: color-mix(in srgb, var(--c-orange) 15%, transparent); border-left: 3px solid var(--c-orange); }
.rte-link { width: min(24rem, 80vw); display: grid; gap: .6rem; }
.rte-link label { display: grid; gap: .35rem; font-weight: 600; font-size: .88rem; }
.rte-link small { color: var(--ink-3); }

.rte__context { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; padding: .6rem .9rem; border-bottom: 1px solid var(--line-soft); background: var(--bg-raise); }
.rte__ctx-group { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.rte__ctx-grow { flex: 1; min-width: 14rem; }
.rte__ctx-label { color: var(--ink-3); font-size: .82rem; font-weight: 600; margin-right: .2rem; }
.rte__alt { min-height: 34px; padding: .35rem .6rem; font-size: .9rem; }
.needs-alt .rte__alt { border-color: var(--c-orange); }
.chip-btn { padding: .32rem .7rem; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: 600 .82rem var(--sans); cursor: pointer; }
.chip-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-btn--danger { color: var(--danger); }

.rte__area { min-height: 26rem; padding: 2rem clamp(1rem, 4vw, 3rem) 3rem; outline: none; max-width: 52rem; margin: 0 auto; }
.rte__area:focus-visible { outline: none; }
.rte__area.is-dropping { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0 0 14px 14px; }
.rte__area .img--wide, .rte__area .img--full { width: 100%; left: 0; transform: none; outline: 1px dashed var(--line); outline-offset: 6px; }
.rte__area figure.img { cursor: default; }
.rte__area figure.img img { cursor: pointer; }
.rte__area figure.is-selected img { outline: 3px solid var(--accent); outline-offset: 3px; }
.rte__area figcaption:empty::before { content: "Add a caption (optional)"; color: var(--ink-3); }
.rte__area .cols > .col { outline: 1px dashed var(--line); outline-offset: 6px; border-radius: 2px; min-height: 2em; }
.rte__area .uploading { color: var(--ink-3); font-style: italic; }
.rte__area .upload-failed { color: var(--danger); }
.rte__foot { display: flex; gap: 1.5rem; flex-wrap: wrap; padding: .6rem .9rem; border-top: 1px solid var(--line-soft); color: var(--ink-3); font-size: .85rem; }
.rte__foot .is-flash { color: var(--c-orange); font-weight: 600; }
[data-count].over { color: var(--c-orange); font-weight: 600; }
@media (max-width: 640px) {
  .rte__bar { top: 64px; gap: .2rem; }
  .rte__group { border-right: 0; padding-right: 0; }
}

/* ---- Analytics: globe and traffic sources -------------------------------- */
.geo-card, .sources { margin-bottom: 3rem; }
.geo-card__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.geo-card h2, .sources h2 { font-size: 1.25rem; }
.geo { display: grid; gap: 2rem; align-items: start; }
@media (min-width: 1000px) { .geo { grid-template-columns: minmax(0, 520px) minmax(0, 1fr); gap: 3rem; } }
.globe { position: relative; display: grid; justify-items: center; }
.globe canvas { display: block; touch-action: none; cursor: grab; max-width: 100%; }
.globe canvas.is-dragging { cursor: grabbing; }
.globe .chart__tip { z-index: 2; }
.globe__legend { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1rem; margin-top: .9rem; font-size: .82rem; color: var(--ink-2); justify-content: center; }
.globe__legend-title { font-weight: 600; color: var(--ink-3); }
.globe__legend-item { display: inline-flex; align-items: center; gap: .4rem; font-variant-numeric: tabular-nums; }
.globe__legend-item i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.globe__hint { margin: .3rem 0 0; color: var(--ink-3); font-size: .8rem; }
.globe--failed canvas { opacity: .3; }
.flag { margin-right: .55rem; }
.attribution { margin-top: 1rem; font-size: .8rem; color: var(--ink-3); }
.attribution a { color: inherit; }
.setup-note { padding: 1.2rem 1.4rem; border: 1px dashed var(--line); border-radius: 12px; background: var(--bg-raise); }
.setup-note pre { margin: .6rem 0; padding: .7rem .9rem; border-radius: 8px; background: #0b1222; color: #d6deeb; overflow-x: auto; font-size: .88rem; }
.sources h3 { font-size: 1rem; font-family: var(--sans); margin-bottom: .6rem; }
.share { display: inline-flex; align-items: center; gap: .5rem; justify-content: flex-end; }
.share__track { display: inline-block; width: 60px; height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.share__bar { display: block; height: 100%; width: 0; border-radius: 0 4px 4px 0; background: var(--accent); }
.small { font-size: .85rem; }


/* ---- Code blocks: language label, copy button, syntax colours -------------- */
.prose pre { position: relative; tab-size: 4; }
.prose pre[data-lang] { padding-top: 2.5rem; }
.prose pre[data-lang]::before {
  position: absolute; top: .65rem; left: 1.15rem; padding: .1rem .5rem; border-radius: 5px;
  background: #16213a; border: 1px solid #263556; color: #9fb0cc; font: 600 .72rem/1.4 var(--sans);
}
.prose pre[data-lang="plaintext"]::before { content: "Plain text"; }
.prose pre[data-lang="python"]::before { content: "Python"; }
.prose pre[data-lang="javascript"]::before { content: "JavaScript"; }
.prose pre[data-lang="typescript"]::before { content: "TypeScript"; }
.prose pre[data-lang="html"]::before { content: "HTML"; }
.prose pre[data-lang="css"]::before { content: "CSS"; }
.prose pre[data-lang="json"]::before { content: "JSON"; }
.prose pre[data-lang="bash"]::before { content: "Shell"; }
.prose pre[data-lang="sql"]::before { content: "SQL"; }
.prose pre[data-lang="csharp"]::before { content: "C#"; }
.prose pre[data-lang="java"]::before { content: "Java"; }
.prose pre[data-lang="cpp"]::before { content: "C / C++"; }
.prose pre[data-lang="go"]::before { content: "Go"; }
.prose pre[data-lang="rust"]::before { content: "Rust"; }
.prose pre[data-lang="php"]::before { content: "PHP"; }
.prose pre[data-lang="lua"]::before { content: "Lua"; }
.prose pre[data-lang="gdscript"]::before { content: "GDScript"; }
.prose pre code { display: block; white-space: pre; }
.code-copy {
  position: absolute; top: .5rem; right: .55rem; padding: .25rem .65rem; border-radius: 6px;
  border: 1px solid #263556; background: #16213a; color: #c4ccd6; font: 600 .75rem var(--sans); cursor: pointer;
}
.code-copy:hover { color: #fff; border-color: #3a4f7a; }
.tk-keyword { color: #82aaff; }
.tk-string { color: #a3d9a5; }
.tk-number { color: #f78c6c; }
.tk-comment { color: #6c7a96; font-style: italic; }
.tk-function { color: #82d8ff; }
.tk-type, .tk-attr, .tk-decorator, .tk-macro { color: #ffcb8b; }
.tk-literal, .tk-builtin { color: #ff9cac; }
.tk-tag { color: #f07178; }
.tk-property, .tk-selector { color: #c3e88d; }
.tk-variable, .tk-option, .tk-regex, .tk-meta { color: #c792ea; }

/* ---- Image widths (set by dragging an image's corner in the editor) -------- */
.prose figure.img.w-15 { width: 15%; }
.prose figure.img.w-20 { width: 20%; }
.prose figure.img.w-25 { width: 25%; }
.prose figure.img.w-30 { width: 30%; }
.prose figure.img.w-35 { width: 35%; }
.prose figure.img.w-40 { width: 40%; }
.prose figure.img.w-45 { width: 45%; }
.prose figure.img.w-50 { width: 50%; }
.prose figure.img.w-55 { width: 55%; }
.prose figure.img.w-60 { width: 60%; }
.prose figure.img.w-65 { width: 65%; }
.prose figure.img.w-70 { width: 70%; }
.prose figure.img.w-75 { width: 75%; }
.prose figure.img.w-80 { width: 80%; }
.prose figure.img.w-85 { width: 85%; }
.prose figure.img.w-90 { width: 90%; }
.prose figure.img.w-95 { width: 95%; }
.prose figure.img.w-100 { width: 100%; }

/* ---- Editor: code blocks, image handles, drag-and-drop -------------------- */
.rte__area pre { caret-color: #fff; outline: none; }
.rte__area pre:focus-within { box-shadow: 0 0 0 2px var(--accent); }
.rte__area figure.img { position: relative; }
.rte__area figure.is-selected { cursor: grab; }
.img-handle {
  position: absolute; right: -7px; bottom: 1.6rem; width: 16px; height: 16px; border-radius: 4px;
  background: var(--accent); border: 2px solid var(--surface); cursor: nwse-resize; z-index: 3; touch-action: none;
}
.img-size-tip {
  position: absolute; right: 12px; bottom: 2.6rem; padding: .15rem .5rem; border-radius: 6px;
  background: var(--ink); color: var(--bg); font: 600 .75rem var(--sans); z-index: 3; pointer-events: none;
}
.rte { position: relative; }
.rte__drop { position: absolute; height: 3px; border-radius: 3px; background: var(--accent); pointer-events: none; z-index: 6; box-shadow: 0 0 0 3px var(--accent-wash); }
.rte__area figure.is-moving { opacity: .4; }
.rte__ctx-group select { width: auto; min-height: 32px; padding: .2rem 1.8rem .2rem .6rem; font-size: .88rem; }
.rte__head-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

/* ---- Pop-out preview window --------------------------------------------- */
.pv-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.pv-bar {
  display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: center; padding: .55rem 1rem;
  border-bottom: 1px solid var(--line); background: var(--bg-raise); font-size: .88rem;
}
.pv-bar strong { font-family: var(--serif); font-size: 1rem; margin-right: .4rem; }
.pv-bar .segmented a, .pv-bar .segmented button { padding: .3rem .75rem; border-radius: 999px; border: 0; background: none; color: var(--ink-2); font: 600 .82rem var(--sans); cursor: pointer; }
.pv-bar .segmented [aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.pv-status { margin-left: auto; color: var(--ink-3); }
.pv-status.is-live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: .45rem; }
.pv-stage { flex: 1; display: flex; justify-content: center; overflow: hidden; background: var(--bg-raise); }
.pv-stage iframe { width: 100%; height: 100%; border: 0; background: var(--bg); transition: width .25s var(--ease); }
.pv-stage.is-device iframe { border-left: 1px solid var(--line); border-right: 1px solid var(--line); box-shadow: var(--shadow); }
.pv-note { margin: 0 0 1.5rem; padding: .7rem 1rem; border-radius: 10px; border: 1px dashed var(--line); color: var(--ink-3); font-size: .9rem; }

.img--right > .img-handle { right: auto; left: -7px; cursor: nesw-resize; }
.rte__area figure.is-moving { pointer-events: none; }
.article__cover, .post-row__cover img, .mini-post img { height: auto; }
.brand img { flex: none; width: 28px; height: 28px; }

.meta--byline { align-items: center; }
.byline { display: inline-flex; align-items: center; gap: .5rem; color: var(--ink) !important; font-weight: 600; text-decoration: none; }
.byline:hover span { text-decoration: underline; }

/* Cover picker in the post editor */
.cover-pick { display: grid; gap: .5rem; }
.cover-pick .label { font-weight: 600; font-size: .93rem; }
.cover-pick__row { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.cover-pick__frame { width: 240px; aspect-ratio: 1200 / 630; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-raise); display: grid; place-items: center; color: var(--ink-3); font-size: .88rem; }
.cover-pick__frame img { width: 100%; height: 100%; object-fit: cover; }
.cover-pick__actions { display: grid; gap: .5rem; flex: 1; min-width: 16rem; }
.cover-pick__actions small { color: var(--ink-3); font-size: .85rem; }
.article__cover { object-fit: cover; }
