@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:      #0e0f11;
  --bg2:     #161719;
  --bg3:     #1e2024;
  --bg4:     #26282d;
  --border:  rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --text:    #f0f0ee;
  --muted:   #8a8b8e;
  --accent:  #4f9cf9;
  --accent2: #7c6af7;
  --green:   #3ecf8e;
  --amber:   #f5a623;
  --red:     #f25c5c;
  --teal:    #2dd4bf;
  --font-d:  'DM Serif Display', serif;
  --font-b:  'DM Sans', sans-serif;
  --font-m:  'JetBrains Mono', monospace;
  --r:       10px;
  --r-lg:    16px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── LAYOUT ────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: 60px 1fr;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(14,15,17,0.95);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-family: var(--font-d);
  font-size: 21px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.logo-pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:0.4; transform:scale(0.75); }
}

.topbar-right { display:flex; align-items:center; gap:10px; }

.main-body {
  display: grid;
  grid-template-columns: 220px 1fr;
}

/* ── SIDEBAR ───────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border);
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.sidebar-section {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  border: 1px solid transparent;
  user-select: none;
  text-decoration: none;
}

.nav-link:hover { background:var(--bg3); color:var(--text); }

.nav-link.active {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--border2);
  font-weight: 500;
}

.nav-icon {
  width: 26px; height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.ni-site  { background: rgba(62,207,142,0.12); }
.ni-ads   { background: rgba(79,156,249,0.12); }
.ni-hist  { background: rgba(255,255,255,0.05); }

.badge-ai {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 6px;
  background: rgba(124,106,247,0.2);
  color: var(--accent2);
  border-radius: 4px;
  font-weight: 600;
}

/* ── PAGE CONTENT ──────────────────────── */
.page-content {
  padding: 36px 44px;
  max-width: 960px;
}

.page { display: none; }
.page.active { display: block; }

.page-head { margin-bottom: 28px; }

.page-title {
  font-family: var(--font-d);
  font-size: 30px;
  letter-spacing: -0.3px;
  line-height: 1.2;
  margin-bottom: 5px;
}

.page-desc { color: var(--muted); font-size: 13px; }

/* ── SUB TABS ──────────────────────────── */
.sub-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg3);
  padding: 4px;
  border-radius: 10px;
  width: fit-content;
  margin-bottom: 28px;
}

.sub-tab {
  padding: 7px 18px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--muted);
  border: none;
  background: none;
  font-family: var(--font-b);
}

.sub-tab:hover:not(.active) { color: var(--text); }
.sub-tab.active { background: var(--bg4); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.3); }

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

/* ── URL BAR ───────────────────────────── */
.url-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  align-items: stretch;
}

.url-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.url-icon {
  position: absolute;
  left: 14px;
  color: var(--muted);
  font-size: 15px;
  pointer-events: none;
}

/* ── INPUTS ────────────────────────────── */
input, textarea, select {
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-family: var(--font-b);
  font-size: 14px;
  border-radius: var(--r);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,156,249,0.1);
}

.inp-url {
  width: 100%;
  padding: 11px 14px 11px 42px;
}

.inp-text {
  width: 100%;
  padding: 10px 14px;
}

select {
  padding: 10px 36px 10px 14px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%238a8b8e' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

textarea {
  width: 100%;
  padding: 11px 14px;
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

/* ── BUTTONS ───────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--r);
  font-family: var(--font-b);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s;
  border: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6aaeff; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); background: var(--bg4); }

.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ── CARDS ─────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 18px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--text);
}

/* ── SCORE GRID ────────────────────────── */
.score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.score-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.score-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.score-card.good::after { background: var(--green); }
.score-card.ok::after   { background: var(--amber); }
.score-card.bad::after  { background: var(--red); }

.score-num {
  font-family: var(--font-d);
  font-size: 34px;
  line-height: 1;
  margin-bottom: 4px;
}
.score-num.good { color: var(--green); }
.score-num.ok   { color: var(--amber); }
.score-num.bad  { color: var(--red); }

.score-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── METRIC ROWS ───────────────────────── */
.metric-list { display: flex; flex-direction: column; gap: 9px; }

.metric-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: var(--bg3);
  border-radius: 9px;
  border: 1px solid var(--border);
}

.metric-icon {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.metric-name { flex: 1; font-size: 13px; font-weight: 500; }
.metric-sub  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.metric-val  { font-family: var(--font-m); font-size: 12px; color: var(--text); }

/* ── BADGES ────────────────────────────── */
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.badge-good { background: rgba(62,207,142,0.15); color: var(--green); }
.badge-ok   { background: rgba(245,166,35,0.15);  color: var(--amber); }
.badge-bad  { background: rgba(242,92,92,0.15);   color: var(--red); }
.badge-info { background: rgba(79,156,249,0.15);  color: var(--accent); }

/* ── ISSUE LIST ────────────────────────── */
.issue-list { display: flex; flex-direction: column; gap: 9px; }

.issue {
  display: flex;
  gap: 12px;
  padding: 13px 15px;
  background: var(--bg3);
  border-radius: 9px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  animation: slideUp 0.25s ease;
}
.issue.p1 { border-left-color: var(--red); }
.issue.p2 { border-left-color: var(--amber); }
.issue.p3 { border-left-color: var(--teal); }

@keyframes slideUp {
  from { opacity:0; transform:translateY(5px); }
  to   { opacity:1; transform:translateY(0); }
}

.issue-p {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}
.issue.p1 .issue-p { background:rgba(242,92,92,0.15); color:var(--red); }
.issue.p2 .issue-p { background:rgba(245,166,35,0.15); color:var(--amber); }
.issue.p3 .issue-p { background:rgba(45,212,191,0.15); color:var(--teal); }

.issue-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.issue-desc  { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ── SEO CHECKLIST ─────────────────────── */
.seo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seo-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  background: var(--bg3);
  border-radius: 9px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.check-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
  margin-top: 1px;
}
.ci-pass { background:rgba(62,207,142,0.18); color:var(--green); }
.ci-fail { background:rgba(242,92,92,0.18); color:var(--red); }
.ci-warn { background:rgba(245,166,35,0.18); color:var(--amber); }
.ci-info { background:rgba(79,156,249,0.18); color:var(--accent); }

.check-label { font-weight: 500; font-size: 13px; display: block; margin-bottom: 2px; }
.check-val   { color: var(--muted); font-size: 11px; }

/* ── UPLOAD ZONE ───────────────────────── */
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--r);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg3);
  margin-bottom: 14px;
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--accent); background: rgba(79,156,249,0.05); }
.upload-icon { font-size: 26px; margin-bottom: 8px; }
.upload-text { font-size: 13px; color: var(--muted); }
.upload-text strong { color: var(--accent); }
.upload-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.file-tags { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.file-tag  { display:flex; align-items:center; gap:6px; padding:5px 11px; background:var(--bg4); border:1px solid var(--border2); border-radius:6px; font-size:12px; color:var(--muted); }
.file-tag .ok { color:var(--green); }

/* ── IMG PREVIEW ───────────────────────── */
.img-previews { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:14px; }
.img-thumb { border-radius:8px; overflow:hidden; border:1px solid var(--border2); position:relative; }
.img-thumb img { height:72px; width:auto; display:block; }

/* ── AI RESPONSE ───────────────────────── */
.ai-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-top: 18px;
  display: none;
  animation: slideUp 0.3s ease;
}
.ai-box.show { display: block; }

.ai-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.ai-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.ai-name { font-size: 13px; font-weight: 600; }
.ai-meta { font-size: 11px; color: var(--muted); }

.ai-body {
  font-size: 13px;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
}

/* ── LOADING ───────────────────────────── */
.loading {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 18px 0;
  color: var(--muted);
  font-size: 13px;
}
.loading.show { display: flex; }

.spinner {
  width: 17px; height: 17px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform:rotate(360deg); } }

/* ── TIPS GRID ─────────────────────────── */
.tips-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; margin-bottom:20px; }

.tip {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}
.tip-icon  { font-size: 20px; margin-bottom: 9px; }
.tip-title { font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.tip-body  { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ── HISTORY ───────────────────────────── */
.hist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  background: var(--bg3);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 9px;
  cursor: pointer;
  transition: all 0.15s;
}
.hist-item:hover { border-color: var(--border2); background: var(--bg4); }

.hist-icon { width:34px; height:34px; border-radius:8px; background:var(--bg4); display:flex; align-items:center; justify-content:center; font-size:15px; flex-shrink:0; }
.hist-url  { font-size: 13px; font-weight: 500; }
.hist-meta { font-size: 11px; color: var(--muted); }
.hist-type { margin-left:auto; font-size:11px; padding:3px 8px; border-radius:5px; font-weight:500; background:rgba(79,156,249,0.12); color:var(--accent); }

/* ── EMPTY STATE ───────────────────────── */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}
.empty-icon  { font-size: 38px; margin-bottom: 12px; }
.empty-title { font-family: var(--font-d); font-size: 20px; color: var(--text); margin-bottom: 7px; }
.empty-text  { font-size: 13px; max-width: 320px; margin: 0 auto; }

/* ── STATUS BAR ────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  color: var(--muted);
}
.status-dot { width:7px; height:7px; border-radius:50%; flex-shrink:0; }
.status-dot.ok  { background: var(--green); }
.status-dot.err { background: var(--red); }
.status-dot.unk { background: var(--amber); }

/* ── MODAL ─────────────────────────────── */
.modal-wrap {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  z-index: 200;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
}
.modal-wrap.open { display: flex; }

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 18px;
  padding: 30px;
  width: 460px;
  max-width: 92vw;
  animation: slideUp 0.2s ease;
}

.modal-title { font-family: var(--font-d); font-size: 21px; margin-bottom: 4px; }
.modal-desc  { font-size: 12px; color: var(--muted); margin-bottom: 22px; }

.key-field { margin-bottom: 14px; }
.key-label { font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing:0.07em; display:block; margin-bottom:6px; }
.key-wrap  { position:relative; }
.key-input {
  width: 100%;
  padding: 9px 36px 9px 13px;
  font-family: var(--font-m);
  font-size: 12px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: var(--r);
  outline: none;
}
.key-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,156,249,0.1); }
.key-eye { position:absolute; right:9px; top:50%; transform:translateY(-50%); background:none; border:none; color:var(--muted); cursor:pointer; font-size:15px; padding:3px; }

.modal-footer { display:flex; justify-content:flex-end; gap:9px; margin-top:22px; }

/* ── TOAST ─────────────────────────────── */
#toast {
  position: fixed;
  bottom: 22px; right: 22px;
  background: var(--bg2);
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 13px;
  font-family: var(--font-b);
  box-shadow: 0 4px 20px rgba(0,0,0,0.45);
  z-index: 999;
  animation: slideUp 0.2s ease;
  max-width: 320px;
}

/* ── SCROLLBAR ─────────────────────────── */
::-webkit-scrollbar { width:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--bg4); border-radius:3px; }

/* ── RESPONSIVE ────────────────────────── */
@media (max-width: 768px) {
  .main-body { grid-template-columns: 1fr; }
  .sidebar   { display: none; }
  .page-content { padding: 20px 16px; }
  .score-grid { grid-template-columns: repeat(2,1fr); }
  .seo-grid, .form-grid-2, .tips-grid { grid-template-columns: 1fr; }
}
