:root {
  --persona: #6957d8;
  --ink: #17202a;
  --muted: #677281;
  --line: #dfe4e8;
  --soft: #f4f6f8;
  --paper: #ffffff;
  --navy: #0c1724;
  --success: #147a52;
  --warning: #a76513;
  --danger: #b63d4d;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef1f3;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--persona) 9%, transparent), transparent 36%), #eef1f3; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.topbar { height: 76px; padding: 0 4vw; display: flex; align-items: center; justify-content: space-between; gap: 24px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); position: sticky; top: 0; z-index: 30; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--navy); color: white; font-weight: 800; box-shadow: inset 0 0 0 4px color-mix(in srgb, var(--persona) 65%, transparent); }
.brand strong, .owner-chip strong { display: block; font-size: 14px; }
.brand small, .owner-chip small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.owner-chip { display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 8px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.owner-avatar { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: white; font-size: 12px; font-weight: 800; background: var(--persona); }

main { width: min(1500px, 94vw); margin: 0 auto; padding: 40px 0 72px; }
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 32px; padding: 10px 4px 30px; }
.eyebrow { display: inline-block; color: var(--persona); font-weight: 800; letter-spacing: .13em; font-size: 10px; }
.hero h1 { margin: 8px 0 8px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 4.5vw, 62px); letter-spacing: -.035em; line-height: 1; }
.hero p { max-width: 750px; margin: 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #32b47d; box-shadow: 0 0 0 4px rgba(50,180,125,.14); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { border: 1px solid var(--line); background: rgba(255,255,255,.75); color: var(--muted); padding: 11px 16px; border-radius: 12px; font-weight: 700; }
.tab.active { background: var(--navy); color: white; border-color: var(--navy); }
.tab-panel { display: none; }
.tab-panel.active { display: grid; }
.panel-grid { grid-template-columns: minmax(0, 1.06fr) minmax(440px, .94fr); gap: 18px; align-items: start; }

.workspace-card { background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 16px 44px rgba(22,32,42,.055); }
.input-card { padding: 24px; }
.output-card { min-height: 760px; padding: 24px; position: sticky; top: 94px; max-height: calc(100vh - 112px); overflow: auto; }
.card-heading > div, .section-heading, .output-header, .fact-heading, .news-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card-heading > div { justify-content: flex-start; }
.card-heading h2, .output-header h2, .news-header h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 28px; letter-spacing: -.02em; }
.card-heading p, .section-heading p, .news-header p { margin: 5px 0 0; color: var(--muted); line-height: 1.5; font-size: 13px; }
.step { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: white; background: var(--persona); font-weight: 800; }

.form-row { margin-top: 24px; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: block; color: #3f4853; font-size: 12px; font-weight: 750; }
input, textarea, select { width: 100%; border: 1px solid #d6dce1; border-radius: 11px; color: var(--ink); background: #fff; outline: none; transition: border .18s, box-shadow .18s; }
input, select { height: 43px; padding: 0 12px; }
textarea { padding: 11px 12px; line-height: 1.5; resize: vertical; }
label > input, label > textarea, label > select { margin-top: 7px; }
input:focus, textarea:focus, select:focus { border-color: var(--persona); box-shadow: 0 0 0 3px color-mix(in srgb, var(--persona) 13%, transparent); }
label small, .evidence-item small { display: block; margin-top: 7px; color: var(--muted); font-weight: 450; line-height: 1.45; }

.section-block { margin-top: 26px; padding-top: 24px; border-top: 1px solid #edf0f2; }
.section-heading { align-items: center; }
.section-heading h3, .reply-section h3, .fact-check-card h3, .editorial-notes h3 { margin: 0; font-size: 14px; }
.context-pill { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; color: var(--persona); background: color-mix(in srgb, var(--persona) 10%, white); font-size: 9px; font-weight: 800; }
.event-brief { margin-top: 22px; padding: 18px; border: 1px solid color-mix(in srgb, var(--persona) 24%, var(--line)); border-radius: 16px; background: color-mix(in srgb, var(--persona) 4%, #fbfcfd); }
.event-brief.section-block { border-top-color: color-mix(in srgb, var(--persona) 24%, var(--line)); }
.event-brief .form-row { margin-top: 16px; }
.event-field { margin-top: 16px; }
.primary-button, .secondary-button, .read-button, .icon-button { border: 0; border-radius: 10px; font-weight: 750; }
.primary-button { padding: 12px 18px; color: white; background: var(--navy); box-shadow: 0 7px 16px rgba(12,23,36,.18); }
.primary-button:hover { background: color-mix(in srgb, var(--persona) 42%, var(--navy)); }
.primary-button:disabled, .read-button:disabled { opacity: .58; cursor: wait; }
.secondary-button { padding: 9px 12px; color: var(--ink); background: var(--soft); border: 1px solid var(--line); }
.secondary-button:hover { border-color: color-mix(in srgb, var(--persona) 45%, var(--line)); }
.icon-button { width: 38px; height: 40px; font-size: 21px; color: #7b8490; background: transparent; }
.read-button { height: 40px; padding: 0 13px; white-space: nowrap; color: white; background: var(--persona); }

.source-list, .evidence-list { display: grid; gap: 10px; margin-top: 13px; }
.source-item, .evidence-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: #fbfcfd; }
.source-item.loaded { border-color: color-mix(in srgb, var(--success) 34%, var(--line)); background: #f8fcfa; }
.source-item.error { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.source-row { display: grid; grid-template-columns: 28px minmax(0,1fr) auto auto; align-items: center; gap: 8px; }
.source-number { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); background: #e9edf0; font-size: 11px; font-weight: 800; }
.source-row input { margin: 0; height: 40px; }
.source-preview { margin: 11px 0 0 36px; }
.source-preview > div { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 7px; font-size: 11px; }
.source-preview > div strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-preview > div span { color: var(--success); white-space: nowrap; }
.source-preview textarea { background: white; font-size: 12px; }
.source-warning, .source-error { color: var(--warning) !important; font-size: 11px; }
.source-error { margin: 8px 0 0 36px; }

.evidence-head { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 8px; }
.evidence-head select { height: 40px; margin: 0; }
.evidence-item textarea { margin-top: 9px; font-size: 12px; }
.generate-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 28px; padding: 17px; border-radius: 15px; background: color-mix(in srgb, var(--persona) 7%, #f7f8fa); border: 1px solid color-mix(in srgb, var(--persona) 18%, var(--line)); }
.generate-row strong, .generate-row small { display: block; }
.generate-row strong { font-size: 13px; }
.generate-row small { margin-top: 4px; color: var(--muted); font-size: 11px; }

.empty-state { min-height: 680px; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 40px; }
.empty-state.compact { min-height: 300px; }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px; background: color-mix(in srgb, var(--persona) 12%, white); color: var(--persona); font-size: 24px; }
.empty-state h2, .empty-state h3 { margin: 17px 0 8px; font-family: Georgia, "Times New Roman", serif; }
.empty-state p { max-width: 430px; margin: 0; color: var(--muted); line-height: 1.6; font-size: 13px; }
.output-content { display: grid; gap: 20px; }
.output-header { align-items: center; }
.fact-check-card { padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: #fafbfc; }
.fact-heading { display: block; }
.fact-heading > div { display: flex; align-items: center; gap: 9px; }
.fact-heading p { margin: 9px 0 0; color: var(--muted); line-height: 1.5; font-size: 12px; }
.fact-status, .verdict { display: inline-flex; align-items: center; border-radius: 999px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.fact-status { padding: 5px 8px; font-size: 9px; background: #e8edf1; }
.fact-status.verified, .verdict.verified, .verdict.supported { color: var(--success); background: #e7f5ee; }
.fact-status.mixed, .verdict.unverified, .verdict.opinion { color: var(--warning); background: #fff2db; }
.fact-status.insufficient, .verdict.disputed { color: var(--danger); background: #fbe9ec; }
.fact-claims { display: grid; gap: 9px; margin-top: 13px; }
.claim-row { padding: 11px; border-radius: 11px; background: white; border: 1px solid #e8ecef; }
.claim-row > div:first-child { display: flex; align-items: flex-start; gap: 8px; }
.claim-row strong { font-size: 11px; line-height: 1.45; }
.verdict { flex: 0 0 auto; padding: 4px 6px; font-size: 8px; }
.claim-row p { margin: 7px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.claim-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.claim-sources a { padding: 4px 7px; border-radius: 7px; color: #365b8b; background: #edf4fc; font-size: 9px; text-decoration: none; }
.warning-list p { margin: 8px 0 0; color: var(--warning); font-size: 10px; }

.draft-editor textarea { min-height: 310px; margin-top: 8px; font-family: Georgia, "Times New Roman", serif; font-size: 15px; line-height: 1.62; }
.draft-editor small { display: flex; justify-content: space-between; }
.over-limit { color: var(--danger); font-weight: 800; }
.reply-section { padding-top: 18px; border-top: 1px solid var(--line); }
.count-pill { padding: 6px 8px; border-radius: 999px; color: var(--persona); background: color-mix(in srgb, var(--persona) 10%, white); font-size: 9px; font-weight: 800; }
.reply-list { display: grid; gap: 9px; margin-top: 13px; }
.reply-option { display: grid; grid-template-columns: 26px minmax(0,1fr); gap: 8px; align-items: start; }
.reply-option > span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 8px; background: var(--navy); color: white; font-size: 10px; }
.reply-option textarea { margin: 0; font-size: 11px; }
.google-doc-link { display: block; margin-top: 14px; padding: 12px; border-radius: 11px; text-align: center; color: white; background: var(--persona); text-decoration: none; font-size: 12px; font-weight: 800; }
.google-doc-link.disabled { pointer-events: none; opacity: .48; }
.editorial-notes { padding: 13px; border-radius: 12px; background: #fff8ec; color: #78521e; }
.editorial-notes p { margin: 7px 0 0; font-size: 11px; line-height: 1.45; }

.news-panel { padding: 26px; }
.news-header { align-items: flex-end; }
.news-controls { display: grid; grid-template-columns: minmax(220px, 350px) auto; gap: 8px; }
.news-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 10px; color: var(--muted); font-size: 10px; font-weight: 650; }
.news-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; margin-top: 22px; }
.news-card { display: flex; flex-direction: column; padding: 17px; min-height: 390px; border: 1px solid var(--line); border-radius: 16px; background: #fbfcfd; }
.news-card-top { display: flex; justify-content: space-between; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.news-card h3 { margin: 13px 0 9px; font-family: Georgia, "Times New Roman", serif; font-size: 19px; line-height: 1.18; }
.news-card > p, .news-insight p { color: var(--muted); font-size: 11px; line-height: 1.55; }
.news-insight { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e8ecef; }
.news-insight strong { font-size: 10px; }
.news-insight p { margin: 5px 0 0; }
.news-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 15px; }
.news-actions a { color: #406b9c; font-size: 10px; font-weight: 750; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 12px 16px; border-radius: 12px; color: white; background: var(--navy); box-shadow: 0 14px 35px rgba(0,0,0,.22); opacity: 0; pointer-events: none; transition: .22s; z-index: 80; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

@media (max-width: 1100px) {
  .panel-grid { grid-template-columns: 1fr; }
  .output-card { position: static; max-height: none; }
  .news-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 720px) {
  .topbar { height: auto; padding: 12px 4vw; }
  .brand small, .owner-chip small { display: none; }
  main { width: min(94vw, 680px); padding-top: 22px; }
  .hero { display: block; }
  .tabs { overflow-x: auto; }
  .tab { white-space: nowrap; }
  .two-columns, .news-grid { grid-template-columns: 1fr; }
  .input-card, .output-card, .news-panel { padding: 17px; border-radius: 17px; }
  .source-row { grid-template-columns: 26px minmax(0,1fr) auto; }
  .source-row .icon-button { grid-column: 3; }
  .read-button { grid-column: 2 / 3; width: fit-content; }
  .source-preview, .source-error { margin-left: 0; }
  .generate-row, .news-header { display: block; }
  .generate-row .primary-button { width: 100%; margin-top: 14px; }
  .news-controls { grid-template-columns: 1fr; margin-top: 16px; }
}
