/* ==========================================================================
   Portfolio Design System (Radix Palette + Tactile Minimalism)
   ========================================================================== */

:root,
html.light {
  color-scheme: light;

  /* Radix Gray Light */
  --gray-1: #fcfcfc;
  --gray-2: #f9f9f9;
  --gray-3: #f0f0f0;
  --gray-4: #e8e8e8;
  --gray-5: #e0e0e0;
  --gray-6: #d9d9d9;
  --gray-7: #cecece;
  --gray-8: #bbbbbb;
  --gray-9: #8d8d8d;
  --gray-10: #838383;
  --gray-11: #646464;
  --gray-12: #202020;
  --gray-a2: rgba(0, 0, 0, 0.03);
  --gray-a3: rgba(0, 0, 0, 0.055);

  /* Default Accent: Brown Light */
  --accent-2: #fcf9f6;
  --accent-4: #f0e4d9;
  --accent-5: #ebdaca;
  --accent-7: #dcbc9f;
  --accent-9: #ad7f58;
  --accent-11: #815e46;
  --accent-12: #3e332e;
  --accent-a2: rgba(170, 85, 0, 0.035);
  --pink-a3: rgba(244, 0, 140, 0.085);

  --yellow-3: #fffab8;
  --yellow-11: #9e6c00;

  /* Semantic tokens */
  --bg: var(--gray-2);
  --body-bg: #faf3ef;
  --surface: color-mix(in srgb, var(--gray-1) 88%, var(--gray-2));
  --surface-strong: color-mix(in srgb, var(--gray-1) 96%, var(--gray-3));
  --surface-tint: color-mix(in srgb, var(--gray-a3) 72%, transparent);
  --fg: var(--gray-12);
  --fg-secondary: var(--gray-11);
  --muted: var(--gray-9);
  --muted-soft: var(--gray-8);
  --border: color-mix(in srgb, var(--gray-6) 46%, transparent);
  --border-strong: color-mix(in srgb, var(--gray-7) 64%, transparent);
  --nav-border: color-mix(in srgb, var(--fg) 6%, transparent);
  --nav-grad-top: color-mix(in srgb, var(--body-bg) 78%, transparent);
  --nav-grad-bottom: color-mix(in srgb, var(--body-bg) 42%, transparent);

  --selection-bg: var(--accent-9);
  --selection-fg: var(--gray-1);
  --kbd-bg: var(--gray-3);
  --kbd-fg: var(--gray-11);
  --kbd-border: var(--gray-4);

  --radius-small: 4px;
  --radius-base: 8px;
  --radius-large: 12px;
  --focus-ring: color-mix(in srgb, var(--gray-12) 18%, transparent);
  --shadow-ambient: 0 1px 1px rgba(15, 23, 42, 0.03), 0 10px 24px rgba(15, 23, 42, 0.05);
  --shadow-elevated: 0 1px 1px rgba(15, 23, 42, 0.04), 0 14px 36px rgba(15, 23, 42, 0.08);

  --duration-hover: 0.16s;
  --duration-press: 0.14s;
  --duration-soft: 0.22s;
  --ease-standard: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-productive: cubic-bezier(0.16, 1, 0.3, 1);

  /* GitHub Graph Light */
  --ghc-bg: #ebedf0;
  --ghc-empty-border: rgba(27, 31, 35, 0.06);
  --ghc-l1: #9be9a8;
  --ghc-l2: #40c463;
  --ghc-l3: #30a14e;
  --ghc-l4: #216e39;
  --ghc-hover-border: rgba(33, 110, 57, 0.35);

  --code-bg: #f5f2ef;
  --code-border: color-mix(in srgb, var(--gray-6) 60%, transparent);
  --max-col: 640px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html.dark {
  color-scheme: dark;

  /* Radix Gray Dark */
  --gray-1: #111111;
  --gray-2: #191919;
  --gray-3: #222222;
  --gray-4: #2a2a2a;
  --gray-5: #313131;
  --gray-6: #3a3a3a;
  --gray-7: #484848;
  --gray-8: #606060;
  --gray-9: #6e6e6e;
  --gray-10: #7b7b7b;
  --gray-11: #b4b4b4;
  --gray-12: #eeeeee;
  --gray-a2: rgba(255, 255, 255, 0.035);
  --gray-a3: rgba(255, 255, 255, 0.065);

  /* Default Accent: Brown Dark */
  --accent-2: #1c1816;
  --accent-4: #322922;
  --accent-5: #3e3128;
  --accent-7: #614a39;
  --accent-9: #ad7f58;
  --accent-11: #dbb594;
  --accent-12: #f2e1ca;
  --accent-a2: rgba(173, 127, 88, 0.08);
  --pink-a3: rgba(244, 0, 140, 0.06);

  --bg: var(--gray-2);
  --body-bg: var(--gray-2);
  --surface: color-mix(in srgb, var(--gray-1) 88%, var(--gray-2));
  --surface-strong: color-mix(in srgb, var(--gray-1) 96%, var(--gray-3));
  --surface-tint: color-mix(in srgb, var(--gray-a3) 72%, transparent);
  --fg: var(--gray-12);
  --fg-secondary: var(--gray-11);
  --muted: var(--gray-9);
  --muted-soft: var(--gray-8);
  --border: color-mix(in srgb, var(--gray-6) 42%, transparent);
  --border-strong: color-mix(in srgb, var(--gray-7) 58%, transparent);
  --nav-border: color-mix(in srgb, var(--fg) 5%, transparent);
  --nav-grad-top: color-mix(in srgb, var(--bg) 72%, transparent);
  --nav-grad-bottom: color-mix(in srgb, var(--bg) 38%, transparent);

  --selection-bg: #a37b73;
  --selection-fg: var(--gray-1);
  --kbd-bg: var(--gray-3);
  --kbd-fg: var(--gray-11);
  --kbd-border: var(--gray-4);

  /* GitHub Graph Dark */
  --ghc-bg: #121814;
  --ghc-empty-border: rgba(255, 255, 255, 0.06);
  --ghc-l1: #0e4429;
  --ghc-l2: #006d32;
  --ghc-l3: #26a641;
  --ghc-l4: #39d353;
  --ghc-hover-border: rgba(57, 211, 83, 0.35);

  --code-bg: #141414;
  --code-border: color-mix(in srgb, var(--gray-6) 55%, transparent);
}

/* Optional Accent Presets (customizable via config.yaml or /customize) */
html.light[data-accent="amber"] { --accent-4: #fef2c8; --accent-5: #fde6a4; --accent-7: #ebc06b; --accent-9: #c78116; --accent-11: #8c5600; --accent-12: #462c06; }
html.dark[data-accent="amber"]  { --accent-4: #332510; --accent-5: #402e13; --accent-7: #66491d; --accent-9: #d99732; --accent-11: #f5c372; --accent-12: #fce8c7; }

html.light[data-accent="sage"]  { --accent-4: #e4efe6; --accent-5: #d6e6d9; --accent-7: #a8c7ae; --accent-9: #4c8257; --accent-11: #376140; --accent-12: #1e3623; }
html.dark[data-accent="sage"]   { --accent-4: #1d2920; --accent-5: #243328; --accent-7: #38503f; --accent-9: #5b9968; --accent-11: #94cfa0; --accent-12: #d6f0db; }

html.light[data-accent="rose"]  { --accent-4: #f7e4e8; --accent-5: #f0d4da; --accent-7: #dda7b3; --accent-9: #ba586e; --accent-11: #8a3a4c; --accent-12: #4a1e28; }
html.dark[data-accent="rose"]   { --accent-4: #331e24; --accent-5: #40252d; --accent-7: #663b47; --accent-9: #c9687f; --accent-11: #eba3b4; --accent-12: #fae1e7; }

html.light[data-accent="slate"] { --accent-4: #e6e9ee; --accent-5: #dbe0e7; --accent-7: #b5c0ce; --accent-9: #5a6c82; --accent-11: #415063; --accent-12: #202833; }
html.dark[data-accent="slate"]  { --accent-4: #22262e; --accent-5: #2a303a; --accent-7: #424b5a; --accent-9: #7889a1; --accent-11: #b0bfd4; --accent-12: #e3ebf5; }

html.light[data-accent="indigo"] { --accent-4: #e6e8f8; --accent-5: #dadcf4; --accent-7: #aeb4e8; --accent-9: #5560c7; --accent-11: #3d459c; --accent-12: #1f2454; }
html.dark[data-accent="indigo"]  { --accent-4: #21243c; --accent-5: #292d4a; --accent-7: #3f4673; --accent-9: #6e78d9; --accent-11: #a7aff0; --accent-12: #dfe3fc; }

/* Base Reset & Typography */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 21px;
  letter-spacing: -0.09px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "calt", "ccmp", "locl", "kern";
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--fg);
  background-color: var(--body-bg);
  text-wrap: pretty;
  position: relative;
}

/* Layered atmospheric gradients & noise matching amaanworks.me */
html.light body {
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E"),
    radial-gradient(circle at 50% 0%, var(--pink-a3), transparent 55%),
    radial-gradient(circle at 80% 20%, var(--accent-a2), transparent 50%);
  background-repeat: repeat, no-repeat, no-repeat;
  background-size: 200px 200px, 100% 100%, 100% 100%;
}

html.dark body {
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E"),
    radial-gradient(circle at top, var(--gray-a2), transparent 48%);
  background-repeat: repeat, no-repeat;
  background-size: 200px 200px, 100% 100%;
}

html[data-noise="false"] body {
  background-image: none;
}

html.light[data-noise="false"][data-gradients="true"] body {
  background-image:
    radial-gradient(circle at 50% 0%, var(--pink-a3), transparent 55%),
    radial-gradient(circle at 80% 20%, var(--accent-a2), transparent 50%);
}

html.dark[data-noise="false"][data-gradients="true"] body {
  background-image: radial-gradient(circle at top, var(--gray-a2), transparent 48%);
}

html[data-gradients="false"][data-noise="true"] body {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
}

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

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

h1, h2, h3, h4 {
  margin: 0;
  text-wrap: balance;
}

p {
  margin: 0;
}

/* Container */
.page-shell {
  width: 100%;
  max-width: var(--max-col);
  margin: 0 auto;
  padding: 0 1.5rem;
}

main {
  padding-bottom: 6rem;
}

/* Focus Ring */
.ui-focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring);
}

/* ==========================================================================
   Sticky Glassmorphic Top Navbar (Rounded Borders)
   ========================================================================== */
.site-nav {
  position: sticky;
  top: 0.85rem;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 1.15rem;
  padding: 0.7rem 1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--nav-grad-top) 0%, var(--nav-grad-bottom) 100%);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-ambient);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}

.nav-links-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.55rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  transition: color var(--duration-hover) var(--ease-standard), background-color var(--duration-hover) var(--ease-standard);
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--fg);
}

.nav-indicator {
  position: absolute;
  bottom: -0.71rem;
  left: 0;
  height: 2px;
  width: 0;
  border-radius: 9999px;
  background: var(--accent-9);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.28s var(--ease-productive),
    width 0.28s var(--ease-productive),
    opacity 0.2s var(--ease-standard);
}

html.dark .nav-indicator {
  box-shadow:
    0 0 14px color-mix(in srgb, var(--accent-9) 75%, transparent),
    0 -2px 10px color-mix(in srgb, var(--accent-9) 45%, transparent);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  color: var(--muted);
  transition:
    color var(--duration-hover) var(--ease-standard),
    background-color var(--duration-hover) var(--ease-standard),
    transform var(--duration-press) var(--ease-standard);
}

.icon-btn:hover {
  color: var(--fg);
  background: var(--surface-tint);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Hero & Bio
   ========================================================================== */
.hero-header {
  margin-top: 6.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

@media (max-width: 640px) {
  .hero-header {
    margin-top: 4rem;
    flex-wrap: wrap;
  }
}

.hero-title {
  font-size: 2.45rem;
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -0.045em;
  color: var(--fg);
}

@media (max-width: 640px) {
  .hero-title {
    font-size: 2rem;
  }
}

.char-reveal {
  display: inline-block;
  white-space: pre;
  opacity: 0;
  filter: blur(6px);
  transform: translateY(4px);
  animation: charReveal 0.45s var(--ease-standard) forwards;
}

@keyframes charReveal {
  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .char-reveal {
    opacity: 1;
    filter: none;
    transform: none;
    animation: none;
  }
}

.social-row {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.skills-row {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.ui-skill-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.26rem 0.78rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: default;
  color: var(--accent-12);
  background: color-mix(in srgb, var(--accent-4) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-7) 55%, transparent);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08);
  transition:
    background-color var(--duration-hover) var(--ease-standard),
    border-color var(--duration-hover) var(--ease-standard),
    transform var(--duration-hover) var(--ease-standard);
}

.ui-skill-tag:hover {
  background: color-mix(in srgb, var(--accent-5) 95%, transparent);
  border-color: color-mix(in srgb, var(--accent-7) 85%, transparent);
}

.bio-block {
  margin-top: 3.75rem;
  max-width: 36rem;
  font-size: 1rem;
  line-height: 1.9;
  color: var(--fg);
}

.bio-link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: var(--muted-soft);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--duration-hover) var(--ease-standard);
}

.bio-link:hover {
  text-decoration-color: var(--fg);
}

/* ==========================================================================
   GitHub Contribution Graph
   ========================================================================== */
.ghc-section {
  margin-top: 5.5rem;
  display: flex;
  justify-content: flex-start;
  overflow-x: auto;
}

.ghc-wrapper {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  gap: 0.35rem;
  user-select: none;
}

.ghc-months {
  position: relative;
  height: 1rem;
  margin-left: 2.1rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.ghc-month-label {
  position: absolute;
  top: 0;
  white-space: nowrap;
}

.ghc-body {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.ghc-weekdays {
  display: grid;
  grid-template-rows: repeat(7, var(--ghc-cell));
  gap: var(--ghc-gap);
  width: 1.65rem;
  font-size: 0.72rem;
  color: var(--muted);
  text-align: right;
  line-height: var(--ghc-cell);
}

.ghc-grid {
  --ghc-cell: 0.82rem;
  --ghc-gap: 0.24rem;
  display: flex;
  gap: var(--ghc-gap);
}

.ghc-wrapper {
  --ghc-cell: 0.82rem;
  --ghc-gap: 0.24rem;
}

@media (max-width: 900px) {
  .ghc-wrapper {
    --ghc-cell: 0.72rem;
    --ghc-gap: 0.2rem;
  }
}

@media (max-width: 640px) {
  .ghc-wrapper {
    --ghc-cell: 0.56rem;
    --ghc-gap: 0.16rem;
  }
  .ghc-weekdays {
    display: none;
  }
  .ghc-months {
    margin-left: 0;
  }
}

.ghc-week {
  display: flex;
  flex-direction: column;
  gap: var(--ghc-gap);
}

.ghc-cell {
  width: var(--ghc-cell);
  height: var(--ghc-cell);
  border-radius: 0.28rem;
  border: 1px solid var(--ghc-empty-border);
  background: var(--ghc-bg);
  transition:
    transform 0.14s var(--ease-standard),
    border-color 0.14s var(--ease-standard);
}

.ghc-cell[data-level="1"] { background: var(--ghc-l1); border-color: transparent; }
.ghc-cell[data-level="2"] { background: var(--ghc-l2); border-color: transparent; }
.ghc-cell[data-level="3"] { background: var(--ghc-l3); border-color: transparent; }
.ghc-cell[data-level="4"] { background: var(--ghc-l4); border-color: transparent; }

.ghc-cell:hover,
.ghc-cell:focus-visible {
  transform: translateY(-1px);
  border-color: var(--ghc-hover-border);
  outline: none;
}

.ghc-tooltip {
  position: fixed;
  z-index: 90;
  pointer-events: none;
  padding: 0.28rem 0.7rem;
  border-radius: 9999px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-elevated);
  opacity: 0;
  transform: translate(-50%, -100%) translateY(-4px);
  transition: opacity 0.12s var(--ease-standard);
}

.ghc-tooltip.is-visible {
  opacity: 1;
}

/* ==========================================================================
   Portfolio Sections (Projects, Blogs, OSS, Library)
   ========================================================================== */
.portfolio-section {
  margin-top: 5.5rem;
  scroll-margin-top: 6rem;
}

.portfolio-section:first-of-type {
  margin-top: 6.5rem;
}

.section-header {
  display: block;
  margin-bottom: 1.25rem;
}

.ui-section-title {
  display: inline-block;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  color: var(--fg);
  transition: color var(--duration-hover) var(--ease-standard);
}

.section-header:hover .ui-section-title {
  color: var(--accent-11);
}

.ui-section-description {
  margin-top: 0.35rem;
  font-size: 0.92rem;
  line-height: 1.75;
  max-width: 34rem;
  color: color-mix(in srgb, var(--muted) 92%, transparent);
}

.item-list {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 0.75rem;
  border-top: 1px solid var(--border);
  transition: background-color var(--duration-hover) var(--ease-standard);
}

.list-row:hover {
  background: color-mix(in srgb, var(--surface-tint) 38%, transparent);
}

.list-row-main {
  min-width: 0;
  flex: 1;
}

.row-title {
  font-size: 1rem;
  font-weight: 500;
  color: var(--fg-secondary);
  transition: color var(--duration-hover) var(--ease-standard);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row:hover .row-title {
  color: var(--fg);
}

.row-subtitle {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.tag-row {
  margin-top: 0.55rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.ui-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.16rem 0.62rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--fg-secondary);
  background: var(--surface-tint);
  border: 1px solid var(--border);
  transition:
    color var(--duration-hover) var(--ease-standard),
    border-color var(--duration-hover) var(--ease-standard),
    background-color var(--duration-hover) var(--ease-standard);
}

.list-row:hover .ui-tag,
.ui-tag.is-active {
  color: var(--fg);
  border-color: var(--border-strong);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.row-date {
  flex-shrink: 0;
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.read-more-link {
  display: inline-block;
  margin-top: 0.85rem;
  padding-left: 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
  transition: color var(--duration-hover) var(--ease-standard);
}

.read-more-link:hover {
  color: var(--fg);
}

/* OpenSource PR Icon Box */
.oss-row-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 0;
  flex: 1;
}

.oss-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.75rem;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface-tint);
}

.oss-icon-box svg {
  width: 16px;
  height: 16px;
}

.oss-icon-box.is-merged { color: #38bdf8; }
.oss-icon-box.is-open { color: #4ade80; }
.oss-icon-box.is-closed { color: #f87171; }

html.light .oss-icon-box.is-merged { color: #0284c7; }
html.light .oss-icon-box.is-open { color: #16a34a; }
html.light .oss-icon-box.is-closed { color: #dc2626; }

/* ==========================================================================
   Subpages, Breadcrumbs & Article Prose
   ========================================================================== */
.breadcrumb {
  margin-top: 2rem;
  margin-bottom: 1.35rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--muted);
  flex-wrap: wrap;
}

.breadcrumb a {
  transition: color var(--duration-hover) var(--ease-standard);
}

.breadcrumb a:hover {
  color: var(--fg);
}

.breadcrumb-sep {
  opacity: 0.6;
  font-size: 0.78rem;
}

.breadcrumb-current {
  color: var(--fg-secondary);
  max-width: 24rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subpage-header {
  margin-bottom: 1.5rem;
}

.article-layout {
  position: relative;
}

.article-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.article-title {
  font-size: 1.5rem;
  line-height: 1.28;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--fg);
}

.article-meta {
  margin-top: 0.55rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.article-prose {
  margin-top: 2.25rem;
  font-size: 1rem;
  line-height: 1.78;
  color: var(--fg-secondary);
}

.article-prose h2 {
  margin-top: 2.25rem;
  margin-bottom: 0.85rem;
  font-size: 1.32rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--fg);
  scroll-margin-top: 6rem;
}

.article-prose h3 {
  margin-top: 1.75rem;
  margin-bottom: 0.65rem;
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
  scroll-margin-top: 6rem;
}

.article-prose p {
  margin-bottom: 1.1rem;
}

.article-prose strong {
  color: var(--fg);
  font-weight: 600;
}

.article-prose a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--muted-soft);
  text-underline-offset: 3px;
}

.article-prose a:hover {
  text-decoration-color: var(--fg);
}

.article-prose ul,
.article-prose ol {
  margin: 0.8rem 0 1.2rem;
  padding-left: 1.35rem;
}

.article-prose li {
  margin-bottom: 0.45rem;
}

.article-prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.75rem 0;
}

.article-prose blockquote {
  margin: 1.25rem 0;
  padding: 0.35rem 0 0.35rem 1rem;
  border-left: 2px solid var(--accent-9);
  color: var(--muted);
}

.article-prose :not(pre) > code {
  padding: 0.14rem 0.42rem;
  border-radius: var(--radius-small);
  font-size: 0.86em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  background: var(--kbd-bg);
  color: var(--kbd-fg);
  border: 1px solid var(--kbd-border);
}

.article-prose pre {
  margin: 1.4rem 0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-large);
  border: 1px solid var(--code-border);
  background: var(--code-bg) !important;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.article-prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4rem 0;
  font-size: 0.9rem;
}

.article-prose th,
.article-prose td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.article-prose th {
  color: var(--fg);
  font-weight: 600;
}

/* Prev / Next Navigation */
.article-nav {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.article-nav-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: 48%;
}

.article-nav-item.is-next {
  margin-left: auto;
  text-align: right;
  align-items: flex-end;
}

.article-nav-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.article-nav-title {
  font-size: 0.94rem;
  font-weight: 500;
  color: var(--fg-secondary);
  transition: color var(--duration-hover) var(--ease-standard);
}

.article-nav-item:hover .article-nav-title {
  color: var(--fg);
}

/* Sticky Right Table of Contents (xl screens >= 1240px) */
.toc-sidebar {
  display: none;
}

@media (min-width: 1240px) {
  .toc-sidebar {
    display: block;
    position: fixed;
    top: 6.5rem;
    right: max(2rem, calc(50% - 37rem));
    width: 14rem;
    max-height: calc(100vh - 9rem);
    overflow-y: auto;
  }
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.toc-link {
  display: block;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
  transition: color var(--duration-hover) var(--ease-standard);
}

.toc-link.level-3 {
  padding-left: 0.75rem;
}

.toc-link:hover,
.toc-link.is-active {
  color: var(--fg);
}

/* ==========================================================================
   Footer & Segmented Theme Switcher
   ========================================================================== */
.site-footer {
  margin-top: 3.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.footer-credit {
  font-size: 0.85rem;
  color: var(--muted);
}

.footer-credit a {
  text-decoration: underline;
  text-decoration-color: var(--muted-soft);
  text-underline-offset: 2px;
  color: var(--fg-secondary);
}

.footer-credit a:hover {
  color: var(--fg);
  text-decoration-color: var(--fg);
}

.theme-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-ambient);
}

.theme-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 9999px;
  color: var(--muted);
  transition:
    color var(--duration-hover) var(--ease-standard),
    background-color var(--duration-hover) var(--ease-standard);
}

.theme-pill-btn:hover {
  color: var(--fg);
}

.theme-pill-btn.is-active {
  color: var(--fg);
  background: var(--surface-tint);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.06);
}

.theme-pill-btn svg {
  width: 14px;
  height: 14px;
}

/* ==========================================================================
   Chroma Syntax Highlighting Overrides (Light & Dark Adaptive)
   ========================================================================== */
.chroma { color: #d8dee9; background: transparent; }
.chroma .ln { color: var(--muted); margin-right: 1rem; user-select: none; opacity: 0.65; }
.chroma .k, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr, .chroma .kt { color: #c678dd; }
.chroma .nf, .chroma .fm { color: #61afef; }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl, .chroma .sd, .chroma .s2, .chroma .se, .chroma .sh, .chroma .si, .chroma .sx, .chroma .sr, .chroma .s1 { color: #98c379; }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi, .chroma .il, .chroma .mo { color: #d19a66; }
.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1, .chroma .cs, .chroma .cp, .chroma .cpf { color: #6e7681; font-style: italic; }
.chroma .na, .chroma .nb, .chroma .nc, .chroma .nd, .chroma .ne, .chroma .nx { color: #e5c07b; }
.chroma .o, .chroma .ow { color: #56b6c2; }

html.light .chroma { color: #24292f; }
html.light .chroma .k, html.light .chroma .kd, html.light .chroma .kn, html.light .chroma .kp, html.light .chroma .kr, html.light .chroma .kt { color: #8250df; }
html.light .chroma .nf, html.light .chroma .fm { color: #0550ae; }
html.light .chroma .s, html.light .chroma .sa, html.light .chroma .sb, html.light .chroma .sc, html.light .chroma .dl, html.light .chroma .sd, html.light .chroma .s2, html.light .chroma .se, html.light .chroma .sh, html.light .chroma .si, html.light .chroma .sx, html.light .chroma .sr, html.light .chroma .s1 { color: #116329; }
html.light .chroma .m, html.light .chroma .mb, html.light .chroma .mf, html.light .chroma .mh, html.light .chroma .mi, html.light .chroma .il, html.light .chroma .mo { color: #953800; }
html.light .chroma .c, html.light .chroma .ch, html.light .chroma .cm, html.light .chroma .c1, html.light .chroma .cs, html.light .chroma .cp, html.light .chroma .cpf { color: #6e7781; }
html.light .chroma .na, html.light .chroma .nb, html.light .chroma .nc, html.light .chroma .nd, html.light .chroma .ne, html.light .chroma .nx { color: #953800; }

/* ==========================================================================
   Customize Studio UI
   ========================================================================== */
.studio-card {
  margin-top: 1.25rem;
  padding: 1.25rem;
  border-radius: var(--radius-large);
  border: 1px solid var(--border);
  background: var(--surface);
}

.studio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

@media (max-width: 640px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
}

.studio-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.studio-field.is-full {
  grid-column: 1 / -1;
}

.studio-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg-secondary);
}

.studio-input,
.studio-textarea,
.studio-select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-base);
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  font-size: 0.88rem;
}

.studio-textarea {
  min-height: 5.5rem;
  resize: vertical;
  line-height: 1.5;
}

.studio-input:focus,
.studio-textarea:focus,
.studio-select:focus {
  outline: none;
  border-color: var(--accent-9);
}

.studio-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.48rem 0.95rem;
  border-radius: var(--radius-base);
  font-size: 0.84rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface-tint);
  color: var(--fg);
  transition: background-color 0.15s, border-color 0.15s;
}

.studio-btn:hover {
  border-color: var(--accent-9);
}

.studio-btn.is-primary {
  background: var(--accent-9);
  border-color: var(--accent-9);
  color: #ffffff;
}

.studio-btn.is-primary:hover {
  opacity: 0.92;
}

.studio-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 9999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-strong);
  color: var(--fg);
  font-size: 0.84rem;
  box-shadow: var(--shadow-elevated);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
}

.studio-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}
