:root {
  --ink: #1c1917;
  --paper: #faf8f5;
  --cream: #f0ebe3;
  --muted: #78716c;
  --rule: #d6cfc6;
  --accent: #c2410c;
  --code-bg: #1c1917;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Noto Serif SC', 'Playfair Display', Georgia, serif;
  line-height: 1.7;
  overflow-x: hidden;
}

/* --- Header --- */

header {
  border-bottom: 1px solid var(--rule);
  padding: 0 clamp(24px, 5vw, 80px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  background: rgba(250, 248, 245, 0.92);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.logo {
  font-family: 'Playfair Display', serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--ink);
  text-decoration: none;
}

.logo span { color: var(--accent); }

nav a {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  margin-left: 24px;
  letter-spacing: 0.5px;
  transition: color 0.15s;
}

nav a:hover { color: var(--ink); }

/* --- Hero --- */

.hero {
  padding: clamp(60px, 10vw, 110px) clamp(24px, 5vw, 80px) 60px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  max-width: 1100px;
  margin: 0 auto;
}

.announcement-banner {
  grid-column: 1 / -1;
  margin-bottom: 8px;
}

.announcement-inner {
  background: var(--cream);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 14px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.announcement-inner > div { flex: 1; font-size: 14px; line-height: 1.7; }
.announcement-inner h1, .announcement-inner h2, .announcement-inner h3 { margin: 0 0 6px; font-size: 15px; }
.announcement-inner p { margin: 0 0 6px; }
.announcement-inner a { color: var(--accent); }
.announcement-inner code { background: rgba(0,0,0,0.06); padding: 1px 4px; border-radius: 3px; font-size: 12px; }

.announcement-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.hero-eyebrow {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 14px;
}

.hero h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.15;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.5px;
}

.hero h1 em { font-style: italic; color: var(--accent); }

.hero-desc {
  font-size: 15px;
  color: var(--muted);
  max-width: 400px;
  margin-bottom: 28px;
  line-height: 1.8;
  white-space: pre-line;
}

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 4px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
}

.btn-primary { background: var(--ink); color: var(--paper); }
.btn-primary:hover { background: #292524; transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-sm { padding: 7px 14px; font-size: 11px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Preview card --- */

.hero-visual { position: relative; }

.preview-card {
  background: var(--ink);
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  position: relative;
  box-shadow: 10px 10px 0 var(--rule);
}

.preview-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 0.4s;
  background: #292524;
}

.preview-card img.loaded { opacity: 1; }

.loading-text {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: #78716c;
  letter-spacing: 1px;
}

.curtain {
  position: absolute;
  inset: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  z-index: 10;
  transition: opacity 0.4s;
}

.curtain.hidden { opacity: 0; pointer-events: none; }

.curtain-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid #78716c;
  display: flex;
  align-items: center;
  justify-content: center;
}

.curtain-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #78716c;
  text-transform: uppercase;
}

.preview-controls {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.preview-filters {
  display: flex;
  gap: 8px;
  flex: 1;
}

.preview-filters select,
.preview-filters input {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 7px 10px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--cream);
  color: var(--ink);
  min-width: 0;
  flex: 1;
}

.rotate { animation: spin 0.6s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Sections --- */

.section-label {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}

.section-label::before,
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.section-label span {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 80px) 60px;
}

.band {
  background: var(--cream);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 48px 0;
  margin-bottom: 60px;
}

.band-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(24px, 5vw, 80px);
}

.band-desc {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 20px;
}

/* --- Tags bar --- */

.tags-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tags-loading {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--muted);
}

.tag-chip {
  appearance: none;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 7px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s;
}

.tag-chip:hover {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.tag-chip-cat {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.tag-chip-cat:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--paper);
}

/* --- Usage accordion --- */

.usage-list { display: flex; flex-direction: column; gap: 10px; }

.usage-item {
  background: var(--cream);
  border-radius: 6px;
  border: 1px solid var(--rule);
  overflow: hidden;
}

.usage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.usage-header:hover { background: rgba(0,0,0,0.02); }

.usage-meta { display: flex; flex-direction: column; gap: 2px; }

.usage-tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
}

.usage-item h3 { font-size: 14px; font-weight: 600; color: var(--ink); }

.usage-chevron { flex-shrink: 0; transition: transform 0.25s; color: var(--muted); }
.usage-item.collapsed .usage-chevron { transform: rotate(-90deg); }

.usage-body { padding: 0 20px 18px; }
.usage-body p { font-size: 13px; color: var(--muted); margin-bottom: 10px; line-height: 1.6; }
.usage-item.collapsed .usage-body { display: none; }

/* --- Code blocks --- */

.code-block {
  background: var(--code-bg);
  border-radius: 6px;
  padding: 14px 18px;
  margin: 12px 0 0;
  position: relative;
}

.code-block pre {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: #d6d3d1;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
}

.cm { color: #78716c; }
.ck { color: #86efac; }
.cv { color: #fca5a5; }
.cs { color: #fcd34d; }

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #292524;
  border: none;
  border-radius: 3px;
  padding: 3px 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: #78716c;
  cursor: pointer;
  transition: color 0.15s;
}

.copy-btn:hover { color: #d6d3d1; }

/* --- Endpoint table --- */

.endpoint-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 12px;
}

.endpoint-table th {
  text-align: left;
  padding: 10px 12px;
  background: var(--cream);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--rule);
}

.endpoint-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.endpoint-table td:first-child {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  white-space: nowrap;
}

.method {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 9px;
  font-weight: 500;
  background: #dcfce7;
  color: #166534;
  margin-right: 5px;
}

/* --- FAQ / errors --- */

.error-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
}

.error-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--cream);
  border-radius: 5px;
  border: 1px solid var(--rule);
}

.error-code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  min-width: 32px;
}

.error-desc { font-size: 13px; color: var(--muted); }

/* --- Meta section --- */

.meta-section { padding-bottom: 40px; }

/* --- Modal --- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(28, 25, 23, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: min(680px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--paper);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(28, 25, 23, 0.2);
  padding: 24px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-head h3 { margin: 0; font-size: 1.1rem; }

.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  min-height: 140px;
}

.modal-grid img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 6px;
  background: var(--cream);
}

.modal-grid .preview-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 36px;
}

.modal-actions { margin-top: 14px; display: flex; gap: 10px; }

/* --- Footer --- */

footer {
  border-top: 1px solid var(--rule);
  padding: 28px clamp(24px, 5vw, 80px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

footer p {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

/* --- Animations --- */

.fade-in {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s, transform 0.5s;
}

.fade-in.visible { opacity: 1; transform: none; }

/* --- Responsive --- */

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; gap: 36px; }
  .hero-visual { order: -1; }
  header { flex-direction: column; height: auto; padding: 12px 20px; gap: 8px; }
  nav { display: flex; gap: 16px; }
  nav a { margin-left: 0; }
  .preview-controls { flex-direction: column; }
  .modal-grid { grid-template-columns: 1fr 1fr; }
}
