/* ── Design Tokens ────────────────────────────────────────── */
:root {
  --bg-page: #FAF8F5;
  --bg-card: #FFFFFF;
  --bg-subtle: #F5F1EC;
  --bg-hover: rgba(0, 0, 0, 0.03);
  --bg-overlay: rgba(0, 0, 0, 0.04);

  --text-primary: #1C1917;
  --text-secondary: #6B6560;
  --text-tertiary: #9E9892;
  --text-inverse: #F5F1EC;

  --accent: #CC785C;
  --accent-hover: #B8674D;
  --accent-soft: rgba(204, 120, 92, 0.08);
  --accent-glow: rgba(204, 120, 92, 0.18);

  --green: #2D7A3F;
  --green-soft: rgba(45, 122, 63, 0.08);
  --red: #C53030;

  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.12);
  --border-card: rgba(0, 0, 0, 0.06);

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Noto Serif SC', 'Source Han Serif SC', ui-serif, Georgia, serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', Consolas, monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-full: 999px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.06);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.08);
  --shadow-glow: 0 0 0 4px var(--accent-soft);

  --transition-fast: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg-page: #1B1B1B;
  --bg-card: #242424;
  --bg-subtle: #2A2A2A;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-overlay: rgba(255, 255, 255, 0.04);

  --text-primary: #ECECEC;
  --text-secondary: #9E9A95;
  --text-tertiary: #6B6560;
  --text-inverse: #1C1917;

  --accent: #E07D5E;
  --accent-hover: #EB8E73;
  --accent-soft: rgba(224, 125, 94, 0.12);
  --accent-glow: rgba(224, 125, 94, 0.2);

  --green: #3D8F52;
  --green-soft: rgba(61, 143, 82, 0.12);
  --red: #E55353;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --border-card: rgba(255, 255, 255, 0.06);

  --shadow-xs: none;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.12);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.18);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.24);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg-page: #1B1B1B;
    --bg-card: #242424;
    --bg-subtle: #2A2A2A;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-overlay: rgba(255, 255, 255, 0.04);
    --text-primary: #ECECEC;
    --text-secondary: #9E9A95;
    --text-tertiary: #6B6560;
    --text-inverse: #1C1917;
    --accent: #E07D5E;
    --accent-hover: #EB8E73;
    --accent-soft: rgba(224, 125, 94, 0.12);
    --accent-glow: rgba(224, 125, 94, 0.2);
    --green: #3D8F52;
    --green-soft: rgba(61, 143, 82, 0.12);
    --red: #E55353;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --border-card: rgba(255, 255, 255, 0.06);
    --shadow-xs: none;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.12);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.18);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.24);
  }
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 420;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg-page);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; color: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-sm); }

/* ── Header ────────────────────────────────────────────────── */
.header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  max-width: 720px; margin: 0 auto; padding: 0 24px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-serif); font-size: 1.1rem; font-weight: 580;
  color: var(--text-primary); letter-spacing: -0.01em;
  transition: opacity var(--transition-fast);
}
.logo:hover { opacity: 0.75; }
.logo-text { font-size: 0.95rem; }

/* ── Header Buttons (Moci standard tool-btn pattern) ──────── */
.header-right { display: flex; align-items: center; gap: 8px; }

.tool-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-card);
  color: var(--text-secondary); cursor: pointer; font-family: var(--font-sans);
  font-size: 0.75rem; font-weight: 550; padding: 0; line-height: 1;
  box-shadow: var(--shadow-xs);
  transition: color var(--transition-fast), border-color var(--transition-fast),
              background-color var(--transition-fast), box-shadow var(--transition-fast);
}
.tool-btn:hover {
  color: var(--text-primary); border-color: var(--accent);
  background: var(--bg-subtle);
  box-shadow: var(--shadow-sm);
}
.tool-btn svg { width: 16px; height: 16px; }

.lang-btn { width: auto; padding: 0 10px; }

/* Theme icon switching */
[data-theme="dark"] .icon-sun, [data-theme="light"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .icon-sun { display: none; }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-moon { display: none; }
}

/* ── Main Layout ───────────────────────────────────────────── */
.main {
  flex: 1; max-width: 720px; width: 100%; margin: 0 auto; padding: 32px 24px 64px;
}

/* ── Tab Bar ───────────────────────────────────────────────── */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 32px;
  background: var(--bg-subtle); padding: 4px; border-radius: var(--radius-md);
  transition: background-color var(--transition-smooth);
}
.tab {
  flex: 1; padding: 8px 20px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500; color: var(--text-secondary);
  transition: background-color var(--transition-smooth), color var(--transition-smooth), box-shadow var(--transition-smooth);
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  background: var(--bg-card); color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* ── Tab Panels ────────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeSlideIn 0.35s ease; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Footer ────────────────────────────────────────────────── */
.footer {
  text-align: center; padding: 24px; color: var(--text-tertiary);
  font-size: 0.8rem; border-top: 1px solid var(--border);
}

/* ── Reduced Motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .main { padding: 24px 16px 48px; }
  .header-inner { padding: 0 16px; }
}


/* ── Upload Zone ───────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 52px 32px;
  text-align: center;
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color var(--transition-smooth), background-color var(--transition-smooth), box-shadow var(--transition-smooth);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: var(--shadow-glow);
}
.upload-zone.drag-over { background: var(--accent-glow); border-style: solid; }
.upload-icon {
  color: var(--text-tertiary); margin-bottom: 16px;
  transition: color var(--transition-smooth), transform var(--transition-smooth);
}
.upload-zone:hover .upload-icon { color: var(--accent); transform: translateY(-2px); }
.upload-title {
  font-family: var(--font-serif); font-size: 1.15rem; font-weight: 580;
  margin-bottom: 8px; color: var(--text-primary); letter-spacing: -0.01em;
}
.upload-hint { color: var(--text-tertiary); font-size: 0.82rem; max-width: 320px; margin: 0 auto; line-height: 1.6; }

/* ── Result Card ───────────────────────────────────────────── */
.result-card {
  margin-top: 32px; background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: var(--radius-xl); overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: fadeSlideIn 0.4s ease;
}
.result-card-inner { padding: 32px; }

.result-image-row {
  text-align: center; margin-bottom: 24px;
}
.result-thumb {
  width: 200px; height: 200px; border-radius: var(--radius-lg);
  object-fit: cover;
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}
.result-verdict-row {
  display: flex; align-items: center; justify-content: center; gap: 16px;
  margin-bottom: 28px; padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.verdict-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 16px; border-radius: var(--radius-full);
  font-size: 0.82rem; font-weight: 550;
}
.verdict-safe {
  background: var(--green-soft); color: var(--green);
  border: 1px solid rgba(45, 122, 63, 0.15);
}
.verdict-nsfw {
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid rgba(204, 120, 92, 0.18);
}
.verdict-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.result-timing { font-size: 0.78rem; color: var(--text-tertiary); }

/* ── Bar Chart (CSS Grid for perfect alignment) ───────────── */
.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row {
  display: grid; grid-template-columns: 90px 1fr 48px;
  align-items: center; gap: 12px;
}
.bar-label {
  font-size: 0.82rem; font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap; text-align: center;
}
.bar-track {
  height: 6px; background: var(--bg-subtle);
  border-radius: var(--radius-full); overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: var(--radius-full);
  transition: width 0.55s cubic-bezier(0.22, 0.61, 0.36, 1);
  width: 0;
}
.bar-row .bar-fill { background: var(--accent); opacity: 0.4; }
.bar-row.highlight .bar-fill { background: var(--accent); opacity: 1; }
.bar-value {
  font-size: 0.78rem; color: var(--text-secondary);
  text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 500; white-space: nowrap;
}

/* ── Spinner ───────────────────────────────────────────────── */
.spinner-overlay { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 48px; }
.spinner {
  width: 28px; height: 28px; border: 2.5px solid var(--bg-subtle);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-text { color: var(--text-secondary); font-size: 0.88rem; }

/* ── Error State ───────────────────────────────────────────── */
.error-state {
  text-align: center; padding: 48px 24px; color: var(--text-secondary);
}
.error-state svg { margin-bottom: 14px; color: var(--text-tertiary); }

/* ── API Docs ──────────────────────────────────────────────── */
.docs-card {
  background: var(--bg-card); border: 1px solid var(--border-card);
  border-radius: var(--radius-lg); margin-bottom: 28px;
  overflow: hidden; box-shadow: var(--shadow-xs);
}
.docs-card-header {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.method-badge {
  display: inline-flex; padding: 4px 12px; border-radius: var(--radius-sm);
  font-size: 0.78rem; font-weight: 600; font-family: var(--font-mono);
  letter-spacing: 0.02em;
}
.method-post { background: var(--accent-soft); color: var(--accent); }
.method-get { background: var(--green-soft); color: var(--green); }
.endpoint-path {
  font-family: var(--font-mono); font-size: 0.9rem;
  color: var(--text-primary); font-weight: 500;
}
.docs-card-body { padding: 24px 28px 28px; }
.docs-card-body > p { color: var(--text-secondary); margin-bottom: 16px; font-size: 0.9rem; line-height: 1.7; }
.docs-card-body h4 {
  font-family: var(--font-serif); font-size: 1rem; font-weight: 580;
  margin: 22px 0 10px; color: var(--text-primary);
}
.docs-card-body h4:first-child { margin-top: 0; }
.docs-card-body ul {
  color: var(--text-secondary); font-size: 0.88rem;
  margin: 6px 0 14px 18px; line-height: 1.75;
}
.docs-card-body ul li { margin-bottom: 3px; }
.docs-card-body ul li code {
  font-family: var(--font-mono); font-size: 0.82rem;
  background: var(--bg-subtle); padding: 1px 6px; border-radius: 4px;
}
.docs-card-body p code {
  font-family: var(--font-mono); font-size: 0.82rem;
  background: var(--bg-subtle); padding: 1px 6px; border-radius: 4px;
}

/* ── Tables ────────────────────────────────────────────────── */
.docs-table {
  width: 100%; border-collapse: collapse; margin: 10px 0 16px;
  font-size: 0.86rem;
}
.docs-table th {
  text-align: left; font-weight: 550; color: var(--text-primary);
  padding: 8px 12px; border-bottom: 2px solid var(--border);
}
.docs-table td {
  padding: 8px 12px; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.docs-table td:first-child code {
  font-family: var(--font-mono); font-size: 0.8rem;
  background: var(--bg-subtle); padding: 1px 6px; border-radius: 4px;
}

/* ── Code Blocks ───────────────────────────────────────────── */
.code-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.code-tab {
  padding: 6px 16px; font-size: 0.78rem; font-weight: 500;
  color: var(--text-tertiary); border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-subtle);
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}
.code-tab:hover { color: var(--text-primary); border-color: var(--border-strong); }
.code-tab.active {
  color: var(--text-primary); background: var(--bg-card);
  border-color: var(--accent); box-shadow: var(--shadow-xs);
}

/* Warm dark code block (Claude-style) */
.code-block {
  background: #1E1B1A; border-radius: var(--radius-md);
  padding: 22px 24px; overflow-x: auto; position: relative;
  border: 1px solid var(--border);
}
[data-theme="dark"] .code-block { background: #161412; }
.code-block pre { margin: 0; }
.code-block code {
  font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.8;
  color: #D4C5B9; white-space: pre; tab-size: 2;
}

.copy-btn {
  margin-top: 8px; padding: 5px 14px; font-size: 0.74rem; font-weight: 500;
  color: var(--text-secondary); background: var(--bg-subtle);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  transition: color var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}
.copy-btn:hover { color: var(--text-primary); background: var(--bg-card); border-color: var(--border-strong); }
.copy-btn.copied { color: var(--green); border-color: var(--green); background: var(--green-soft); }

/* ── Health Badge ──────────────────────────────────────────── */
.health-badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 14px; border-radius: var(--radius-full);
  font-size: 0.82rem; font-weight: 500;
}
.health-ok { background: var(--green-soft); color: var(--green); }
.health-dot {
  width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  animation: pulse-dot 2s ease-in-out infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Response JSON Display ─────────────────────────────────── */
.json-display {
  background: #1E1B1A; border-radius: var(--radius-md);
  padding: 20px 24px; overflow-x: auto; margin-top: 4px;
}
[data-theme="dark"] .json-display { background: #161412; }
.json-display code {
  font-family: var(--font-mono); font-size: 0.78rem; line-height: 1.8; color: #D4C5B9;
}
.json-key { color: #C4A47A; }
.json-str { color: #A0B87C; }
.json-num { color: #D4956A; }
.json-bool { color: #CE9A6A; }
