/* ── AI Analyst — ChatGPT/Claude-style centered chat input ─────────── */
.ai-section.ai-chat-style {
  padding: 28px 24px 22px 24px;
  display: flex; flex-direction: column;
  /* Fill remaining vertical space in initial viewport
     viewport - header(60) - main padding(48) - meta-bar(~36) - charts(~250) - gaps(32) ≈ 100vh - 426px
     Greeting + input + templates ≈ 280px so we use the larger of the two */
  min-height: calc(100vh - 60px - 48px - 36px - 260px - 32px);
  justify-content: center;
}
/* Output area gets clear separation from the chips above */
.ai-section.ai-chat-style .ai-output {
  margin-top: 28px;
}
.ai-section.ai-chat-style .ai-output:empty { margin-top: 0; }
.ai-section.ai-chat-style #ai-thinking { margin-top: 22px; }
.ai-chat-greeting {
  text-align: center;
  padding: 8px 12px 18px 12px;
}
.ai-chat-icon {
  font-size: 32px; opacity: .85; margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(245,158,11,.35));
}
.ai-chat-title {
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.6px; color: var(--text);
  margin: 0;
}
.ai-chat-sub {
  font-size: 13px; color: var(--muted-hi);
  margin: 6px 0 0 0;
}

/* ChatGPT-style pill input */
.ai-chat-input-wrap {
  width: 100%;
  max-width: 760px;
  margin: 6px auto 0 auto;
}
.ai-chat-input-pill {
  display: flex; align-items: flex-end;
  gap: 8px;
  background: var(--glass-input);
  border: 1px solid var(--border-std);
  border-radius: 28px;
  padding: 8px 10px;
  box-shadow:
    inset 0 1px 0 var(--border-specular),
    0 4px 16px rgba(17,17,26,.05),
    0 1px 3px rgba(17,17,26,.05);
  transition:
    border-color .2s ease,
    background-color .2s ease,
    box-shadow .2s ease,
    transform .12s ease;
}
.ai-chat-input-pill:focus-within {
  border-color: var(--accent);
  background-color: var(--glass-hover);
  box-shadow:
    inset 0 1px 0 var(--border-specular),
    0 0 0 4px var(--accent-glow);
}
.ai-chat-plus {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-std);
  background: transparent;
  color: var(--text);
  font-size: 20px; font-weight: 300;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, transform .12s ease;
}
.ai-chat-plus:hover  { background: var(--glass-hover); }
.ai-chat-plus:active { transform: scale(.92); }
.ai-chat-textarea {
  flex: 1; min-width: 0;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  resize: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.45;
  padding: 8px 4px !important;
  max-height: 200px;
  overflow-y: auto;
}
.ai-chat-textarea::placeholder { color: var(--muted); }
.ai-chat-send {
  flex-shrink: 0;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--accent-btn);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.30),
    0 3px 10px rgba(245,158,11,.35);
  transition: transform .12s ease, box-shadow .15s ease;
}
.ai-chat-send:hover    { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 5px 16px rgba(245,158,11,.50); }
.ai-chat-send:active   { transform: scale(.94); }
.ai-chat-send:disabled { opacity: .4; cursor: not-allowed; }
.ai-chat-send-icon { display: inline-block; font-weight: 700; line-height: 1; transform: translateY(-1px); }

/* Quick template chips below input */
.ai-chat-quick-row {
  display: flex; flex-wrap: wrap; gap: 6px;
  justify-content: center;
  margin-top: 14px;
  max-width: 760px; margin-left: auto; margin-right: auto;
}
.ai-chat-quick-row.ai-tpl-hidden { display: none; }
.ai-chat-quick-row .ai-tpl-btn {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 16px;
  background: var(--glass-input);
  border: 1px solid var(--border-std);
  color: var(--text2);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .12s ease;
}
.ai-chat-quick-row .ai-tpl-btn:hover {
  background: var(--glass-hover);
  border-color: var(--accent);
  color: var(--text);
}
.ai-chat-quick-row .ai-tpl-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── Distribution pie panel (right sticky) — pie top, legend bottom ──── */
.distribution-card {
  padding: 18px 18px 16px;
  position: relative;
}
.distribution-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(245,158,11,0.4) 50%, transparent 100%);
  pointer-events: none;
}
/* New vertical layout: donut centered on top, rows below */
.dist-row-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.dist-pie-wrap {
  position: relative;
  width: 150px; height: 150px;
  flex: 0 0 150px;
}
.dist-pie-wrap canvas {
  max-width: 150px !important;
  max-height: 150px !important;
}
.dist-legend {
  width: 100%;
  display: flex; flex-direction: column; gap: 3px;
  font-size: 11.5px;
}
.dist-legend .dist-row {
  display: flex; align-items: center; gap: 7px;
  padding: 3px 6px; border-radius: 6px;
  transition: background .14s;
}
.dist-legend .dist-row:hover { background: var(--glass-input); }
.dist-legend .dist-dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 4px currentColor;
}
.dist-legend .dist-label {
  flex: 1; color: var(--text2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-weight: 500;
}
.dist-legend .dist-count {
  font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; min-width: 24px; text-align: right;
}
.dist-legend .dist-pct {
  color: var(--muted); font-size: 10.5px; min-width: 38px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Distribution card — center donut with total label overlay ───────── */
.dist-pie-center-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
}
.dist-pie-center-label .dist-total-num {
  font-size: 20px; font-weight: 800; color: var(--text);
  letter-spacing: -0.04em; line-height: 1;
}
.dist-pie-center-label .dist-total-lbl {
  font-size: 9px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; margin-top: 1px;
}

/* ── Card headers — larger titles with amber icon accent ─────────────── */
.chart-card-header {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 16px;
}
.chart-card .chart-title,
.efficiency-card .eff-title {
  font-size: 14px; font-weight: 700; letter-spacing: -0.3px; color: var(--text);
}
.card-header-icon {
  font-size: 17px; line-height: 1;
  filter: drop-shadow(0 1px 5px rgba(245,158,11,.5));
  flex-shrink: 0;
}
.card-header-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}

/* ── Smooth card entrance animation ─────────────────────────────────── */
@keyframes cardFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
#page-single.active .single-left > *,
#page-single.active .single-right > * {
  animation: cardFadeUp .35s cubic-bezier(.22,1,.36,1) both;
}
#page-single.active .single-left > *:nth-child(1) { animation-delay: .04s; }
#page-single.active .single-left > *:nth-child(2) { animation-delay: .09s; }
#page-single.active .single-left > *:nth-child(3) { animation-delay: .14s; }
#page-single.active .single-left > *:nth-child(4) { animation-delay: .18s; }
#page-single.active .single-right > *:nth-child(1) { animation-delay: .07s; }
#page-single.active .single-right > *:nth-child(2) { animation-delay: .12s; }

/* ── Empty state polish ──────────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px;
  padding: 32px 20px; text-align: center;
  color: var(--muted);
}
.empty-state-icon { font-size: 32px; opacity: .45; }
.empty-state-text { font-size: 13px; font-weight: 500; }
.empty-state-sub  { font-size: 11.5px; color: var(--muted); }

/* ── Meta bar — single page info strip ───────────────────────────────── */
#page-single .meta-bar {
  padding: 2px 0 4px;
}

/* ── Ensure single-right cards fill width properly ───────────────────── */
.single-right .efficiency-card,
.single-right .distribution-card {
  width: 100%;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Single Page — Final Polish Layer
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

/* Page wrapper — breathing room */
#page-single #single-content {
  padding: 8px 0 32px;
}

/* ── Meta strip — clean project/date info ────────────────────────────── */
#page-single .meta-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 22px;
  padding: 14px 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  backdrop-filter: blur(12px);
}
#page-single .meta-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 9px;
  padding: 6px 13px;
  font-size: 12.5px;
  color: rgba(255,255,255,0.55);
  white-space: nowrap;
}
#page-single .meta-pill span {
  color: rgba(255,255,255,0.90);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: -.15px;
}

/* ── Chart card — header fixed to flex space-between ─────────────────── */
#page-single .chart-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 12px;
  margin-bottom: 0;
}
#page-single .chart-title { font-size: 14px; font-weight: 700; letter-spacing: -.3px; }
#page-single .chart-subtitle { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ── Chart canvas — proper breathing room ────────────────────────────── */
#page-single .chart-wrap-compact {
  padding: 0 16px 20px;
  min-height: 210px;
}
#page-single .chart-wrap-compact canvas {
  min-height: 200px !important;
  max-height: 240px !important;
}

/* ── Chart card — ambient top glow ──────────────────────────────────── */
#page-single .chart-card {
  position: relative;
  overflow: hidden;
}
#page-single .chart-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 5%, rgba(245,158,11,0.25) 50%, transparent 95%);
  z-index: 1;
}

/* ── Efficiency card — spacing ───────────────────────────────────────── */
.efficiency-card {
  padding: 22px 22px;
}
.efficiency-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(245,158,11,0.50), transparent);
  pointer-events: none;
}
.efficiency-card { position: relative; }

/* KPI chips grid */
.eff-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}
.eff-kpi {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.eff-kpi-val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1;
}
.eff-kpi-lbl {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Distribution card — tighter ─────────────────────────────────────── */
.distribution-card {
  padding: 20px 20px 18px;
}
.distribution-card .chart-card-header {
  padding: 0 0 14px !important;
}

/* ── Metrika card — polished header ──────────────────────────────────── */
.metrika-card { position: relative; }
.metrika-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent 5%, rgba(245,158,11,0.20) 50%, transparent 95%);
}

/* ── KW table card ───────────────────────────────────────────────────── */
.ca-kw-table-card {
  border-radius: var(--r-lg);
  overflow: hidden;
}
.ca-table-controls {
  padding: 16px 20px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ca-kw-table th {
  background: rgba(8,5,2,0.88);
  backdrop-filter: blur(20px);
  padding: 11px 14px;
  font-size: 10px;
  letter-spacing: .7px;
}
.ca-kw-table td { padding: 9px 14px; }

/* ── Reset zoom button style ─────────────────────────────────────────── */
#page-single .btn-ghost.btn-sm {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 7px;
  opacity: 0.7;
  transition: opacity .15s;
}
#page-single .btn-ghost.btn-sm:hover { opacity: 1; }

/* ── Right column wider on large screens ────────────────────────────── */
@media (min-width: 1280px) {
  .single-layout { grid-template-columns: 1fr 360px; gap: 22px; }
}
@media (min-width: 1600px) {
  .single-layout { grid-template-columns: 1fr 420px; gap: 24px; }
}

/* Light theme adjustments */
[data-theme="light"] #page-single .meta-bar {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.07);
}
[data-theme="light"] #page-single .meta-pill {
  background: rgba(0,0,0,0.04);
  border-color: rgba(0,0,0,0.08);
  color: rgba(0,0,0,0.55);
}
[data-theme="light"] #page-single .meta-pill span { color: rgba(0,0,0,0.85); }
[data-theme="light"] .eff-kpi {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.07);
}

/* ── Webmaster & Metrika cards spacing ──────────────────────────────── */
#metrika-card,
#webmaster-card {
  margin-top: 0;
}

/* ── Right column card title sizing ─────────────────────────────────── */
.distribution-card .chart-card-header {
  margin-bottom: 14px;
}
.distribution-card .chart-title {
  font-size: 13.5px; font-weight: 700; letter-spacing: -0.25px;
}

/* ── Keyword history table (rows=keywords × cols=dates) ─────────────── */
.kw-history-card { padding: 16px 18px; }
.kwh-table-wrap {
  margin-top: 8px;
  overflow-x: auto; overflow-y: auto;
  max-height: 580px;
  border: 1px solid var(--border-dim);
  border-radius: 12px;
}
.kwh-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 11px;
  table-layout: fixed;
}
.kwh-table thead th {
  background: var(--glass-dark);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  position: sticky; top: 0; z-index: 3;
  padding: 5px 2px; font-size: 9.5px; font-weight: 600;
  letter-spacing: -.05px; text-transform: none;
  color: var(--text2); text-align: center;
  border-bottom: 1px solid var(--border-std);
  white-space: nowrap;
}
.kwh-table thead th.kwh-col-kw,
.kwh-table thead th.kwh-col-freq,
.kwh-table tbody td.kwh-cell-kw,
.kwh-table tbody td.kwh-cell-freq {
  position: sticky; left: 0; z-index: 2;
  background: var(--bg);
}
.kwh-table thead th.kwh-col-kw   { text-align: left;  text-transform: uppercase; font-size: 9.5px; letter-spacing: .5px; color: var(--muted); width: 150px; }
.kwh-table thead th.kwh-col-freq { text-align: right; text-transform: uppercase; font-size: 9.5px; letter-spacing: .5px; color: var(--muted); left: 150px; width: 50px; }
.kwh-table tbody td.kwh-cell-freq { left: 150px; text-align: right; }
.kwh-table thead th.kwh-col-kw   { z-index: 4; }
.kwh-table thead th.kwh-col-freq { z-index: 4; }
.kwh-table thead th.kwh-col-data { width: 38px; min-width: 38px; }
.kwh-table tbody td {
  padding: 2px 1px;
  border-bottom: 1px solid var(--border-dim);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.kwh-table tbody td.kwh-cell-kw {
  padding: 4px 8px;
  font-weight: 500; color: var(--text); text-align: left;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 11.5px;
}
.kwh-table tbody td.kwh-cell-freq { padding: 4px 8px; font-weight: 600; color: var(--text2); font-size: 11px; }
.kwh-table tbody tr:hover td { background: rgba(255,255,255,.03); }
.kwh-table tbody tr:hover td.kwh-cell-kw,
.kwh-table tbody tr:hover td.kwh-cell-freq { background: rgba(255,255,255,.05); }
/* Tighter pos pills for the dense kwh table — must fit ~15 visible columns */
.kwh-table tbody td .bm-pos {
  font-size: 12.5px; font-weight: 700;
  padding: 1px 3px; border-radius: 5px;
  min-width: 24px; line-height: 1.25;
  letter-spacing: -0.4px;
}
.kwh-table tbody td .bm-pos.bm-pos-none { font-size: 11px; font-weight: 400; }
[data-theme="light"] .kwh-table thead th { background: rgba(255,255,255,.85); }
[data-theme="light"] .kwh-table thead th.kwh-col-kw,
[data-theme="light"] .kwh-table thead th.kwh-col-freq,
[data-theme="light"] .kwh-table tbody td.kwh-cell-kw,
[data-theme="light"] .kwh-table tbody td.kwh-cell-freq { background: var(--bg); }
[data-theme="light"] .kwh-table tbody tr:hover td { background: rgba(0,0,0,.025); }

/* On wider viewports, keep right column same width but make sure efficiency + distribution
   both fit in viewport when sticky */
.single-right > * { flex-shrink: 0; }

