/* ==========================================================================
   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; }
}
