/* Quiet — a Margin theme. Clean sans-serif reading, frosted bars, a floating clap bar.
   Colours come from the accent setting (--accent); everything else follows light/dark. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --accent: #0a6ff0;
  --q-bg: #ffffff;
  --q-soft: #f5f5f7;
  --q-softer: #fafafb;
  --q-ink: #1d1d1f;
  --q-ink-2: #3a3a3c;
  --q-muted: #6e6e73;
  --q-faint: #86868b;
  --q-line: rgba(0, 0, 0, .08);
  --q-glass: rgba(250, 250, 252, .78);
  --q-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 28px rgba(0, 0, 0, .08);
  --q-accent-text: color-mix(in srgb, var(--accent) 86%, #000);
  --q-accent-soft: color-mix(in srgb, var(--accent) 11%, transparent);
  --q-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --q-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  --q-ease: cubic-bezier(.32, .72, 0, 1);

  /* Margin's reader UI reads these. */
  --m-accent: var(--accent);
  --m-accent-text: var(--q-accent-text);
  --m-bg: var(--q-bg);
  --m-surface: #ffffff;
  --m-grouped: #f2f2f7;
  --m-ink: var(--q-ink);
  --m-muted: var(--q-muted);
  --m-line: var(--q-line);
  --m-soft: var(--q-soft);
  --m-glass: var(--q-glass);
  --m-font: var(--q-font);
  --m-radius: 16px;
  --m-highlight: color-mix(in srgb, var(--accent) 15%, transparent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --q-bg: #0b0b0c;
    --q-soft: #1c1c1e;
    --q-softer: #141416;
    --q-ink: #f5f5f7;
    --q-ink-2: #d1d1d6;
    --q-muted: #a1a1a6;
    --q-faint: #8e8e93;
    --q-line: rgba(255, 255, 255, .1);
    --q-glass: rgba(18, 18, 20, .74);
    --q-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .45);
    --q-accent-text: color-mix(in srgb, var(--accent) 70%, #fff);
    --q-accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
    --m-surface: #1c1c1e;
    --m-grouped: #111113;
    --m-highlight: color-mix(in srgb, var(--accent) 30%, transparent);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --q-bg: #0b0b0c;
  --q-soft: #1c1c1e;
  --q-softer: #141416;
  --q-ink: #f5f5f7;
  --q-ink-2: #d1d1d6;
  --q-muted: #a1a1a6;
  --q-faint: #8e8e93;
  --q-line: rgba(255, 255, 255, .1);
  --q-glass: rgba(18, 18, 20, .74);
  --q-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .45);
  --q-accent-text: color-mix(in srgb, var(--accent) 70%, #fff);
  --q-accent-soft: color-mix(in srgb, var(--accent) 22%, transparent);
  --m-surface: #1c1c1e;
  --m-grouped: #111113;
  --m-highlight: color-mix(in srgb, var(--accent) 30%, transparent);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--q-bg);
  color: var(--q-ink);
  font: 400 17px/1.5 var(--q-font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
.q-main { flex: 1; }

/* ---------- bar ---------- */
.q-bar {
  position: sticky; top: 0; z-index: 40;
  background: var(--q-glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--q-line);
  padding-top: env(safe-area-inset-top, 0px);
}
.q-bar-inner {
  max-width: 1160px; margin: 0 auto; height: 56px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  display: flex; align-items: center; gap: 18px;
}
.q-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.q-brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 15px; letter-spacing: -.01em;
}
.q-brand-logo { width: 30px; height: 30px; border-radius: 9px; object-fit: cover; }
.q-brand-name { font-weight: 650; font-size: 16.5px; letter-spacing: -.018em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-nav { display: flex; gap: 20px; font-size: 15px; color: var(--q-muted); }
.q-nav a { transition: color .2s; }
.q-bar-gap { flex: 1; }

/* ---------- shared ---------- */
.q-avatar { border-radius: 50%; object-fit: cover; background: var(--q-soft); flex: none; }
.q-kicker { display: block; font-size: 13px; font-weight: 600; letter-spacing: .02em; color: var(--q-accent-text); margin: 0 0 8px; }
.q-pill {
  display: inline-flex; align-items: center; height: 34px; padding: 0 15px; border-radius: 17px;
  background: var(--q-soft); color: var(--q-ink); font-size: 14.5px; font-weight: 500;
  transition: background .2s, transform .2s var(--q-ease);
}
.q-pill:active { transform: scale(.97); }
.q-pill-solid { background: var(--accent); color: #fff; }
.q-empty { color: var(--q-muted); padding: 24px 0; }

.q-hero { max-width: 800px; margin: 80px auto 48px; padding: 0 20px; text-align: center; }
.q-hero-small { margin-top: 64px; }
.q-hero-title { margin: 0; font-size: clamp(38px, 6vw, 60px); line-height: 1.03; font-weight: 750; letter-spacing: -.04em; text-wrap: balance; }
.q-hero-text { margin: 18px auto 0; max-width: 620px; font-size: 21px; line-height: 1.45; color: var(--q-muted); letter-spacing: -.012em; text-wrap: pretty; }

.q-section { max-width: 1160px; margin: 0 auto 64px; padding: 0 20px; }
.q-section-title { font-size: 22px; font-weight: 700; letter-spacing: -.022em; margin: 0 0 20px; }

/* ---------- featured ---------- */
.q-lead { max-width: 1160px; margin: 0 auto 64px; padding: 0 20px; }
.q-lead-link {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: center; gap: 40px;
  padding: 16px; border-radius: 28px; background: var(--q-softer);
  transition: background .25s;
}
.q-lead-cover { display: block; border-radius: 18px; overflow: hidden; aspect-ratio: 16 / 10; background: var(--q-soft); }
.q-lead-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--q-ease); }
.q-lead-text { display: flex; flex-direction: column; gap: 12px; padding: 12px 24px 12px 0; }
.q-lead-title { font-size: clamp(28px, 3.4vw, 40px); line-height: 1.08; font-weight: 750; letter-spacing: -.032em; text-wrap: balance; }
.q-lead-desc { font-size: 18px; line-height: 1.5; color: var(--q-muted); }

/* ---------- cards ---------- */
.q-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 40px 28px; }
.q-grid-3 { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.q-card-link { display: flex; flex-direction: column; gap: 14px; height: 100%; }
.q-card-cover { display: block; aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden; background: var(--q-soft); }
.q-card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--q-ease); }
.q-card-text { display: flex; flex-direction: column; gap: 7px; }
.q-card-blog { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; color: var(--q-ink-2); }
.q-card-title { font-size: 21px; line-height: 1.22; font-weight: 700; letter-spacing: -.022em; text-wrap: balance; }
.q-card-desc { font-size: 15.5px; line-height: 1.5; color: var(--q-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q-card-meta { font-size: 13.5px; color: var(--q-faint); font-variant-numeric: tabular-nums; }

.q-list { max-width: 760px; margin: 0 auto; }
.q-row + .q-row { border-top: 1px solid var(--q-line); }
.q-row-link { display: flex; align-items: center; gap: 28px; padding: 26px 0; }
.q-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.q-row-title { font-size: 23px; line-height: 1.2; font-weight: 700; letter-spacing: -.025em; text-wrap: balance; }
.q-row-desc { font-size: 16px; line-height: 1.5; color: var(--q-muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q-row-cover { flex: none; width: 168px; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--q-soft); }
.q-row-cover img { width: 100%; height: 100%; object-fit: cover; }

.q-writers { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.q-writer { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 20px 12px; border-radius: 18px; background: var(--q-softer); text-align: center; }
.q-writer-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.q-writer-meta { font-size: 13px; color: var(--q-faint); }
.q-tags { display: flex; flex-wrap: wrap; gap: 8px; }

.q-pages { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 40px 0 0; }
.q-pages-at { font-size: 14px; color: var(--q-muted); font-variant-numeric: tabular-nums; }

.q-profile { max-width: 640px; margin: 64px auto 40px; padding: 0 20px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.q-profile-avatar { width: 88px; height: 88px; }
.q-profile-name { margin: 18px 0 0; font-size: 36px; line-height: 1.1; font-weight: 750; letter-spacing: -.035em; }
.q-profile-handle { margin: 6px 0 0; color: var(--q-muted); font-size: 15.5px; }
.q-profile-bio { margin: 14px 0 0; font-size: 18px; line-height: 1.5; color: var(--q-ink-2); text-wrap: pretty; }
.q-profile-links { margin: 18px 0 0; }

/* ---------- article ---------- */
.q-article { max-width: 720px; margin: 0 auto; padding: 64px 20px 0; }
.q-article-head .q-tags { margin-bottom: 18px; }
.q-tag {
  display: inline-flex; align-items: center; height: 28px; padding: 0 11px; border-radius: 14px;
  background: var(--q-soft); color: var(--q-muted); font-size: 13.5px; font-weight: 600;
}
.q-tag-first { background: var(--q-accent-soft); color: var(--q-accent-text); }
.q-title { margin: 0; font-size: clamp(34px, 5.2vw, 50px); line-height: 1.05; font-weight: 750; letter-spacing: -.036em; text-wrap: balance; }
.q-subtitle { margin: 16px 0 0; font-size: 21px; line-height: 1.42; color: var(--q-muted); letter-spacing: -.012em; text-wrap: pretty; }
.q-byline { display: flex; align-items: center; gap: 12px; margin: 30px 0 0; }
.q-byline .q-avatar { width: 42px; height: 42px; }
.q-byline-text { display: flex; flex-direction: column; gap: 1px; }
.q-byline-name { font-weight: 600; font-size: 15.5px; }
.q-byline-meta { font-size: 14px; color: var(--q-muted); font-variant-numeric: tabular-nums; }

.q-cover { margin: 40px -60px 8px; }
.q-cover img { display: block; width: 100%; border-radius: 20px; }

.q-prose { margin-top: 40px; font-size: 19px; line-height: 1.7; letter-spacing: -.008em; color: var(--q-ink); }
.q-prose p { margin: 0 0 1.3em; }
.q-prose h2 { font-size: 27px; line-height: 1.22; font-weight: 700; letter-spacing: -.025em; margin: 1.9em 0 .55em; }
.q-prose h3 { font-size: 21px; line-height: 1.3; font-weight: 700; letter-spacing: -.018em; margin: 1.7em 0 .5em; }
.q-prose h4, .q-prose h5, .q-prose h6 { font-size: 18px; font-weight: 700; margin: 1.5em 0 .4em; }
.q-prose a { color: var(--q-accent-text); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.q-prose strong { font-weight: 650; }
.q-prose ul, .q-prose ol { padding-left: 1.35em; margin: 0 0 1.3em; }
.q-prose li { margin: .35em 0; padding-left: .2em; }
.q-prose li::marker { color: var(--q-faint); }
.q-prose blockquote { margin: 1.6em 0; padding: 2px 0 2px 22px; border-left: 3px solid var(--q-line); color: var(--q-ink-2); font-size: 20px; }
.q-prose blockquote p:last-child { margin-bottom: 0; }
.q-prose :not(pre) > code { font-family: var(--q-mono); font-size: .86em; background: var(--q-soft); padding: .14em .4em; border-radius: 6px; }
.q-prose pre { margin: 1.6em 0; padding: 18px 20px; background: var(--q-soft); border-radius: 14px; overflow-x: auto; font: 14.5px/1.6 var(--q-mono); }
.q-prose hr { border: 0; margin: 2.4em 0; text-align: center; height: 20px; }
.q-prose hr::before { content: '· · ·'; color: var(--q-faint); letter-spacing: .5em; font-size: 20px; }
.q-prose img { border-radius: 12px; }
.q-prose input[type="checkbox"] { accent-color: var(--accent); margin-right: .4em; }

.q-dock { position: sticky; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 30; display: flex; justify-content: center; margin: 44px 0 0; pointer-events: none; }
.q-dock .m-actions {
  pointer-events: auto; gap: 2px; padding: 5px; border-radius: 28px;
  background: var(--q-glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 0 0 1px var(--q-line), var(--q-shadow);
}
.q-dock .m-actions-gap { flex: none; width: 1px; height: 22px; background: var(--q-line); margin: 0 4px; }
.q-dock .m-action { height: 44px; padding: 0 16px; border-radius: 22px; }
.q-dock .m-clap { background: var(--q-accent-soft); color: var(--q-accent-text); }

.q-article-foot { margin: 48px 0 0; display: flex; flex-direction: column; gap: 28px; }
.q-author { display: flex; align-items: center; gap: 16px; padding: 22px 0; border-top: 1px solid var(--q-line); border-bottom: 1px solid var(--q-line); }
.q-author .q-avatar { width: 56px; height: 56px; }
.q-author-text { display: flex; flex-direction: column; gap: 2px; }
.q-author-text .q-kicker { margin: 0; color: var(--q-faint); font-weight: 500; }
.q-author-name { font-weight: 700; font-size: 19px; letter-spacing: -.018em; }
.q-author-bio { font-size: 15px; color: var(--q-muted); line-height: 1.45; }

.q-after { max-width: 720px; margin: 0 auto; padding: 0 20px; }
.q-after .q-section { max-width: none; padding: 0; margin-top: 64px; }

.q-error { max-width: 640px; margin: 120px auto; padding: 0 20px; text-align: center; }
.q-error .q-hero-text { margin-bottom: 28px; }

/* ---------- footer ---------- */
.q-foot { border-top: 1px solid var(--q-line); margin-top: 96px; color: var(--q-faint); font-size: 14px; }
.q-foot-inner { max-width: 1160px; margin: 0 auto; padding: 22px max(20px, env(safe-area-inset-right)) calc(22px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 20px; }
.q-foot a { transition: color .2s; }

@media (hover: hover) {
  .q-nav a:hover, .q-foot a:hover { color: var(--q-ink); }
  .q-pill:hover { background: color-mix(in srgb, var(--q-soft) 70%, var(--q-ink) 8%); }
  .q-pill-solid:hover { background: var(--q-accent-text); }
  .q-card-link:hover .q-card-cover img, .q-lead-link:hover .q-lead-cover img { transform: scale(1.03); }
  .q-card-link:hover .q-card-title, .q-row-link:hover .q-row-title { color: var(--q-accent-text); }
  .q-lead-link:hover { background: var(--q-soft); }
  .q-writer:hover { background: var(--q-soft); }
}

/* ---------- phones ---------- */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .q-nav { display: none; }
  .q-hero { margin: 48px auto 36px; }
  .q-hero-text { font-size: 18px; }
  .q-lead-link { grid-template-columns: 1fr; gap: 16px; padding: 10px; border-radius: 22px; }
  .q-lead-text { padding: 4px 10px 14px; }
  .q-grid { grid-template-columns: 1fr; gap: 32px; }
  .q-row-link { gap: 16px; padding: 20px 0; align-items: flex-start; }
  .q-row-title { font-size: 19px; }
  .q-row-desc { -webkit-line-clamp: 2; font-size: 15px; }
  .q-row-cover { width: 96px; border-radius: 10px; margin-top: 26px; }
  .q-article { padding-top: 36px; }
  .q-subtitle { font-size: 19px; }
  .q-cover { margin: 28px -20px 0; }
  .q-cover img { border-radius: 0; }
  .q-prose { font-size: 18px; line-height: 1.68; margin-top: 30px; }
  .q-prose h2 { font-size: 23px; }
  .q-prose pre { margin-left: -20px; margin-right: -20px; border-radius: 0; padding: 16px 20px; font-size: 13.5px; }
  .q-dock .m-action { padding: 0 14px; }
  .q-foot { margin-top: 64px; }
  .q-foot-inner { flex-wrap: wrap; gap: 10px 18px; }
}

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

/* Headings wrap evenly and paragraphs avoid a lone last word. */
h1, h2, h3, .q-title { text-wrap: balance; }
p { text-wrap: pretty; }
.q-page-blog .q-empty { text-align: center; }
