/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --text: #1a1a2e;
  --text-secondary: #555;
  --text-dim: #888;
  --bg: #ffffff;
  --bg-alt: #f8f9fc;
  --border: #e8eaed;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --green: #059669;
  --blue: #2563eb;
  --red: #dc2626;
  --orange: #d97706;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-alt);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* ===== Navigation ===== */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 800;
  font-size: 1rem;
}

.logo-icon-sm {
  width: 26px;
  height: 26px;
  font-size: 0.85rem;
  border-radius: 6px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}

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

.lang-toggle {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
}

.lang-toggle:hover {
  background: var(--border);
  color: var(--text);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 22px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 0.85rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #4338ca;
  color: #fff;
  box-shadow: var(--shadow);
}

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

.btn-outline:hover {
  background: var(--bg-alt);
  border-color: #ccc;
  color: var(--text);
}

/* ===== Hero ===== */
.hero {
  padding: 140px 0 80px;
  text-align: center;
}

.badge {
  display: inline-block;
  padding: 6px 16px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 24px;
}

.hero h1 {
  font-size: 3.4rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}

.hero-sub {
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 36px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-bottom: 56px;
}

.hero-code {
  max-width: 560px;
  margin: 0 auto;
  background: #1e1e2e;
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-align: left;
  box-shadow: var(--shadow-lg);
}

.code-header {
  display: flex;
  gap: 6px;
  padding: 14px 18px;
  background: rgba(255,255,255,0.06);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-red { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green { background: #28c840; }

.hero-code pre {
  padding: 16px 22px 22px;
  font-size: 0.88rem;
  line-height: 1.7;
  overflow-x: auto;
}

.hero-code code {
  background: none;
  border: none;
  padding: 0;
  color: #cdd6f4;
  font-size: 0.88rem;
}

.c-gray { color: #6c7086; }
.c-dim { color: #a6adc8; }
.c-green { color: #a6e3a1; }
.c-blue { color: #89b4fa; }

/* ===== Sections ===== */
.section {
  padding: 96px 0;
}

.section-alt {
  background: var(--bg-alt);
}

.section-title {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  margin-bottom: 12px;
}

.section-sub {
  text-align: center;
  color: var(--text-secondary);
  font-size: 1.05rem;
  margin-bottom: 56px;
}

/* ===== Features Grid ===== */
.features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.feature-card {
  padding: 32px 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  transition: box-shadow 0.2s;
}

.feature-card:hover {
  box-shadow: var(--shadow);
}

.feature-icon {
  font-size: 1.6rem;
  margin-bottom: 16px;
}

.feature-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ===== Steps ===== */
.steps {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.step {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.step-num {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
}

.step-content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.step-code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  margin-bottom: 8px;
}

.step-content p {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ===== Architecture ===== */
.arch-diagram {
  max-width: 720px;
  margin: 0 auto 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.arch-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.arch-arrow {
  font-size: 1.4rem;
  color: var(--text-dim);
}

.arch-connector {
  font-size: 1.4rem;
  color: var(--text-dim);
}

.arch-box {
  padding: 20px 24px;
  border-radius: var(--radius);
  text-align: center;
  min-width: 150px;
}

.arch-label {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

.arch-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.arch-ports {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.arch-client {
  background: #f0e7fe;
  border: 1px solid #d8b4fe;
}

.arch-caddy {
  background: #d1fae5;
  border: 1px solid #6ee7b7;
  min-width: 260px;
}

.arch-browser {
  background: #fee2e2;
  border: 1px solid #fca5a5;
}

.arch-api {
  background: #dbeafe;
  border: 1px solid #93c5fd;
}

.arch-db {
  background: #fef3c7;
  border: 1px solid #fcd34d;
}

.tech-stack {
  text-align: center;
}

.tech-stack h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.tech-tags {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.tag {
  padding: 6px 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ===== Quick Start ===== */
.quickstart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  max-width: 720px;
  margin: 0 auto;
}

.qs-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.qs-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.qs-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 14px;
}

.qs-card-wide {
  /* inherits grid width */
}

.qs-card-highlight {
  border: 2px solid var(--accent);
  background: var(--accent-light);
}

.qs-card-highlight .code-block {
  background: var(--text);
}

.qs-card-highlight .code-block code {
  color: #e2e8f0;
  font-size: 0.95rem;
  user-select: all;
}

/* Copy button */
.code-block-copy {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.copy-btn:hover {
  background: rgba(255,255,255,0.2);
  color: #e2e8f0;
}

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

.copy-btn .check-icon {
  display: none;
  color: var(--green);
}

.copy-btn.copied .copy-icon {
  display: none;
}

.copy-btn.copied .check-icon {
  display: block;
}

.code-block {
  background: #1e1e2e;
  border-radius: 8px;
  overflow-x: auto;
}

.code-block pre {
  padding: 16px 20px;
  font-size: 0.85rem;
  line-height: 1.7;
}

.code-block code {
  background: none;
  border: none;
  padding: 0;
  color: #cdd6f4;
  font-size: 0.85rem;
}

.qs-table {
  margin-top: 20px;
}

.qs-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.qs-table th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.qs-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

/* ===== CLI Reference ===== */
.cli-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin-bottom: 32px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.cli-group {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.cli-group h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.cli-config {
  max-width: 480px;
  margin: 0 auto;
  text-align: center;
}

.cli-config h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
}

.cli-config p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 14px;
}

/* ===== API Table ===== */
.api-table-wrap {
  overflow-x: auto;
}

.api-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.api-table th {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.api-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.api-table td:last-child {
  font-family: var(--font);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.method {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  font-family: var(--font);
}

.method.post {
  background: #dbeafe;
  color: var(--blue);
}

.method.get {
  background: #d1fae5;
  color: var(--green);
}

.method.delete {
  background: #fee2e2;
  color: var(--red);
}

.method.put {
  background: #fef3c7;
  color: #b45309;
}

/* ===== Footer ===== */
.footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.footer-right a {
  color: var(--text-secondary);
}

.footer-sep {
  color: var(--border);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .hero h1 {
    font-size: 2.2rem;
  }

  .hero-sub br {
    display: none;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }

  .quickstart-grid {
    grid-template-columns: 1fr;
  }

  .cli-grid {
    grid-template-columns: 1fr;
  }

  .nav-links a:not(.btn) {
    display: none;
  }

  .arch-row {
    flex-direction: column;
  }

  .arch-arrow {
    transform: rotate(90deg);
  }

  .hero-actions {
    flex-direction: column;
    align-items: center;
  }

  .section-title {
    font-size: 1.7rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 12px;
  }
}
