:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #5f6c7b;
  --accent: #b42318;
  --ok: #18794e;
  --warn: #b54708;
  --border: #d6e0ea;
  --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

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

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top right, #eaf1fb 0%, var(--bg) 50%);
  color: var(--text);
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.4rem, 2vw + 1rem, 2rem);
}

.status-wrap {
  text-align: right;
}

.status {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
}

.status.connected {
  background: #edfcf2;
  color: var(--ok);
  border-color: #98d8b3;
}

.status.connecting {
  background: #fff8eb;
  color: var(--warn);
  border-color: #f5d29c;
}

.status.disconnected {
  background: #fef3f2;
  color: var(--accent);
  border-color: #f7c3bf;
}

#refresh-time {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.1rem;
  min-width: 0;
  overflow-x: hidden;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  grid-template-areas: "controls headlines";
  gap: 1rem;
  align-items: start;
}

.headlines-panel {
  grid-area: headlines;
  min-width: 0;
}

.controls-panel {
  grid-area: controls;
  position: sticky;
  top: 1rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.panel-head span {
  font-size: 0.9rem;
  color: var(--muted);
}

.control-group {
  display: block;
  margin: 0 0 1rem;
}

.control-group h3 {
  margin: 0 0 0.25rem;
  font-size: 0.96rem;
}

.control-group h3 label {
  color: inherit;
}

.control-note {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.first-hand-group {
  border: 1px solid #b9d0f0;
  border-radius: 10px;
  padding: 0.75rem;
  background: linear-gradient(120deg, #edf5ff 0%, #f7fbff 100%);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: #123f75;
}

.toggle-row input {
  width: 1.1rem;
  height: 1.1rem;
}

.control-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--text);
  background: #fff;
}

.control-input:focus {
  border-color: #8db3ea;
  outline: 2px solid #b7cff0;
  outline-offset: 1px;
}

.feed-toggles {
  display: grid;
  gap: 0.45rem;
  max-height: 260px;
  overflow: auto;
  padding-right: 0.15rem;
}

.feed-toggle {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.9rem;
  color: #24313f;
  min-width: 0;
}

.feed-toggle input {
  margin-top: 0.2rem;
}

.feed-toggle span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.reset-button {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f2f6fb;
  color: #16365f;
  font: inherit;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
}

.reset-button:hover {
  background: #e7effa;
}

.error-banner {
  margin: 0 0 0.8rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid #f6c3be;
  border-radius: 8px;
  color: #932018;
  background: #fef2f1;
  font-size: 0.9rem;
}

.error-banner.hidden {
  display: none;
}

.news-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 0.9rem;
}

.headline {
  background: #fbfdff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  min-width: 0;
  animation: rise-in 180ms ease-out both;
}

.headline a {
  display: block;
  color: #0d3d7e;
  text-decoration: none;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.headline a:hover {
  text-decoration: underline;
}

.headline-badges {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.badge-source {
  background: #f1f6fe;
  color: #184f8f;
  border-color: #bfd5ef;
}

.badge-source[data-source-type="official"] {
  background: #eaf6ec;
  color: #195c31;
  border-color: #b5dfc2;
}

.badge-source[data-source-type="osint_social"] {
  background: #eef4ff;
  color: #234a8a;
  border-color: #c4d6f8;
}

.badge-source[data-source-type="sensor"] {
  background: #edf8fb;
  color: #1a6070;
  border-color: #b8dfe8;
}

.badge-source[data-source-type="wire"] {
  background: #f4f5f7;
  color: #495566;
  border-color: #cfd7e2;
}

.badge-trust {
  background: #fff8eb;
  color: #8b4a07;
  border-color: #efcc93;
}

.meta {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta span + span::before {
  content: "\2022";
  margin: 0 0.4rem;
}

@media (max-width: 760px) {
  .topbar {
    flex-direction: column;
  }

  .status-wrap {
    text-align: left;
  }
}

@media (max-width: 960px) {
  .dashboard {
    grid-template-columns: 1fr;
    grid-template-areas:
      "headlines"
      "controls";
    gap: 0.85rem;
  }

  .controls-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 1rem 0.65rem 1.5rem;
  }

  .panel {
    padding: 0.85rem;
    border-radius: 10px;
  }

  .headline {
    padding: 0.65rem 0.7rem;
  }

  .headline a {
    font-size: 0.98rem;
  }

  .meta {
    font-size: 0.8rem;
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
