
@layer components {
  .reading-progress {
    position: fixed;
    inset: 0 0 auto;
    z-index: 200;
    height: 4px;
    background: var(--accent);
    transform: scaleX(var(--progress, 0));
    transform-origin: left;
  }
  .toc {
    position: sticky;
    top: var(--sticky-top);
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 4px solid var(--accent);
  }
  .toc__title { padding: 1rem 1.2rem; border-bottom: 1px solid var(--border); font-size: 1.1rem; }
  .toc__list {
    max-height: calc(100vh - 260px);
    margin: 0;
    padding: .5rem 0;
    overflow: auto;
    list-style: none;
  }
  .toc__link {
    display: grid;
    grid-template-columns: 2.2rem minmax(0, 1fr);
    align-items: baseline;
    padding: .5rem 1.2rem;
    border-left: 3px solid transparent;
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color .2s, background .2s, border-color .2s;
  }
  .toc__link i { color: var(--placeholder); font: 700 .75rem var(--font-mono); }
  .toc__link:hover { background: var(--surface-muted); color: var(--ink); }
  .toc__link[aria-current] { background: var(--surface-muted); border-left-color: var(--accent); color: var(--ink); font-weight: 700; }
  .toc__link[aria-current] i { color: var(--accent-strong); }
  @media (max-width: 1000px) {
    .toc { position: static; }
    .toc__list { display: flex; max-height: none; padding: .4rem; overflow-x: auto; scrollbar-width: none; }
    .toc__list li { flex: none; }
    .toc__link { grid-template-columns: auto auto; gap: .4rem; border-left: 0; border-bottom: 3px solid transparent; }
    .toc__link[aria-current] { border-bottom-color: var(--accent); }
  }
  .rich-text {
    min-width: 0;
    color: var(--graphite);
    font-size: 1.04rem;
    line-height: 1.78;
    overflow-wrap: break-word;
  }
  .rich-text > * + * { margin-top: 1.05rem; }
  .rich-text h2,
  .rich-text h3,
  .rich-text h4 {
    color: var(--ink);
    line-height: 1.15;
    scroll-margin-top: var(--sticky-top);
  }
  .rich-text h2 { margin-top: 2.4rem; font-size: clamp(1.4rem, 2.3vw, 1.75rem); }
  .rich-text h3 { margin-top: 1.8rem; font-size: 1.3rem; }
  .rich-text h4 { margin-top: 1.4rem; font-size: 1.1rem; }
  .rich-text > :first-child { margin-top: 0; }
  .rich-text a:not(.btn) { color: var(--accent-strong); font-weight: 600; text-underline-offset: 3px; }
  .rich-text a:not(.btn):hover { color: var(--ink); }
  .rich-text strong { color: var(--ink); }
  .rich-text ul,
  .rich-text ol { padding-left: 1.3rem; }
  .rich-text li + li { margin-top: .4rem; }
  .rich-text ul li::marker { color: var(--accent); }
  .rich-text blockquote {
    margin-inline: 0;
    padding: 1.1rem 1.4rem;
    background: var(--surface-muted);
    border-left: 5px solid var(--accent);
    color: var(--ink);
    font-size: 1.12rem;
  }
  .rich-text img,
  .rich-text video,
  .rich-text iframe { max-width: 100%; height: auto; }
  .rich-text iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; }
  .rich-text figure { margin-inline: 0; }
  .rich-text figcaption { margin-top: .5rem; color: var(--text-muted); font-size: var(--text-sm); }
  .rich-text table { display: block; width: 100%; overflow-x: auto; border-collapse: collapse; }
  .rich-text th,
  .rich-text td { padding: .6rem .8rem; border: 1px solid var(--border); text-align: left; }
  .rich-text th { background: var(--surface-muted); color: var(--ink); }
  .rich-text hr { margin-block: 2rem; border: 0; border-top: 1px solid var(--border); }
  .rich-text pre,
  .rich-text code { font-family: var(--font-mono); font-size: .9em; }
  .rich-text pre { padding: 1rem; overflow-x: auto; background: var(--surface-muted); }
}


@layer components {
  .post-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1.1rem;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .post-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .post-card {
    position: relative;
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: border-color .3s, box-shadow .3s;
  }
  .post-card:hover { border-color: var(--ink); box-shadow: 0 24px 48px -30px var(--shadow-color); }
  .post-card__media { display: block; overflow: hidden; background: var(--surface-muted); }
  .post-card__image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    transition: transform .6s var(--ease-out);
  }
  .post-card:hover .post-card__image { transform: scale(1.04); }
  .post-card__body { display: flex; flex-direction: column; gap: .55rem; padding: 1.1rem 1.2rem 1.3rem; }
  .post-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem .9rem;
    color: var(--accent-strong);
    font: 600 .6875rem var(--font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .post-card__meta a { position: relative; z-index: 1; color: inherit; text-decoration: none; }
  .post-card__meta a:hover { text-decoration: underline; }
  .post-card__meta span + span::before,
  .post-card__meta a + span::before { content: "·"; margin-right: .9rem; color: var(--placeholder); }
  .post-card__title { font-size: 1.3rem; line-height: 1.15; }
  .post-card__title a { color: var(--ink); text-decoration: none; }
  .post-card__title a::after { content: ""; position: absolute; inset: 0; }
  .post-card__excerpt { color: var(--text-muted); font-size: var(--text-sm); }
  .post-card__date { margin-top: auto; padding-top: .4rem; color: var(--placeholder); font: 600 var(--text-xs) var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
  @media (max-width: 900px) {
    .post-grid, .post-grid--two { grid-template-columns: minmax(0, 1fr); }
  }
  @media (min-width: 560px) and (max-width: 900px) {
    .post-grid, .post-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
}


@layer pages {
  .blog-band__title { margin-top: 1rem; }
  .blog-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: clamp(1.5rem, 4vw, 3.2rem);
    align-items: start;
    padding-block: clamp(2.6rem, 5vw, 4rem) clamp(3.6rem, 7vw, 5.4rem);
  }
  .blog-layout__main { display: grid; gap: 1.6rem; min-width: 0; }
  .blog-lead {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    background: var(--surface-dark);
    color: var(--text-on-dark);
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 28px), calc(100% - 52px) 100%, 0 100%);
  }
  .blog-lead__media { display: block; min-height: 100%; overflow: hidden; background: var(--surface-darker); }
  .blog-lead__image { width: 100%; height: 100%; min-height: 260px; object-fit: cover; transition: transform .6s var(--ease-out); }
  .blog-lead:hover .blog-lead__image { transform: scale(1.04); }
  .blog-lead__body { display: flex; flex-direction: column; justify-content: center; gap: .9rem; padding: clamp(1.4rem, 3vw, 2.4rem); }
  .blog-lead .kicker { color: var(--accent-on-dark); }
  .blog-lead__title { color: var(--surface); font-size: clamp(1.6rem, 2.8vw, 2.2rem); line-height: 1.05; }
  .blog-lead__title a { color: inherit; text-decoration: none; }
  .blog-lead__title a::after { content: ""; position: absolute; inset: 0; }
  .blog-lead__excerpt { color: var(--text-on-dark-muted); }
  .blog-lead__meta {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem 1rem;
    color: var(--text-on-dark-muted);
    font: 600 var(--text-xs) var(--font-mono);
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .blog-empty {
    display: grid;
    justify-items: center;
    gap: .9rem;
    padding: clamp(3rem, 7vw, 5rem) 1rem;
    background: var(--surface);
    border: 1.5px dashed var(--border);
    text-align: center;
  }
  .blog-empty__icon { display: grid; place-items: center; width: 80px; height: 80px; background: var(--surface-muted); }
  .blog-empty__icon .icon { width: 36px; height: 36px; color: var(--accent-strong); }
  .blog-empty__title { font-size: clamp(1.5rem, 3vw, 2rem); }
  .blog-empty p { max-width: 44ch; color: var(--text-muted); }
  .blog-sidebar { position: sticky; top: var(--sticky-top); display: grid; gap: 1.2rem; }
  .blog-search { display: flex; background: var(--surface); border: 1.5px solid var(--border); }
  .blog-search:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .18); }
  .blog-search__input { flex: 1; min-width: 0; height: 48px; padding: 0 1rem; background: none; border: 0; color: var(--ink); font-size: .95rem; outline: none; }
  .blog-search__button { display: grid; place-items: center; width: 48px; background: var(--ink); border: 0; color: var(--surface); cursor: pointer; }
  .blog-search__button:hover { background: var(--accent); color: var(--on-accent); }
  .blog-widget { background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--accent); }
  .blog-widget__title { padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); font-size: 1.05rem; }
  .blog-widget__list { margin: 0; padding: .4rem 0; list-style: none; }
  .blog-widget .tag-list { padding: 1rem 1.1rem; }
  .blog-widget__link {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .45rem 1.1rem;
    border-left: 3px solid transparent;
    color: var(--text-muted);
    font-size: .9rem;
    text-decoration: none;
  }
  .blog-widget__link:hover { background: var(--surface-muted); color: var(--ink); }
  .blog-widget__link[aria-current] { background: var(--surface-muted); border-left-color: var(--accent); color: var(--ink); font-weight: 700; }
  .blog-widget__count { color: var(--placeholder); font: 600 var(--text-xs) var(--font-mono); }
  .blog-archive + .blog-archive { border-top: 1px solid var(--border); }
  .blog-archive__year {
    display: flex;
    justify-content: space-between;
    padding: .7rem 1.1rem;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
    list-style: none;
  }
  .blog-archive__year::-webkit-details-marker { display: none; }
  .blog-archive__year::after { content: "+"; margin-left: .8rem; color: var(--accent-strong); }
  .blog-archive[open] > .blog-archive__year::after { content: "–"; }
  .blog-archive__year .blog-widget__count { margin-left: auto; }
  .blog-rss { display: inline-flex; align-items: center; gap: .45rem; color: var(--accent-strong); font-size: .875rem; font-weight: 600; text-decoration: none; }
  .blog-rss:hover { text-decoration: underline; }
  .blog-rss .icon { width: 15px; height: 15px; }
  .tag-list { display: flex; flex-wrap: wrap; gap: .45rem; margin: 0; padding: 0; list-style: none; }
  .tag-list__tag {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 .8rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    color: var(--ink);
    font-size: .8125rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s, border-color .2s;
  }
  .tag-list__tag::before { content: "#"; margin-right: .15rem; color: var(--accent-strong); }
  .tag-list__tag:hover, .tag-list__tag[aria-current] { background: var(--ink); border-color: var(--ink); color: var(--surface); }
  .preview-banner {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .5rem;
    padding: .7rem 1rem;
    background: var(--accent);
    color: var(--on-accent);
    font-weight: 600;
    text-align: center;
  }
  .preview-banner .icon { width: 18px; height: 18px; }
  .article-band__inner { padding-bottom: 5.6rem; }
  .article-band__inner > * { max-width: 980px; }
  .article-band__kicker { margin-top: 1.4rem; text-decoration: none; }
  .article-band__title { margin-top: 1rem; color: var(--surface); font-size: clamp(2.2rem, 5vw, 4rem); font-weight: 800; line-height: 1; overflow-wrap: anywhere; }
  .article-band__lede { max-width: 62ch; margin-top: 1.1rem; color: var(--text-on-dark-muted); font-size: var(--text-lg); }
  .article-byline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .6rem 1.4rem;
    margin-top: 1.6rem;
    color: var(--text-on-dark-muted);
    font-size: .9rem;
  }
  .article-byline > span { display: inline-flex; align-items: center; gap: .5rem; }
  .article-byline .icon { width: 15px; height: 15px; color: var(--accent-on-dark); }
  .article-byline b { color: var(--surface); }
  .article-byline__photo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
  .article-byline__initial {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    background: var(--accent);
    color: var(--on-accent);
    border-radius: 50%;
    font: 800 1.1rem var(--font-display);
  }
  .article-cover { position: relative; z-index: 2; margin-top: -3.6rem; }
  .article-cover__image { width: 100%; max-height: 620px; aspect-ratio: 2 / 1; object-fit: cover; background: var(--surface-muted); box-shadow: 0 30px 60px -36px var(--shadow-color); }
  .article-layout {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: clamp(1.5rem, 4vw, 3.6rem);
    align-items: start;
    padding-block: clamp(2.4rem, 5vw, 3.6rem) clamp(2.6rem, 5vw, 4rem);
  }
  .article-layout--single { grid-template-columns: minmax(0, 1fr); max-width: 860px; }
  .article-main { display: grid; gap: 2rem; min-width: 0; max-width: 780px; }
  .article-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem 2rem;
    padding-top: 1.6rem;
    border-top: 1px solid var(--border);
  }
  .share { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; color: var(--text-muted); font-size: .875rem; }
  .share > span { margin-right: .4rem; }
  .share__button {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    cursor: pointer;
    transition: background .2s, color .2s, border-color .2s;
  }
  .share__button .icon { width: 16px; height: 16px; }
  .share__button:hover, .share__button.is-done { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
  .article-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
  .article-steps__link {
    display: grid;
    gap: .35rem;
    padding: 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    text-decoration: none;
    transition: border-color .2s;
  }
  .article-steps__link:hover { border-color: var(--ink); }
  .article-steps__link small { display: inline-flex; align-items: center; gap: .35rem; color: var(--accent-strong); font: 600 var(--text-xs) var(--font-mono); letter-spacing: .1em; text-transform: uppercase; }
  .article-steps__link small .icon { width: 14px; height: 14px; }
  .article-steps__link b { font: 700 1.05rem/1.25 var(--font-display); }
  .article-steps__link--next { grid-column: 2; text-align: right; }
  .article-steps__link--next small { justify-content: flex-end; }
  .article-products { background: var(--surface-muted); }
  .article-categories { padding-block: 0 clamp(2rem, 4vw, 3rem); }
  .article-categories__title { margin-bottom: 1rem; font-size: 1.3rem; }
  .article-categories__list { display: flex; flex-wrap: wrap; gap: .6rem; margin: 0; padding: 0; list-style: none; }
  .article-categories__link {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    min-height: 48px;
    padding: .3rem .9rem .3rem .3rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--ink);
    font-weight: 600;
    text-decoration: none;
  }
  .article-categories__link img { width: 40px; height: 40px; object-fit: contain; background: var(--surface-muted); }
  .article-categories__link .icon { width: 15px; height: 15px; color: var(--accent-strong); }
  .article-categories__link:hover { border-color: var(--ink); }
  @media (max-width: 1000px) {
    .blog-layout, .article-layout { grid-template-columns: minmax(0, 1fr); }
    .blog-sidebar { position: static; }
    .blog-lead { grid-template-columns: minmax(0, 1fr); }
    .blog-lead__image { aspect-ratio: 16 / 9; min-height: 0; }
  }
  @media (max-width: 560px) {
    .article-steps { grid-template-columns: minmax(0, 1fr); }
    .article-steps__link--next { grid-column: auto; }
    .article-cover { margin-top: -2.4rem; }
  }
}

