:root {
  --blue: #74dfff;
  --pink: #ff8cbf;
  --soft: #ffb1d3;
  --pale: #ffe0ec;
  --bg: #16111c;
  --fg: #ffe9f2;
  --muted: #b79bb0;

  --surface: #1e1627;
  --surface-2: #271d33;
  --border: rgba(255, 177, 211, 0.24);
  --border-blue: rgba(116, 223, 255, 0.36);
  --mint: #8ef2cb;
  --amber: #ffd180;
  --pill-ink: #3a1830;
  color-scheme: dark;
}

@view-transition {
  navigation: auto;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
}

body {
  min-block-size: 100dvb;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.75rem 1.25rem 3rem;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.65 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  accent-color: var(--pink);
}

::selection {
  background: rgba(255, 140, 191, 0.32);
  color: var(--pale);
}

.flag {
  position: fixed;
  inset: 0 0 auto 0;
  height: 8px;
  z-index: 50;
  background: linear-gradient(
    90deg,
    var(--blue) 0 20%,
    var(--soft) 20% 40%,
    #fff 40% 60%,
    var(--soft) 60% 80%,
    var(--blue) 80%
  );
}

.read-progress {
  position: fixed;
  inset: 8px 0 auto 0;
  height: 2px;
  z-index: 49;
  transform-origin: left center;
  transform: scaleX(var(--scroll-progress, 0));
  background: linear-gradient(90deg, var(--blue), var(--pink));
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.skip-link:focus-visible {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 100;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  background: var(--pale);
  color: var(--pill-ink);
  text-decoration: none;
  font-weight: 700;
}

/* Header & Klaudia Hero */
.site-header {
  width: 100%;
  max-width: 28rem;
  text-align: center;
  margin-block-end: 2.25rem;
}

.sprite-btn {
  display: inline-grid;
  place-items: center;
  padding: 0.25rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 12px;
}

.sprite {
  display: block;
  width: 13.5rem;
  max-width: 72vw;
  height: auto;
  animation: bob 1.6s steps(1) infinite;
}

.is-home .sprite {
  width: 13.5rem;
}

body:not(.is-home):not(.is-404) .sprite {
  width: 8.5rem;
}

.sprite-btn.is-booped .sprite {
  animation: boop-hop 0.35s steps(2) 1;
}

.eye {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 5s infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-6px);
  }
}

@keyframes boop-hop {
  0% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-10px) scale(1.04, 0.96);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes blink {
  0%,
  94%,
  100% {
    transform: scaleY(1);
  }
  96% {
    transform: scaleY(0.1);
  }
}

.site-header h1,
.site-title {
  margin: 1rem 0 0.55rem;
  font-size: 2rem;
  letter-spacing: 0.02em;
  font-weight: 700;
  line-height: 1.2;
  text-wrap: balance;
}

body:not(.is-home):not(.is-404) .site-title {
  font-size: 1.45rem;
}

.site-title a {
  text-decoration: none;
}

.site-title a:hover {
  color: var(--pink);
}

.pill {
  display: inline-block;
  margin: 0.15rem 0 0;
  padding: 0.18rem 0.95rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--pill-ink);
  background: linear-gradient(
    90deg,
    var(--blue),
    var(--pale),
    var(--soft),
    var(--pale),
    var(--blue)
  );
  max-width: 100%;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

nav[aria-label="Primary"] {
  margin-top: 1.35rem;
}

.nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  flex-wrap: balance;
  justify-content: center;
  gap: 0.75rem 1.35rem;
}

.nav-list a {
  display: inline-flex;
  align-items: center;
  min-block-size: 28px;
  padding-inline: 0.15rem;
}

.nav-list a[aria-current="page"] {
  color: var(--blue);
  text-decoration-color: var(--blue);
}

a {
  color: var(--fg);
  text-decoration-color: var(--pink);
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

a:hover {
  color: var(--pink);
}

:where(a:any-link, button, input, summary, pre, [tabindex="0"]):focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

/* Main Content Column */
main {
  width: 100%;
  max-width: 44rem;
  flex: 1 0 auto;
}

body.is-404 main {
  max-width: 28rem;
  text-align: center;
}

main:focus {
  outline: none;
}

h1,
h2,
h3,
h4 {
  text-wrap: balance;
  line-height: 1.3;
}

p,
blockquote,
li {
  text-wrap: pretty;
}

/* Home Intro & Search */
.intro-block {
  text-align: center;
  max-width: 36rem;
  margin: 0 auto 1.75rem;
}

.intro-block p {
  margin: 0;
}

.search-panel {
  display: block;
  margin-bottom: 1.75rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.search-form {
  margin: 0;
}

.search-form input[type="search"] {
  width: 100%;
  min-block-size: 42px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--border-blue);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.95rem;
}

.search-form input[type="search"]::placeholder {
  color: var(--muted);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  flex-wrap: balance;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-block-size: 30px;
  padding: 0.2rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.filter-chip:hover {
  border-color: var(--pink);
  color: var(--pink);
}

.filter-chip.is-active {
  background: var(--pink);
  border-color: var(--pink);
  color: var(--pill-ink);
  font-weight: 700;
}

.chip-count {
  opacity: 0.78;
  font-size: 0.76rem;
}

.search-status {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
}

/* Post Cards */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.post-item[hidden] {
  display: none;
}

.post-card {
  padding: 1.25rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.16s ease, transform 0.16s ease;
}

.post-card:hover {
  border-color: var(--pink);
}

.post-card-meta,
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
}

.post-card-title {
  margin: 0.45rem 0 0.5rem;
  font-size: 1.28rem;
}

.post-card-title a {
  text-decoration-thickness: 2px;
}

.post-card-summary {
  margin: 0 0 0.85rem;
  color: var(--pale);
  font-size: 0.94rem;
}

.tag-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
}

.tag-link {
  display: inline-flex;
  align-items: center;
  min-block-size: 24px;
  font-size: 0.82rem;
  color: var(--blue);
  text-decoration-color: rgba(116, 223, 255, 0.45);
}

.tag-link:hover {
  color: var(--pink);
  text-decoration-color: var(--pink);
}

.draft-badge {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 209, 128, 0.18);
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 0.74rem;
  font-weight: 700;
}

.empty-state {
  padding: 1.5rem;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.btn-reset {
  margin-top: 0.5rem;
  min-block-size: 34px;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--pink);
  border-radius: 999px;
  background: transparent;
  color: var(--pink);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.btn-reset:hover {
  background: var(--pink);
  color: var(--pill-ink);
}

/* Breadcrumb & Post Page */
.breadcrumb {
  margin: 0 0 1.25rem;
  font-size: 0.88rem;
}

.post-article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.65rem 1.75rem;
}

.post-header {
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.post-header h1 {
  margin: 0.65rem 0 0.65rem;
  font-size: clamp(1.55rem, 3.6vw, 2.05rem);
}

.post-lede {
  margin: 0 0 0.95rem;
  font-size: 0.98rem;
  color: var(--pale);
}

/* TOC */
.toc {
  margin-bottom: 1.6rem;
  padding: 0.8rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.toc summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--blue);
  min-block-size: 26px;
}

.toc-list {
  margin: 0.75rem 0 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.toc-level-3 {
  margin-left: 1rem;
}

.toc-level-4 {
  margin-left: 2rem;
}

/* Article Prose */
.prose {
  max-width: 68ch;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.32rem;
  color: var(--pale);
}

.prose h3 {
  margin: 1.6rem 0 0.6rem;
  font-size: 1.12rem;
  color: var(--soft);
}

.prose h4 {
  margin: 1.35rem 0 0.5rem;
  font-size: 1rem;
  color: var(--blue);
}

.heading-anchor {
  opacity: 0.35;
  text-decoration: none;
  font-size: 0.85em;
  margin-left: 0.25rem;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
.heading-anchor:focus-visible {
  opacity: 1;
  color: var(--pink);
}

.prose p {
  margin: 1rem 0;
}

.prose ul,
.prose ol {
  margin: 1rem 0;
  padding-left: 1.5rem;
}

.prose li + li {
  margin-top: 0.35rem;
}

.task-item {
  list-style: none;
  margin-left: -1.2rem;
}

.task-box {
  display: inline-block;
  margin-right: 0.45rem;
  color: var(--blue);
}

.task-item[data-checked="true"] .task-box {
  color: var(--pink);
}

.prose hr {
  border: 0;
  height: 2px;
  margin: 2rem 0;
  background: linear-gradient(90deg, var(--blue), var(--pink), transparent);
}

.prose blockquote {
  margin: 1.35rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 3px solid var(--pink);
  color: var(--pale);
}

.prose blockquote p {
  margin: 0.5rem 0;
}

.callout {
  margin: 1.35rem 0;
  padding: 0.9rem 1.05rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
}

.callout-title {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--blue);
}

.callout-tip {
  border-left-color: var(--mint);
}
.callout-tip .callout-title {
  color: var(--mint);
}

.callout-important {
  border-left-color: var(--pink);
}
.callout-important .callout-title {
  color: var(--pink);
}

.callout-warning,
.callout-caution {
  border-left-color: var(--amber);
}
.callout-warning .callout-title,
.callout-caution .callout-title {
  color: var(--amber);
}

.prose mark {
  background: rgba(116, 223, 255, 0.22);
  color: var(--fg);
  padding: 0.05em 0.25em;
  border-radius: 4px;
}

.prose code {
  padding: 0.12em 0.38em;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid rgba(255, 177, 211, 0.16);
  color: var(--blue);
  font-size: 0.9em;
}

/* Code Blocks */
.code-block {
  margin: 1.4rem 0;
  background: #110c16;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.85rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.code-lang {
  color: var(--soft);
  font-weight: 700;
}

.copy-btn {
  min-block-size: 26px;
  padding: 0.15rem 0.65rem;
  border: 1px solid var(--border-blue);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.76rem;
  cursor: pointer;
}

.copy-btn:hover {
  border-color: var(--pink);
  color: var(--pink);
}

.code-block pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
}

.code-block pre code {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-size: inherit;
}

/* Syntax Highlight Tokens */
.tok-comment {
  color: var(--muted);
  font-style: italic;
}
.tok-string {
  color: var(--mint);
}
.tok-number {
  color: var(--amber);
}
.tok-keyword {
  color: var(--pink);
  font-weight: 600;
}
.tok-fn {
  color: var(--blue);
}
.tok-prop,
.tok-attr {
  color: var(--soft);
}
.tok-tag {
  color: var(--pink);
}
.tok-punct {
  color: var(--muted);
}

/* Figures & Tables */
.post-figure {
  margin: 1.5rem 0;
  text-align: center;
}

.post-figure img,
.prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.post-figure figcaption {
  margin-top: 0.55rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.table-wrap {
  margin: 1.4rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table-wrap th,
.table-wrap td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.table-wrap th {
  background: var(--surface-2);
  color: var(--pale);
}

.table-wrap tr:last-child td {
  border-bottom: 0;
}

/* Post Pager */
.post-pager {
  margin-top: 1.5rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.9rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
}

.pager-link:hover {
  border-color: var(--pink);
}

.pager-next {
  text-align: right;
}

.pager-title {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--pink);
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

/* Tags Archive */
.archive-header {
  margin-bottom: 1.5rem;
}

.archive-header h1 {
  margin: 0 0 0.35rem;
}

.tags-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.85rem;
}

.tag-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
}

.tag-card:hover {
  border-color: var(--pink);
}

.tag-name {
  font-weight: 700;
  color: var(--blue);
}

/* Footer */
.site-footer {
  width: 100%;
  max-width: 44rem;
  margin-top: 2.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0.35rem 0;
}

@media (max-width: 600px) {
  body {
    padding: 2.25rem 0.9rem 2.5rem;
  }

  .post-article {
    padding: 1.2rem 1.05rem;
  }

  .post-pager {
    grid-template-columns: 1fr;
  }

  .pager-next {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .sprite,
  .eye,
  .sprite-btn.is-booped .sprite {
    animation: none;
  }
  .post-card {
    transition: none;
  }
}

@media (forced-colors: active) {
  body {
    background: Canvas;
    color: CanvasText;
  }
  a {
    color: LinkText;
  }
  .pill,
  .filter-chip.is-active {
    background: Highlight;
    color: HighlightText;
    border: 1px solid ButtonText;
  }
  .post-card,
  .post-article,
  .search-panel,
  .code-block,
  .tag-card,
  .pager-link {
    border: 1px solid CanvasText;
  }
  :where(a:any-link, button, input, summary, pre, [tabindex="0"]):focus-visible {
    outline: 3px solid Highlight;
  }
}
