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

:root {
  --bg: #f5f6fa;
  --white: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f1f5;
  --border: #e2e4ec;
  --border-light: #ecedf2;
  --text: #1a1d2e;
  --text-dim: #6b7084;
  --text-light: #9499b3;
  --primary: #4f46e5;
  --primary-light: #ede9fe;
  --primary-hover: #4338ca;
  --green: #16a34a;
  --green-light: #dcfce7;
  --yellow: #ca8a04;
  --yellow-light: #fef9c3;
  --orange: #ea580c;
  --orange-light: #ffedd5;
  --red: #dc2626;
  --red-light: #fee2e2;
  --ring-bg: #e5e7eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.07);
  --sidebar-width: 220px;
  --right-panel-width: 408px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

.anchor {
  display: block;
  position: relative;
  top: -1rem;
  visibility: hidden;
}

/* ═══════════════════════════════════════════
   LEFT SIDEBAR
   ═══════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.25rem 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.brand-icon {
  font-size: 1.5rem;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: .75rem .75rem;
  gap: .2rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .65rem .85rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  transition: background .15s, color .15s;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
}

.sidebar-footer p {
  font-size: .72rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* ═══════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════ */

.main {
  margin-left: var(--sidebar-width);
  margin-right: var(--right-panel-width);
  flex: 1;
  min-height: 100vh;
  padding: 2rem 2.5rem 3rem;
  max-width: 780px;
}

.main-header {
  margin-bottom: 1.75rem;
}

.main-header h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: .25rem;
  margin-right: .5rem;
}

/* ── Input card ── */

.input-card {
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.input-card label {
  display: block;
  font-weight: 600;
  margin-bottom: .65rem;
  font-size: .92rem;
}

textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  font-size: .92rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}

textarea::placeholder {
  color: var(--text-light);
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .75rem;
}

.char-count {
  font-size: .78rem;
  color: var(--text-light);
}

.buttons {
  display: flex;
  gap: .5rem;
}

.btn {
  padding: .55rem 1.3rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .2s, opacity .2s, transform .1s;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

/* ── Loading state ── */

.loading-section {
  animation: fadeUp .3s ease;
}

.loading-section.hidden { display: none; }

.loading-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 2rem;
}

.loading-spinner-large {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 1.25rem;
}

.loading-card h3 {
  font-size: 1.1rem;
  margin-bottom: .35rem;
}

.loading-card > p {
  font-size: .82rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

.loading-steps {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  text-align: left;
  max-width: 340px;
  margin: 0 auto;
}

.loading-step {
  font-size: .8rem;
  color: var(--text-light);
  padding-left: 1.5rem;
  position: relative;
  transition: color .3s;
}

.loading-step::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-radius: 50%;
  transition: border-color .3s, background .3s;
}

.loading-step.active {
  color: var(--primary);
  font-weight: 500;
}

.loading-step.active::before {
  border-color: var(--primary);
  border-top-color: transparent;
  animation: spin .6s linear infinite;
}

.loading-step.done {
  color: var(--green);
}

.loading-step.done::before {
  border-color: var(--green);
  background: var(--green);
}

/* ── Results ── */

.results-section {
  animation: fadeUp .4s ease;
}

.results-section.hidden { display: none; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.score-card {
  display: flex;
  align-items: center;
  gap: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.score-ring-wrapper {
  position: relative;
  width: 130px;
  height: 130px;
  flex-shrink: 0;
}

.score-ring {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.score-ring-bg {
  fill: none;
  stroke: var(--ring-bg);
  stroke-width: 10;
}

.score-ring-fill {
  fill: none;
  stroke: var(--green);
  stroke-width: 10;
  stroke-linecap: round;
  stroke-dasharray: 377;
  stroke-dashoffset: 377;
  transition: stroke-dashoffset 1s ease, stroke .4s;
}

.score-value {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#score-number {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
}

.score-label {
  font-size: .72rem;
  color: var(--text-light);
  margin-top: 2px;
}

.score-info { flex: 1; }
.score-info h2 { font-size: 1.25rem; margin-bottom: .35rem; }
.score-info p { color: var(--text-dim); font-size: .88rem; line-height: 1.55; }

/* Breakdown */

.breakdown h3, .tips h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
}

.breakdown-items {
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: .85rem;
}

.breakdown-item .bi-label {
  width: 170px;
  flex-shrink: 0;
  font-size: .82rem;
  color: var(--text-dim);
}

.breakdown-item .bi-bar-track {
  flex: 1;
  height: 7px;
  background: var(--ring-bg);
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-item .bi-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .8s ease;
}

.breakdown-item .bi-value {
  width: 38px;
  text-align: right;
  font-size: .78rem;
  font-weight: 600;
}

/* Tips */

.tips ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.tips li {
  font-size: .85rem;
  color: var(--text-dim);
  padding-left: 1.3rem;
  position: relative;
  line-height: 1.55;
}

.tips li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

/* ── How it works ── */

.how-it-works {
  margin-bottom: 2rem;
}

.how-it-works h3 {
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .85rem;
}

.feature {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  text-align: center;
  transition: border-color .2s, box-shadow .2s;
}

.feature:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.feature-icon { font-size: 1.6rem; margin-bottom: .4rem; }
.feature h4 { font-size: .85rem; margin-bottom: .25rem; }
.feature p { font-size: .76rem; color: var(--text-dim); line-height: 1.45; }

/* Footer */

footer {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
}

footer p {
  font-size: .74rem;
  color: var(--text-light);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ═══════════════════════════════════════════
   RIGHT PANEL — RELIABLE SOURCES
   ═══════════════════════════════════════════ */

.right-panel {
  width: var(--right-panel-width);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  background: var(--white);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 1.25rem;
  z-index: 90;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border-light);
}

.panel-header h3 {
  font-size: .95rem;
  font-weight: 700;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* ── Rich source preview cards ── */

.source-cards-rich {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.rich-card {
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
  transition: border-color .2s, box-shadow .2s, transform .15s;
}

.rich-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.rich-card-img {
  position: relative;
  width: 100%;
  height: 130px;
  overflow: hidden;
  background: var(--surface-2);
}

.rich-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: transform .3s ease;
}

.rich-card:hover .rich-card-img img {
  transform: scale(1.03);
}

.rich-card-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  padding: .2rem .55rem;
  border-radius: 4px;
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .04em;
  background: rgba(0,0,0,.55);
  color: #fff;
  backdrop-filter: blur(4px);
}

.live-badge {
  background: var(--red);
  animation: pulse 1.5s ease infinite;
}

.rich-card-body {
  padding: .6rem .85rem .4rem;
}

.rich-card-source-name {
  font-size: .78rem;
  font-weight: 700;
  color: var(--text);
  display: block;
  margin-bottom: .15rem;
}

.rich-card-body p {
  font-size: .7rem;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rich-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .4rem .85rem .55rem;
}

.rich-card-source {
  font-size: .65rem;
  color: var(--text-light);
}

.rich-card-more {
  font-size: .7rem;
  font-weight: 600;
  color: var(--primary);
  padding: .2rem .55rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  transition: background .15s;
}

.rich-card:hover .rich-card-more {
  background: var(--primary-light);
}

.panel-section {
  margin-bottom: 1.25rem;
}

.panel-section h4 {
  font-size: .85rem;
  font-weight: 700;
  margin-bottom: .6rem;
  color: var(--text);
}

.panel-tip {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: .85rem;
  font-size: .76rem;
  color: var(--primary);
  line-height: 1.55;
}

.panel-tip strong {
  font-weight: 700;
}

/* ═══════════════════════════════════════════
   MOBILE OVERLAY
   ═══════════════════════════════════════════ */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 90;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width: 1200px) {
  .right-panel {
    display: none;
  }

  .main {
    margin-right: 0;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open {
    display: block;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .main-header {
    display: flex;
    align-items: center;
  }

  .main {
    margin-left: 0;
    padding: 1.25rem 1rem 2rem;
  }

  .score-card {
    flex-direction: column;
    text-align: center;
  }

  .breakdown-item .bi-label {
    width: 110px;
    font-size: .76rem;
  }

  .features {
    grid-template-columns: 1fr;
  }

  .main-header h1 {
    font-size: 1.3rem;
  }
}

@media (min-width: 769px) and (max-width: 1200px) {
  .main {
    margin-left: var(--sidebar-width);
    max-width: none;
  }
}
