:root {
  --bg: #f4efe6;
  --panel: #ffffff;
  --ink: #1d1f24;
  --muted: #656a76;
  --line: #d7d6d0;
  --primary: #0a5f8d;
  --primary-2: #157db6;
  --danger: #c23b22;
  --warning: #c38800;
  --ok: #1f8a55;
  --shadow: 0 10px 28px rgba(24, 28, 40, 0.11);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Source Sans 3", sans-serif;
  color: var(--ink);
  background: linear-gradient(140deg, #f7f2e7, #f0eee6 38%, #e9f0f1);
}

body.ar {
  font-family: "Cairo", "Source Sans 3", sans-serif;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(12, 12, 12, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 12, 12, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1360px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.topbar.compact {
  margin-bottom: 10px;
}

.brand {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.11em;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
}

h1 {
  margin: 3px 0 0;
  font-size: clamp(1.5rem, 2.5vw, 2.3rem);
  line-height: 1.1;
}

h2,
h3 {
  margin: 0;
}

.topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  background: #fff;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--ink);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--ink);
  color: #fff;
}

.ghost-btn,
.solid-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.ghost-btn {
  background: #fff;
  color: var(--ink);
}

.ghost-btn:hover {
  border-color: #969390;
}

.solid-btn {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.solid-btn:hover {
  background: var(--primary-2);
  border-color: var(--primary-2);
}

.ad-row {
  margin: 14px 0;
}

.ad-slot {
  border: 1px dashed #afadab;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6f7077;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  text-align: center;
  padding: 8px;
}

.ad-slot.small {
  min-height: 250px;
}

.ad-adsense {
  border: 1px dashed #afadab;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
}

.ad-adsense-top {
  min-height: 90px;
}

.ad-adsense-side {
  min-height: 250px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  padding: 10px;
}

.field-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.field-wrap span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.field-wrap select,
.field-wrap input,
.admin-form input,
.admin-form textarea,
.admin-form select,
.profile-modal input,
.profile-modal select {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 9px 10px;
  min-height: 40px;
  font-size: 14px;
  font-family: inherit;
}

.field-search {
  grid-column: span 2;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 11px;
  text-transform: capitalize;
  font-size: 13px;
  cursor: pointer;
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.layout {
  display: grid;
  grid-template-columns: 2fr minmax(320px, 1fr);
  gap: 12px;
  min-height: calc(100vh - 220px);
}

.map-panel,
.feed-panel,
.card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.feed-panel {
  display: flex;
  flex-direction: column;
}

.feed-head {
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}

.new-count-badge {
  display: none;
  border: 1px solid #f2b65e;
  background: #fff6df;
  color: #885300;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
}

.new-count-badge.show {
  display: inline-flex;
}

.ad-block {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.sources-panel {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #f8f8f5;
}

.sources-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sources-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.sources-head span {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.sources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 170px;
  overflow: auto;
}

.source-group-title {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

.source-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 6px;
  font-size: 12px;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.source-chip:hover {
  border-color: #9b9997;
}

.source-chip-label {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-rating {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  line-height: 1.1;
  font-family: "IBM Plex Mono", monospace;
  border: 1px solid transparent;
}

.source-type-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 10px;
  line-height: 1.1;
  font-family: "IBM Plex Mono", monospace;
  border: 1px solid #d3d8dd;
  background: #f4f7fa;
  color: #3a4a59;
}

.source-rating-high {
  background: #e8f7ef;
  color: #0a6b3a;
  border-color: #8fd5ad;
}

.source-rating-medium {
  background: #eff5ff;
  color: #1d4da6;
  border-color: #a5bde8;
}

.source-rating-caution {
  background: #fff5df;
  color: #915d00;
  border-color: #e8c47c;
}

.source-rating-low {
  background: #ffe8e8;
  color: #9f2626;
  border-color: #e7a2a2;
}

.feed-list {
  overflow: auto;
  padding: 10px;
  max-height: calc(100vh - 450px);
}

.feed-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  background: #fff;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.feed-item-new {
  border-color: #f2b65e;
  box-shadow: 0 0 0 1px rgba(242, 182, 94, 0.45), 0 10px 24px rgba(34, 33, 41, 0.1);
}

.feed-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(34, 33, 41, 0.11);
}

.feed-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.feed-head-tags {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.new-pill {
  border: 1px solid #f2b65e;
  background: #fff6df;
  color: #885300;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  text-transform: capitalize;
  font-family: "IBM Plex Mono", monospace;
  background: color-mix(in srgb, var(--tag) 15%, white);
  color: color-mix(in srgb, var(--tag) 70%, black);
}

.feed-item time {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: var(--muted);
}

.feed-item h3 {
  margin: 0 0 6px;
  font-size: 1.03rem;
  line-height: 1.3;
}

.feed-item p {
  margin: 0;
  color: #31333a;
}

.feed-foot {
  margin-top: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.source-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}

.feed-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.comments-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.comments-toggle {
  font-size: 12px;
}

.comments-panel {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 180px;
  overflow: auto;
}

.comment-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  background: #fcfcfc;
}

.comment-item-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}

.comment-item-head time {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.comment-item p {
  margin: 0;
  font-size: 13px;
  color: #2c2e35;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comment-form .comment-author,
.comment-form .comment-body {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 8px;
  font-size: 13px;
  font-family: inherit;
}

.comment-form .comment-body {
  min-height: 70px;
  resize: vertical;
}

.comment-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-submit {
  padding: 6px 10px;
  font-size: 12px;
}

.comment-status {
  min-height: 16px;
  font-size: 12px;
}

.link-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 5px 8px;
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
}

.link-btn:hover {
  border-color: #9f9e9b;
}

.custom-pin-wrap {
  border: 0;
  background: transparent;
}

.custom-pin {
  width: 18px;
  height: 18px;
  display: inline-block;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: var(--pin, var(--danger));
  border: 2px solid #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.custom-pin-new {
  box-shadow: 0 0 0 0 rgba(242, 182, 94, 0.75), 0 6px 16px rgba(0, 0, 0, 0.35);
  animation: pinPulse 1.6s ease-out infinite;
}

.live-notice {
  margin: 8px 10px 0;
  display: none;
  border: 1px solid #f2b65e;
  border-radius: 10px;
  background: #fff6df;
  color: #885300;
  padding: 8px 10px;
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
}

.live-notice.show {
  display: block;
}

@keyframes pinPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(242, 182, 94, 0.75), 0 6px 16px rgba(0, 0, 0, 0.35);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(242, 182, 94, 0), 0 6px 16px rgba(0, 0, 0, 0.35);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(242, 182, 94, 0), 0 6px 16px rgba(0, 0, 0, 0.35);
  }
}

.profile-modal {
  border: 1px solid var(--line);
  border-radius: 14px;
  width: min(520px, 92vw);
  padding: 0;
}

.profile-modal::backdrop {
  background: rgba(17, 20, 30, 0.42);
}

.profile-modal form {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-modal menu {
  margin: 6px 0 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.empty,
.status-inline {
  margin: 10px;
  color: var(--muted);
}

.popup h4 {
  margin: 0 0 6px;
}

.popup p {
  margin: 5px 0;
}

.admin-shell {
  max-width: 1120px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
}

.user-layout,
.sources-page-layout,
.about-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.form-actions-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.sources-page-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sources-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.summary-chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.summary-chip strong {
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
}

.summary-chip span {
  font-size: 15px;
  font-weight: 700;
}

.sources-class-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sources-page-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.source-catalog-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
}

.source-catalog-group h3 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.source-catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.source-catalog-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfcfc;
  padding: 8px;
}

.source-catalog-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.source-catalog-item a {
  color: var(--primary);
  word-break: break-all;
}

.about-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card {
  padding: 14px;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.admin-events {
  margin-top: 10px;
  max-height: 540px;
  overflow: auto;
}

.admin-sources {
  margin-top: 10px;
  max-height: 320px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-source-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #fff;
}

.admin-source-item a {
  color: var(--primary);
  text-decoration: none;
}

.admin-source-item a:hover {
  text-decoration: underline;
}

.admin-events-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px;
  margin-bottom: 8px;
}

.status-up {
  color: var(--ok);
}

.status-loading {
  color: var(--warning);
}

.status-error {
  color: var(--danger);
}

@media (max-width: 1140px) {
  .toolbar {
    grid-template-columns: 1fr 1fr 2fr 1fr;
  }

  .field-search {
    grid-column: span 2;
  }

  .chip-row {
    grid-column: span 3;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  #map {
    min-height: 460px;
  }

  .feed-list {
    max-height: 320px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .source-catalog-grid {
    grid-template-columns: 1fr;
  }

  .sources-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .field-search,
  .chip-row {
    grid-column: auto;
  }

  .ad-slot.small {
    min-height: 110px;
  }

  #map {
    min-height: 390px;
  }

  .form-grid-3 {
    grid-template-columns: 1fr;
  }
}

html[dir="rtl"] .topbar,
html[dir="rtl"] .feed-item-head,
html[dir="rtl"] .feed-foot,
html[dir="rtl"] .feed-actions,
html[dir="rtl"] .profile-modal menu {
  direction: rtl;
}
