:root {
  --navy: #10233f;
  --blue: #1e5eff;
  --indigo: #4f46e5;
  --teal: #087f74;
  --gold: #b7791f;
  --red: #b42318;
  --ink: #182230;
  --muted: #5f6c7b;
  --line: #d9e1ec;
  --soft: #f4f7fb;
  --white: #ffffff;
  --shadow: 0 20px 50px rgba(24, 34, 48, 0.09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #edf3ff 0, #f8fafc 360px, #fff 100%);
  line-height: 1.55;
}

a { color: inherit; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 5vw, 72px);
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; font-weight: 900; color: var(--navy); }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; color: white; background: linear-gradient(135deg, var(--blue), var(--indigo)); }
.nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav a { text-decoration: none; padding: 9px 13px; border-radius: 999px; color: #334155; font-weight: 750; }
.nav a:hover, .nav a[aria-current="page"] { background: #eaf0ff; color: #1d4ed8; }

.shell { max-width: 1420px; margin: 0 auto; padding: 32px clamp(16px, 4vw, 48px) 60px; }
.hero { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 26px; align-items: stretch; margin-bottom: 26px; }
.hero-copy, .hero-note, .card { background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.hero-copy { padding: clamp(28px, 5vw, 58px); }
.hero-note { padding: 25px; border-left: 6px solid var(--indigo); }
.eyebrow { margin: 0 0 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--indigo); font-size: .78rem; }
h1 { margin: 0 0 16px; color: var(--navy); font-size: clamp(2.1rem, 4.8vw, 4.8rem); line-height: 1.02; letter-spacing: -.045em; }
h2 { margin: 0 0 8px; color: var(--navy); line-height: 1.15; }
h3 { color: var(--navy); }
.lead { max-width: 760px; color: #42526a; font-size: 1.08rem; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; }
.btn, button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--indigo);
  color: white;
  font: inherit;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}
.btn.secondary, button.secondary { background: #e8edf5; color: #172033; }
button:disabled { opacity: .52; cursor: not-allowed; }

.module-grid, .feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; }
.module-card, .feature-card { padding: 25px; background: white; border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.module-card { text-decoration: none; transition: transform .18s ease, border-color .18s ease; }
.module-card:hover { transform: translateY(-3px); border-color: #9eb5ff; }
.module-card .tag { display: inline-block; padding: 5px 9px; border-radius: 999px; color: #3730a3; background: #eef2ff; font-size: .78rem; font-weight: 850; }

.grid-two { display: grid; grid-template-columns: minmax(360px, .88fr) minmax(470px, 1.12fr); gap: 22px; align-items: start; }
.card { padding: 24px; }
.form-card label { display: block; margin: 14px 0; font-weight: 780; color: #24324a; }
.field-label { display: block; margin-bottom: 6px; }
.help, .muted { color: var(--muted); font-size: .91rem; }
input, select, textarea {
  width: 100%;
  border: 1.5px solid #c7d1df;
  border-radius: 13px;
  padding: 12px 13px;
  background: white;
  color: #111827;
  font: inherit;
}
select { background: #eef4ff; border-color: #9db8ff; font-weight: 750; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(30,94,255,.14); border-color: var(--blue); }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.check { display: flex !important; gap: 9px; align-items: center; font-weight: 650 !important; }
.check input { width: auto; }
.priority { padding: 13px; border: 1px solid #bed2ff; border-left: 5px solid var(--blue); border-radius: 16px; background: #f2f6ff; }
.status { min-height: 25px; color: #334155; font-weight: 700; }
.output-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.output-box { min-height: 650px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92rem; line-height: 1.55; }
.result-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 12px; }

.idea-list { display: grid; gap: 16px; }
.idea-card { border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: #fbfdff; }
.idea-card h3 { margin: 0 0 6px; }
.idea-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pill { display: inline-block; padding: 5px 9px; border-radius: 999px; background: #ecfdf3; color: #067647; font-size: .8rem; font-weight: 800; }
.pill.score { background: #eef2ff; color: #4338ca; }
.idea-section { margin: 10px 0; }
.idea-section strong { color: #24324a; }
.idea-section ul { margin: 5px 0 0 18px; padding: 0; }
.warning { padding: 11px 13px; border-radius: 12px; color: #8a2b0d; background: #fff3e8; border: 1px solid #ffd0a8; }
.source-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px,1fr)); gap: 12px; }
.source { padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdff; }
.source a { color: #1d4ed8; font-weight: 750; }
.footer { padding: 26px; text-align: center; color: var(--muted); }

@media (max-width: 900px) {
  .hero, .grid-two, .module-grid, .feature-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .two-cols { grid-template-columns: 1fr; }
  .result-head { flex-direction: column; }
}

/* Article source attachment workflow */
.source-search-panel {
  margin: 20px 0;
  padding: 18px;
  border: 1px solid #b9caff;
  border-left: 5px solid var(--indigo);
  border-radius: 18px;
  background: linear-gradient(180deg, #f7f9ff 0%, #ffffff 100%);
}
.source-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}
.source-panel-head h3 { margin: 0 0 5px; }
.source-panel-head p { margin: 0; }
.source-count-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 11px;
  border-radius: 999px;
  background: #e8edff;
  color: #3730a3;
  font-size: .82rem;
  font-weight: 900;
}
.source-controls {
  display: grid;
  grid-template-columns: minmax(150px, .42fr) minmax(240px, 1fr);
  gap: 14px;
  align-items: end;
}
.compact-label { margin: 8px 0 !important; }
.source-check {
  margin: 8px 0 13px !important;
  padding: 10px 12px;
  border: 1px solid #d6def1;
  border-radius: 12px;
  background: white;
}
.compact-actions { margin-top: 12px; }
.ghost-button {
  background: white;
  color: #344054;
  border: 1px solid #cbd5e1;
}
.attached-summary {
  margin: 10px 0 14px;
  padding: 11px 13px;
  border-radius: 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #28543c;
  font-size: .91rem;
}
.compact-source-grid {
  grid-template-columns: 1fr;
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}
.source-compact { padding: 11px 12px; }
.source-title-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.source-origin {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: .69rem;
  font-weight: 850;
}
.source-abstract {
  margin: 9px 0;
  color: #43516a;
  font-size: .88rem;
}
.source-hint {
  margin: 8px 0;
  color: #4b5563;
  font-size: .82rem;
}

@media (max-width: 700px) {
  .source-panel-head, .source-title-line { flex-direction: column; }
  .source-controls { grid-template-columns: 1fr; }
  .source-origin { align-self: flex-start; }
}

/* Staged independent-article workflow and research resources */
.stage-panel,
.continuation-panel,
.research-resource-panel {
  margin: 18px 0;
  padding: 17px;
  border: 1px solid #c7d5ee;
  border-radius: 18px;
  background: #f8fbff;
}
.stage-panel { border-left: 5px solid var(--teal); }
.continuation-panel { border-left: 5px solid var(--gold); background: #fffaf1; }
.research-resource-panel { border-left: 5px solid var(--blue); background: linear-gradient(180deg, #f5f8ff 0%, #fff 100%); }
.stage-message {
  margin-top: 9px;
  padding: 10px 12px;
  border-radius: 11px;
  background: white;
  border: 1px solid #dbe4f0;
  color: #3b4a60;
  font-size: .91rem;
  font-weight: 650;
}
.disabled-section {
  opacity: .58;
  filter: grayscale(.12);
  pointer-events: none;
}
.disabled-section input,
.disabled-section textarea,
.disabled-section select {
  background: #eef1f5;
}
.compact-upload {
  margin: -4px 0 9px;
  padding: 9px 14px;
}
.resource-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}
.resource-columns h3,
.resource-columns h4 { margin: 8px 0 10px; }
.resource-list { display: grid; gap: 10px; }
.resource-card {
  padding: 13px;
  border: 1px solid #d9e1ec;
  border-radius: 14px;
  background: #fff;
}
.resource-card p { margin: 7px 0; }
.resource-card a { color: #1d4ed8; font-weight: 780; }
.resource-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.resource-type {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 999px;
  background: #ecfdf3;
  color: #067647;
  font-size: .7rem;
  font-weight: 850;
}
.resource-inline {
  margin: 14px 0;
  padding: 13px;
  border: 1px solid #bfdbfe;
  border-radius: 14px;
  background: #eff6ff;
}
.resource-inline details { margin: 9px 0; }
.resource-inline summary { cursor: pointer; color: #1d4ed8; font-weight: 800; }
.resource-inline .resource-card { margin-top: 8px; background: white; }
.pill.route { background: #fff7ed; color: #9a3412; }
.output-stack { display: grid; gap: 20px; }
.instrument-output {
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.instrument-box { min-height: 470px; }

@media (max-width: 900px) {
  .resource-columns { grid-template-columns: 1fr; }
}

/* Article-topic relevance and generation notes */
.warning-details {
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid #f2c68c;
  border-radius: 12px;
  background: #fff8ed;
  color: #7a3d08;
  font-size: .9rem;
}
.warning-details ul { margin: 8px 0 0 20px; padding: 0; }
.warning-details li { margin: 4px 0; }
.source-match {
  margin: 8px 0;
  padding: 7px 9px;
  border-radius: 9px;
  background: #f0fdf4;
  color: #166534;
  font-size: .78rem;
}
[hidden] { display: none !important; }
