:root {
  --ink: #152035;
  --ink-soft: #5f6b82;
  --line: #d6deeb;
  --surface: #ffffff;
  --surface-alt: #f3f6fb;
  --brand: #0e63e6;
  --brand-2: #08a37a;
  --brand-soft: rgba(14, 99, 230, 0.12);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 700px at 95% -15%, rgba(14, 99, 230, 0.10), transparent 62%),
    radial-gradient(900px 500px at -5% 0%, rgba(8, 163, 122, 0.10), transparent 55%),
    #f7f9fd;
}

main { flex: 1; }

h1, h2, h3, h4, h5, h6 {
  font-family: "Fraunces", serif;
  letter-spacing: -0.01em;
  color: #0f1b32;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: #0b4fb9; }

.site-topbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-color: var(--line) !important;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  color: var(--ink);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff;
  font-weight: 700;
}

.top-link {
  color: var(--ink-soft);
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 10px;
}

.top-link.active,
.top-link:hover {
  color: var(--ink);
  background: #eef3fc;
}

.site-footer {
  background: #fff;
  border-color: var(--line) !important;
}

.card,
.modal-content,
.dropdown-menu,
.accordion-item,
.list-group-item {
  border-color: var(--line) !important;
  background: var(--surface) !important;
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(23, 42, 79, 0.04);
}

.accordion-button {
  background: #fff !important;
  color: var(--ink) !important;
}

.form-control,
.form-select {
  background: #fff !important;
  color: var(--ink) !important;
  border-color: #ccd6e6 !important;
}

.form-control::placeholder { color: #8090ad; }

.btn-primary {
  background: linear-gradient(120deg, var(--brand) 0%, #2f7fff 100%);
  border-color: transparent;
}

.btn-primary:hover { background: #0d58cc; }

.btn-outline-secondary {
  border-color: #c8d3e6;
  color: #2e3e5f;
}

.hero-section {
  background: linear-gradient(180deg, rgba(14, 99, 230, 0.07) 0%, rgba(14, 99, 230, 0) 100%);
}

.border-muted { border-color: var(--line) !important; }
.text-muted { color: var(--ink-soft) !important; }
.bg-white { background-color: #fff !important; }
.text-body { color: var(--ink) !important; }

/* Compatibility: .bg-dark used in API docs code blocks — keep dark for code */
.bg-dark { background: #1e293b !important; color: #e2e8f0 !important; }
.bg-dark pre, .bg-dark code { color: #e2e8f0; }
.text-light, .text-white { color: var(--ink) !important; }
.border-secondary { border-color: var(--line) !important; }
.text-secondary { color: var(--ink-soft) !important; }

/* Old components still referenced by tool templates */
.audio-waveform {
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(90deg, #dfe7f3 0%, #f0f4fb 25%, #dfe7f3 50%, #f0f4fb 75%, #dfe7f3 100%);
  background-size: 220% 100%;
}

.audio-waveform.loading { animation: wave 1.4s linear infinite; }
@keyframes wave { 0% { background-position: 220% 0; } 100% { background-position: -220% 0; } }

.file-upload-area {
  border: 2px dashed #c8d4e8 !important;
  border-radius: 14px !important;
  transition: all .2s ease;
}

.file-upload-area:hover,
.file-upload-area.drag-over {
  border-color: var(--brand) !important;
  background: #f4f8ff !important;
}

.file-upload-area .upload-preview { min-height: 56px; }

/* ── Audio Player ── */
.audio-player-wrap .card { box-shadow: none; }

.audio-play-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
}

.audio-download-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
}

/* ── Voice Chat ── */
.chat-message { max-width: 80%; }

.chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  line-height: 1.5;
}

.chat-bubble.user {
  background: var(--brand);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  background: var(--surface-alt);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.voice-chat-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.voice-chat-status.bg-success { animation: pulse-dot 1.5s ease-in-out infinite; }

.voice-chat-typing .bi-three-dots { animation: typing-fade 1.2s ease-in-out infinite; }

@keyframes typing-fade {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ── Voice Recorder ── */
#waveform-canvas {
  border-radius: 12px;
  background: var(--surface-alt);
}

.recording-indicator {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #dc3545;
}

.recording .recording-indicator { animation: pulse-dot 1s ease-in-out infinite; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

/* ── API Docs ── */
.api-docs-sidebar {
  position: sticky;
  top: 80px;
}

.api-docs-sidebar .nav-link {
  color: var(--ink-soft);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  border-left: 2px solid transparent;
}

.api-docs-sidebar .nav-link:hover {
  color: var(--ink);
  background: var(--surface-alt);
}

.api-docs-sidebar .nav-link.active {
  color: var(--brand);
  background: var(--brand-soft);
  border-left-color: var(--brand);
  font-weight: 600;
}

.api-docs-section { scroll-margin-top: 80px; }

.api-code-block {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.api-code-block .code-header {
  background: var(--surface-alt);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.api-code-tabs .nav-link {
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--ink-soft);
  border-radius: 6px;
  cursor: pointer;
}

.api-code-tabs .nav-link.active {
  background: var(--brand);
  color: #fff;
}

.api-code-tabs .nav-link:hover:not(.active) {
  background: #e2e8f0;
}

.code-pane pre {
  margin: 0;
  padding: 16px;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.82rem;
  line-height: 1.6;
  overflow-x: auto;
  border-radius: 0;
}

.code-pane pre code {
  color: inherit;
  background: transparent;
}

.code-copy-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}

.code-copy-btn:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand);
}

.code-copy-btn.copied {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

.api-try-it {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  background: var(--surface-alt);
}

.try-it-response pre {
  font-size: 0.8rem;
  line-height: 1.5;
}

/* ── Character Counter ── */
.char-counter { font-size: 0.8rem; color: var(--ink-soft); }
.char-counter.near-limit { color: #e67e22; }
.char-counter.at-limit { color: #dc3545; font-weight: 600; }

/* ── Offcanvas mobile nav ── */
.offcanvas {
  background: var(--surface) !important;
  border-color: var(--line) !important;
}

.offcanvas .nav-link {
  color: var(--ink);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.offcanvas .nav-link:hover { color: var(--brand); }

/* ── Mobile Responsive ── */
@media (max-width: 991.98px) {
  .api-docs-sidebar {
    position: static;
    margin-bottom: 1.5rem;
  }

  .api-docs-sidebar .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }

  .api-docs-sidebar .nav-link {
    border-left: none;
    padding: 4px 10px;
    font-size: 0.8rem;
  }

  h1.display-5 { font-size: 1.75rem; }
  h1.display-6 { font-size: 1.5rem; }
}

@media (max-width: 767.98px) {
  .hero-section { padding: 2rem 0 !important; }

  .api-code-tabs .nav-link {
    padding: 3px 6px;
    font-size: 0.72rem;
  }

  .code-pane pre {
    font-size: 0.75rem;
    padding: 12px;
  }

  #voice-chat { height: 400px !important; }
}
