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

:root {
  --bg-primary:       #0d1117;
  --bg-secondary:     #161b22;
  --bg-card:          #1c2230;
  --bg-input:         #0d1117;
  --border-color:     #30363d;
  --text-primary:     #e6edf3;
  --text-secondary:   #8b949e;
  --text-muted:       #6e7681;
  --accent-blue:      #1a9fd4;
  --accent-blue-hover:#1589b8;
  --accent-link:      #58a6ff;
  --error-bg:         #2d1b1b;
  --error-text:       #f85149;
  --success:          #3fb950;
  --warn:             #d29922;
  --font-body:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Header ─────────────────────────────── */

.site-header {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.logo-icon { width: 44px; height: 44px; flex-shrink: 0; }
.logo-icon svg { width: 100%; height: 100%; }

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.menu-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 2px;
  transition: background-color 0.2s;
}

.menu-toggle:hover span { background-color: var(--accent-blue); }

/* ─── Main ───────────────────────────────── */

.site-main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 48px 20px 64px;
  position: relative;
}

/* ─── Hero ───────────────────────────────── */

.tool-hero { margin-bottom: 40px; }

.tool-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.2;
}

.tool-description {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 680px;
  line-height: 1.7;
}

/* ─── Input Card ─────────────────────────── */

.tool-input-section { margin-bottom: 24px; }

.input-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 28px 28px 24px;
}

.input-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.keyword-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: var(--font-body);
  padding: 11px 16px;
  outline: none;
  transition: border-color 0.2s;
}

.keyword-input::placeholder { color: var(--text-muted); }
.keyword-input:focus         { border-color: var(--accent-blue); }

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font-body);
  padding: 11px 24px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover    { background: var(--accent-blue-hover); }
.btn-primary:active   { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9375rem;
  font-family: var(--font-body);
  font-weight: 500;
  padding: 11px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}

.btn-secondary:hover { color: var(--text-primary); border-color: var(--accent-blue); }

.input-options {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.select-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.select-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.tool-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: var(--font-body);
  padding: 7px 28px 7px 10px;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238b949e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color 0.2s;
}

.tool-select:focus { border-color: var(--accent-blue); }

.input-hint {
  margin-top: 12px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ─── Error ──────────────────────────────── */

.error-banner {
  background: var(--error-bg);
  border: 1px solid var(--error-text);
  border-radius: 6px;
  padding: 12px 18px;
  color: var(--error-text);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

/* ─── Results Tabs ───────────────────────── */

.results-section { margin-top: 8px; }

.results-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-family: var(--font-body);
  font-weight: 500;
  padding: 10px 18px;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--accent-blue);
  border-bottom-color: var(--accent-blue);
}

.tab-panel         { display: none; }
.tab-panel.active  { display: block; }

/* ─── Panel Cards ────────────────────────── */

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 22px 24px;
  margin-bottom: 16px;
}

.panel-card-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ─── Overview Grid ──────────────────────── */

.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.full-width { grid-column: 1 / -1; }

/* ─── Intent Badge ───────────────────────── */

.intent-badge-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.intent-badge {
  font-size: 1rem;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 20px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.intent-informational  { background: #0d2d3f; color: #1a9fd4; border: 1px solid #1a9fd455; }
.intent-commercial     { background: #2d220d; color: #d29922; border: 1px solid #d2992255; }
.intent-transactional  { background: #0d2d1a; color: #3fb950; border: 1px solid #3fb95055; }
.intent-navigational   { background: #2a1f3d; color: #a78bfa; border: 1px solid #a78bfa55; }
.intent-mixed          { background: #1e1e2e; color: #8b949e; border: 1px solid #30363d; }

.confidence-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.confidence-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.confidence-track {
  width: 80px;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.confidence-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--accent-blue);
  transition: width 0.5s ease;
  width: 0;
}

.confidence-val {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 32px;
}

.panel-meta {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ─── SERP Features ──────────────────────── */

.features-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feature-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
}

.feature-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.feature-dot.yes { background: var(--success); }
.feature-dot.no  { background: var(--border-color); }

.feature-name { color: var(--text-secondary); flex: 1; }

.feature-status-yes { color: var(--success);      font-size: 0.75rem; font-weight: 600; }
.feature-status-no  { color: var(--text-muted);   font-size: 0.75rem; }

/* ─── Composition ────────────────────────── */

.composition-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comp-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.comp-label {
  width: 160px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.comp-bar-track {
  flex: 1;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  min-width: 80px;
}

.comp-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent-blue);
  transition: width 0.4s ease;
}

.comp-bar-fill.type-blog        { background: #1a9fd4; }
.comp-bar-fill.type-ecommerce   { background: #3fb950; }
.comp-bar-fill.type-video       { background: #e05252; }
.comp-bar-fill.type-local       { background: #d29922; }
.comp-bar-fill.type-forum       { background: #a78bfa; }
.comp-bar-fill.type-tool        { background: #38bdf8; }
.comp-bar-fill.type-other       { background: #6e7681; }

.comp-pct {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.comp-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  width: 32px;
  flex-shrink: 0;
}

/* ─── Results List ───────────────────────── */

.result-item {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-color);
  align-items: flex-start;
}

.result-item:last-child { border-bottom: none; }

.result-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
  margin-top: 2px;
}

.result-body { flex: 1; min-width: 0; }

.result-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent-link);
  text-decoration: none;
  line-height: 1.4;
  display: block;
  word-break: break-word;
}

.result-title:hover { text-decoration: underline; }

.result-domain {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.result-type-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-top: 6px;
  display: inline-block;
  text-transform: capitalize;
}

.type-blog      { background: #0d2d3f; color: #1a9fd4; }
.type-ecommerce { background: #0d2d1a; color: #3fb950; }
.type-video     { background: #2d1010; color: #e05252; }
.type-local     { background: #2d220d; color: #d29922; }
.type-forum     { background: #2a1f3d; color: #a78bfa; }
.type-tool      { background: #0d1f2d; color: #38bdf8; }
.type-other     { background: #1e1e2e; color: #8b949e; }

/* ─── Guidance ───────────────────────────── */

.guidance-section { margin-bottom: 22px; }

.guidance-section-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.guidance-format-badge {
  display: inline-block;
  background: var(--bg-secondary);
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 8px;
}

.guidance-note {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.guidance-wc {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.guidance-wc strong { color: var(--text-primary); }

.outline-list {
  list-style: none;
  margin-top: 8px;
}

.outline-list li {
  font-size: 0.875rem;
  color: var(--text-secondary);
  padding: 5px 0;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.outline-list li:last-child { border-bottom: none; }

.outline-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 1px 6px;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ─── Export Row ─────────────────────────── */

.export-row {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: var(--font-body);
  font-weight: 500;
  padding: 10px 20px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn-export svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-export:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: var(--bg-secondary);
}

/* ─── Loading ────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 17, 23, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  backdrop-filter: blur(4px);
  pointer-events: all;
}

.loading-overlay.hidden {
  pointer-events: none;
}

.loading-inner { text-align: center; }

.loader-ring {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 0 auto 16px;
}

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

.loading-text {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* ─── FAQ ────────────────────────────────── */

.faq-section {
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--border-color);
}

.faq-heading {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 24px;
}

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 7px;
  overflow: hidden;
}

.faq-q {
  display: block;
  padding: 14px 18px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s;
}

.faq-q::-webkit-details-marker { display: none; }

.faq-q::after {
  content: '+';
  float: right;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
}

.faq-item[open] .faq-q { background: var(--bg-secondary); }
.faq-item[open] .faq-q::after { content: '−'; }

.faq-a {
  padding: 0 18px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.faq-a code {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.8125rem;
  color: var(--text-primary);
}

/* ─── Ad Slots ───────────────────────────── */

.ad-slot {
  width: 100%;
  overflow: hidden;
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.ad-slot > * {
  pointer-events: auto;
}

.ad-slot-top {
  margin: 0 0 24px;
  min-height: 270px;
}

.ad-slot-bottom {
  margin: 24px 0 0;
  min-height: 100px;
}

.ad-slot:empty  { display: none; min-height: 0; }

/* ─── Focus Visible ──────────────────────── */

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-export:focus-visible,
.tab-btn:focus-visible,
.tool-select:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ─── Utility ────────────────────────────── */

.hidden { display: none !important; }

/* ─── Footer ─────────────────────────────── */

.site-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 48px 20px 40px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 48px;
}

.footer-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.footer-desc {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 400px;
}

.footer-links-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.footer-links ul { list-style: none; }

.footer-links li { margin-bottom: 12px; }

.footer-links a {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
}

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

.footer-link-accent { color: var(--accent-link) !important; }

.footer-bottom {
  border-top: 1px solid var(--border-color);
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 20px;
}

.footer-bottom p {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.heart { color: #e05252; }

.footer-dev-link { color: var(--accent-link); text-decoration: none; }
.footer-dev-link:hover { text-decoration: underline; }

/* ─── Responsive ─────────────────────────── */

@media (max-width: 700px) {
  .tool-title { font-size: 1.5rem; }

  .input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-primary,
  .btn-secondary { width: 100%; justify-content: center; }

  .input-options { flex-direction: column; gap: 12px; }

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

  .comp-label { width: 120px; }

  .footer-inner { grid-template-columns: 1fr; gap: 32px; }

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

  .btn-export { justify-content: center; }
}
