/* ChromaStage Wiki — polished wiki-style user manual */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #fafafa;
  --card-bg: #ffffff;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --text-faint: #86868b;
  --accent: #34c759;
  --accent-dark: #28a745;
  --warn: #ff9500;
  --danger: #ff3b30;
  --code-bg: #1e1e1e;
  --code-fg: #d4d4d4;
  --border: #d2d2d7;
  --border-soft: #e5e5ea;
  --sidebar-bg: #f5f5f7;
  --sidebar-width: 280px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 8px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
               "Noto Sans Thai", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.logo {
  font-size: 32px;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-faint);
}

.nav-section {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 20px 8px 8px;
}

.nav a {
  display: block;
  padding: 6px 12px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.nav a:hover {
  background: rgba(52, 199, 89, 0.1);
  color: var(--accent-dark);
}

.sidebar-footer {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.live-link, .api-link {
  display: block;
  padding: 10px;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  transition: transform 0.15s;
}

.live-link {
  background: var(--accent);
  color: white;
}

.api-link {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.live-link:hover, .api-link:hover { transform: translateY(-1px); }

/* ===== Main ===== */
.main {
  margin-left: var(--sidebar-width);
  max-width: 1100px;
  padding: 0 40px 80px;
}

/* ===== Hero ===== */
.hero {
  background: linear-gradient(135deg, #161616 0%, #2c2c2c 100%);
  color: white;
  padding: 80px 0;
  margin: 0 -40px 40px;
  text-align: center;
  border-radius: 0 0 32px 32px;
}

.hero-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 40px;
}

.hero-tag {
  display: inline-block;
  padding: 6px 16px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 99px;
  font-size: 13px;
  margin-bottom: 24px;
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,0.05);
}

.hero h1 {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1.05;
  margin-bottom: 24px;
}

.hero-accent {
  background: linear-gradient(90deg, #34c759, #30d158, #5ac8fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-desc {
  font-size: 18px;
  color: rgba(255,255,255,0.8);
  max-width: 700px;
  margin: 0 auto 40px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 40px 0;
}

.stat {
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  padding: 24px 16px;
}

.stat-num {
  font-size: 40px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -1px;
  line-height: 1;
}

.stat-label {
  font-size: 14px;
  color: rgba(255,255,255,0.9);
  margin-top: 8px;
  font-weight: 600;
}

.stat-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
}

.hero-toc {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 32px;
}

.cta {
  display: inline-block;
  padding: 14px 24px;
  border-radius: 99px;
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.cta-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 16px rgba(52,199,89,0.4);
}

.cta-secondary {
  background: rgba(255,255,255,0.1);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}

.cta:hover { transform: translateY(-2px); }

/* ===== Section ===== */
.section {
  margin: 64px 0;
}

.section-divider {
  margin: 80px 0 32px;
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 60px;
}

.section-emoji {
  font-size: 36px;
  margin-bottom: 8px;
}

h2 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 16px;
  color: var(--text);
}

h3 {
  font-size: 22px;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--text);
}

h4 {
  font-size: 17px;
  font-weight: 700;
  margin: 24px 0 8px;
  color: var(--text);
}

.lead {
  font-size: 17px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

/* ===== Code ===== */
pre {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 18px 22px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: "JetBrains Mono", "Fira Code", Consolas, "SF Mono", monospace;
  font-size: 13px;
  line-height: 1.6;
  margin: 12px 0;
  border: 1px solid #2a2a2a;
}

pre code { color: inherit; background: none; font-size: inherit; }

code {
  background: rgba(0,0,0,0.06);
  color: #c7254e;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 13px;
}

pre code { background: transparent; color: inherit; padding: 0; }

/* ===== Flow Steps ===== */
.flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 32px 0;
}

.flow-step {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  box-shadow: var(--shadow-sm);
}

.flow-num {
  position: absolute;
  top: -16px;
  left: -16px;
  width: 40px;
  height: 40px;
  background: var(--accent);
  color: white;
  font-size: 18px;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.flow-title {
  font-weight: 700;
  margin: 8px 0 4px;
  font-size: 15px;
}

.flow-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== Tables ===== */
.data-table, .api-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
}

.data-table th, .api-table th {
  background: var(--sidebar-bg);
  padding: 14px 18px;
  text-align: left;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
}

.data-table td, .api-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}

.data-table tr:last-child td, .api-table tr:last-child td {
  border-bottom: none;
}

.row-best { background: rgba(52, 199, 89, 0.06); }
.row-warn { background: rgba(255, 149, 0, 0.06); }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.tag-best { background: var(--accent); color: white; }

/* ===== API verbs ===== */
.verb {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  min-width: 40px;
  text-align: center;
}

.verb-get { background: rgba(0, 122, 255, 0.15); color: #007aff; }
.verb-post { background: rgba(52, 199, 89, 0.15); color: var(--accent-dark); }
.verb-del { background: rgba(255, 59, 48, 0.15); color: var(--danger); }

/* ===== Test Case ===== */
.test-case {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 28px;
  margin: 32px 0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

.test-case:hover { box-shadow: var(--shadow-md); }

.case-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-soft);
}

.case-id {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  font-size: 14px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.case-header h3 {
  font-size: 22px;
  margin: 0;
  flex: 1;
}

.case-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.case-badge {
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
}

.case-badge.pass {
  background: var(--accent);
  color: white;
}

.case-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 28px;
  align-items: start;
}

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

.case-image img {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  display: block;
  margin-bottom: 4px;
}

.caption {
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 8px;
  margin-bottom: 16px;
  font-style: italic;
}

.case-content ul { margin: 8px 0 16px 20px; }
.case-content li { margin: 4px 0; font-size: 15px; }

/* ===== Watermark grid ===== */
.wm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.wm-grid > div {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.wm-grid img {
  width: 100%;
  display: block;
}

.wm-label {
  padding: 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: var(--text-muted);
  border-top: 1px solid var(--border-soft);
  background: var(--sidebar-bg);
}

/* ===== Callouts ===== */
.callout {
  padding: 18px 22px;
  border-radius: var(--radius);
  margin: 16px 0;
  border-left: 4px solid;
}

.callout-info { background: rgba(0, 122, 255, 0.08); border-color: #007aff; }
.callout-bug { background: rgba(255, 59, 48, 0.08); border-color: var(--danger); }

.callout-title {
  font-weight: 700;
  margin-bottom: 6px;
  font-size: 15px;
}

.callout p { font-size: 14px; color: var(--text); }
.callout p + p { margin-top: 8px; }

/* ===== Bug note ===== */
.bug-note {
  background: rgba(255, 149, 0, 0.08);
  border: 1px solid rgba(255, 149, 0, 0.3);
  border-left: 4px solid var(--warn);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  margin: 12px 0;
}

.warn { color: var(--warn); }

/* ===== Hint ===== */
.hint {
  font-size: 14px;
  color: var(--text-muted);
  background: var(--sidebar-bg);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  margin: 12px 0;
}

/* ===== Troubleshooting ===== */
.trouble-item {
  background: var(--card-bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
}

.trouble-q {
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 15px;
}

.trouble-a {
  font-size: 14px;
  color: var(--text-muted);
}

.trouble-a strong { color: var(--accent-dark); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .nav { columns: 2; }
  .nav-section { columns: 1; }
  .sidebar-footer { position: static; margin-top: 16px; }
  .main { margin-left: 0; padding: 24px; }
  .hero { margin: 0 -24px 40px; padding: 48px 0; }
  .hero h1 { font-size: 36px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .flow { grid-template-columns: 1fr; }
  .wm-grid { grid-template-columns: repeat(2, 1fr); }
  .section-divider { margin: 48px 0 24px; padding-top: 32px; }
  h2 { font-size: 28px; }
}

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