/* ─── Design Tokens ──────────────────────────────────────── */
:root {
  --bg:           #f7f5f0;
  --bg-card:      #f9f7f3;
  --text:         #2c251e;
  --text-2:       #8b8680;
  --border:       #e0ddd6;
  --btn-bg:       #2e2a26;
  --btn-hover:    #3d3832;
  --link-color:   #8b5a2b;
  --font-body:    "Sora", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
  --font-mono:    "Geist Mono", "SFMono-Regular", "Menlo", monospace;
  --sidebar-w:    180px;
  --content-max:  780px;
  --desktop-gutter: 3rem;
}

/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
img, audio { max-width: 100%; display: block; }

audio {
  width: 100%;
  height: 40px;
  border-radius: 999px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.1em 0.4em;
  background: rgba(44, 37, 30, 0.07);
  border-radius: 4px;
}

strong { font-weight: 600; }

::selection { background: rgba(139, 90, 43, 0.18); }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb {
  background: rgba(44, 37, 30, 0.18);
  border-radius: 999px;
}

/* ─── Layout ─────────────────────────────────────────────── */

/* Sidebar hidden on mobile */
.sidebar { display: none; }

.mobile-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.mobile-brand {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}

.mobile-actions { display: flex; gap: 0.5rem; }

.content-main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

/* Desktop: show sidebar, offset content */
@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    height: 100vh;
    flex-direction: column;
    padding: 2.5rem 1.5rem 4rem;
    border-right: 1px solid var(--border);
    background: var(--bg);
    z-index: 40;
  }

  .mobile-header { display: none; }

  .content-main {
    max-width: calc(var(--content-max) + var(--sidebar-w) + (var(--desktop-gutter) * 2));
    margin: 0 auto;
    padding: 3.5rem var(--desktop-gutter) 6rem calc(var(--sidebar-w) + var(--desktop-gutter));
  }

  .site-footer { margin-left: 0; }
}

/* ─── Sidebar ────────────────────────────────────────────── */
.sidebar-inner {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  height: 100%;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.sidebar-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  background: var(--btn-bg);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.52rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.sidebar-name {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
}

.sidebar-links {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sidebar-link {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-2);
  padding: 0.4rem 0.6rem;
  border-radius: 5px;
  transition: color 140ms, background 140ms;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(44, 37, 30, 0.05);
}

.sidebar-link.active {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, opacity 140ms;
  text-decoration: none;
}

.btn-dark {
  background: var(--btn-bg);
  color: #fff;
  border-color: var(--btn-bg);
}

.btn-dark:hover { background: var(--btn-hover); border-color: var(--btn-hover); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--text);
  background: rgba(44, 37, 30, 0.04);
}

.btn-sm {
  padding: 0.45rem 0.9rem;
  font-size: 0.75rem;
}

/* ─── Banner ─────────────────────────────────────────────── */
.banner-wrap {
  margin-bottom: 2rem;
  border-radius: 10px;
  overflow: hidden;
  line-height: 0;
}

.banner-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  border-radius: 10px;
}

/* ─── Paper Header ───────────────────────────────────────── */
.paper-header {
  text-align: center;
  /* padding-bottom: 2.5rem; */
  border-bottom: 1px solid var(--border);
  /* margin-bottom: 2.5rem; */
}

.paper-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tag {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-2);
}

h1 {
  font-family: var(--font-body);
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 0.85rem;
}

.paper-subtitle {
  font-size: 1rem;
  color: var(--text);
  opacity: 0.8;
  max-width: 46rem;
  /* margin: 0 auto 1.75rem; */
  line-height: 1.7;
}

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  gap: 0.5rem;
  text-align: center;
}

.meta-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
}

.meta-value {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
}

/* ─── Sections ───────────────────────────────────────────── */
.paper-section {
  margin-bottom: 0;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
  padding-top: 2.5rem;
  scroll-margin-top: 5rem;
}

.paper-section:last-child {
  border-bottom: none;
}

h2 {
  font-family: var(--font-body);
  font-size: clamp(18px, 2.5vw, 28px);
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 1.25rem;
}

h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.body-text {
  font-size: 15px;
  color: var(--text);
  line-height: 1.8;
}

.body-content {
  margin: 1.25rem 0;
}

.section-note {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

/* ─── Feature Grid ──────────────────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.feature-item {
  padding: 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.feature-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
}

.feature-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.feature-desc {
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.55;
}

/* ─── Code Blocks ────────────────────────────────────────── */
.code-block {
  background: rgba(44, 37, 30, 0.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 0.6rem 0 1.5rem;
  overflow-x: auto;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.75;
  color: var(--text);
  background: none;
  padding: 0;
  border-radius: 0;
  white-space: pre;
}

.qs-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0;
}

/* ─── Architecture ───────────────────────────────────────── */
.arch-intro a {
  color: var(--link-color);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.arch-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.arch-card {
  flex: 1;
  padding: 1.1rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.arch-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.5rem;
}

.arch-card p:last-child {
  font-size: 0.845rem;
  color: var(--text-2);
  line-height: 1.6;
  margin-top: 0.4rem;
}

.arch-arrow {
  display: flex;
  align-items: center;
  color: var(--text-2);
  font-size: 1rem;
  flex-shrink: 0;
  padding: 0 0.2rem;
}

.arch-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.arch-detail-card {
  padding: 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.arch-copy {
  font-size: 0.845rem;
  color: var(--text);
  line-height: 1.65;
}

.arch-copy-muted {
  color: var(--text-2);
  margin-top: 0.8rem;
}

.arch-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.arch-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(44, 37, 30, 0.04);
  font-family: var(--font-mono);
  font-size: 0.67rem;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* ─── Architecture figure ────────────────────────────────── */
.arch-figure {
  margin: 1.5rem 0 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  /* border-radius: 10px; */
  padding: 1.25rem;
}

.arch-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

.fig-caption {
  margin-top: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-2);
  line-height: 1.6;
  text-align: center;
}

.fact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.fact-item {
  padding: 0.85rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.845rem;
  color: var(--text);
  line-height: 1.5;
}

/* ─── Demo Tabs ──────────────────────────────────────────── */
.demo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.demo-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.42rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.845rem;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, color 140ms;
}

.demo-tab:hover {
  border-color: var(--text);
  background: rgba(44, 37, 30, 0.04);
}

.demo-tab.active {
  background: var(--btn-bg);
  color: #fff;
  border-color: var(--btn-bg);
}

/* ─── Sample Grid & Card ─────────────────────────────────── */
.sample-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

.sample-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: box-shadow 150ms ease;
}

.sample-card:hover {
  box-shadow: 0 3px 14px rgba(44, 37, 30, 0.08);
}

.sample-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.sample-lang {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 0.3rem;
}

.sample-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.status-chip {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.audio-panel {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.audio-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.audio-label-button {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  width: fit-content;
  cursor: pointer;
  transition: color 140ms, opacity 140ms, text-decoration-color 140ms;
}

.audio-label-button:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.audio-label-button[aria-expanded="true"] {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-panel {
  background: rgba(44, 37, 30, 0.04);
  border-radius: 6px;
  padding: 0.65rem 0.75rem;
}

.sample-text {
  font-size: 0.845rem;
  color: var(--text);
  line-height: 1.65;
  max-height: 6rem;
  overflow-y: auto;
  white-space: pre-line;
  margin-top: 0.3rem;
}

/* Compact cards (multilingual) */
.sample-card.compact .sample-text {
  max-height: 5rem;
}

/* ─── Language Badges ────────────────────────────────────── */
.lang-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.badge {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text);
  background: var(--bg-card);
}

/* ─── Notice (error state) ───────────────────────────────── */
.notice-card {
  grid-column: 1 / -1;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  font-size: 0.875rem;
  color: var(--text-2);
}

/* ─── Reveal animation ───────────────────────────────────── */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 500ms ease, transform 500ms ease;
}

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

/* ─── Footer ─────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.75rem 1.25rem;
  background: var(--bg);
}

.footer-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-2);
}

@media (min-width: 1024px) {
  .footer-inner {
    max-width: calc(var(--content-max) + var(--sidebar-w) + (var(--desktop-gutter) * 2));
    padding: 0 var(--desktop-gutter) 0 calc(var(--sidebar-w) + var(--desktop-gutter));
  }
}

.footer-links {
  display: flex;
  gap: 1.25rem;
}

.footer-links a {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-2);
  transition: color 140ms;
}

.footer-links a:hover { color: var(--text); }

/* ─── Noscript ───────────────────────────────────────────── */
.noscript-banner {
  position: fixed;
  inset: auto 1rem 1rem;
  max-width: 26rem;
  padding: 1rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-2);
  font-size: 0.875rem;
  box-shadow: 0 8px 24px rgba(44, 37, 30, 0.1);
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .arch-row {
    flex-direction: column;
  }
  .arch-arrow {
    transform: rotate(90deg);
    align-self: center;
  }
  .arch-detail-grid {
    grid-template-columns: 1fr;
  }
  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .fact-grid,
  .sample-grid {
    grid-template-columns: 1fr;
  }
  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  .paper-actions {
    flex-direction: column;
    align-items: center;
  }
  .paper-actions .btn {
    width: 100%;
    max-width: 18rem;
  }
}

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

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