:root {
  color-scheme: light;
  --bg: #f5f8fc;
  --surface: #ffffff;
  --surface-muted: #eef5ff;
  --border: #d7e2ef;
  --border-strong: #91a7c2;
  --text: #10233f;
  --muted: #60728a;
  --primary: #0a3b78;
  --primary-dark: #062b59;
  --danger: #a33838;
  --warning: #875a13;
  --shadow: 0 8px 22px rgba(10, 59, 120, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: linear-gradient(180deg, #ffffff 0, var(--bg) 180px);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--primary);
  border-radius: 7px;
  background: var(--primary);
  color: #ffffff;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  background: var(--primary-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--primary);
  font-weight: 650;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 680px);
  gap: 24px;
  align-items: end;
  padding: 22px clamp(16px, 3vw, 32px);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  color: var(--primary-dark);
  font-size: clamp(1.55rem, 2.4vw, 2.2rem);
}

h2 {
  font-size: 1.05rem;
}

.connection-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.75fr) auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(10, 59, 120, 0.22);
  outline-offset: 2px;
}

small {
  color: var(--muted);
  font-weight: 500;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
}

.summary-list,
.editor-panel {
  min-height: calc(100dvh - 146px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-list {
  overflow: hidden;
}

.section-header {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.section-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-list-body {
  display: grid;
  max-height: calc(100dvh - 236px);
  overflow: auto;
}

.list-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.list-tabs button {
  min-height: 42px;
  border-color: var(--border-strong);
  background: #ffffff;
  color: var(--primary);
}

.list-tabs button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.summary-item {
  width: 100%;
  min-height: 112px;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
  padding: 14px 16px;
  text-align: left;
}

.summary-item:hover,
.summary-item.active {
  background: var(--surface-muted);
}

.summary-item.active {
  box-shadow: inset 4px 0 0 var(--primary);
}

.summary-item-title {
  display: block;
  margin-bottom: 8px;
  font-weight: 750;
}

.summary-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.risk {
  border-radius: 999px;
  padding: 2px 8px;
  background: #eaf2ff;
  color: var(--primary-dark);
}

.risk.medium {
  background: #fff4d9;
  color: var(--warning);
}

.risk.high {
  background: #fde7e7;
  color: var(--danger);
}

.status-message {
  padding: 0 16px;
  color: var(--muted);
}

.pipeline-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border-bottom: 1px solid var(--border);
  background: var(--border);
}

.pipeline-stats div {
  display: grid;
  gap: 2px;
  min-height: 68px;
  align-content: center;
  background: #fbfdff;
  padding: 12px 16px;
}

.pipeline-stats strong {
  color: var(--primary);
  font-size: 1.35rem;
  line-height: 1;
}

.pipeline-stats span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 650;
}

.status-message:not(:empty) {
  padding-block: 12px;
  border-bottom: 1px solid var(--border);
}

.editor-panel {
  overflow: auto;
}

.empty-state {
  display: grid;
  min-height: calc(100dvh - 148px);
  place-content: center;
  padding: 32px;
  text-align: center;
}

.empty-state p {
  max-width: 480px;
  margin: 12px auto 0;
  color: var(--muted);
}

.hidden {
  display: none;
}

.editor-heading {
  align-items: start;
}

.editor-heading h2 {
  max-width: 920px;
  font-size: 1.25rem;
}

.article-preview {
  margin: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfdff;
}

.article-preview > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.article-preview p {
  max-height: 210px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  color: #24364f;
}

.image-preview {
  margin: 14px 14px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #eef5ff;
  aspect-ratio: 16 / 9;
}

.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.no-image-message {
  margin: 0;
  padding: 14px;
  color: var(--muted);
  font-weight: 650;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 16px 16px;
}

.wide {
  grid-column: 1 / -1;
}

@media (max-width: 980px) {
  .app-header,
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: stretch;
  }

  .summary-list,
  .editor-panel {
    min-height: auto;
  }

  .summary-list-body {
    max-height: 48dvh;
  }

  .editor-panel {
    scroll-margin-top: 12px;
  }
}

@media (max-width: 680px) {
  .app-header {
    padding: 18px 14px;
  }

  .dashboard-shell {
    padding: 12px;
  }

  .connection-panel,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .section-header,
  .article-preview > div {
    align-items: stretch;
    flex-direction: column;
  }

  button {
    width: 100%;
  }

  .summary-list-body {
    max-height: 44dvh;
  }

  .editor-heading h2 {
    font-size: 1.1rem;
  }

  .article-preview {
    margin: 12px;
  }

  .form-grid {
    gap: 14px;
    padding: 0 12px 12px;
  }
}
