:root {
  --bg-base: #0b121a;
  --bg-panel: rgba(18, 26, 38, 0.88);
  --bg-panel-strong: rgba(23, 33, 46, 0.97);
  --ink: #eaf1fb;
  --ink-soft: #b2bfd3;
  --ink-muted: #c9d4e4;
  --teal: #86c9c1;
  --teal-soft: #8bb8de;
  --orange: #f4a261;
  --orange-soft: #f8c08f;
  --line: rgba(165, 190, 220, 0.24);
  --font-body: "Instrument Sans", "Segoe UI", sans-serif;
  --font-title: "Merriweather", Georgia, serif;
  --measure-prose: 74ch;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow: 0 14px 34px rgba(2, 8, 16, 0.42);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(130deg, #0b121b 0%, #122031 50%, #172739 100%);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.62;
}

a {
  color: var(--teal);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--teal-soft);
  outline-offset: 3px;
  border-radius: 8px;
}

.ambient {
  position: fixed;
  width: 500px;
  height: 500px;
  filter: blur(85px);
  pointer-events: none;
  z-index: -2;
  opacity: 0.34;
}

.ambient-warm {
  top: -160px;
  right: -80px;
  background: radial-gradient(circle, rgba(244, 162, 97, 0.95) 0%, rgba(244, 162, 97, 0) 72%);
  animation: floatWarm 14s ease-in-out infinite;
}

.ambient-cool {
  left: -180px;
  bottom: -200px;
  background: radial-gradient(circle, rgba(108, 181, 243, 0.9) 0%, rgba(108, 181, 243, 0) 68%);
  animation: floatCool 16s ease-in-out infinite;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  z-index: -3;
  opacity: 0.2;
  pointer-events: none;
  background-image: linear-gradient(rgba(122, 208, 200, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 208, 200, 0.12) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black 15%, transparent 78%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(14px, 3vw, 38px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 14, 23, 0.8);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--teal);
  font-weight: 700;
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--orange), var(--teal));
  box-shadow: 0 0 0 6px rgba(244, 162, 97, 0.2);
}

.brand-text {
  font-family: var(--font-title);
  letter-spacing: 0.1px;
}

.top-links {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  font-size: 0.95rem;
}

.top-links a {
  text-decoration: none;
  color: var(--ink-soft);
  transition: color 0.2s ease;
}

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

.top-link-pill {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  padding: 8px 14px;
  border-radius: 999px;
}

.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  color: var(--teal);
  border-radius: 999px;
  font-size: 0.88rem;
  padding: 8px 14px;
}

.shell {
  max-width: 1360px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
  padding: 30px clamp(14px, 3vw, 34px) 44px;
}

body.reading-mode .shell {
  grid-template-columns: minmax(0, 1fr);
}

body.reading-mode .main-content {
  max-width: min(1160px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  column-gap: 18px;
  align-items: start;
}

body.reading-mode .hero-panel {
  grid-column: 1 / -1;
}

body.reading-mode .top-links {
  display: none;
}

body.reading-mode .menu-toggle {
  display: inline-flex;
}

.blog-toc {
  display: none;
}

body.reading-mode .blog-toc.is-visible {
  display: block;
  position: sticky;
  top: 92px;
  border: 1px solid rgba(191, 167, 131, 0.36);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(251, 244, 230, 0.94) 0%, rgba(247, 238, 219, 0.94) 100%);
  padding: 14px 12px;
  box-shadow: 0 8px 20px rgba(13, 9, 5, 0.14);
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.toc-title {
  margin: 0 0 10px;
  font-family: var(--font-title);
  font-size: 0.9rem;
  color: #4a3721;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.toc-links {
  display: grid;
  gap: 4px;
}

.toc-item {
  display: block;
  color: #5f4121;
  text-decoration: none;
  font-size: 0.92rem;
  line-height: 1.44;
  border-radius: 8px;
  padding: 7px 8px;
  transition: background 0.18s ease, color 0.18s ease;
}

.toc-item:hover {
  color: #3e260d;
  background: rgba(174, 126, 69, 0.17);
}

.toc-item.active {
  color: #3e260d;
  background: rgba(174, 126, 69, 0.22);
}

.toc-item-sub {
  padding-left: 18px;
  font-size: 0.88rem;
  color: #735739;
}

.sidebar {
  position: sticky;
  top: 90px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  background: var(--bg-panel);
  backdrop-filter: blur(7px);
  padding: 16px;
  max-height: calc(100vh - 120px);
  overflow: auto;
}

body.reading-mode .sidebar {
  position: fixed;
  top: 74px;
  left: 12px;
  right: 12px;
  max-height: calc(100vh - 95px);
  transform: translateY(-16px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 40;
}

body.reading-mode .sidebar.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.sidebar section + section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed rgba(154, 187, 223, 0.28);
}

.sidebar-title {
  margin: 0 0 8px;
  color: var(--ink-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.sidebar a {
  display: block;
  text-decoration: none;
  color: var(--ink);
  padding: 9px 10px;
  line-height: 1.45;
  border-radius: 10px;
  transition: background 0.25s ease, transform 0.25s ease;
}

.sidebar a:hover,
.sidebar a.active {
  background: rgba(108, 181, 243, 0.2);
  transform: translateX(2px);
}

.main-content {
  display: grid;
  gap: 20px;
}

.hero-panel,
.content-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  background: var(--bg-panel);
  backdrop-filter: blur(8px);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 20px;
  padding: clamp(20px, 2.5vw, 32px);
  overflow: hidden;
  position: relative;
}

.hero-panel:not(.has-hero-image) {
  grid-template-columns: minmax(0, 1fr);
}

.hero-copy {
  position: relative;
  z-index: 2;
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(122, 208, 200, 0.12) 0%, transparent 60%);
}

.route-label {
  margin: 0;
  display: inline-block;
  border: 1px solid rgba(108, 181, 243, 0.35);
  color: var(--teal-soft);
  border-radius: 999px;
  font-size: 0.77rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 5px 10px;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-title);
  line-height: 1.27;
  letter-spacing: 0.006em;
}

h1 {
  font-size: clamp(1.82rem, 3.2vw, 2.72rem);
  margin: 0.62rem 0 0.7rem;
  color: #f4f7ff;
}

.page-subtitle {
  margin: 0;
  max-width: 64ch;
  color: var(--ink-soft);
  font-size: clamp(1rem, 1.52vw, 1.12rem);
  line-height: 1.72;
}

.page-subtitle.is-hidden {
  display: none;
}

.hero-badges {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-badges span {
  font-size: 0.84rem;
  border-radius: 999px;
  border: 1px solid rgba(154, 187, 223, 0.34);
  background: var(--bg-panel-strong);
  padding: 8px 11px;
}

.hero-visual {
  display: none;
  align-items: center;
}

.hero-panel.has-hero-image .hero-visual {
  display: flex;
}

.hero-visual img {
  width: 100%;
  max-width: 280px;
  margin-left: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: center top;
  border-radius: 20px;
  border: 1px solid rgba(154, 187, 223, 0.35);
  box-shadow: 0 16px 40px rgba(4, 10, 18, 0.62);
}

.hero-panel.is-blog-hero {
  grid-template-columns: minmax(0, 1fr);
  min-height: clamp(260px, 30vw, 360px);
  align-items: end;
}

.hero-panel.is-blog-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    180deg,
    rgba(9, 18, 30, 0.08) 0%,
    rgba(8, 16, 28, 0.2) 50%,
    rgba(8, 16, 28, 0.42) 100%
  );
}

.hero-panel.is-blog-post .hero-copy {
  display: none;
}

.hero-panel.is-blog-hero .hero-visual {
  display: flex;
  position: absolute;
  inset: 0;
  z-index: 0;
}

.hero-panel.is-blog-hero .hero-visual img {
  width: 100%;
  max-width: none;
  height: 100%;
  margin-left: 0;
  aspect-ratio: auto;
  border-radius: 0;
  border: 0;
  box-shadow: none;
  object-fit: cover;
  filter: saturate(0.88) contrast(1.08);
}

.hero-panel.is-blog-route .route-label {
  border-color: rgba(244, 162, 97, 0.5);
  color: var(--orange-soft);
}

.hero-panel.is-blog-route .hero-badges {
  display: none;
}

.content-card {
  padding: clamp(20px, 2.6vw, 34px);
}

body.reading-mode .content-card {
  grid-column: 2;
}

.content-card > * {
  max-width: var(--measure-prose);
  margin-left: auto;
  margin-right: auto;
}

.content-card > pre,
.content-card > table,
.content-card > .video-embed {
  max-width: 100%;
}

.content-card.blog-post {
  background: linear-gradient(180deg, rgba(251, 247, 239, 0.99) 0%, rgba(246, 239, 227, 0.99) 100%);
  border-color: rgba(190, 162, 124, 0.52);
  box-shadow: 0 16px 36px rgba(10, 8, 5, 0.26);
}

.content-card.blog-post > * {
  max-width: 72ch;
  margin-left: auto;
  margin-right: auto;
}

.content-card.blog-post > pre,
.content-card.blog-post > table,
.content-card.blog-post > .video-embed,
.content-card.blog-post > figure,
.content-card.blog-post > p:has(> img:only-child) {
  max-width: 100%;
}

.content-card.blog-post > pre {
  width: 100%;
}

.content-card.blog-post h1 {
  margin-top: 0.35rem;
  color: #2f2417;
  line-height: 1.22;
  font-size: clamp(1.74rem, 2.7vw, 2.26rem);
  text-wrap: balance;
}

.content-card.blog-post h2 {
  color: #3f2f1c;
  margin-top: 2.1rem;
  font-size: clamp(1.24rem, 2vw, 1.58rem);
}

.content-card.blog-post h3 {
  color: #4a3823;
  font-size: clamp(1.02rem, 1.72vw, 1.16rem);
}

.content-card.blog-post blockquote {
  border-left-color: #ae7e45;
  background: rgba(241, 228, 204, 0.72);
  border-radius: 10px;
  padding: 12px 14px;
  color: #4b3720;
}

.content-card.blog-post p,
.content-card.blog-post li {
  color: #3b3023;
  font-size: 1.07rem;
  line-height: 1.9;
}

.content-card.blog-post ul,
.content-card.blog-post ol {
  padding-left: 1.4rem;
  margin-top: 0.8rem;
  margin-bottom: 1.1rem;
}

.content-card.blog-post li + li {
  margin-top: 0.65rem;
}

.content-card.blog-post a {
  color: #8d5520;
  text-decoration-thickness: 2px;
}

.content-card.blog-post a[href^="http"] {
  word-break: break-all;
}

.content-card.blog-post a:hover {
  color: #734216;
}

.content-card h1 {
  font-size: clamp(1.58rem, 2.68vw, 2.16rem);
  margin-bottom: 0.6rem;
}

.content-card h2 {
  font-size: clamp(1.12rem, 1.96vw, 1.5rem);
  margin-top: 2.05rem;
  margin-bottom: 0.68rem;
}

.content-card h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.48rem;
  font-size: clamp(0.99rem, 1.72vw, 1.12rem);
}

.content-card p,
.content-card li,
.content-card td,
.content-card blockquote {
  color: #dbe5f4;
  line-height: 1.86;
  font-size: 1.02rem;
}

.content-card p {
  margin-top: 0.75rem;
  margin-bottom: 0.95rem;
}

.content-card ul,
.content-card ol {
  padding-left: 1.2rem;
}

.content-card li + li {
  margin-top: 0.5rem;
}

.content-card pre {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid rgba(154, 187, 223, 0.22);
  background: #0c1724;
  color: #e9f2f1;
  padding: 16px;
}

.content-card pre code {
  display: block;
}

.content-card code {
  font-family: "JetBrains Mono", "Courier New", monospace;
  font-size: 0.9rem;
}

.content-card p code,
.content-card li code {
  background: rgba(108, 181, 243, 0.16);
  border-radius: 6px;
  padding: 1px 6px;
}

.content-card img {
  display: block;
  max-width: 100%;
  height: auto;
}

.content-card.blog-post p > img:only-child,
.content-card.blog-post figure img {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(175, 141, 97, 0.36);
  box-shadow: 0 10px 24px rgba(16, 10, 4, 0.18);
}

.content-card.blog-post img {
  width: 100%;
}

.content-card table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  border: 1px solid rgba(154, 187, 223, 0.26);
  background: var(--bg-panel-strong);
}

.content-card th,
.content-card td {
  border: 1px solid rgba(154, 187, 223, 0.18);
  text-align: left;
  padding: 10px;
}

.content-card blockquote {
  margin: 1rem 0;
  border-left: 4px solid var(--orange);
  padding: 5px 0 5px 16px;
  font-style: italic;
}

.content-card a {
  color: var(--teal-soft);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1.6px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.video-embed {
  position: relative;
  width: 100%;
  margin: 14px 0 22px;
  padding-top: 56.25%;
  border: 1px solid rgba(154, 187, 223, 0.28);
  border-radius: 14px;
  overflow: hidden;
  background: #0a1522;
  box-shadow: 0 12px 30px rgba(2, 8, 16, 0.45);
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.loading,
.error {
  margin: 0;
  color: var(--ink-soft);
}

.footer {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 clamp(14px, 3vw, 34px) 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  color: #91a1b7;
  font-size: 0.9rem;
}

.footer a {
  text-decoration: none;
  border-bottom: 1px solid rgba(154, 187, 223, 0.42);
}

.reveal {
  opacity: 0;
  transform: translateY(22px);
  animation: revealUp 0.8s ease forwards;
}

.content-card.reveal {
  animation-delay: 0.09s;
}

@keyframes floatWarm {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(-40px, 34px);
  }
}

@keyframes floatCool {
  0%,
  100% {
    transform: translate(0, 0);
  }
  50% {
    transform: translate(34px, -36px);
  }
}

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  body.reading-mode .main-content {
    grid-template-columns: minmax(0, 1fr);
    max-width: min(980px, 100%);
  }

  body.reading-mode .content-card {
    grid-column: 1;
  }

  body.reading-mode .blog-toc.is-visible {
    position: static;
    max-height: none;
    margin-bottom: 4px;
  }

  .sidebar {
    position: fixed;
    top: 74px;
    left: 12px;
    right: 12px;
    max-height: calc(100vh - 95px);
    transform: translateY(-16px) scale(0.98);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 40;
  }

  .sidebar.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
  }

  .top-links {
    display: none;
  }

  .menu-toggle {
    display: inline-flex;
  }
}

@media (max-width: 760px) {
  h1 {
    font-size: clamp(1.58rem, 7.6vw, 2.02rem);
    line-height: 1.2;
  }

  .content-card {
    padding: 18px 16px 22px;
  }

  .content-card h1 {
    font-size: clamp(1.46rem, 6.8vw, 1.92rem);
  }

  .content-card h2 {
    font-size: clamp(1.08rem, 4.9vw, 1.28rem);
    margin-top: 1.7rem;
  }

  .content-card h3 {
    font-size: clamp(0.98rem, 4vw, 1.06rem);
  }

  .content-card p,
  .content-card li,
  .content-card td,
  .content-card blockquote {
    font-size: 1rem;
    line-height: 1.8;
  }

  .hero-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-visual {
    justify-content: flex-start;
    order: -1;
  }

  .hero-visual img {
    margin-left: 0;
    max-width: 180px;
  }

  .hero-badges {
    gap: 8px;
  }

  .hero-badges span {
    font-size: 0.78rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ambient-warm,
  .ambient-cool,
  .reveal,
  .content-card.reveal {
    animation: none !important;
    transform: none !important;
  }
}
