:root {
  --bg: #060b16;
  --panel: rgba(10, 18, 36, 0.92);
  --panel-2: rgba(8, 15, 30, 0.88);
  --text: #e8eefb;
  --muted: #9faed0;
  --line: rgba(110, 138, 191, 0.24);
  --accent: #4da3ff;
  --accent-2: #2f79f5;
  --danger: #ff7a7a;
  --warn: #f7d06a;
  --ok: #7ee39f;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(45, 91, 180, 0.22), transparent 26%),
    radial-gradient(circle at top right, rgba(31, 144, 113, 0.14), transparent 22%),
    var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
a { color: #8ec5ff; }

button, .button-like {
  background: rgba(24, 39, 76, 0.88);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.72rem 0.95rem;
  cursor: pointer;
  text-align: center;
}

button.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border: none;
  color: white;
}

.button-like { display: inline-block; }

input, select {
  background: rgba(7, 13, 26, 0.92);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.72rem 0.82rem;
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 360px;
  grid-template-rows: auto 1fr;
  height: 100vh;
  gap: 1rem;
  padding: 1rem;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-actions {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar h1 {
  margin: 0;
  font-size: 1.8rem;
}

.subtle { color: var(--muted); }
.tiny { font-size: 0.82rem; }
.no-gap { margin: 0; }
.badge {
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  background: rgba(255, 255, 255, 0.03);
  white-space: nowrap;
}

.sidebar, .map-panel, .timeline-panel { min-height: 0; }
.left-panel, .right-panel, .map-panel, .timeline-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.left-panel,
.right-panel {
  overflow: auto;
  padding-right: 0.15rem;
}

.main-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 320px;
  gap: 1rem;
}

.panel-block {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
  min-height: 0;
  backdrop-filter: blur(8px);
}

.compact-panel { padding: 0.9rem 1rem; }
.no-pad { padding: 0; overflow: hidden; }
.panel-block h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.compact-header {
  align-items: flex-start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.small-gap { gap: 0.55rem; }
.grow { flex: 1; }
.grow-section { min-height: 260px; }
.section-card { overflow: hidden; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.summary-pill {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
  background: rgba(255,255,255,0.03);
}

.summary-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
}

.summary-pill strong {
  display: block;
  font-size: 1rem;
}

.field span {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow: auto;
  min-height: 0;
}

.short-list { max-height: 220px; }

.feed-row, .toggle-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.feed-row {
  justify-content: space-between;
  padding: 0.72rem 0.78rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
}

.feed-row .feed-main {
  min-width: 0;
}

.feed-row .feed-title {
  font-size: 0.92rem;
  line-height: 1.25;
  margin-bottom: 0.18rem;
}

.feed-row .meta {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.35;
}

.feed-row .feed-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.42rem;
}

.tag-mini {
  font-size: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.14rem 0.42rem;
  color: var(--muted);
}

.feed-error { border-color: rgba(255, 122, 122, 0.5); }
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.toggle-chip {
  border: 1px solid var(--line);
  padding: 0.46rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  background: rgba(9, 18, 34, 0.9);
}

.toggle-chip input { width: auto; }
.wide-chip { justify-content: flex-start; width: 100%; }

.map-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.95rem 1rem 0.85rem;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(11, 19, 38, 0.96), rgba(11, 19, 38, 0.72));
}

.toolbar-title { font-weight: 700; }
.toolbar-subtle { color: var(--muted); font-size: 0.85rem; }
.toolbar-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.mini-pill {
  font-size: 0.78rem;
  color: #dce8ff;
  background: rgba(77, 163, 255, 0.12);
  border: 1px solid rgba(77, 163, 255, 0.28);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 0.8rem 1rem 1rem;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.map-legend i {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.legend-outline {
  border: 1px solid var(--warn);
  background: transparent;
}

.event-list, .headline-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: auto;
}

.event-item, .headline-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.03);
}

.event-item { cursor: pointer; }
.event-item.active {
  border-color: rgba(77, 163, 255, 0.75);
  box-shadow: 0 0 0 1px rgba(77, 163, 255, 0.35) inset;
}

.event-topline, .event-meta, .headline-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.event-title, .headline-title {
  display: block;
  margin: 0.4rem 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.event-summary, .headline-summary {
  margin: 0 0 0.55rem;
  color: #d8dff5;
  line-height: 1.45;
}

.details-empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.02);
}

.details-card h3 { margin-top: 0; }
.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.cell {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem;
  background: rgba(255, 255, 255, 0.03);
}

.source-links {
  margin-bottom: 1rem;
  word-break: break-word;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.9rem;
  max-height: 260px;
  overflow: auto;
}

.is-hidden { display: none; }

.leaflet-control-zoom a {
  background: rgba(12, 19, 34, 0.9);
  color: var(--text);
  border-bottom-color: var(--line);
}

@media (max-width: 1500px) {
  .app-shell {
    grid-template-columns: 320px minmax(0, 1fr) 330px;
  }
}

@media (max-width: 1320px) {
  .app-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    height: auto;
  }

  .left-panel, .main-panel, .right-panel {
    grid-column: 1;
  }

  .main-panel {
    grid-template-rows: 460px 320px;
  }

  .right-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    justify-content: stretch;
  }

  .field-grid,
  .summary-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }
}


.left-summary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
}

.summary-grid-wide {
  margin-bottom: 0.8rem;
}

.left-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.mini-action {
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  font-size: 0.84rem;
}

.left-tabs-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.left-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.left-tab {
  padding: 0.6rem 0.4rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  color: var(--muted);
}

.left-tab.is-active {
  background: rgba(77, 163, 255, 0.16);
  color: var(--text);
  border-color: rgba(77, 163, 255, 0.45);
}

.tab-panel {
  display: none;
  min-height: 0;
  flex: 1;
}

.tab-panel.is-active {
  display: flex;
  flex-direction: column;
}

.tall-list {
  flex: 1;
  min-height: 0;
}

.left-panel .panel-block {
  overflow: hidden;
}

.feed-row {
  align-items: flex-start;
}

.feed-row input[type="checkbox"] {
  margin-top: 0.2rem;
}

@media (max-width: 1360px) {
  .app-shell {
    grid-template-columns: 310px minmax(0, 1fr) 340px;
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    grid-column: 1;
  }

  .left-panel, .right-panel, .main-panel {
    overflow: visible;
  }

  .main-panel {
    grid-template-rows: 520px 320px;
  }
}


.feed-group {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.025);
  overflow: hidden;
}

.feed-group + .feed-group {
  margin-top: 0.7rem;
}

.feed-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--line);
}

.feed-group-title {
  font-size: 0.88rem;
  font-weight: 700;
  text-transform: capitalize;
}

.feed-group-meta {
  font-size: 0.74rem;
  color: var(--muted);
}

.feed-group-body {
  display: flex;
  flex-direction: column;
}

.feed-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  padding: 0.72rem 0.85rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.feed-group .feed-row:last-child {
  border-bottom: 0;
}

.feed-title {
  font-size: 0.9rem;
  line-height: 1.25;
}

.meta {
  margin-top: 0.16rem;
  line-height: 1.35;
}

.feed-tags {
  margin-top: 0.32rem;
}

.left-panel {
  background: linear-gradient(180deg, rgba(9,18,36,0.94) 0%, rgba(7,14,27,0.95) 100%);
}

.left-summary .summary-pill strong {
  font-size: 1rem;
}

.left-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(10,18,36,0.98) 0%, rgba(10,18,36,0.92) 100%);
  padding-bottom: 0.2rem;
}

.tab-panel {
  overflow: auto;
  padding-right: 0.1rem;
}

#headlineList .headline-item {
  border-left: 3px solid rgba(83,212,176,0.45);
}

.section-card {
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
