/*
 * MDSwap — rendered markdown preview, not raw editor.
 */

/* @critical-start */
:root,
:root[data-theme="midnight"] {
  --bg: #0a0b0e;
  --surface: #14161c;
  --surface-2: #1c1f27;
  --surface-3: #262932;
  --border: #2c2f38;
  --border-soft: #1f222a;
  --ink: #ecedef;
  --ink-soft: #b9bbc1;
  --muted: #8a8d96;
  --syntax: #555861;
  --accent: #67d4ff;
  --accent-strong: #94e3ff;
  --accent-hover: #94e3ff;
  --accent-bg: rgba(103, 212, 255, 0.12);
  --accent-ink: #021924;
  --link: #67d4ff;
  --good: #6ee7a3;
  --warn: #f5c46e;
  --bad: #ff7d7d;
  --danger: #ef6b6b;
  --info: #7fa9ff;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.6), 0 18px 40px rgba(0, 0, 0, 0.45);
  --shadow-soft: 0 1px 0 rgba(0, 0, 0, 0.25);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
  color-scheme: dark;
}

:root[data-theme="purple"] {
  --bg: #0c0916;
  --surface: #161023;
  --surface-2: #1f1730;
  --surface-3: #2a1f40;
  --border: #322342;
  --border-soft: #221733;
  --ink: #f1eff7;
  --ink-soft: #cbc4dd;
  --muted: #9088a3;
  --syntax: #5a5070;
  --accent: #b58cff;
  --accent-strong: #d6b9ff;
  --accent-hover: #d6b9ff;
  --accent-bg: rgba(181, 140, 255, 0.16);
  --accent-ink: #14072a;
  --link: #c8a6ff;
  --good: #84e7b1;
  --warn: #f5c46e;
  --bad: #ff8b8b;
  --danger: #f47272;
  --info: #87b9ff;
  color-scheme: dark;
}

:root[data-theme="blue"] {
  --bg: #08101e;
  --surface: #0f1a2e;
  --surface-2: #15233c;
  --surface-3: #1e2f4d;
  --border: #2a3f5f;
  --border-soft: #1a2840;
  --ink: #ecf0f8;
  --ink-soft: #bfcadb;
  --muted: #7d89a4;
  --syntax: #495673;
  --accent: #5fa0ff;
  --accent-strong: #8cbdff;
  --accent-hover: #8cbdff;
  --accent-bg: rgba(95, 160, 255, 0.16);
  --accent-ink: #04132c;
  --link: #8cbdff;
  --good: #6ee7a3;
  --warn: #f5c46e;
  --bad: #ff8585;
  --danger: #ee6464;
  --info: #9ec8ff;
  color-scheme: dark;
}

:root[data-theme="forest"] {
  --bg: #07120c;
  --surface: #0f1c14;
  --surface-2: #15281c;
  --surface-3: #1d3527;
  --border: #284939;
  --border-soft: #16291e;
  --ink: #ecf0eb;
  --ink-soft: #bccdbc;
  --muted: #7e8b80;
  --syntax: #4b5b51;
  --accent: #5cca8b;
  --accent-strong: #8ee4b1;
  --accent-hover: #8ee4b1;
  --accent-bg: rgba(92, 202, 139, 0.16);
  --accent-ink: #042214;
  --link: #8ee4b1;
  --good: #8ee4b1;
  --warn: #f5c46e;
  --bad: #ff8585;
  --danger: #ee6464;
  --info: #7fb6e0;
  color-scheme: dark;
}

:root[data-theme="daylight"] {
  --bg: #fbfaf6;
  --surface: #ffffff;
  --surface-2: #f4f2ec;
  --surface-3: #e9e6dd;
  --border: #d2cec3;
  --border-soft: #ebe7dd;
  --ink: #0f1318;
  --ink-soft: #3a3d44;
  --muted: #62656e;
  --syntax: #9a9b9f;
  --accent: #4a2cdc;
  --accent-strong: #6a4dff;
  --accent-hover: #3a1fc4;
  --accent-bg: rgba(74, 44, 220, 0.1);
  --accent-ink: #ffffff;
  --link: #4a2cdc;
  --good: #15803d;
  --warn: #9a6700;
  --bad: #b91c1c;
  --danger: #b91c1c;
  --info: #1d4ed8;
  --shadow: 0 1px 0 rgba(31, 35, 40, 0.04), 0 18px 40px rgba(31, 35, 40, 0.08);
  --shadow-soft: 0 1px 0 rgba(31, 35, 40, 0.04);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

html {
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

::selection {
  background: var(--accent-bg);
  color: var(--accent-strong);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}

a:hover {
  border-bottom-color: var(--link);
}

a:visited {
  color: color-mix(in srgb, var(--link) 70%, var(--muted));
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ===== App layout ===== */
#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}

/* Skip-link, hidden until focused. */
.skip-link {
  position: absolute;
  left: -1000px;
  top: -1000px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 14px;
  border-radius: 6px;
  z-index: 1000;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

main:focus {
  outline: none;
}
/* @critical-end */

/* Footer baseline. */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 24px 28px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.86rem;
}
.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-soft); }
.footer-links { display: flex; flex-wrap: wrap; gap: 14px; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--ink); }

@media (max-width: 640px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* ===== Top app bar ===== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 36px);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 1.04rem;
  border-bottom: 0;
}

.brand:hover {
  border-bottom: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: -0.02em;
}

img.brand-mark {
  background: transparent;
  border-radius: 0;
  object-fit: contain;
  width: 40px;
  height: 40px;
  margin-right: -2px;
}

.footer-brand img.brand-mark.footer-brand-mark {
  width: 32px;
  height: 32px;
  margin-right: 0;
}

.appbar-spacer {
  flex: 1;
}

.appbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ===== Document area ===== */
.document {
  padding: 24px clamp(16px, 4vw, 36px) 96px;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
}

.reading {
  max-width: 820px;
  margin: 0 auto;
}

/* ===== Filename pill (subtle MD callback) ===== */
.filename {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0;
  margin-bottom: 18px;
}

.filename .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.filename a {
  color: var(--ink-soft);
  border-bottom: 0;
}

.filename a:hover {
  color: var(--ink);
}

.filename .sep {
  color: var(--syntax);
}

.filename .file {
  color: var(--ink);
}

/* ===== Typography ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--sans);
  color: var(--ink);
  letter-spacing: -0.018em;
  line-height: 1.18;
  margin: 0 0 0.4em;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 4.5vw, 2.85rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 0.3em;
}

h2 {
  font-size: 1.55rem;
  margin-top: 2.2rem;
}

h3 {
  font-size: 1.18rem;
  margin-top: 1.6rem;
}

h4 {
  font-size: 1rem;
  color: var(--ink-soft);
  margin-top: 1.4rem;
  text-transform: none;
  letter-spacing: 0;
}

p {
  margin: 0 0 1em;
  color: var(--ink);
}

.lead {
  font-size: 1.18rem;
  color: var(--ink-soft);
  line-height: 1.55;
  margin-bottom: 1.5em;
  max-width: 680px;
}

ul,
ol {
  margin: 0 0 1em;
  padding-left: 1.4em;
}

li {
  margin: 0.2em 0;
}

li::marker {
  color: var(--muted);
}

blockquote {
  margin: 0 0 1.2em;
  padding: 8px 16px;
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink);
}

blockquote p {
  margin: 0;
}

hr {
  border: 0;
  height: 1px;
  background: var(--border-soft);
  margin: 2.4em 0;
}

code {
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.86em;
  color: var(--accent-strong);
}

pre {
  margin: 0 0 1.2em;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--ink);
}

pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

pre.fenced {
  position: relative;
  padding-top: 32px;
}

pre.fenced .fence-label {
  position: absolute;
  top: 8px;
  left: 16px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.2em;
  font-size: 0.94rem;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

th {
  background: var(--surface-2);
  font-weight: 700;
}

img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

/* ===== Buttons ===== */
.btn,
.btn-primary,
.btn-quiet,
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.94rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:hover,
.btn-primary:hover,
.btn-quiet:hover {
  border-color: var(--accent);
  background: var(--surface-2);
  border-bottom-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink-soft);
}

.btn-quiet:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: transparent;
}

.btn-danger {
  color: var(--bad);
  border-color: var(--border);
}

.btn-danger:hover {
  border-color: var(--bad);
  color: var(--danger);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
}

a.btn,
a.btn-primary,
a.btn-quiet,
a.btn-icon {
  border-bottom: 1px solid var(--border);
}

/* Buttons rendered as <a> were inheriting the muted color from the global
   a:visited rule once their href had been clicked, which made the text
   blend into the button background (especially noticeable on the lavender
   "Publish an MD" CTA in the purple theme). Restore the unvisited foreground
   per button class so visited state is visually identical to fresh state. */
a.btn:visited,
a.btn:visited:hover { color: var(--ink); }
a.btn-primary:visited,
a.btn-primary:visited:hover { color: var(--accent-ink); }
a.btn-quiet:visited,
a.btn-quiet:visited:hover { color: var(--ink-soft); }
a.btn-icon:visited,
a.btn-icon:visited:hover { color: var(--ink); }
a.btn-danger:visited,
a.btn-danger:visited:hover { color: var(--bad); }

a.btn:hover,
a.btn-quiet:hover,
a.btn-icon:hover {
  border-bottom-color: var(--accent);
}

a.btn-primary {
  border-bottom-color: var(--accent);
}

a.btn-primary:hover {
  border-bottom-color: var(--accent-strong);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 14px 0 0;
}

.btn-row.spread {
  justify-content: space-between;
}

/* ===== Theme picker ===== */
.theme-picker {
  position: relative;
}

.theme-picker > .picker-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.86rem;
  cursor: pointer;
}

.theme-picker > .picker-trigger:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.theme-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.theme-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: none;
  z-index: 30;
}

.theme-picker.open .theme-popover {
  display: block;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  color: var(--ink);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.92rem;
}

.theme-option:hover,
.theme-option.active {
  background: var(--surface-2);
}

.theme-option.active::after {
  content: "✓";
  margin-left: auto;
  color: var(--accent);
  font-weight: 700;
}

/* Theme swatch fills (preview circles) */
.swatch-midnight { background: linear-gradient(135deg, #0a0b0e 50%, #67d4ff 50%); }
.swatch-purple { background: linear-gradient(135deg, #0c0916 50%, #b58cff 50%); }
.swatch-blue { background: linear-gradient(135deg, #08101e 50%, #5fa0ff 50%); }
.swatch-forest { background: linear-gradient(135deg, #07120c 50%, #5cca8b 50%); }
.swatch-daylight { background: linear-gradient(135deg, #fbfaf6 50%, #4a2cdc 50%); }

/* ===== Notifications bell ===== */
.notif-bell {
  position: relative;
}

.notif-bell > .notif-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 1rem;
  cursor: pointer;
  position: relative;
}

.notif-bell > .notif-trigger:hover,
.notif-bell.open > .notif-trigger {
  border-color: var(--accent);
  color: var(--ink);
}

.notif-bell .notif-icon {
  font-size: 1rem;
  line-height: 1;
}

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bad, #ef5b5b);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  border: 1px solid var(--surface);
}

.notif-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 30;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notif-list {
  overflow-y: auto;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.notif-empty {
  padding: 16px 12px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  text-align: center;
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 0;
  color: var(--ink);
  border-radius: var(--radius-sm);
  text-align: left;
  font: inherit;
  cursor: pointer;
  position: relative;
}

.notif-item:hover,
.notif-item:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.notif-item:focus-visible {
  box-shadow: 0 0 0 2px var(--accent);
}

.notif-item.unread {
  background: var(--surface-2);
}

.notif-item-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--accent);
}

.notif-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.notif-item-text {
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--ink);
  word-break: break-word;
}

.notif-item-meta {
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.notif-item-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.notif-footer {
  border-top: 1px solid var(--border);
  padding: 6px;
  display: flex;
  justify-content: flex-end;
}

.notif-mark-all {
  font-size: 0.82rem;
}

/* ===== Account pill ===== */
.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px 0 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
  border-bottom: 1px solid var(--border);
}

.account-pill:hover {
  border-color: var(--accent);
  border-bottom-color: var(--accent);
}

.account-pill img,
.account-pill .avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.74rem;
}

.account-pill .handle {
  font-family: var(--mono);
  font-size: 0.84rem;
  color: var(--ink-soft);
}

/* ===== Search bar (in app bar) ===== */
.search-input {
  flex: 1;
  max-width: 480px;
  height: 40px;
  padding: 0 16px 0 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.94rem;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237d808a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 14px center;
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

/* ===== Frontmatter card (subtle MD callback) ===== */
.frontmatter {
  margin: 0 0 24px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--ink-soft);
  display: grid;
  gap: 6px;
  position: relative;
}

.frontmatter::before,
.frontmatter::after {
  content: "---";
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}

.frontmatter .row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
}

.frontmatter .key {
  color: var(--accent);
  font-weight: 600;
}

.frontmatter .key::after {
  content: ":";
  color: var(--syntax);
}

.frontmatter .value {
  color: var(--ink);
  word-break: break-word;
}

.frontmatter .value a {
  color: var(--link);
  border-bottom: 1px solid transparent;
}

.frontmatter .value a:hover {
  border-bottom-color: var(--link);
}

.frontmatter .value .tag {
  display: inline-block;
  margin: 0 4px 2px 0;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent-strong);
  font-size: 0.78rem;
}

/* ===== Filter chips ===== */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 24px;
  align-items: center;
}

.chip-row .label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-right: 4px;
}

.chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.86rem;
  cursor: pointer;
  font-family: var(--sans);
}

.chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin: 0 0 32px;
}

.card {
  display: grid;
  gap: 10px;
  padding: 18px 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  border-bottom: 1px solid var(--border);
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  border-bottom-color: var(--accent);
  box-shadow: var(--shadow-soft);
}

.card-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}

.card-type {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.card-title {
  margin: 0;
  font-size: 1.0625rem;
  line-height: 1.3;
  color: var(--ink);
  font-weight: 700;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tagline {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.5;
  -webkit-line-clamp: 2;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 4px 0 0;
}

.card-tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.card-tag::before {
  content: "#";
  color: var(--syntax);
  margin-right: 1px;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  font-size: 0.78rem;
  color: var(--muted);
}

.card-foot a {
  color: var(--ink-soft);
}

.card-foot a:hover {
  color: var(--accent);
}

/* Reddit-style: title pops, everything else collapses to a single muted line. */
.card-reddit {
  gap: 8px;
}
.card-reddit .card-title {
  -webkit-line-clamp: 2;
  font-size: 1.25rem;
  line-height: 1.3;
}
.card-meta-flat {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.55;
  display: flex;
  flex-wrap: wrap;
  gap: 0 7px;
  align-items: baseline;
}
.card-meta-flat > span { display: inline-flex; align-items: baseline; }
.card-meta-flat .meta-dot { color: var(--muted); opacity: 0.55; padding: 0 1px; }
.card-meta-flat .meta-type {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
}
.card-meta-flat .meta-author { color: var(--ink-soft); }
.card-meta-flat .meta-stars { color: var(--ink-soft); }
.card-meta-flat .meta-stars-count { color: var(--muted); margin-left: 3px; }
.card-meta-flat .meta-stars.muted { color: var(--muted); }
.card-meta-flat .meta-score { color: var(--ink-soft); font-weight: 600; }
.card-meta-flat .meta-license { color: var(--muted); font-family: var(--mono); font-size: 0.875rem; }
.card-meta-flat .meta-age { color: var(--muted); }
.card-meta-flat .meta-tag { color: var(--muted); font-family: var(--mono); }
.card-meta-flat .meta-tag::before { content: "#"; color: var(--syntax); margin-right: 1px; }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 8px 0 32px;
  font-size: 0.95rem;
  color: var(--muted);
}
.pager-arrow {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.pager-arrow:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pager-arrow:active:not(:disabled) { transform: translateY(1px); }
.pager-arrow:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager-status { font-variant-numeric: tabular-nums; }

.card-insights {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-soft);
  font-size: 0.78rem;
  color: var(--muted);
}

.card-insights-label {
  font-weight: 600;
  color: var(--ink);
}

.sparkline {
  display: inline-block;
  vertical-align: middle;
  color: var(--accent);
  flex-shrink: 0;
}

.sparkline rect {
  fill: currentColor;
}

.author-insights-sparkline {
  margin: 4px 0 8px;
  color: var(--accent);
}

/* ===== Stars ===== */
.star-row {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: 0.86rem;
}

.star.filled {
  color: var(--warn);
}

.star.empty {
  color: var(--syntax);
}

.rating-summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--muted);
}

.rating-summary.muted .star.empty {
  color: var(--syntax);
}

.rating-number {
  color: var(--ink-soft);
  font-weight: 600;
}

/* ===== Hero (home page) ===== */
.hero {
  padding: 36px 0 12px;
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: -0.03em;
  font-weight: 800;
  line-height: 1.05;
}

.hero .lead {
  font-size: 1.22rem;
  margin-bottom: 24px;
}

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 12px;
}

.daily-hero {
  margin: 0 0 32px;
  padding: 24px 28px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 70%);
}

.daily-hero h2,
.daily-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
}

.daily-hero h2 a {
  color: inherit;
  text-decoration: none;
}

.daily-hero h2 a:hover {
  color: var(--accent);
}

.daily-hero-eyebrow {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.74rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.daily-hero-lead {
  font-size: 1.05rem;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

.daily-hero-meta {
  font-size: 0.86rem;
  color: var(--muted);
  margin: 0 0 14px;
}

.daily-hero-body {
  margin: 8px 0 14px;
  font-size: 0.96rem;
}

.daily-archive {
  list-style: none;
  padding: 0;
  margin: 24px 0;
  display: grid;
  gap: 8px;
}

.daily-archive li > a {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  align-items: center;
}

.daily-archive li > a:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, transparent);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin: 16px 0 28px;
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface);
}

.metric-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.metric-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}

.admin-top {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 24px;
  font-size: 0.86rem;
}

.admin-top th,
.admin-top td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
}

.admin-top th {
  color: var(--muted);
  font-weight: 600;
  border-bottom-color: var(--border);
}

.admin-widget {
  margin: 24px 0;
  padding: 16px 18px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
}

.admin-widget h3 {
  margin: 8px 0 4px;
  font-size: 0.96rem;
  font-weight: 700;
}

/* ===== Admin nav (was inline style) ===== */
.admin-nav {
  display: flex;
  gap: 8px;
  margin: 12px 0 24px;
  flex-wrap: wrap;
}

/* ===== Admin queue table (was inline styles) ===== */
.admin-queue {
  width: 100%;
  border-collapse: collapse;
}

.admin-queue th,
.admin-queue td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border-soft);
}

.admin-queue th {
  border-bottom-color: var(--border);
}

.admin-queue td.created,
.admin-queue td.note {
  font-size: 0.86rem;
}

.admin-queue td.note {
  max-width: 24em;
}

.admin-queue td.actions {
  white-space: nowrap;
}

/* ===== Audit log (was inline styles) ===== */
.audit-log {
  list-style: none;
  padding: 0;
  margin: 0;
}

.audit-log li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.86rem;
}

/* ===== Validation feedback (was inline styles in publish form) ===== */
.validation-list {
  padding-left: 18px;
  margin: 0;
}

.validation-list li {
  color: var(--bad);
}

.validation-success {
  color: var(--good);
  margin: 0;
}

/* ===== Profile banner socials line (was inline style) ===== */
.profile-banner-links {
  margin-top: 8px;
  font-size: 0.86rem;
}

/* ===== Message thread status (was inline style) ===== */
.message-status-bar {
  padding: 0 14px 8px;
}

/* ===== Publish form bot-check note (was inline style) ===== */
.bot-check-note {
  font-size: 0.86rem;
}

/* ===== Newsletter form (transparency.html, community/conduct.html) ===== */
.newsletter-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 8px 0 16px;
}

.newsletter-form label {
  font-size: 0.86rem;
}

.newsletter-form input[type="email"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  min-width: 240px;
}

.newsletter-disclaimer {
  font-size: 0.86rem;
}

/* ===== Account deletion-cancelled page (api/account.js) ===== */
.delete-page-body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 2em;
  max-width: 48em;
}

/* ===== Embed iframe (api/embed.js) ===== */
.embed-body {
  margin: 0;
  background: #0a0b0e;
  color: #ecedef;
  font-family: ui-sans-serif, system-ui, -apple-system, sans-serif;
}

.embed-card {
  padding: 14px 16px;
  border: 1px solid #2c2f38;
  border-radius: 10px;
  max-width: 640px;
  margin: 8px auto;
}

.embed-eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a8d96;
}

.embed-card h1 {
  font-size: 1.0625rem;
  line-height: 1.3;
  margin: 0.4em 0;
}

.embed-card p.lead {
  font-size: 0.9rem;
  color: #b9bbc1;
  margin: 0 0 8px;
}

.embed-card pre {
  background: #14161c;
  border: 1px solid #2c2f38;
  border-radius: 8px;
  padding: 10px;
  overflow: auto;
  font-size: 0.86rem;
  line-height: 1.55;
  max-height: 240px;
}

.embed-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.embed-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid #2c2f38;
  border-radius: 8px;
  color: #ecedef;
  background: transparent;
  text-decoration: none;
  font-size: 0.86rem;
}

.embed-btn-primary {
  background: #67d4ff;
  color: #0a0b0e;
  border-color: #67d4ff;
}

.embed-source {
  font-size: 0.78rem;
  color: #8a8d96;
  margin-top: 6px;
}

.embed-source a {
  color: #94e3ff;
}

.embed-not-found {
  margin: 1.2em;
  font-family: system-ui, -apple-system, sans-serif;
}

/* ===== Sections ===== */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 36px 0 16px;
}

.section-head h2 {
  margin: 0;
}

.section-head .meta {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
}

/* ===== Layouts ===== */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 36px;
  align-items: start;
}

.split > .split-side {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 84px;
}

.side-block {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.side-block h3 {
  margin: 0 0 10px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.side-block p {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.side-block .meta-list {
  display: grid;
  gap: 6px;
}

.side-block .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.86rem;
  color: var(--muted);
}

.side-block .meta-row strong {
  color: var(--ink);
  font-weight: 600;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}

.toc-list li {
  margin: 0;
}

.toc-list li::marker {
  display: none;
}

.toc-list a {
  display: block;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border-bottom: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
  line-height: 1.3;
}

.toc-list a:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-bottom: 0;
}

.toc-list a.active {
  background: var(--accent-bg);
  color: var(--accent-strong);
  font-weight: 600;
}

.kbd-inline {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.2;
}

.shortcuts-grid {
  display: grid;
  gap: 8px;
  margin: 8px 0 16px;
}

.shortcuts-grid .row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: center;
  font-size: 0.92rem;
}

.shortcuts-grid .row .keys {
  display: inline-flex;
  gap: 4px;
}

.shortcuts-grid .row .desc {
  color: var(--ink-soft);
}

/* ===== Listing actions ===== */
.listing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 28px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
}

.listing-actions .secondary-actions {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}

.listing-more {
  position: relative;
  margin-left: auto;
}

.listing-more-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 30;
  display: grid;
}

.listing-more-popover button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: 0;
  color: var(--ink);
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 0.92rem;
  cursor: pointer;
}

.listing-more-popover button:hover {
  background: var(--surface-2);
}

.listing-more-popover button.danger {
  color: var(--bad);
}

.listing-more-popover button.danger:hover {
  color: var(--danger);
}

/* ===== Markdown body (rendered preview) ===== */
.markdown {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
}

.markdown h1 {
  font-size: 1.85rem;
  margin-top: 0;
}

.markdown h2 {
  font-size: 1.45rem;
  margin-top: 1.8rem;
}

.markdown h3 {
  font-size: 1.16rem;
}

.markdown > * + * {
  margin-top: 0.9rem;
}

.markdown ul,
.markdown ol {
  padding-left: 1.5em;
}

.markdown blockquote {
  font-size: 1rem;
}

.markdown a {
  border-bottom: 1px solid var(--accent-bg);
  color: var(--link);
}

.markdown a:hover {
  border-bottom-color: var(--link);
}

.markdown details {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  background: var(--surface);
}

.markdown summary {
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.86rem;
  color: var(--muted);
}

/* ===== Forms ===== */
.form {
  display: grid;
  gap: 16px;
}

.form .field {
  display: grid;
  gap: 6px;
}

.form .field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.form label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.form input,
.form select,
.form textarea {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.96rem;
  transition: border-color 0.12s ease;
}

.form textarea {
  height: auto;
  min-height: 120px;
  padding: 12px 14px;
  resize: vertical;
  line-height: 1.55;
  font-family: var(--mono);
  font-size: 0.92rem;
}

.form textarea.tall {
  min-height: 320px;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-bg);
  outline-offset: 0;
}

.form input:disabled,
.form input[readonly] {
  color: var(--muted);
  background: var(--surface-2);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.field-help {
  font-size: 0.82rem;
  color: var(--muted);
}

.status-line {
  font-size: 0.86rem;
  color: var(--muted);
  min-height: 18px;
}

.status-line.error { color: var(--bad); }
.status-line.success { color: var(--good); }
.status-line.pending { color: var(--ink-soft); }

/* ===== System notice ===== */
.system-notice {
  margin: 0 0 18px;
  padding: 10px 14px;
  border: 1px solid var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 0.9rem;
}

.system-notice::before {
  content: "⚠ ";
  color: var(--warn);
  font-weight: 700;
}

.empty {
  padding: 28px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}

.empty-state {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 36px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--muted);
}

.empty-state h2 {
  margin: 4px 0 0;
  font-size: 1.1rem;
  color: var(--ink);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-state .btn-row {
  margin-top: 8px;
}

.filter-result-count {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px;
}

/* ===== Profile ===== */
.profile-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  margin: 8px 0 28px;
}

.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  object-fit: cover;
  cursor: pointer;
}

.profile-avatar.placeholder {
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.profile-banner h1 {
  margin: 0;
}

.profile-handle {
  font-family: var(--mono);
  color: var(--muted);
  font-size: 0.92rem;
}

.profile-handle .at { color: var(--syntax); }

/* ===== Admin badge ===== */
.admin-badge {
  display: inline-block;
  vertical-align: -0.15em;
  margin-left: 6px;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  pointer-events: none;
  user-select: none;
  overflow: visible;
}

.admin-badge-sm { width: 1em; height: 1em; }
.admin-badge-lg {
  width: 0.85em;
  height: 0.85em;
  vertical-align: 0.05em;
  margin-left: 12px;
}

.profile-banner h1 .admin-badge { width: 0.6em; height: 0.6em; }

.profile-admin-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 4px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent, #67d4ff);
  background: linear-gradient(90deg, rgba(103, 212, 255, 0.12), rgba(110, 231, 163, 0.08));
  border: 1px solid rgba(103, 212, 255, 0.35);
  border-radius: 999px;
  width: max-content;
  max-width: 100%;
}

.profile-admin-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent, #67d4ff);
  box-shadow: 0 0 8px rgba(103, 212, 255, 0.7);
}

.profile-bio {
  max-width: 680px;
  margin-top: 6px;
  color: var(--ink);
}

.profile-actions {
  margin: 14px 0 0;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.profile-stat {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.profile-stat .key {
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.profile-stat .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* ===== Avatar uploader ===== */
.avatar-upload {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 14px;
}

.avatar-upload .preview {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.avatar-upload .preview.placeholder {
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--ink-soft);
}

.avatar-upload .help {
  font-size: 0.84rem;
  color: var(--muted);
  margin: 0 0 8px;
}

/* ===== Reviews ===== */
.review {
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
}

.review .body {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.55;
}

.review .meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 60%, rgba(0, 0, 0, 0.6));
  backdrop-filter: blur(4px);
}

.modal-card {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 51;
  width: min(480px, calc(100vw - 24px));
  max-height: calc(100vh - 60px);
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 1.32rem;
}

.modal-card p {
  margin: 0 0 16px;
  color: var(--ink-soft);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 1rem;
}

.modal-close:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}

.oauth-actions {
  flex-direction: column;
  border-top: 1px solid var(--border-soft);
  margin-top: 12px;
  padding-top: 12px;
  gap: 8px;
}

.oauth-actions .btn {
  width: 100%;
}

.rating-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 8px 0 14px;
}

.rating-picker label {
  display: block;
  position: relative;
}

.rating-picker input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rating-picker span {
  display: grid;
  height: 44px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-weight: 600;
  cursor: pointer;
  background: var(--surface);
}

.rating-picker input:checked + span {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* ===== Toast ===== */
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  pointer-events: none;
  list-style: none;
  margin: 0;
  padding: 0;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 500;
  animation: toast-in 200ms ease-out;
}

.toast-stack .toast {
  position: static;
  pointer-events: auto;
}

/* ===== Messages ===== */
.thread-page {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  margin-top: 14px;
}

.thread-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
  border-right: 1px solid var(--border-soft);
  background: var(--surface);
  max-height: 600px;
  overflow-y: auto;
}

.thread-list li {
  margin: 0;
  padding: 0;
}

.thread-list li::marker { display: none; }

.thread-summary {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  border-left: 3px solid transparent;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
}

a.thread-summary {
  border-bottom: 1px solid var(--border-soft);
}

.thread-summary:hover {
  background: var(--surface-2);
}

.thread-summary.active {
  background: var(--surface-2);
  border-left-color: var(--accent);
}

.thread-summary .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--ink);
}

.thread-summary .who img,
.thread-summary .who .avatar-fallback {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.74rem;
  color: var(--ink);
  flex-shrink: 0;
}

.thread-summary .name {
  font-weight: 600;
}

.thread-summary .handle {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.thread-summary .preview {
  font-size: 0.82rem;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.thread-summary .stamp {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
}

.thread-empty {
  padding: 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.thread-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
}

.thread-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}

.thread-header img,
.thread-header .avatar-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  font-weight: 700;
  font-family: var(--mono);
}

.thread-header .name {
  font-weight: 700;
  font-size: 0.96rem;
}

.thread-header .handle {
  font-size: 0.82rem;
  color: var(--muted);
  font-family: var(--mono);
}

.thread-stream {
  padding: 18px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
  align-content: end;
  min-height: 360px;
  max-height: 480px;
  background: var(--bg);
}

.message {
  max-width: min(560px, 86%);
  padding: 10px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.94rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message .stamp {
  display: block;
  margin-top: 4px;
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--mono);
}

.message.outgoing {
  justify-self: end;
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.message.outgoing .stamp {
  color: color-mix(in srgb, var(--accent-ink) 50%, transparent);
}

.thread-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}

.thread-compose textarea {
  height: 44px;
  min-height: 44px;
  max-height: 200px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.94rem;
  line-height: 1.4;
  resize: vertical;
}

.thread-compose textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-bg);
}

.thread-no-selection {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* ===== Page error ===== */
.error-state {
  padding: 32px;
  border: 1px solid var(--bad);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  color: var(--ink);
}

/* ===== Source toggle (listing) ===== */
.source-toggle {
  margin-top: 22px;
}

.source-toggle summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 0.84rem;
  list-style: none;
}

.source-toggle summary::-webkit-details-marker {
  display: none;
}

.source-toggle summary:hover {
  border-color: var(--accent);
}

.source-toggle[open] summary {
  border-color: var(--accent);
  color: var(--ink);
}

.source-toggle pre {
  margin-top: 12px;
}

/* ===== Responsive ===== */
@media (max-width: 880px) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }

  .split > .split-side {
    position: static;
  }

  .thread-page {
    grid-template-columns: 1fr;
  }

  .thread-list {
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    max-height: 220px;
  }

  .form .field-row {
    grid-template-columns: 1fr;
  }

  .profile-banner {
    grid-template-columns: 1fr;
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .card:hover { transform: none; }
  .toast { animation: none; }
}

@media (max-width: 640px) {
  .appbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .search-input {
    order: 99;
    flex-basis: 100%;
    max-width: none;
  }

  .listing-actions .secondary-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
  }

  .modal-card {
    width: calc(100vw - 20px);
  }
}

/* ===== Utility ===== */
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }
