:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #637083;
  --line: #d8dee8;
  --panel: #f7f8fa;
  --accent: #11615c;
  --accent-dark: #0b4643;
  --sky: #28a8e0;
  --sky-dark: #0877bf;
  --sky-light: #9ed8f2;
  --danger: #9f1d25;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #ffffff;
}

img,
ins {
  max-width: 100%;
}

a {
  color: var(--accent);
}

.site-header {
  border-bottom: 1px solid #b9d8e8;
  background: #fff;
}

.sky-band {
  position: relative;
  height: 78px;
  overflow: hidden;
  border-top: 4px solid #e7f5fb;
  background:
    radial-gradient(110% 120% at 70% -10%, rgba(255, 255, 255, 0.38) 0 36%, rgba(255, 255, 255, 0) 37%),
    linear-gradient(180deg, #0a76bd 0%, var(--sky) 62%, #43b8e8 100%);
}

.sky-band::after {
  position: absolute;
  right: -8%;
  bottom: -62px;
  width: 72%;
  height: 126px;
  content: "";
  border-radius: 55% 0 0 0 / 100% 0 0 0;
  background: linear-gradient(135deg, rgba(205, 239, 253, 0.7), rgba(255, 255, 255, 0.1));
}

.header-main {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.25rem;
  width: min(1180px, calc(100% - 2rem));
  min-height: 112px;
  margin: 0 auto;
  padding: 1rem 0;
}

.brand-identity {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1.15rem;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.brand-logo {
  width: clamp(76px, 8vw, 104px);
  height: auto;
}

.brand-copy {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.brand {
  color: #2a2a2a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.7rem);
  font-weight: 700;
  line-height: 0.95;
  text-decoration: none;
}

.brand-tagline {
  color: #747474;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  line-height: 1.2;
}

.site-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.site-nav a {
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  color: #075386;
  font-weight: 650;
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a:focus-visible {
  color: #fff;
  background: linear-gradient(180deg, var(--sky), var(--sky-dark));
}

.page {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.page-wide {
  width: min(1280px, calc(100% - 2rem));
}

.site-footer {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto 2rem;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 240px) auto;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.search-intro h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.25;
}

input,
button {
  font: inherit;
}

input[type="search"],
input[type="text"],
input[type="number"],
input[type="password"],
input[type="file"],
select {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  resize: vertical;
}

button {
  min-height: 2.75rem;
  padding: 0.65rem 1rem;
  border: 0;
  border-radius: 6px;
  color: #fff;
  background: var(--accent);
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.25rem;
}

.layout.has-right-ad {
  grid-template-columns: 260px minmax(0, 1fr) minmax(160px, 220px);
}

.facets,
.right-ad {
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  align-self: start;
}

.facets h2,
.results h2,
.admin-panel h1,
.auth-form h1 {
  margin-top: 0;
}

.facets ul {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.facets li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #e8ecf1;
}

.active-filter,
.results-meta,
.muted {
  color: var(--muted);
}

.clear-filter {
  display: inline-block;
  margin-top: 0.25rem;
}

.results-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  background: var(--panel);
  font-weight: 700;
}

.arabic {
  text-align: right;
  font-size: 1.08rem;
  line-height: 1.7;
}

.arabic-column {
  text-align: right;
}

.search-hit {
  padding: 0 0.1em;
  border-radius: 2px;
  background: #ffe66d;
}

.empty {
  text-align: center;
  color: var(--muted);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.notice {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: #eef8f6;
}

.error {
  color: var(--danger);
  background: #fff0f1;
}

.auth-form,
.admin-panel,
.prose {
  max-width: 760px;
}

.auth-form,
.admin-panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-panel-wide {
  max-width: 1100px;
}

.term-search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 220px) auto;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.term-edit-form label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.term-delete-form {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #7b151c;
}

.password-section {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.auth-form label,
.import-form label,
.settings-form label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.admin-shell {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 1.25rem;
}

.admin-nav {
  display: grid;
  gap: 0.75rem;
  align-self: start;
}

.admin-nav form {
  margin: 0;
}

.summary {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--panel);
  border-radius: 8px;
}

.ad-slot {
  display: block;
  margin: 1rem 0;
}

.ad-slot-leaderboard {
  min-height: 90px;
}

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

.right-ad .ad-slot-side,
.facets .ad-slot-side {
  width: 100%;
}

.ad-slot-footer {
  min-height: 90px;
}

@media (max-width: 1279px) {
  .layout.has-right-ad {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .right-ad {
    display: none;
  }
}

@media (max-width: 800px) {
  .layout,
  .layout.has-right-ad,
  .admin-shell,
  .search-form {
    grid-template-columns: 1fr;
  }

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

  .sky-band {
    height: 54px;
  }

  .header-main {
    align-items: flex-start;
    min-height: auto;
    padding: 1rem 0;
    flex-direction: column;
  }

  .brand-identity {
    width: 100%;
  }

  .brand-logo {
    width: 72px;
  }

  .site-nav {
    justify-content: flex-start;
  }

  .ad-slot-left,
  .right-ad {
    display: none;
  }

  .facets,
  .right-ad,
  .admin-panel,
  .auth-form {
    padding: 0.875rem;
  }
}

@media (max-width: 520px) {
  .page,
  .site-footer {
    width: min(100% - 1rem, 1180px);
  }

  th,
  td {
    padding: 0.6rem;
  }

  table {
    min-width: 640px;
  }

  .brand-identity {
    gap: 0.75rem;
  }

  .brand {
    font-size: 1.85rem;
  }

  .brand-tagline {
    font-size: 0.95rem;
  }

  .site-nav a {
    padding: 0.45rem 0.55rem;
  }
}
