:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --border: #e2e8f0;
  --surface: #f1f5f9;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-secondary: #334155;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #ffffff;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --input-focus: #2563eb;
  --badge-bg: #f1f5f9;
  --badge-text: #334155;
  --code-bg: #f8fafc;
  --code-border: #e2e8f0;
  --switch-active: #2563eb;
  --switch-active-text: #ffffff;
  --tab-bg: #f1f5f9;
  --tab-active-bg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090d16;
    --card-bg: #0f172a;
    --card-border: #1e293b;
    --border: #1e293b;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --text-secondary: #cbd5e1;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-text: #ffffff;
    --input-bg: #090d16;
    --input-border: #334155;
    --input-focus: #3b82f6;
    --badge-bg: #1e293b;
    --badge-text: #f1f5f9;
    --code-bg: #0d121f;
    --code-border: #1e293b;
    --switch-active: #3b82f6;
    --switch-active-text: #ffffff;
    --tab-bg: #1e293b;
    --tab-active-bg: #0f172a;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2.5rem 1.25rem 3.5rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Layout Containers */
.main-wrapper {
  width: 100%;
  max-width: 580px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto 0;
  transition: max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-wrapper.has-result,
.main-wrapper.preview-mode {
  max-width: min(1060px, 94vw) !important;
}

/* Keep top input forms, hero, options, and status box at 580px max-width */
.main-wrapper > :not(.result-card) {
  width: 100%;
  max-width: 580px;
}

.container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

/* Header & Nav */
.hero {
  text-align: center;
  margin-bottom: 2.25rem;
}

.hero-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 0.85rem;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

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

.hero h1 {
  font-size: clamp(2rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin-bottom: 0.65rem;
  color: var(--text);
}

.hero h1 b {
  font-weight: 800;
}

.hero p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
  max-width: 480px;
  margin: 0 auto;
}

.format-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 1rem;
}

.format-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 9999px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  user-select: none;
}

.format-badge:hover {
  border-color: var(--primary);
  color: var(--text);
  background: var(--card-bg);
}

.format-badge svg {
  width: 12px;
  height: 12px;
  color: var(--primary);
}

.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 12px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  transition: color 0.2s;
}

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

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Navigation Tabs */
.tabs-nav {
  display: inline-flex;
  background: var(--tab-bg);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--card-border);
  width: 100%;
}

.tab-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}

.tab-btn.active {
  background: var(--tab-active-bg);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.tab-btn svg {
  width: 14px;
  height: 14px;
}

.tab-content {
  display: none;
  width: 100%;
}

.tab-content.active {
  display: block;
}

/* Inputs & Form Elements */
.input-bar {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-bottom: 1.25rem;
}

.text-input {
  flex: 1;
  height: 50px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 1px var(--input-focus);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--card-bg);
  border-color: var(--primary);
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  height: 50px;
  padding: 0 22px;
  background: var(--primary);
  color: var(--primary-text);
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(37, 99, 235, 0.15);
  transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(37, 99, 235, 0.25);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.99);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  height: 30px;
  padding: 0 10px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  font-family: inherit;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--input-focus);
}

.btn-secondary.active {
  background: var(--surface);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Dropzone */
.dropzone {
  border: 1.5px dashed var(--card-border);
  background: var(--code-bg);
  border-radius: 8px;
  padding: 2.2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  margin-bottom: 1.25rem;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--input-focus);
  background: var(--input-bg);
}

.dropzone svg {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.dropzone-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

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

/* Raw Textarea */
.raw-textarea {
  width: 100%;
  height: 140px;
  padding: 12px;
  border-radius: 6px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  outline: none;
  resize: vertical;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.raw-textarea:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 1px var(--input-focus);
}

/* Card & Options */
.card {
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--card-bg);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.5rem;
}

.card-header {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
}

.option-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.tooltip-container {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tooltip-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--card-border);
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.tooltip-badge:hover, .tooltip-badge:focus {
  background: var(--card-border);
  border-color: var(--primary);
}

.tooltip-content {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 260px;
  padding: 8px 12px;
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.78rem;
  line-height: 1.45;
  font-weight: 400;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
  z-index: 50;
  text-align: left;
}

.tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #0f172a;
}

.tooltip-container:hover .tooltip-content,
.tooltip-container.open .tooltip-content {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-2px);
}

.checkbox-custom {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--card-border);
  border-radius: 4px;
  background: var(--input-bg);
  cursor: pointer;
  position: relative;
  outline: none;
  transition: all 0.15s ease;
}

.checkbox-custom:checked {
  background: var(--switch-active);
  border-color: var(--switch-active);
}

.checkbox-custom:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid var(--switch-active-text);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.select-custom {
  height: 30px;
  padding: 0 8px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.select-custom:focus {
  border-color: var(--input-focus);
}

/* Status Message */
.status-box {
  width: 100%;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.88rem;
  margin-bottom: 1.25rem;
  display: none;
  align-items: center;
  gap: 10px;
}

.status-box.loading {
  display: flex;
  background: var(--code-bg);
  border: 1px solid var(--card-border);
  color: var(--text);
}

.status-box.error {
  display: flex;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
}

.status-box.success {
  display: flex;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #10b981;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--card-border);
  border-top-color: var(--input-focus);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Result Section */
.result-card {
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: var(--card-bg);
  overflow: hidden;
  margin-bottom: 1.5rem;
  display: none;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 8px 12px;
  background: var(--code-bg);
  border-bottom: 1px solid var(--card-border);
  gap: 8px;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.share-box {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--code-bg);
  border-bottom: 1px solid var(--card-border);
}

.share-link-input {
  flex: 1;
  height: 32px;
  padding: 0 10px;
  border-radius: 4px;
  border: 1px solid var(--input-border);
  background: var(--input-bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  outline: none;
}

.result-textarea {
  width: 100%;
  height: 480px;
  padding: 16px 18px;
  border: none;
  outline: none;
  background: var(--input-bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  white-space: pre-wrap;
}

.preview-box {
  display: none;
  width: 100%;
  min-height: 650px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 2.75rem 3.25rem;
  background: var(--card-bg);
  color: var(--text);
  box-sizing: border-box;
  word-break: break-word;
  resize: vertical;
}

.preview-box > :first-child {
  margin-top: 0;
}

/* API Documentation Cards */
.api-card {
  margin-bottom: 1rem;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  background: var(--card-bg);
  overflow: hidden;
}

.api-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--code-bg);
  border-bottom: 1px solid var(--card-border);
  font-size: 0.84rem;
  font-family: 'JetBrains Mono', monospace;
}

.method-badge {
  font-weight: 700;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.badge-get {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.badge-post {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.api-code {
  padding: 12px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  background: var(--code-bg);
  overflow-x: auto;
  color: var(--text);
}

/* Shared Article & Note Styles */
.article-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
}

.article-header {
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 1.25rem;
}

.article-title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 0.75rem;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-wrap: wrap;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.meta-item svg {
  width: 14px;
  height: 14px;
}

/* Markdown Render Content Styling */
.content {
  line-height: 1.75;
  font-size: 1.05rem;
}

.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  font-weight: 700;
  line-height: 1.3;
}

.content h1 { font-size: 1.8rem; border-bottom: 1px solid var(--card-border); padding-bottom: 0.5rem; }
.content h2 { font-size: 1.5rem; }
.content h3 { font-size: 1.25rem; }

.content p {
  margin-bottom: 1.25rem;
}

.content ul, .content ol {
  margin-bottom: 1.25rem;
  padding-left: 1.75rem;
}

.content li {
  margin-bottom: 0.4rem;
}

.content a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.content blockquote {
  border-left: 4px solid var(--primary);
  padding: 0.6rem 1rem;
  margin: 1.25rem 0;
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
}

.content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--code-bg);
  border-radius: 4px;
  border: 1px solid var(--card-border);
}

.content pre {
  background: var(--code-bg);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1.25rem 0;
}

.content pre code {
  padding: 0;
  border: none;
  background: transparent;
  font-size: 0.92rem;
  line-height: 1.6;
}

.content img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem auto;
  display: block;
}

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
}

.content th, .content td {
  border: 1px solid var(--card-border);
  padding: 10px 14px;
  text-align: left;
}

.content th {
  background: var(--surface);
  font-weight: 600;
}

.content hr {
  border: 0;
  height: 1px;
  background: var(--card-border);
  margin: 2rem 0;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #fff;
  padding: 10px 20px;
  border-radius: 9999px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Footer */
footer {
  margin-top: 2.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

footer a {
  color: var(--text-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

footer a:hover {
  color: var(--text);
}

/* Responsive */
@media (max-width: 540px) {
  .tabs-nav {
    flex-direction: column;
  }
  .input-bar {
    flex-direction: column;
    gap: 10px;
  }
  .text-input {
    width: 100%;
    height: 50px;
    font-size: 16px;
  }
  .btn-primary {
    width: 100%;
    height: 50px;
  }
  .article-card {
    padding: 1.5rem;
  }
  .preview-box {
    padding: 1.5rem 1.25rem;
    min-height: 380px;
  }
}
