:root {
  --bg: #f3efe4;
  --panel: #fff9ed;
  --ink: #1d2f2b;
  --muted: #596a66;
  --brand: #1f4b44;
  --brand-soft: #2f6e63;
  --accent: #b57f3d;
  --edge: #d8c8a8;
  --shadow: 0 12px 32px rgba(31, 75, 68, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Cairo", "Noto Sans Arabic", "Segoe UI", sans-serif;
}

a {
  color: var(--brand);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 8% 10%, rgba(181, 127, 61, 0.18), transparent 36%),
    radial-gradient(circle at 90% 15%, rgba(31, 75, 68, 0.12), transparent 40%),
    linear-gradient(180deg, #f7f3e9 0%, #f0e9da 100%);
}

.reveal {
  animation: rise 420ms ease both;
}

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

.site-header,
.topic-header {
  width: min(1080px, calc(100% - 2rem));
  margin: 2rem auto 1rem;
  padding: 1.25rem;
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 250, 241, 0.92), rgba(247, 238, 220, 0.96));
  box-shadow: var(--shadow);
}

.brand-block h1,
.topic-header h1 {
  margin: 0.2rem 0 0.5rem;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.kicker {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  color: var(--brand-soft);
}

.subhead,
.topic-seo-title {
  margin: 0.25rem 0 0.75rem;
  color: var(--muted);
  line-height: 1.7;
}

.search-block label {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--brand);
  font-weight: 700;
}

.search-row {
  display: flex;
  gap: 0.65rem;
}

.search-row input,
.chat-row input {
  flex: 1;
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  background: #fff;
}

.search-row button,
.chat-row button {
  border: 0;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  padding: 0.75rem 1.1rem;
  cursor: pointer;
}

.layout {
  width: min(1080px, calc(100% - 2rem));
  margin: 1rem auto;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
}

.topic-layout {
  width: min(1080px, calc(100% - 2rem));
  margin: 1rem auto;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.panel h2,
.panel h3 {
  margin: 0 0 0.55rem;
}

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

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

.timeline-list {
  display: grid;
  gap: 0.6rem;
}

.timeline-item {
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  display: grid;
  gap: 0.25rem;
}

.timeline-item small {
  color: var(--muted);
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}

.topic-card {
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 0.9rem;
  display: grid;
  gap: 0.45rem;
}

.topic-card h3 {
  margin: 0;
  font-size: 1rem;
}

.topic-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.topic-card .meta {
  font-size: 0.86rem;
  color: var(--brand-soft);
}

.topic-meta {
  list-style: none;
  margin: 0.6rem 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.topic-byline {
  margin: 0.6rem 0 0;
  color: var(--brand);
  font-weight: 700;
}

.topic-body p {
  line-height: 1.9;
  margin: 0 0 0.8rem;
}

.internal-link {
  color: var(--brand);
  font-weight: 700;
}

.topic-claims,
.topic-related,
.topic-references {
  margin: 0;
  padding-inline-start: 1.1rem;
  display: grid;
  gap: 0.45rem;
}

.topic-references li {
  line-height: 1.6;
}

.site-footer {
  width: min(1080px, calc(100% - 2rem));
  margin: 1.2rem auto 2.1rem;
  padding: 0.9rem 1rem;
  border: 1px dashed var(--edge);
  border-radius: 12px;
  text-align: center;
  color: var(--brand);
  background: rgba(255, 249, 237, 0.72);
}

.chat-toggle {
  position: fixed;
  inset-inline-end: 1rem;
  bottom: 1rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-soft));
  color: #fff;
  padding: 0.75rem 1rem;
  box-shadow: 0 10px 24px rgba(31, 75, 68, 0.35);
  cursor: pointer;
}

.chat-panel {
  position: fixed;
  inset-inline-end: 1rem;
  bottom: 4.4rem;
  width: min(410px, calc(100% - 2rem));
  max-height: min(540px, 75vh);
  display: none;
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 16px;
  padding: 0.8rem;
  box-shadow: var(--shadow);
}

.chat-panel[aria-hidden="false"] {
  display: block;
}

.chat-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-panel header h3 {
  margin: 0;
  font-size: 1rem;
}

.chat-panel header button {
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
}

.chat-note {
  color: var(--muted);
  line-height: 1.65;
  margin: 0.5rem 0;
}

.chat-turnstile {
  min-height: 1px;
  margin-bottom: 0.5rem;
}

.chat-row {
  display: flex;
  gap: 0.5rem;
}

.chat-output {
  margin-top: 0.65rem;
  max-height: 300px;
  overflow: auto;
  display: grid;
  gap: 0.45rem;
}

.chat-result {
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
}

.chat-result a {
  font-weight: 700;
}

.back-link {
  font-size: 0.9rem;
  font-weight: 700;
}

@media (max-width: 880px) {
  .layout,
  .topic-layout {
    grid-template-columns: 1fr;
  }

  .search-row,
  .chat-row {
    flex-direction: column;
  }
}

