:root {
  --bg: #080b12;
  --surface: rgba(17, 22, 34, 0.86);
  --surface-2: #151b28;
  --surface-3: #1b2231;
  --text: #eef2ff;
  --muted: #9aa6bd;
  --border: rgba(255, 255, 255, 0.09);
  --accent: #7c5cff;
  --accent-2: #23c6a3;
  --danger: #ff647c;
  --warning: #ffbd59;
  --radius: 22px;
  --shadow: 0 28px 80px rgba(0, 0, 0, .35);
}

body.light {
  --bg: #f5f7fb;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-2: #ffffff;
  --surface-3: #f0f3fa;
  --text: #172033;
  --muted: #657089;
  --border: rgba(24, 32, 48, .09);
  --shadow: 0 25px 70px rgba(44, 55, 85, .12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  transition: background .25s ease, color .25s ease;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.bg-orb { position: fixed; width: 420px; height: 420px; border-radius: 50%; filter: blur(110px); opacity: .15; pointer-events: none; z-index: -1; }
.orb-1 { background: var(--accent); left: -130px; top: -140px; }
.orb-2 { background: var(--accent-2); right: -170px; top: 30%; }

.topbar {
  width: min(1240px, calc(100% - 32px));
  margin: 18px auto 0;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 18px;
  backdrop-filter: blur(20px);
  position: sticky;
  top: 12px;
  z-index: 20;
}
.brand { color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: linear-gradient(135deg, var(--accent), #a78bfa); color: white; font-size: 22px; font-weight: 900; box-shadow: 0 10px 30px rgba(124, 92, 255, .25); }
.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.status-pill { border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); padding: 8px 12px; border-radius: 999px; font-size: 13px; }
.dot { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: var(--accent-2); margin-right: 6px; box-shadow: 0 0 0 4px rgba(35, 198, 163, .12); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }

.app-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 64px 0 80px; }
.hero { max-width: 820px; margin: 10px auto 42px; text-align: center; }
.eyebrow { color: var(--accent-2); font-size: 12px; font-weight: 800; letter-spacing: .18em; }
.hero h1 { margin: 14px 0 16px; font-size: clamp(36px, 6vw, 66px); line-height: 1.02; letter-spacing: -.045em; }
.hero p { margin: 0 auto; color: var(--muted); font-size: 18px; max-width: 720px; }

.card { border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.generator-card, #titlesSection, .editor-card, .score-card, .originality-card { padding: 24px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-heading > div:first-child { display: flex; align-items: center; gap: 11px; }
.section-heading h2 { margin: 0; font-size: 20px; }
.step { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 30px; padding: 0 9px; border-radius: 9px; background: rgba(124, 92, 255, .12); color: #a997ff; font-size: 12px; font-weight: 900; }
.hint, .muted { color: var(--muted); font-size: 13px; }

.keyword-row { display: flex; gap: 14px; align-items: end; }
.grow { flex: 1; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 7px; font-weight: 700; }
input, select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 13px;
  padding: 0 14px;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}
input:focus, select:focus { border-color: rgba(124, 92, 255, .7); box-shadow: 0 0 0 4px rgba(124, 92, 255, .10); }
.options-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 18px; }

.primary-btn, .secondary-btn, .ghost-btn {
  border: 0;
  border-radius: 12px;
  min-height: 42px;
  padding: 0 16px;
  font-weight: 800;
  transition: transform .15s ease, opacity .15s ease, background .2s ease;
}
.primary-btn:hover, .secondary-btn:hover, .ghost-btn:hover { transform: translateY(-1px); }
.primary-btn { background: linear-gradient(135deg, var(--accent), #9f7aea); color: #fff; box-shadow: 0 12px 30px rgba(124, 92, 255, .25); }
.secondary-btn { background: rgba(35, 198, 163, .15); border: 1px solid rgba(35, 198, 163, .25); color: #57e2c5; }
.ghost-btn { background: var(--surface-3); border: 1px solid var(--border); color: var(--text); }
.large { height: 48px; min-width: 210px; }
.full { width: 100%; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.spinner { display: none; width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; margin-left: 8px; vertical-align: middle; }
button.loading .spinner { display: inline-block; }
button.loading { pointer-events: none; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }

#titlesSection { margin-top: 20px; }
.titles-grid { display: grid; gap: 12px; }
.title-card { display: grid; grid-template-columns: 76px 1fr auto; gap: 16px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 15px; transition: border-color .2s, transform .2s; }
.title-card:hover { border-color: rgba(124, 92, 255, .45); transform: translateY(-2px); }
.score-badge { width: 64px; height: 64px; border-radius: 16px; background: rgba(124, 92, 255, .12); display: grid; place-items: center; text-align: center; }
.score-badge strong { font-size: 20px; display: block; line-height: 1; }
.score-badge small { font-size: 9px; color: var(--muted); }
.title-copy h3 { margin: 0 0 5px; font-size: 16px; }
.title-copy p { margin: 0; color: var(--muted); font-size: 12px; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; margin-top: 20px; align-items: start; }
.sidebar-stack { display: grid; gap: 20px; position: sticky; top: 94px; }
.sticky-heading { position: sticky; top: 88px; background: var(--surface); padding: 2px 0 15px; z-index: 5; backdrop-filter: blur(18px); }
.compact { margin-bottom: 14px; }
.action-row { display: flex; gap: 8px; }

.loading-panel { min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 10px; }
.loader { width: 44px; height: 44px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-panel strong { color: var(--text); }

.article-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.metric { border: 1px solid var(--border); background: var(--surface-2); border-radius: 14px; padding: 13px; }
.metric span { color: var(--muted); display: block; font-size: 11px; }
.metric strong { font-size: 22px; }
.snippet-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 16px; padding: 16px; margin-bottom: 24px; display: grid; gap: 13px; }
.snippet-box span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: .05em; }
.snippet-box strong, .snippet-box p { margin: 3px 0 0; }
.slug-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; }
.slug-row code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #b8aaff; }
.slug-row button { background: var(--surface-3); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 5px 9px; }
.article-preview { background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; padding: clamp(22px, 4vw, 38px); }
.article-preview h1 { font-size: 32px; line-height: 1.15; letter-spacing: -.025em; }
.article-preview h2 { margin-top: 30px; font-size: 23px; }
.article-preview h3 { margin-top: 24px; }
.article-preview p, .article-preview li { color: color-mix(in srgb, var(--text) 87%, var(--muted)); }
.article-preview a { color: #9f8cff; }
.article-preview blockquote { border-left: 3px solid var(--accent); margin-left: 0; padding-left: 18px; color: var(--muted); }

.score-list { display: grid; gap: 11px; }
.score-item { display: grid; gap: 5px; }
.score-top { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; }
.score-top span { color: var(--muted); }
.progress { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #a78bfa); border-radius: inherit; }
.empty-state { color: var(--muted); font-size: 13px; padding: 10px 0; }
.originality-result { margin-top: 14px; }
.originality-score { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.originality-score strong { font-size: 34px; }
.findings { display: grid; gap: 8px; margin-top: 12px; }
.finding { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 10px; font-size: 12px; }
.finding a { color: #a997ff; word-break: break-all; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: 360px; padding: 12px 16px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .25s ease; z-index: 100; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255, 100, 124, .4); }
.footer { width: min(1180px, calc(100% - 32px)); margin: 0 auto; color: var(--muted); text-align: center; font-size: 12px; padding: 0 0 35px; }

@media (max-width: 900px) {
  .options-grid { grid-template-columns: repeat(2, 1fr); }
  .workspace-grid { grid-template-columns: 1fr; }
  .sidebar-stack { position: static; }
  .sticky-heading { position: static; }
}
@media (max-width: 640px) {
  .app-shell { width: min(100% - 20px, 1180px); padding-top: 38px; }
  .topbar { width: calc(100% - 20px); }
  .status-pill { display: none; }
  .hero { margin-bottom: 28px; }
  .hero h1 { font-size: 38px; }
  .hero p { font-size: 15px; }
  .generator-card, #titlesSection, .editor-card, .score-card, .originality-card { padding: 17px; }
  .keyword-row { flex-direction: column; align-items: stretch; }
  .options-grid { grid-template-columns: 1fr; }
  .title-card { grid-template-columns: 58px 1fr; }
  .title-card .primary-btn { grid-column: 1 / -1; }
  .score-badge { width: 54px; height: 54px; }
  .section-heading { align-items: flex-start; }
  .hint { display: none; }
  .article-meta-grid { grid-template-columns: 1fr; }
  .action-row { flex-wrap: wrap; justify-content: flex-end; }
  .slug-row { grid-template-columns: 1fr auto; }
  .slug-row > span { grid-column: 1 / -1; }
}
