/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #1e293b; line-height: 1.5; }

/* === Screens === */
.screen { min-height: 100vh; }
.hidden { display: none !important; }

/* === Auth === */
.auth-card { max-width: 400px; margin: 120px auto; background: #fff; border-radius: 12px; padding: 48px 32px; text-align: center; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.auth-card h1 { font-size: 28px; margin-bottom: 8px; }
.auth-card p { color: #64748b; margin-bottom: 24px; }
.auth-options { display: flex; flex-direction: column; gap: 10px; }
.auth-options button, .token-form button { width: 100%; padding: 12px; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; background: #3b82f6; color: #fff; font-weight: 600; transition: background .15s; }
.auth-options button:hover, .token-form button:hover { background: #2563eb; }
.divider { margin: 20px 0 12px; color: #94a3b8; font-size: 13px; }
.token-form input { width: 100%; padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; margin-bottom: 10px; }

/* === Header === */
header { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: #fff; border-bottom: 1px solid #e2e8f0; }
header h1 { font-size: 20px; }
.btn-small { padding: 6px 16px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; }
.btn-small:hover { background: #f8fafc; }

/* === Bars === */
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: #fff; border-bottom: 1px solid #e2e8f0; position: relative; }
.bar label { font-weight: 600; font-size: 14px; white-space: nowrap; }
.bar select, .bar input[type="text"] { flex: 1; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; }
.bar button { padding: 8px 20px; border: none; border-radius: 6px; background: #3b82f6; color: #fff; font-weight: 600; cursor: pointer; font-size: 14px; }
.bar button:hover { background: #2563eb; }

/* === Search Dropdown === */
.dropdown { position: absolute; top: 100%; left: 24px; right: 24px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; max-height: 320px; overflow-y: auto; z-index: 100; box-shadow: 0 8px 24px rgba(0,0,0,.1); }
.dropdown-item { padding: 12px 16px; cursor: pointer; border-bottom: 1px solid #f1f5f9; }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item:hover { background: #f8fafc; }
.dropdown-item .item-title { font-weight: 600; font-size: 14px; }
.dropdown-item .item-meta { font-size: 12px; color: #64748b; margin-top: 2px; }

/* === Workspace === */
.workspace-layout { display: grid; grid-template-columns: 1fr 420px; height: calc(100vh - 110px); }

/* === Preview Panel === */
.preview-panel { display: flex; flex-direction: column; border-right: 1px solid #e2e8f0; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid #e2e8f0; background: #fff; }
.back-btn { background: none; border: 1px solid #e2e8f0; border-radius: 6px; padding: 4px 10px; cursor: pointer; font-size: 16px; color: #64748b; line-height: 1; transition: background .15s, color .15s; }
.back-btn:hover { background: #f1f5f9; color: #1e293b; }
.edit-cms-btn { padding: 4px 12px; border: none; border-radius: 6px; background: #3b82f6; color: #fff; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s; }
.edit-cms-btn:hover { background: #2563eb; }
.panel-header h2 { font-size: 15px; }
.url-badge { font-size: 12px; color: #3b82f6; background: #eff6ff; padding: 4px 10px; border-radius: 12px; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; cursor: pointer; }
.url-badge:hover { background: #dbeafe; text-decoration: underline; }
#preview-frame { flex: 1; border: none; width: 100%; background: #fff; }

/* === SEO Panel === */
.seo-panel { display: flex; flex-direction: column; overflow-y: auto; background: #fafbfc; }

/* --- Grade --- */
.grade-section { display: flex; align-items: center; gap: 20px; padding: 24px 20px; background: #fff; border-bottom: 1px solid #e2e8f0; }
.grade-circle { width: 80px; height: 80px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; border: 5px solid; }
.grade-circle span { font-size: 32px; font-weight: 700; }
.grade-A { border-color: #22c55e; color: #16a34a; }
.grade-B { border-color: #84cc16; color: #65a30d; }
.grade-C { border-color: #eab308; color: #ca8a04; }
.grade-D { border-color: #f97316; color: #ea580c; }
.grade-F { border-color: #ef4444; color: #dc2626; }
.grade-info { flex: 1; }
.grade-info span:first-child { font-size: 28px; font-weight: 700; }
.score-max { font-size: 16px; color: #94a3b8; }
#grade-summary { font-size: 13px; color: #64748b; margin-top: 4px; }

/* --- Keyword Bar --- */
.keyword-bar { display: flex; align-items: center; gap: 8px; padding: 12px 20px; background: #fff; border-bottom: 1px solid #e2e8f0; }
.keyword-bar label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.keyword-bar input { flex: 1; padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; }
.keyword-bar button { padding: 6px 14px; border: none; border-radius: 6px; background: #3b82f6; color: #fff; cursor: pointer; font-size: 13px; font-weight: 600; }

/* --- Meta Snapshot --- */
.meta-snapshot { padding: 16px 20px; background: #fff; border-bottom: 1px solid #e2e8f0; }
.snippet-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #94a3b8; margin-bottom: 8px; }
.snippet-box { padding: 12px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; }
.snippet-title { font-size: 18px; color: #1a0dab; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet-url { font-size: 13px; color: #006621; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet-desc { font-size: 13px; color: #545454; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta-stats { display: flex; gap: 20px; margin-top: 12px; font-size: 13px; color: #64748b; }
.meta-stats strong { color: #1e293b; }

/* --- Checks --- */
.checks-container { padding: 0; }
.check-category { border-bottom: 1px solid #e2e8f0; }
.check-category-header { padding: 12px 20px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #64748b; background: #f8fafc; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.check-category-header:hover { background: #f1f5f9; }
.check-category-header .counts { display: flex; gap: 8px; }
.count-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.count-good { background: #dcfce7; color: #16a34a; }
.count-warn { background: #fef9c3; color: #ca8a04; }
.count-error { background: #fee2e2; color: #dc2626; }
.check-list { list-style: none; }
.check-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 20px; border-top: 1px solid #f1f5f9; font-size: 13px; }
.check-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.dot-good { background: #22c55e; }
.dot-warning { background: #eab308; }
.dot-error { background: #ef4444; }
.dot-info { background: #94a3b8; }

/* === Recently Viewed === */
.recent-section { padding: 24px; }
.recent-heading { font-size: 16px; font-weight: 700; margin-bottom: 16px; color: #1e293b; }
.recent-empty { color: #94a3b8; font-size: 14px; padding: 32px 0; text-align: center; }
.recent-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.recent-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 12px; padding: 20px; cursor: pointer; transition: box-shadow .15s, border-color .15s; position: relative; overflow: hidden; }
.recent-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); border-color: #cbd5e1; }
.recent-card-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-card-path { font-size: 12px; color: #64748b; margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-card-score { display: flex; align-items: center; gap: 12px; }
.recent-grade-dot { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: #fff; flex-shrink: 0; }
.recent-grade-dot.grade-bg-A { background: #22c55e; }
.recent-grade-dot.grade-bg-B { background: #84cc16; }
.recent-grade-dot.grade-bg-C { background: #eab308; }
.recent-grade-dot.grade-bg-D { background: #f97316; }
.recent-grade-dot.grade-bg-F { background: #ef4444; }
.recent-score-info { flex: 1; min-width: 0; }
.recent-score-value { font-size: 14px; font-weight: 600; }
.recent-score-date { font-size: 11px; color: #94a3b8; }
.recent-deviation { font-size: 12px; font-weight: 600; margin-left: auto; white-space: nowrap; }
.deviation-up { color: #16a34a; }
.deviation-down { color: #dc2626; }
.deviation-same { color: #94a3b8; }
.recent-history { display: flex; gap: 3px; align-items: flex-end; margin-top: 10px; height: 24px; }
.recent-history-bar { flex: 1; min-width: 4px; max-width: 12px; border-radius: 2px 2px 0 0; background: #e2e8f0; }

/* === Loading === */
.loading { text-align: center; padding: 48px; color: #64748b; }
.spinner { display: inline-block; width: 28px; height: 28px; border: 3px solid #e2e8f0; border-top-color: #3b82f6; border-radius: 50%; animation: spin .6s linear infinite; margin-bottom: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Suggest Bar --- */
.suggest-bar { padding: 12px 20px; background: #fff; border-bottom: 1px solid #e2e8f0; }
.suggest-bar button { width: 100%; padding: 10px; border: none; border-radius: 8px; background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer; transition: opacity .15s; }
.suggest-bar button:hover { opacity: .9; }
.suggest-bar button:disabled { opacity: .5; cursor: not-allowed; }

/* --- Suggestions --- */
.suggestions-container { padding: 0 0 20px; }
.suggestion-summary { padding: 12px 20px; font-size: 13px; color: #475569; background: #f5f3ff; border-bottom: 1px solid #e2e8f0; }
.suggestion-item { padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.suggestion-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.suggestion-field { font-weight: 700; font-size: 13px; color: #1e293b; text-transform: uppercase; letter-spacing: .3px; }
.suggestion-impact { font-size: 11px; font-weight: 600; padding: 2px 10px; border-radius: 10px; }
.impact-high { background: #fee2e2; color: #dc2626; }
.impact-medium { background: #fef9c3; color: #ca8a04; }
.impact-low { background: #dcfce7; color: #16a34a; }
.suggestion-reason { font-size: 13px; color: #64748b; margin-bottom: 8px; }
.suggestion-diff { font-size: 12px; margin-bottom: 4px; word-break: break-word; }
.diff-label { font-weight: 600; color: #64748b; }
.diff-old { color: #dc2626; text-decoration: line-through; }
.diff-new { color: #16a34a; }
.apply-btn { margin-top: 8px; padding: 6px 18px; border: none; border-radius: 6px; background: #8b5cf6; color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; }
.apply-btn:hover { background: #7c3aed; }
.apply-btn:disabled { opacity: .5; cursor: not-allowed; }
.apply-btn.applied { background: #22c55e; }

/* === Responsive === */
@media (max-width: 900px) {
  .workspace-layout { grid-template-columns: 1fr; grid-template-rows: 50vh 1fr; }
  .preview-panel { border-right: none; border-bottom: 1px solid #e2e8f0; }
}
