:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --soft: #f1f5f9;
  --line: #e2e8f0;
  --green: #10b981;
  --green-soft: #ecfdf5;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --red: #b83b32;
  --gold: #b7791f;
  --gold-soft: #fffbeb;
  --shadow: 0 14px 36px rgba(15, 23, 42, .08);
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.topbar {
  height: 66px;
  display: grid;
  grid-template-columns: 320px 1fr auto;
  gap: 18px;
  align-items: center;
  padding: 0 22px;
  background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
}
.product-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: -.02em;
}
.logo-dot {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  font-weight: 900;
}
.workflow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.workflow span {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--soft);
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.app {
  min-height: calc(100vh - 66px);
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
}
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow-y: auto;
  max-height: calc(100vh - 66px);
}
.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.brand h1 { font-size: 18px; letter-spacing: 0; }
.status-pill {
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill.ready {
  color: var(--green);
  border-color: #94d5bd;
  background: var(--green-soft);
}
.key-status-btn {
  background: var(--gold-soft);
  color: var(--gold);
}
.key-status-btn.ready {
  color: var(--green);
  border-color: #94d5bd;
  background: var(--green-soft);
}
.section-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 18px 0 8px;
}
.field { margin-bottom: 12px; }
.label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 6px;
}
.hint {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  margin-top: 5px;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfaf7;
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 10px;
  outline: none;
  font-size: 13px;
}
textarea { resize: vertical; min-height: 78px; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  border-color: var(--blue);
  background: #fff;
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 13px;
}
.check input { width: 15px; height: 15px; }
.btn {
  width: 100%;
  border: 1px solid transparent;
  background: linear-gradient(135deg, #0f172a, #2563eb);
  color: #fff;
  border-radius: 10px;
  padding: 11px 12px;
  font-weight: 800;
  font-size: 13px;
  transition: all .18s ease;
}
.btn.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn.soft {
  background: var(--green-soft);
  color: var(--green);
  border-color: #94d5bd;
}
.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.btn:hover:not(:disabled), .mini-btn:hover, .copy-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .12);
}
.btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.main {
  min-width: 0;
  padding: 22px;
  overflow-y: auto;
  max-height: 100vh;
}
.workspace {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}
.app-view {
  animation: fadeIn .18s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.view-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.view-bar h2 {
  text-align: center;
  font-size: 22px;
  letter-spacing: -.03em;
}
.view-bar > :last-child {
  justify-self: end;
}
.view-tools {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(150px, 220px) 1fr auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
.selected-count {
  align-self: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}
.sticky-cta {
  position: sticky;
  bottom: 0;
  z-index: 10;
  margin-top: 14px;
  padding: 12px;
  background: rgba(248, 250, 252, .92);
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(12px);
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar h2 { font-size: 20px; }
.small-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.mini-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 9px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
}
.step-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  margin-bottom: 12px;
  overflow: hidden;
}
.step-section summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 14px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink);
  background: #fbfdff;
}
.step-section summary::-webkit-details-marker { display: none; }
.step-section summary span {
  color: var(--blue);
  margin-right: 7px;
}
.step-body {
  padding: 13px;
  border-top: 1px solid var(--line);
}
.advanced-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fbfdff;
  margin-bottom: 12px;
}
.advanced-box summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  transition: all .18s ease;
}
.card:hover, .keyword:hover, .topic:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.card h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .07em;
}
.empty {
  min-height: 270px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  background: #fbfaf7;
  border-radius: 16px;
  padding: 34px;
}
.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
}
.hero-empty {
  display: grid;
  gap: 22px;
  width: min(780px, 100%);
}
.hero-empty h2 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -.03em;
  color: var(--ink);
  margin-bottom: 8px;
}
.hero-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.hero-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  text-align: left;
}
.hero-card strong { margin-bottom: 4px; }
.loading {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 26px;
}
.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.keyword-list, .topic-list {
  display: grid;
  gap: 10px;
}
.keyword, .topic {
  border: 1px solid var(--line);
  background: #fbfaf7;
  border-radius: var(--radius);
  padding: 11px;
  display: grid;
  gap: 8px;
  transition: all .18s ease;
}
.keyword.selected, .topic.selected {
  border-color: #80cdae;
  background: var(--green-soft);
}
.keyword-top, .topic-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.keyword-name, .topic-name {
  font-weight: 800;
  font-size: 14px;
  line-height: 1.35;
}
.score-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(135deg, #ecfdf5, #eff6ff);
  border: 1px solid #bfdbfe;
  color: var(--blue);
  font-size: 13px;
  font-weight: 900;
}
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--soft);
  color: var(--muted);
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.keyword p, .topic p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.select-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
}
.selected .select-btn {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.article-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}
.output-tabs {
  max-width: 1080px;
  margin: 0 auto 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tab-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 900;
}
.tab-btn.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #0f172a, #2563eb);
}
.article-layout {
  max-width: 1080px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: start;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.score-panel {
  position: sticky;
  top: 86px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.score-number {
  font-size: 34px;
  font-weight: 950;
  letter-spacing: -.04em;
  color: var(--ink);
}
.score-panel .metric {
  padding: 8px;
}
.article {
  max-width: 820px;
  margin: 0 auto;
  line-height: 1.78;
  font-size: 16px;
}
.article h1 { font-size: 34px; line-height: 1.15; margin: 8px 0 14px; }
.article .deck {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.45;
  border-left: 3px solid var(--gold);
  padding-left: 13px;
  margin-bottom: 20px;
}
.article .byline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 24px;
}
.article h2 { font-size: 24px; line-height: 1.25; margin: 30px 0 10px; }
.article h3 { font-size: 17px; margin: 24px 0 8px; }
.article h4 { font-size: 15px; margin: 20px 0 7px; }
.article h5, .article h6 { font-size: 14px; margin: 18px 0 6px; color: var(--muted); }
.article p { margin-bottom: 15px; }
.article a { color: var(--blue); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
.article ul, .article ol { margin: 0 0 16px 20px; }
.article li { margin-bottom: 7px; }
.article blockquote {
  border-left: 3px solid var(--ink);
  padding: 8px 0 8px 14px;
  margin: 22px 0;
  font-weight: 700;
}
.seo-box {
  max-width: 820px;
  margin: 24px auto 0;
  border: 1px solid var(--line);
  background: #fbfaf7;
  border-radius: var(--radius);
  padding: 14px;
}
.mini-panel {
  max-width: 820px;
  margin: 24px auto 0;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
}
.mini-panel + .article {
  margin-top: 38px;
}
.mini-panel h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 10px;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.metric {
  border: 1px solid var(--line);
  background: #fbfaf7;
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.45;
}
.metric strong { display: block; font-size: 12px; margin-bottom: 2px; }
.history-item {
  border: 1px solid var(--line);
  background: #fbfaf7;
  border-radius: 8px;
  padding: 11px;
  display: grid;
  gap: 7px;
}
.article-actions {
  max-width: 820px;
  margin: 0 auto 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.copy-chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}
.copy-chip.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.seo-row {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.seo-row:last-child { border-bottom: 0; }
.seo-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 11px;
  font-weight: 800;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #141414;
  color: #b8f3dd;
  border-radius: 8px;
  padding: 13px;
  font-size: 12px;
  line-height: 1.6;
}
.overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.52);
  z-index: 50;
  padding: 18px;
}
.overlay.show { display: flex; }
.modal {
  width: min(420px, 100%);
  background: var(--panel);
  border-radius: 10px;
  padding: 20px;
  border: 1px solid var(--line);
}
.modal h2 { font-size: 18px; margin-bottom: 6px; }
.modal p { color: var(--muted); font-size: 13px; line-height: 1.5; margin-bottom: 14px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 800;
  transition: transform .22s ease;
  z-index: 60;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.error {
  border: 1px solid #e5a49e;
  background: #fff0ef;
  color: var(--red);
  border-radius: 8px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.key-error {
  display: none;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  margin-top: 7px;
  line-height: 1.4;
}
.key-error.show { display: block; }
.is-hidden { display: none; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mb-12 { margin-bottom: 12px; }
.badges-offset { margin-top: 7px; }
.export-actions-inline {
  justify-content: flex-start;
  margin: 0;
}
@media (max-width: 920px) {
  .topbar { grid-template-columns: 1fr; height: auto; padding: 14px; align-items: start; }
  .workflow { justify-content: flex-start; flex-wrap: wrap; }
  .top-actions { justify-content: flex-start; flex-wrap: wrap; width: 100%; }
  .app { grid-template-columns: 1fr; }
  .sidebar { max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .main { max-height: none; padding: 14px; }
  .grid { grid-template-columns: 1fr; }
  .article-layout { grid-template-columns: 1fr; }
  .score-panel { position: static; }
  .hero-cards { grid-template-columns: 1fr; }
  .view-bar { grid-template-columns: 1fr; }
  .view-bar h2 { text-align: left; }
  .view-bar > :last-child { justify-self: stretch; }
  .view-tools { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .row, .btn-row { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; }
  .small-actions { width: 100%; }
  .mini-btn { flex: 1; }
  .article-shell { padding: 14px; }
  .article h1 { font-size: 26px; }
  .seo-row { grid-template-columns: 1fr; align-items: start; }
}
