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

@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:wght@400;600;700&family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --navy:        #012851;
  --navy-dark:   #011b38;
  --navy-mid:    #013468;
  --navy-light:  #e6edf5;
  --red:         #c8372d;
  --gold:        #e8a020;
  --green:       #16a34a;
  --yellow:      #d97706;
  --gov-color:   #012851;
  --news-color:  #c8372d;
  --other-color: #64748b;
  --bg:          #edf1f7;
  --card-bg:     #ffffff;
  --text:        #012851;
  --muted:       #4d6480;
  --border:      #c8d6e8;
  --radius:      12px;
  --accent:      #3b82f6;
  --accent-bg:   #eff6ff;
  --danger:      #ef4444;
  --danger-bg:   #fee2e2;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 18px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  background: var(--navy);
  border-bottom: 3px solid var(--gold);
  box-shadow: 0 2px 12px rgba(10, 20, 40, 0.35);
}

.home-link {
  display: flex;
  align-items: center;
  text-decoration: none;
}

.nav-logo {
  height: 48px;
  width: auto;
  display: block;
  border-radius: 4px;
}

/* ── Language switcher ───────────────────────────────── */
.lang-switcher { display: flex; gap: 6px; }
.lang-btn {
  padding: 5px 13px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 20px;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  color: rgba(255,255,255,0.7);
  transition: all 0.18s;
}
.lang-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}
.lang-btn.active {
  background: var(--gold);
  color: var(--navy-dark);
  border-color: var(--gold);
  font-weight: 600;
}

/* ── Main content ────────────────────────────────────── */
main {
  flex: 1;
  min-width: 0;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 24px;
}

/* ── Footer ──────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  text-align: center;
  background: var(--navy-dark);
}

.footer-disclaimer {
  max-width: 720px;
  margin: 0 auto;
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  line-height: 1.5;
}

/* ── Input state ─────────────────────────────────────── */
h1 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--navy);
  line-height: 1.2;
}

p { line-height: 1.6; color: var(--muted); margin-bottom: 24px; }

textarea {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 17px;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: var(--card-bg);
  color: var(--text);
}
textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26, 45, 79, 0.12);
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 24px;
  transition: border-color 0.2s, background 0.2s;
  background: var(--card-bg);
}
.upload-area:hover {
  border-color: var(--navy);
  background: var(--navy-light);
}
.upload-area label { cursor: pointer; color: var(--muted); font-size: 16px; }

#preview-container { position: relative; }
#preview-container:not([hidden]) { display: inline-block; }
#image-preview { max-height: 160px; border-radius: 8px; }
#clear-image {
  position: absolute; top: -8px; right: -8px;
  background: var(--red); color: white;
  border: none; border-radius: 50%;
  width: 24px; height: 24px; cursor: pointer; font-size: 12px;
}

.btn-primary {
  width: 100%;
  padding: 17px;
  background: var(--navy);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 18px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.01em;
}
.btn-primary:hover { background: var(--navy-mid); }
.btn-primary:active { transform: scale(0.99); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  padding: 13px 28px;
  background: none;
  color: var(--navy);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 17px;
  font-family: inherit;
  cursor: pointer;
  margin-top: 24px;
  transition: border-color 0.2s, background 0.2s;
}
.btn-secondary:hover {
  border-color: var(--navy);
  background: var(--navy-light);
}

.error-msg { color: var(--red); font-size: 15px; margin-top: 8px; }

/* ── Error card ──────────────────────────────────────── */
.error-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--danger-bg);
  border: 1.5px solid #fca5a5;
  border-left: 4px solid var(--danger);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.error-card__icon {
  font-size: 22px;
  color: var(--danger);
  line-height: 1;
  flex-shrink: 0;
  margin-top: 1px;
}

.error-card__message {
  color: #991b1b;
  font-size: 15px;
  line-height: 1.55;
  font-weight: 500;
}

/* ── Loading state ───────────────────────────────────── */
.steps-container { display: flex; flex-direction: column; gap: 20px; margin: 40px 0; }
.step { display: flex; align-items: center; gap: 16px; font-size: 20px; }
.step-icon { font-size: 24px; width: 32px; text-align: center; }
.step.done .step-icon { color: var(--green); }
.step.active .step-icon { animation: spin 1s linear infinite; display: inline-block; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ── Result — claim card ─────────────────────────────── */
.result-claim-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--navy);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.result-claim-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}
.result-claim {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 0;
  line-height: 1.5;
}

/* Uploaded image in result */
.result-image {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border-radius: 8px;
  margin-top: 12px;
  object-fit: contain;
}

/* ── Verdict card ────────────────────────────────────── */
.verdict-card {
  border: 1px solid var(--border);
  border-left: 5px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 28px;
  background: var(--card-bg);
}
.verdict-card:has(.verdict-true)         { border-left-color: #2E9E57; background: #f0fdf4; }
.verdict-card:has(.verdict-likely_true)  { border-left-color: #7BC67E; background: #f7fee7; }
.verdict-card:has(.verdict-likely_false) { border-left-color: #F59E0B; background: #fff7ed; }
.verdict-card:has(.verdict-false)        { border-left-color: #EF2B2D; background: #fff5f5; }
.verdict-card:has(.verdict-unverified)   { border-left-color: #9CA3AF; background: #f9fafb; }

.verdict-badge {
  display: inline-block;
  padding: 6px 18px;
  border-radius: 40px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.verdict-true         { background: #dcfce7; color: #2E9E57; }
.verdict-likely_true  { background: #ecfccb; color: #7BC67E; }
.verdict-likely_false { background: #ffedd5; color: #F59E0B; }
.verdict-false        { background: #fee2e2; color: #EF2B2D; }
.verdict-unverified   { background: #f3f4f6; color: #9CA3AF; }

.verdict-explanation {
  font-size: 13px;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 12px;
}

.result-summary {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.4;
}
.result-explanation {
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 0;
  line-height: 1.6;
}

/* ── Sources section ─────────────────────────────────── */
.sources-section { margin-bottom: 8px; }
h2 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 12px;
}

.source-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
}
.source-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tier-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}
.tier-government { background: var(--gov-color); }
.tier-news       { background: var(--news-color); }
.tier-other      { background: var(--other-color); }
.stance-tag {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  border: 1px solid currentColor;
  color: var(--muted);
}
.stance-supports    { color: var(--green); }
.stance-contradicts { color: var(--red); }

.source-title   { font-weight: 600; font-size: 15px; margin-bottom: 3px; color: var(--text); }
.source-url     { font-size: 12px; color: var(--muted); word-break: break-all; margin-bottom: 6px; }
.source-url a   { color: var(--navy); }
.source-snippet { font-size: 14px; color: var(--muted); line-height: 1.5; margin-bottom: 0; }
.credibility-label { font-size: 12px; color: var(--muted); font-style: italic; }

/* ── Share container ─────────────────────────────────── */
#share-container { margin-top: 16px; }
#share-url {
  width: 100%;
  margin-bottom: 0;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--muted);
  font-family: monospace;
}

/* ── History sidebar layout ── */
.app-layout {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  flex: 1;
  width: 100%;
  padding: 16px;
}

#history-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.history-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  margin: 0;
}

.btn-ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.btn-ghost:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.history-empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: 16px;
}

.history-entry {
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  transition: background 0.15s;
}

.history-entry:hover {
  background: var(--bg);
}

.history-entry.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}

.history-entry-claim {
  font-size: 13px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
  line-height: 1.4;
}

.history-entry-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-entry-time {
  font-size: 11px;
  color: var(--muted);
}

.sidebar-balancer {
  width: 260px;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .app-layout {
    flex-direction: column;
  }
  .sidebar-balancer {
    display: none;
  }
  #history-sidebar {
    width: 100%;
    position: static;
    max-height: 200px;
  }
}