@import url("https://fonts.googleapis.com/css2?family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,600;0,6..72,700;1,6..72,400&family=Source+Sans+3:ital,wght@0,400;0,500;0,600;1,400&display=swap");

:root {
  /* Surfaces & brand (preserve off-white + dark green) */
  --bg: #f4f5f2;
  --surface: #fffefb;
  --text: #1a1d23;
  --muted: #5c6578;
  --muted-2: #7a8496;
  --border: #e0e4dc;
  --accent: #2d6a4f;
  --accent-hover: #1b4332;
  --accent-soft: color-mix(in srgb, var(--accent) 12%, var(--surface));
  --danger: #9b2226;
  --danger-hover: #660708;

  /* Typography */
  --font-heading: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-emoji: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
  --fw-heading: 600;
  --fw-body: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --lh-body: 1.55;
  --lh-heading: 1.22;
  --fs-page-title: clamp(1.45rem, 2.5vw, 1.75rem);
  --fs-section: 1.05rem;
  --fs-ui: 0.9375rem;
  --fs-meta: 0.8125rem;
  --fs-meta-sm: 0.75rem;
  --ls-brand: 0.02em;

  /* Layout & depth */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --shadow-nav: 0 1px 0 rgba(45, 106, 79, 0.08), 0 8px 24px rgba(26, 29, 35, 0.06);
  --shadow-card: 0 1px 2px rgba(26, 29, 35, 0.04), 0 4px 14px rgba(26, 29, 35, 0.06);
  --shadow-card-hover: 0 2px 4px rgba(26, 29, 35, 0.05), 0 8px 22px rgba(26, 29, 35, 0.08);
  --space-page-top: 0.35rem;
  --space-section: 1.5rem;
  --space-after-nav: 1.75rem;
  /* Canonical layout breakpoint: 768px (matches primary media queries below). */
  --layout-sidebar-w: 15.75rem;

  /* Nav strip & operational hint */
  --nav-border: color-mix(in srgb, var(--accent) 22%, var(--border));
  --hint-bg: color-mix(in srgb, var(--accent-soft) 55%, var(--bg));
  --hint-border: color-mix(in srgb, var(--accent) 28%, var(--border));
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: var(--fw-body);
  font-size: var(--fs-ui);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 72rem;
  margin: 0 auto;
  padding: var(--space-after-nav) 1.5rem 3rem;
}

.wrap.wrap--wide {
  max-width: 76rem;
}

.wrap.wrap--channels {
  max-width: 96rem;
}

header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--nav-border);
  box-shadow: var(--shadow-nav);
  margin-bottom: 1.5rem;
}

header.site .inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.85rem 1.5rem 0.9rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1.25rem;
}

header.site .site-fetch-hint {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.65rem 1.5rem 0.85rem;
  font-size: var(--fs-meta);
  line-height: 1.45;
  color: var(--text);
  font-family: var(--font-body);
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  background: var(--hint-bg);
  border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

header.site .site-fetch-hint::before {
  content: "";
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.08rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232d6a4f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E");
  background-size: 70%;
  background-position: center;
  background-repeat: no-repeat;
}

header.site .site-fetch-hint strong {
  font-weight: var(--fw-semibold);
  color: var(--accent-hover);
}

header.site .site-fetch-hint a {
  font-weight: var(--fw-medium);
}

header.site .site-fetch-hint-backfill {
  border-left: 3px solid var(--accent);
  padding-left: 0.5rem;
  margin-left: 0;
}

header.site .site-fetch-hint-catchup {
  border-left: 3px solid #2d9d78;
  padding-left: 0.5rem;
  margin-left: 0;
}

.telethon-mode-form {
  margin-top: 0.75rem;
  overflow: visible;
}

.telethon-mode-radial {
  position: relative;
  display: flex;
  justify-content: stretch;
  align-items: stretch;
  gap: 0.65rem;
  padding: 2.25rem 0.5rem 0.5rem;
  max-width: 48rem;
  overflow: visible;
  min-height: 6.5rem;
}

.telethon-mode-radial-arc {
  position: absolute;
  top: 0.55rem;
  left: 4%;
  right: 4%;
  height: 3.5rem;
  border: 2px solid var(--border);
  border-bottom: none;
  border-radius: 999px 999px 0 0;
  pointer-events: none;
  opacity: 0.55;
  box-sizing: border-box;
}

/* Card-style segment: same shell for every option so layout stays even */
.telethon-mode-seg {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
  cursor: pointer;
  position: relative;
  z-index: 1;
  padding: 0.65rem 0.45rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06);
  min-height: 5.75rem;
  justify-content: flex-start;
  user-select: none;
  transition:
    border-color 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease,
    transform 0.08s ease;
}

.telethon-mode-seg:active {
  transform: scale(0.985);
}

.telethon-mode-seg:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.telethon-mode-seg--active,
.telethon-mode-seg:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--surface) 75%, var(--accent) 25%);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 50%, transparent),
    0 2px 8px rgba(0, 0, 0, 0.08);
}

.telethon-mode-seg--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (hover: hover) {
  .telethon-mode-seg:hover {
    border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
    background: color-mix(in srgb, var(--surface) 88%, var(--accent) 12%);
  }

  .telethon-mode-seg--disabled:hover {
    border-color: var(--border);
    background: var(--surface);
    transform: none;
  }
}

/* Stretch native control over the whole card so the entire tile is clickable */
.telethon-mode-seg input[type="radio"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.telethon-mode-seg-dot {
  position: relative;
  z-index: 1;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 2px solid var(--muted);
  background: var(--surface);
  margin-top: 0.1rem;
  flex-shrink: 0;
  transition:
    border-color 0.12s ease,
    background 0.12s ease,
    box-shadow 0.12s ease;
}

.telethon-mode-seg--active .telethon-mode-seg-dot,
.telethon-mode-seg:has(input:checked) .telethon-mode-seg-dot {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 35%, var(--surface));
  box-shadow:
    inset 0 0 0 2px var(--surface),
    0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

.telethon-mode-seg-title {
  position: relative;
  z-index: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.telethon-mode-seg-desc {
  position: relative;
  z-index: 1;
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.3;
}

.telethon-mode-actions {
  margin-top: 0.75rem;
}

header.site h1 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  font-optical-sizing: auto;
  letter-spacing: var(--ls-brand);
  line-height: var(--lh-heading);
}

header.site h1 a {
  color: var(--accent-hover);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

nav.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.15rem;
  font-size: var(--fs-meta);
  font-family: var(--font-body);
  font-weight: var(--fw-medium);
  align-items: center;
}

nav.site-nav a {
  color: var(--muted);
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition:
    color 0.12s ease,
    background 0.12s ease;
}

nav.site-nav .btn-ghost {
  font-size: var(--fs-meta-sm);
}

nav.site-nav .meta {
  font-size: var(--fs-meta-sm);
  padding: 0.2rem 0.45rem;
}

@media (hover: hover) {
  header.site h1 a:hover {
    color: var(--accent);
    border-bottom-color: color-mix(in srgb, var(--accent) 45%, transparent);
    text-decoration: none;
  }

  nav.site-nav a:hover {
    color: var(--accent-hover);
    background: var(--accent-soft);
    text-decoration: none;
  }
}

/* --- App shell: mobile (<768px) vs desktop (>=768px); templates unchanged --- */

@media (max-width: 767px) {
  .wrap {
    padding-left: clamp(1rem, 4vw, 1.5rem);
    padding-right: clamp(1rem, 4vw, 1.5rem);
    padding-bottom: 2.5rem;
  }

  .panel {
    padding: 1rem 1.05rem 1.15rem;
  }

  /* App chrome (non–public landing): larger tap targets, full-width row nav. */
  header.site:not(.site--public) nav.site-nav {
    width: 100%;
    row-gap: 0.25rem;
  }

  header.site:not(.site--public) nav.site-nav a,
  header.site:not(.site--public) nav.site-nav .btn-ghost {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
  }

  header.site:not(.site--public) nav.site-nav .inline-form {
    display: flex;
    width: 100%;
    margin-top: 0.15rem;
  }

  header.site:not(.site--public) nav.site-nav .inline-form .btn-ghost {
    flex: 1;
    justify-content: center;
    min-height: 2.75rem;
  }

  .auth-form-stack .btn-primary,
  .auth-form-stack input[type="text"],
  .auth-form-stack input[type="password"] {
    min-height: 2.75rem;
  }

  /* Public marketing header: stack for thumb reach on narrow viewports. */
  header.site.site--public .inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem 0;
    padding-left: clamp(1rem, 4vw, 1.5rem);
    padding-right: clamp(1rem, 4vw, 1.5rem);
  }

  header.site.site--public nav.site-nav {
    width: 100%;
    max-width: 100%;
  }

  .site-nav-tagline {
    max-width: 100%;
    min-width: 0;
  }

  header.site.site--public {
    overflow-x: clip;
  }

  header.site.site--public nav.site-nav a {
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.85rem;
  }

  .tl-buckets {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  /* Signed-in / app chrome: fixed left sidebar, main content to the right. */
  body:has(> header.site:not(.site--public)) {
    padding-left: var(--layout-sidebar-w);
  }

  header.site:not(.site--public) {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--layout-sidebar-w);
    margin-bottom: 0;
    border-bottom: none;
    border-right: 1px solid var(--nav-border);
    box-shadow: 4px 0 22px rgba(26, 29, 35, 0.06);
    z-index: 50;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  header.site:not(.site--public) .inner {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    max-width: none;
    margin: 0;
    padding: 1.1rem 1rem 1rem;
    gap: 0.6rem;
  }

  header.site:not(.site--public) h1 {
    font-size: 1.2rem;
    padding-bottom: 0.45rem;
    margin-bottom: 0.15rem;
    border-bottom: 1px solid var(--border);
  }

  header.site:not(.site--public) nav.site-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.06rem;
    font-size: var(--fs-ui);
  }

  header.site:not(.site--public) nav.site-nav a,
  header.site:not(.site--public) nav.site-nav .btn-ghost {
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-md);
  }

  header.site:not(.site--public) nav.site-nav .meta {
    padding: 0.35rem 0.55rem;
    margin-top: 0.15rem;
    color: var(--muted);
  }

  header.site:not(.site--public) nav.site-nav .inline-form {
    display: block;
    width: 100%;
    margin-top: 0.15rem;
  }

  header.site:not(.site--public) nav.site-nav .inline-form .btn-ghost {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  header.site:not(.site--public) .site-fetch-hint {
    flex-shrink: 0;
    max-width: none;
    margin: 0;
    padding: 0.6rem 0.85rem 0.75rem;
    font-size: var(--fs-meta-sm);
    line-height: 1.4;
    border-top: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
    border-left: none;
    margin-left: 0;
    padding-left: 0.85rem;
  }

  header.site:not(.site--public) .site-fetch-hint-backfill,
  header.site:not(.site--public) .site-fetch-hint-catchup {
    border-left: none;
    padding-left: 0.85rem;
    border-top: 3px solid var(--accent);
  }

  header.site:not(.site--public) .site-fetch-hint-catchup {
    border-top-color: #2d9d78;
  }

  /* “Contact” / request-access: use width on desktop. */
  section#request-access {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 2rem;
    align-items: start;
  }

  section#request-access > .landing-section-title {
    grid-column: 1 / -1;
    margin-bottom: 0.35rem;
  }

  section#request-access > .landing-hero-cta {
    grid-column: 1 / -1;
    margin-top: 0.35rem;
  }

  .about-text {
    max-width: none;
    column-count: 2;
    column-gap: 2rem;
    column-fill: balance;
  }

  .about-text .about-heading {
    column-span: all;
    margin-bottom: 0.85rem;
  }

  .about-text p {
    break-inside: avoid;
  }
}

/* Page title: first h2 in main content area */
.wrap > h2 {
  margin: var(--space-page-top) 0 var(--space-section);
  font-family: var(--font-heading);
  font-size: var(--fs-page-title);
  font-weight: var(--fw-heading);
  font-optical-sizing: auto;
  line-height: var(--lh-heading);
  color: var(--accent-hover);
  letter-spacing: 0.01em;
}

.wrap:has(#analysis-form) > h2 {
  text-align: center;
}

/* In-panel section titles (h3/h4) */
.panel h3,
.panel h4,
.top-channel-title {
  font-family: var(--font-heading);
  font-optical-sizing: auto;
}

h2 {
  margin: 0 0 0.75rem;
  font-family: var(--font-heading);
  font-size: var(--fs-section);
  font-weight: var(--fw-heading);
  font-optical-sizing: auto;
  color: var(--accent-hover);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem 1.35rem;
  margin-bottom: 1.35rem;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

.about-text {
  max-width: 52rem;
  line-height: 1.65;
  border-top: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding-top: 1.15rem;
}

.about-text .about-heading {
  margin: 0 0 0.75rem;
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: var(--fw-heading);
  font-optical-sizing: auto;
  color: var(--accent-hover);
}

.about-text p {
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

.about-text p:last-child {
  margin-bottom: 0;
}

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

.inline-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.admin-pw-reset summary::-webkit-details-marker {
  display: none;
}

.meta {
  font-size: var(--fs-meta);
  color: var(--muted-2);
  font-weight: var(--fw-body);
  line-height: 1.4;
}

/* Secondary metadata (counts, pipeline status) */
.post-meta-row > .meta,
.top-posts-sub,
.post-media-note,
.channel-handle {
  font-size: var(--fs-meta-sm);
  color: var(--muted-2);
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  opacity: 1;
  transition: opacity 220ms ease;
}

.flash.is-hiding {
  opacity: 0;
}

.flash.info {
  background: #e8f4ea;
  border: 1px solid #b7e1c0;
  color: #1b4332;
}

.flash.error {
  background: #fde8e8;
  border: 1px solid #f5c2c7;
  color: #660708;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="date"],
textarea,
select {
  width: 100%;
  max-width: 22rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: inherit;
  background: var(--surface);
  transition:
    border-color 0.14s ease,
    box-shadow 0.14s ease;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  outline-offset: 1px;
}

@media (hover: hover) {
  input[type="text"]:hover,
  input[type="date"]:hover,
  textarea:hover,
  select:hover {
    border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
  }
}

textarea {
  resize: vertical;
  min-height: 5.5rem;
}

textarea.grok-transcript-input {
  max-width: 100%;
  min-height: 14rem;
  font-family: ui-monospace, monospace;
  font-size: 0.9rem;
}

.grok-import-results h3 {
  margin-top: 0;
}

.grok-import-summary {
  margin: 0.5rem 0 0;
  line-height: 1.5;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.btn {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: var(--fs-meta);
  font-weight: var(--fw-medium);
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background 0.14s ease,
    color 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease,
    transform 0.08s ease;
}

.btn:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 2px;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: color-mix(in srgb, var(--accent-hover) 35%, var(--accent));
}

.btn-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--border);
}

.btn-ghost {
  background: var(--surface);
  color: var(--muted);
  border-color: var(--border);
}

@media (hover: hover) {
  .btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
  }

  .btn-danger:hover {
    background: #fff5f5;
    border-color: var(--danger);
    color: var(--danger-hover);
  }

  .btn-ghost:hover {
    color: var(--accent-hover);
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border));
    background: var(--accent-soft);
  }

  .btn-arabic-toggle:hover {
    background: color-mix(in srgb, var(--accent) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
    color: var(--accent-hover);
  }

  .panel:has(.top-posts-grid) > .toolbar .toolbar-form a.btn-ghost:hover {
    background: color-mix(in srgb, var(--accent) 8%, var(--surface));
    color: var(--accent-hover);
    border-color: transparent;
  }

  .panel:has(.top-posts-grid) > .toolbar .toolbar-form a.btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 22%, var(--surface));
    color: var(--accent-hover);
  }

  .top-posts-link:hover .top-posts-snippet {
    color: var(--accent);
  }

  .top-posts-link:hover .top-posts-engagement {
    color: var(--accent);
  }

  .top-channel-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
  }

  .digest-rich a.digest-source:hover {
    color: var(--accent-hover);
  }

  .analysis-query-row input[type="text"]:hover {
    border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  }

  .analysis-web-secondary .analysis-list a:hover {
    color: var(--accent);
  }

  .analysis-map-search-input:hover {
    border-color: color-mix(in srgb, var(--accent) 38%, var(--border));
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.post-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.post-list li {
  border-bottom: none;
  padding: 0;
}

.post-list li:last-child {
  border-bottom: none;
}

/* Log tail / other simple post-list rows (not channel feed cards) */
.post-list > li.recent-log-line {
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
}

.post-list > li.recent-log-line:last-child {
  border-bottom: none;
}

.post-item {
  padding: 1rem 1.05rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.65) inset;
}

.post-item:last-child {
  margin-bottom: 0;
}

.recent-log-lines .recent-log-line code {
  white-space: pre-wrap;
  word-break: break-word;
}

.recent-log-flood-label {
  color: var(--danger);
}

.recent-log-line--flood_wait {
  border-left: 3px solid var(--danger);
  padding-left: 0.6rem;
  margin-left: -0.1rem;
}

.recent-log-line--flood_wait code {
  color: var(--danger);
  font-weight: 600;
}

.post-body {
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.98rem;
  line-height: var(--lh-body);
  color: var(--text);
}

/* English body only (`p.post-body`); Arabic block is a `div`. */
.post-item p.post-body {
  margin-top: 0.85rem;
}

.post-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.85rem;
}

.post-item .post-meta-row {
  margin-bottom: 0.2rem;
}

.post-item .post-meta-row .btn-arabic-toggle {
  margin-left: 0.5rem;
  flex-shrink: 0;
}

.btn-arabic-toggle {
  padding: 0.32rem 0.65rem;
  font-size: var(--fs-meta-sm);
  line-height: 1.25;
  font-weight: var(--fw-semibold);
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  color: var(--accent-hover);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}

.post-body-ar {
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #f9fbfe;
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

.post-media-block {
  margin: 0.5rem 0 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid #c5d4e8;
  border-radius: 6px;
  background: #f3f6fb;
  font-size: 0.92rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.post-media-label {
  font-weight: 600;
  color: #3d4a5c;
  margin-right: 0.35rem;
}

.post-media-text {
  color: #1a1d23;
}

.post-media-note {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
  color: #5c6578;
}

.post-media-note.post-media-pending {
  font-style: italic;
}

.digest-body {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.1rem 1.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.toolbar-fetch {
  align-self: flex-end;
  margin-bottom: 0.2rem;
}

.toolbar-form label {
  margin-bottom: 0.25rem;
}

.toolbar-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.4rem;
  align-items: flex-end;
}

.toolbar-form > div {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.toolbar-form > div > div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.5rem;
}

.toolbar-right {
  margin-left: auto;
  align-self: flex-end;
  display: inline-flex;
  align-items: flex-end;
  text-align: right;
}

.toolbar .btn,
.toolbar select {
  height: 2.1rem;
}

/* Top Posts — filter / sort as segmented control (not heavy pill buttons) */
.panel:has(.top-posts-grid) > .toolbar {
  margin-bottom: 1rem;
  padding-bottom: 1.15rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 85%, var(--accent));
}

.panel:has(.top-posts-grid) > .toolbar .toolbar-form > div > span.meta {
  display: block;
  font-size: var(--fs-meta-sm);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 0.35rem;
}

.panel:has(.top-posts-grid) > .toolbar .toolbar-form a.btn {
  border-radius: var(--radius-sm);
  border-bottom: 2px solid transparent;
  height: auto;
  min-height: 2.1rem;
  padding: 0.4rem 0.75rem;
}

.panel:has(.top-posts-grid) > .toolbar .toolbar-form a.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: var(--fw-medium);
}

.panel:has(.top-posts-grid) > .toolbar .toolbar-form a.btn-primary {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  color: var(--accent-hover);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  border-bottom: 2px solid var(--accent);
  font-weight: var(--fw-semibold);
  box-shadow: none;
}

.panel:has(.top-posts-grid) > p.meta {
  margin-top: 0.25rem;
  font-size: var(--fs-meta-sm);
  color: var(--muted-2);
}

.toolbar-group-pill {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  cursor: default;
  height: 2.1rem;
}

.channel-heading {
  margin: 0 0 1.35rem;
  padding: 1rem 1.1rem 1.1rem;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 9%, var(--surface)) 0%,
    var(--surface) 55%
  );
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

.channel-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 2.2vw, 1.65rem);
  font-weight: 700;
  font-optical-sizing: auto;
  line-height: 1.2;
  color: var(--accent-hover);
  letter-spacing: 0.01em;
}

.channel-handle {
  margin: 0.35rem 0 0;
  font-size: var(--fs-meta);
}

.channel-title-cell {
  font-weight: 600;
  max-width: 18rem;
}

.post-item.post-highlight {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent),
    var(--shadow-card);
}

.digest-rich {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.38;
  padding: 0.35rem 0;
}

.digest-rich strong {
  font-weight: 700;
  display: block;
  margin: 0.35rem 0 0.12rem;
}

.digest-rich strong:first-child {
  margin-top: 0;
}

.digest-rich ul,
.digest-rich ol {
  margin: 0.5em 0;
  padding-left: 1.35em;
  white-space: normal;
}

.digest-rich li {
  margin: 0.35em 0;
  white-space: normal;
}

.digest-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.digest-controls .digest-toolbar {
  margin-bottom: 0;
}

.digest-rich a.digest-source {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.channel-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) min(22rem, 32vw);
  gap: 2rem;
  align-items: start;
}

@media (max-width: 767px) {
  .channel-split {
    grid-template-columns: 1fr;
  }
}

.channel-posts-main {
  min-width: 0;
}

.top-posts-box {
  border: 1px solid color-mix(in srgb, var(--accent) 15%, var(--border));
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.2rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, var(--surface));
  position: sticky;
  top: 0.75rem;
  box-shadow: var(--shadow-card);
}

.top-posts-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: var(--fw-heading);
  font-optical-sizing: auto;
  color: var(--accent-hover);
}

.top-posts-sub {
  margin: 0 0 1rem;
  line-height: 1.45;
}

.top-posts-list {
  margin: 0;
  padding-left: 1.15rem;
}

.top-posts-item {
  margin-bottom: 0.9rem;
}

.top-posts-item:last-child {
  margin-bottom: 0;
}

.top-posts-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.top-posts-engagement {
  display: block;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: var(--fw-semibold);
  font-variant-numeric: tabular-nums;
  color: var(--accent-hover);
  margin-bottom: 0.35rem;
  letter-spacing: 0.01em;
}

.top-posts-item .top-posts-engagement {
  font-feature-settings: "tnum" 1;
}

.top-posts-snippet {
  font-size: 0.88rem;
  line-height: 1.4;
  word-break: break-word;
}

.top-posts-snippet em {
  font-style: normal;
  font-size: var(--fs-meta-sm);
  color: var(--muted-2);
}

.top-posts-snippet-media {
  color: var(--muted);
  word-break: break-word;
}

.top-posts-no-text {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
}

.top-posts-empty {
  font-size: 0.88rem;
  margin: 0 0 0.25rem;
}

.top-posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  gap: 1rem;
}

.top-channel-card {
  border: 1px solid color-mix(in srgb, var(--border) 92%, var(--accent));
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem 1.1rem;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition:
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    transform 0.12s ease;
}

.top-channel-title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: var(--fw-heading);
  color: var(--accent-hover);
}

.top-channel-handle {
  margin: 0.2rem 0 0.65rem;
  font-size: var(--fs-meta-sm);
  color: var(--muted-2);
}

.top-posts-fallback-note {
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--muted, #5c6578);
  background: #eef1f5;
  border-radius: 6px;
  border-left: 3px solid #c5cad4;
}

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.45rem;
  margin: 0.4rem 0 0.15rem;
}

.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: #eef0f4;
  border-radius: 999px;
  padding: 0.12rem 0.42rem 0.12rem 0.35rem;
  border: 1px solid var(--border);
}

.reaction-emoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
  font-size: 1.2rem;
  line-height: 1;
  font-style: normal;
}

.reaction-chip-custom .reaction-custom-glyph {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1;
}

.reaction-chip .rx-count {
  font-size: 0.72rem;
  font-family: var(--font-body);
  color: var(--muted);
  font-weight: var(--fw-semibold);
  min-width: 0.85rem;
}

.inline-form {
  display: inline;
}

.inline-form button {
  margin: 0;
}

.drag-col {
  width: 2rem;
  text-align: center;
  color: var(--muted);
}

.drag-handle {
  cursor: grab;
  user-select: none;
  font-size: 1rem;
  line-height: 1;
}

tr.dragging {
  opacity: 0.55;
}

.channel-table {
  table-layout: auto;
  min-width: 78rem;
}

.channel-table input[type="text"],
.channel-table textarea,
.channel-table select {
  max-width: none;
}

.channel-table td.meta {
  white-space: nowrap;
}

.channel-table td:last-child {
  white-space: nowrap;
}

.channel-table td:last-child .inline-form {
  margin-right: 0.28rem;
}

.channel-table td:last-child .inline-form:last-child {
  margin-right: 0;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-scroll--y {
  /* Keep large tables readable; ~10 rows visible then scroll. */
  max-height: 520px;
  overflow-y: auto;
}

.table-scroll--y thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}

/* Server Status — Telethon lock timeline */
.tl-wrap {
  margin-top: 0.35rem;
}

.tl-buckets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem 0.3rem;
  align-items: end;
}

.tl-bucket {
  text-align: center;
  min-width: 0;
}

.tl-bar {
  position: relative;
  height: 30px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.tl-seg {
  position: absolute;
  top: 0;
  height: 100%;
  min-width: 1px;
  box-sizing: border-box;
}

.tl-idle {
  background: #e8eaef;
  z-index: 0;
}

.tl-hold {
  z-index: 1;
  border-radius: 1px;
  background: #5c6578;
}

.tl-hold--fetch-periodic {
  background: #2d6a4f;
}

.tl-hold--fetch-startup {
  background: #40916c;
}

.tl-hold--fetch-manual {
  background: #1b4332;
}

.tl-hold--fetch-tab-channels,
.tl-hold--fetch-tab-posts,
.tl-hold--fetch-tab-top-posts {
  background: #52b788;
}

.tl-hold--fetch-channel_add {
  background: #52796f;
}

.tl-hold--fetch-posts_refresh_one,
.tl-hold--fetch-posts_refresh_all {
  background: #74c69d;
}

.tl-hold--backfill-web_manual {
  background: #bc6c25;
}

.tl-hold--backfill-web_scheduled {
  background: #dda15e;
}

.tl-hold--backfill-web_new_channel {
  background: #e76f51;
}

.tl-hold--media-scheduled {
  background: #457b9d;
}

.tl-bucket-label {
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.2;
  word-break: break-word;
}

.tl-bucket-pct {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 1px;
}

.tl-legend {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1rem;
  font-size: 0.8125rem;
  color: var(--muted);
}

.tl-swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 2px;
  vertical-align: -0.1em;
  margin-right: 5px;
}

.tl-swatch-idle {
  background: #e8eaef;
  border: 1px solid var(--border);
}

.tl-active {
  border-left: 3px solid var(--accent);
  padding-left: 0.5rem;
}

.institutional-upload-form label {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.02rem;
  font-weight: var(--fw-heading);
  color: var(--accent-hover);
  margin-top: 1rem;
  margin-bottom: 0.4rem;
}

.institutional-upload-form label:first-of-type {
  margin-top: 0;
}

.institutional-upload-form input[type="text"],
.institutional-upload-form textarea {
  width: 100%;
  max-width: 40rem;
  box-sizing: border-box;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
}

.institutional-upload-form textarea {
  min-height: 5.5rem;
  resize: vertical;
}

.institutional-upload-form input[type="file"] {
  margin-top: 0.25rem;
}

.institutional-upload-form .btn-primary {
  margin-top: 1.1rem;
}

#analysis-form > p.meta {
  margin-top: 0.9rem;
  max-width: 46rem;
}

#analysis-form label {
  font-family: var(--font-heading);
  font-size: 1.08rem;
  font-weight: var(--fw-heading);
  font-optical-sizing: auto;
  color: var(--accent-hover);
  margin-bottom: 0.55rem;
  letter-spacing: 0.01em;
}

.analysis-query-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: stretch;
  margin-top: 0.15rem;
}

.analysis-query-row input[type="text"] {
  max-width: none;
  flex: 1 1 28rem;
  min-height: 3.35rem;
  padding: 0.7rem 1rem;
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.35;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  box-shadow: inset 0 1px 2px rgba(26, 29, 35, 0.04);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.analysis-query-row input[type="text"]:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 42%, transparent);
  outline-offset: 1px;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
}

.analysis-query-row .btn-primary {
  min-height: 3.35rem;
  padding: 0.65rem 1.4rem;
  font-size: var(--fs-ui);
  font-weight: var(--fw-semibold);
  align-self: stretch;
}

/* `hidden` must win over flex layout (author CSS otherwise overrides UA display:none). */
.analysis-loading[hidden] {
  display: none !important;
}

.analysis-loading:not([hidden]) {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  color: var(--text);
  font-size: var(--fs-meta);
  font-weight: var(--fw-medium);
  padding: 1rem 1.15rem;
  border-radius: var(--radius-md);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--accent) 10%, var(--surface)),
    var(--surface)
  );
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border));
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  animation: analysis-strip-pulse 2s ease-in-out infinite;
}

.analysis-loading:not([hidden])::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 45%;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--accent) 70%, transparent),
    var(--accent)
  );
  animation: analysis-progress-shimmer 1.8s ease-in-out infinite;
}

@keyframes analysis-strip-pulse {
  0%,
  100% {
    box-shadow: var(--shadow-card);
  }
  50% {
    box-shadow:
      0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent),
      var(--shadow-card-hover);
  }
}

@keyframes analysis-progress-shimmer {
  0% {
    transform: translateX(-100%);
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateX(320%);
    opacity: 0.5;
  }
}

.analysis-loading:not([hidden]) .analysis-spinner {
  width: 1.2rem;
  height: 1.2rem;
  border: 2px solid color-mix(in srgb, var(--accent) 25%, var(--border));
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: analysis-spin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes analysis-spin {
  to {
    transform: rotate(360deg);
  }
}

.analysis-response {
  white-space: normal;
  line-height: 1.45;
  max-height: none;
  overflow: visible;
  text-overflow: clip;
  word-break: break-word;
}

.analysis-response h1,
.analysis-response h2,
.analysis-response h3 {
  margin: 0.75rem 0 0.35rem;
  font-size: 1rem;
}

.analysis-response p {
  margin: 0.4rem 0;
}

.analysis-list {
  margin: 0.6rem 0 0;
  padding-left: 1.1rem;
}

.analysis-list li {
  margin: 0.3rem 0;
  word-break: break-word;
}

.analysis-bibliography {
  margin-top: 0.25rem;
}

.analysis-bibliography-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0 0 1rem;
}

.analysis-bibliography-heading {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.analysis-bibliography-intro {
  margin: 0 0 0.75rem;
}

.analysis-bibliography-list {
  margin: 0;
  padding-left: 1.35rem;
}

.analysis-bibliography-item {
  margin: 0.45rem 0;
  line-height: 1.45;
  word-break: break-word;
}

.analysis-bibliography-link {
  font-weight: var(--fw-semibold);
}

.analysis-bibliography-nolink {
  font-weight: var(--fw-semibold);
}

.analysis-section-title {
  font-family: var(--font-heading);
  font-optical-sizing: auto;
  font-size: 1.12rem;
  font-weight: var(--fw-heading);
  margin: 0 0 0.5rem;
  color: var(--accent-hover);
}

.analysis-answer-panel {
  border-left: 4px solid var(--accent);
  padding-left: 1.2rem;
  margin-left: 0;
  box-shadow: var(--shadow-card);
}

.analysis-answer-panel .analysis-section-title {
  font-size: 1.38rem;
  margin-bottom: 0.65rem;
  letter-spacing: 0.01em;
}

.analysis-answer-panel .analysis-response {
  font-size: 1.02rem;
  line-height: 1.58;
}

.analysis-corpus {
  border-top: 1px solid color-mix(in srgb, var(--accent) 12%, var(--border));
  padding-top: 0.25rem;
}

.analysis-corpus .analysis-section-title {
  font-size: 1.15rem;
}

.analysis-bibliography-meta {
  font-size: var(--fs-meta-sm);
  color: var(--muted-2);
}

.analysis-excerpt {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: var(--fs-meta);
  line-height: 1.5;
  padding-left: 0.35rem;
  border-left: 2px solid var(--border);
}

.analysis-web-secondary {
  background: color-mix(in srgb, var(--bg) 65%, var(--surface));
  border: 1px dashed color-mix(in srgb, var(--muted) 28%, var(--border));
}

.analysis-web-secondary .analysis-section-title {
  color: var(--muted);
  font-weight: var(--fw-semibold);
  font-size: 1rem;
}

.analysis-web-secondary .analysis-list a {
  font-size: var(--fs-meta);
  color: var(--muted);
}

.analysis-meta-line {
  margin-top: 0.75rem;
}

/* —— Query Analysis: Leaflet geographic reference —— */
.analysis-map-panel {
  margin-top: 0.25rem;
}

.analysis-map-intro {
  max-width: 52rem;
  margin-bottom: 0.85rem;
}

.analysis-map-search {
  margin-bottom: 0.5rem;
}

.analysis-map-search-label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: var(--fw-semibold);
  font-optical-sizing: auto;
  color: var(--accent-hover);
  margin-bottom: 0.4rem;
}

.analysis-map-search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: stretch;
}

.analysis-map-search-input {
  flex: 1 1 18rem;
  min-width: 0;
  min-height: 2.55rem;
  padding: 0.55rem 0.85rem;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--radius-md);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: var(--fs-ui);
  box-shadow: inset 0 1px 2px rgba(26, 29, 35, 0.04);
  transition:
    border-color 0.14s ease,
    box-shadow 0.14s ease;
}

.analysis-map-search-input:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 42%, transparent);
  outline-offset: 1px;
}

.analysis-map-search-row .btn-primary {
  min-height: 2.55rem;
  padding: 0.55rem 1.15rem;
  font-weight: var(--fw-semibold);
}

.analysis-map-msg {
  font-size: var(--fs-meta-sm);
  margin: 0.4rem 0 0.1rem;
  min-height: 1.3em;
  color: var(--muted-2);
}

.analysis-map-msg.is-error {
  color: var(--danger);
  font-weight: var(--fw-medium);
}

.analysis-map {
  height: 480px;
  min-height: 480px;
  width: 100%;
  margin-top: 0.35rem;
  border-radius: var(--radius-md);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  overflow: hidden;
  background: color-mix(in srgb, var(--border) 35%, var(--surface));
  z-index: 0;
}

/* Same element gets .leaflet-container; beat any theme/global rules so Leaflet always has a box. */
.analysis-map.leaflet-container {
  height: 480px;
  min-height: 480px;
  width: 100%;
}

.analysis-map .leaflet-container {
  font-family: var(--font-body);
  height: 100%;
  width: 100%;
}

.analysis-map .leaflet-control-attribution {
  font-size: 0.65rem;
  max-width: 100%;
  white-space: normal;
  line-height: 1.25;
}

.analysis-map-popup-sub {
  margin-top: 0.25rem;
  font-size: var(--fs-meta-sm);
  color: var(--muted);
  line-height: 1.35;
}

.telegram-reauth-export {
  margin-top: 0.5rem;
}

.telegram-reauth-textarea {
  display: block;
  width: 100%;
  max-width: 48rem;
  margin: 0.5rem 0 0.65rem;
  padding: 0.65rem 0.85rem;
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.35;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: var(--radius-md);
  background: var(--surface);
  resize: vertical;
  min-height: 5rem;
}

/* Server Status — live worker + operational tables */
.panel--live-worker {
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
}

.live-worker-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.live-worker-header h3 {
  margin: 0;
}

.live-worker-pill {
  font-size: var(--fs-meta-sm);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  white-space: nowrap;
}

.status-banner {
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.65rem;
  font-size: 0.92rem;
  line-height: 1.4;
}

.status-banner--danger {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  color: var(--text);
}

.status-banner--danger a {
  color: var(--danger);
  font-weight: 600;
}

.live-worker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
  gap: 0.85rem 1.25rem;
}

.live-worker-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  background: var(--surface);
}

.live-worker-card h4 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.live-worker-card p {
  margin: 0.35rem 0;
  font-size: 0.88rem;
  line-height: 1.45;
}

.live-worker-pre {
  margin: 0.35rem 0 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 10rem;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--border) 35%, var(--surface));
  border: 1px solid var(--border);
}

.subhead-fetch-log {
  margin: 1rem 0 0.4rem;
  font-size: 0.92rem;
  font-weight: 600;
}

.table-compact td,
.table-compact th {
  font-size: 0.84rem;
  padding: 0.35rem 0.5rem;
}

.td-error {
  color: color-mix(in srgb, var(--danger) 55%, var(--text));
  font-size: 0.8rem;
  max-width: 28rem;
  word-break: break-word;
}

.row-recent {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.row-running {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.row-pending {
  background: color-mix(in srgb, var(--border) 40%, var(--surface));
}

.sortable-th {
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}

/* --- Public landing (/) --- */
.site--public .inner {
  border-bottom: none;
}

.site-nav-tagline {
  font-size: var(--fs-meta);
  color: var(--muted);
  font-family: var(--font-body);
  font-style: italic;
  max-width: 18rem;
  line-height: 1.35;
}

.wrap.wrap--landing {
  max-width: 54rem;
  padding-top: 0.5rem;
}

.landing {
  font-family: var(--font-body);
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 2rem 2.5rem;
  align-items: start;
  padding-bottom: 2.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--nav-border);
}

.landing-kicker {
  font-size: var(--fs-meta);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 0.35rem;
}

.landing-title {
  font-family: var(--font-heading);
  font-weight: var(--fw-heading);
  font-size: clamp(2.4rem, 5vw, 3.25rem);
  line-height: var(--lh-heading);
  color: var(--accent-hover);
  margin: 0 0 0.5rem;
  letter-spacing: var(--ls-brand);
}

.landing-tagline {
  font-family: var(--font-heading);
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 600;
  color: var(--text);
  margin: 0 0 1rem;
  line-height: 1.35;
}

.landing-lede {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text);
  max-width: 38rem;
}

.landing-hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin-top: 1.25rem;
}

.landing-hero-cta--single {
  margin-bottom: 0.35rem;
}

.landing-cta-note {
  margin: 0.35rem 0 0;
  font-size: var(--fs-meta);
  color: var(--muted);
  max-width: 32rem;
  line-height: 1.45;
}

.landing-cta-note a {
  font-weight: var(--fw-medium);
}

.landing-cta.btn-primary {
  padding: 0.55rem 1.35rem;
  font-size: 1rem;
}

.landing-cta-secondary {
  border-color: var(--border);
}

.landing-hero-map {
  position: relative;
  margin: 0;
  padding: 0.5rem;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  box-shadow: var(--shadow-card);
}

.landing-syria-map {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(56vh, 26rem);
}

.landing-syria-map .syria-reg {
  stroke: var(--surface);
  stroke-width: 1.35;
  stroke-linejoin: round;
}

.landing-syria-map .syria-reg--0 {
  fill: color-mix(in srgb, var(--accent) 38%, var(--surface));
}

.landing-syria-map .syria-reg--1 {
  fill: color-mix(in srgb, var(--accent) 52%, var(--surface));
}

.landing-syria-map .syria-reg--2 {
  fill: color-mix(in srgb, var(--accent) 44%, var(--surface));
}

.landing-syria-map .syria-reg--3 {
  fill: color-mix(in srgb, var(--accent) 58%, var(--surface));
}

.landing-syria-map .syria-reg--4 {
  fill: color-mix(in srgb, var(--accent) 48%, var(--surface));
}

.landing-syria-map .syria-reg--5 {
  fill: color-mix(in srgb, var(--accent) 62%, var(--surface));
}

.landing-syria-map .syria-reg--6 {
  fill: color-mix(in srgb, var(--accent) 42%, var(--surface));
}

.landing-syria-map .syria-reg--7 {
  fill: color-mix(in srgb, var(--accent) 55%, var(--surface));
}

.landing-syria-map .syria-reg--8 {
  fill: color-mix(in srgb, var(--accent) 66%, var(--surface));
}

.landing-syria-outline {
  stroke: var(--accent-hover);
  stroke-width: 2.25;
  stroke-linejoin: round;
  pointer-events: none;
}

.landing-map-note,
.landing-hero-map figcaption {
  margin: 0.45rem 0 0;
  font-size: var(--fs-meta-sm);
  color: var(--muted-2);
  line-height: 1.35;
}

.landing-section {
  padding: 2.25rem 0;
  border-bottom: 1px solid var(--border);
}

.landing-section:last-of-type {
  border-bottom: none;
}

.landing-section-title {
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 2.4vw, 1.6rem);
  font-weight: var(--fw-heading);
  color: var(--accent-hover);
  margin: 0 0 1rem;
  letter-spacing: var(--ls-brand);
}

.landing-prose {
  margin: 0 0 1rem;
  font-size: 1.02rem;
  line-height: 1.65;
  max-width: 44rem;
  color: var(--text);
}

.landing-taxonomy {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.65rem 1.25rem;
}

@media (min-width: 768px) {
  .landing-taxonomy {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.landing-taxonomy li {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent-soft) 40%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 12%, var(--border));
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
}

.landing-tax {
  display: block;
  font-weight: var(--fw-semibold);
  color: var(--accent-hover);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  margin-bottom: 0.2rem;
}

.landing-steps {
  margin: 0;
  padding-left: 1.35rem;
  max-width: 44rem;
}

.landing-steps li {
  margin-bottom: 1rem;
  padding-left: 0.25rem;
  font-size: 1.02rem;
  line-height: 1.6;
  color: var(--text);
}

.landing-steps strong {
  color: var(--accent-hover);
  font-weight: var(--fw-semibold);
}

.landing-audience {
  display: grid;
  gap: 1rem;
}

@media (min-width: 768px) {
  .landing-audience {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.landing-audience-card {
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(45, 106, 79, 0.06);
}

.landing-audience-card h4 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  margin: 0 0 0.45rem;
  color: var(--accent-hover);
}

.landing-audience-card p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
}

.landing-corpus {
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--accent) 14%, var(--border));
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
  margin: 1rem 0 0;
}

.landing-corpus-title {
  margin-bottom: 1.25rem;
}

.landing-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 1.5rem;
  margin: 0;
}

@media (min-width: 768px) {
  .landing-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.landing-stats div {
  margin: 0;
}

.landing-stats dt {
  font-size: var(--fs-meta);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.landing-stats dd {
  margin: 0;
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 3vw, 1.85rem);
  font-weight: 700;
  color: var(--accent-hover);
  line-height: 1.1;
}

.landing-corpus-updated {
  margin: 1rem 0 0;
  font-size: var(--fs-meta);
  color: var(--muted-2);
  max-width: 40rem;
}

.landing-corpus-foot {
  margin: 0.65rem 0 0;
  font-size: var(--fs-meta);
  color: var(--muted);
  max-width: 40rem;
}

.landing-closer .landing-prose:last-of-type {
  margin-bottom: 1.25rem;
}

@media (max-width: 767px) {
  .landing {
    min-width: 0;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-left: 0;
    padding-right: 0;
  }

  .landing-hero-copy {
    min-width: 0;
    width: 100%;
  }

  /* DOM order: copy first, map below (readable mobile stack). */
  .landing-hero-map {
    max-width: min(100%, 22rem);
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  .landing-syria-map {
    max-height: min(50vw + 6rem, 18rem);
  }

  .landing-lede {
    max-width: none;
  }
}

/* --- Landing: small phones (≈360px–430px) — desktop rules above unchanged --- */
@media (max-width: 26.875rem) {
  .wrap.wrap--landing {
    padding-left: clamp(1rem, 5vw, 1.5rem);
    padding-right: clamp(1rem, 5vw, 1.5rem);
    overflow-x: clip;
  }

  .landing-section {
    padding-top: 1.75rem;
    padding-bottom: 1.75rem;
  }

  .landing-title {
    font-size: clamp(1.65rem, 9vw, 2.4rem);
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .landing-tagline {
    font-size: clamp(1rem, 4.2vw, 1.2rem);
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .landing-section-title {
    font-size: clamp(1.15rem, 4.5vw, 1.45rem);
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .landing-prose,
  .landing-steps li {
    font-size: 0.98rem;
  }

  .landing-corpus {
    padding: 1.35rem clamp(0.85rem, 4vw, 1.25rem);
    margin-left: 0;
    margin-right: 0;
  }

  .landing-stats {
    grid-template-columns: 1fr;
    gap: 1rem 0;
  }

  .landing-stats dd {
    font-size: clamp(1.35rem, 6.5vw, 1.65rem);
  }

  .landing-hero-cta {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
  }

  .wrap.wrap--landing .landing-cta.btn-primary,
  .wrap.wrap--landing .landing-hero-cta .landing-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .landing-audience-card h4 {
    font-size: 1rem;
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  .landing-taxonomy li {
    font-size: 0.92rem;
  }
}
