:root {
  --ink: #17201c;
  --ink-2: #5a6862;
  --line: #dfe4e0;
  --bg: #f6f7f5;
  --card: #fff;
  --brand: #1f4d3d;
  --brand-2: #2f7a5f;
  --warn: #8a4b12;
  --bad: #9b2c2c;
  --radius: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", "Geeza Pro", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  font-size: 16px;
}

/* ---------- chrome ---------- */

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--brand);
  color: #fff;
}

.brand { display: flex; align-items: baseline; gap: 12px; }
.mark { font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.sub { font-size: 13px; opacity: .82; }

nav { display: flex; gap: 6px; }

.tab {
  font: inherit;
  font-size: 14px;
  color: #fff;
  background: rgba(255,255,255,.12);
  border: 0;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.tab.is-on { background: #fff; color: var(--brand); font-weight: 600; }

.alert {
  margin: 0;
  padding: 11px 22px;
  background: #fdf3e3;
  border-bottom: 1px solid #efd9b4;
  color: var(--warn);
  font-size: 14px;
}
.alert code { background: #fff; padding: 1px 6px; border-radius: 4px; }

.view {
  max-width: 1120px;
  margin: 22px auto;
  padding: 0 18px;
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
  display: flex;
  gap: 10px;
  align-items: baseline;
}
.panel h2 small { font-weight: 400; font-size: 13px; color: var(--ink-2); }

/* ---------- form ---------- */

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }

input, textarea, select {
  font: inherit;
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfdfc;
  color: var(--ink);
  font-weight: 400;
}
textarea { resize: vertical; line-height: 1.8; }
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--brand-2);
  outline-offset: 1px;
  border-color: transparent;
}

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 620px) { .row { grid-template-columns: 1fr; } }

.req { color: var(--bad); font-weight: 400; font-size: 12px; }

.types { border: 0; padding: 0; margin: 0 0 18px; }
.types legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 8px; }

.types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.types legend { grid-column: 1 / -1; }

.type { margin: 0; cursor: pointer; position: relative; }

/* The radio stays focusable but invisible; it must also stay 1px, or the
   `input { width: 100% }` rule above makes an absolutely positioned element
   as wide as the page and the whole layout overflows sideways. */
.type input {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}
.type-body {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #fdfdfc;
}
.type-body b { display: block; font-size: 14px; }
.type-body em { font-style: normal; font-size: 12px; color: var(--ink-2); }
.type input:checked + .type-body {
  border-color: var(--brand-2);
  background: #eef6f1;
  box-shadow: inset 0 0 0 1px var(--brand-2);
}
.type input:focus-visible + .type-body { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.go {
  font: inherit;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 11px 26px;
  border-radius: 8px;
  cursor: pointer;
}
.go:hover { background: var(--brand-2); }
.go:disabled { background: #b7c1bb; cursor: not-allowed; }

.ghost {
  font: inherit;
  font-size: 14px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
}
.ghost:hover { border-color: var(--brand-2); color: var(--brand); }

.stage { font-size: 13px; color: var(--ink-2); }
.stage.busy::before {
  content: "";
  display: inline-block;
  width: 11px; height: 11px;
  margin-left: 7px;
  border: 2px solid var(--line);
  border-top-color: var(--brand-2);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- output ---------- */

.out-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.out-bar h2 { margin: 0; }
.out-tools { display: flex; gap: 7px; }

.disclaimer {
  margin: 12px 0 18px;
  padding: 9px 13px;
  background: #fdf3e3;
  border-right: 3px solid #d9a441;
  border-radius: 6px;
  font-size: 13px;
  color: var(--warn);
}

.draft {
  font-size: 16.5px;
  line-height: 2.05;
  white-space: normal;
}
.draft h1, .draft h2, .draft h3 { line-height: 1.5; margin: 22px 0 10px; }
.draft h1 { font-size: 21px; text-align: center; }
.draft h2 { font-size: 18px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.draft h3 { font-size: 16px; }
.draft p { margin: 0 0 12px; }
.draft ul, .draft ol { margin: 0 0 12px; padding-inline-start: 26px; }
.draft li { margin-bottom: 6px; }
.draft hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.draft strong { font-weight: 700; }

.cite {
  font: inherit;
  font-size: .92em;
  background: #eef6f1;
  border: 1px solid #bcdccb;
  color: var(--brand);
  border-radius: 5px;
  padding: 0 6px;
  cursor: pointer;
  white-space: nowrap;
}
.cite:hover { background: #dcefe4; }
.cite.bad {
  background: #fdeaea;
  border-color: #eec2c2;
  color: var(--bad);
  cursor: help;
}

/* The model picker reuses the case-type cards but sits three across. */
.models { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }

.meter {
  margin-top: 22px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  font-size: 13px;
  color: var(--ink-2);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}
.meter b { color: var(--ink); font-weight: 600; }
.meter .mtd { margin-inline-start: auto; }

.cited { margin-top: 26px; }
.cited h3 { font-size: 15px; margin: 0 0 10px; }
.src {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 14px;
  margin-bottom: 9px;
  background: #fdfdfc;
}
.src .meta { font-size: 13px; color: var(--ink-2); margin-bottom: 5px; }
.src .meta b { color: var(--ink); }
.src .txt { font-size: 14.5px; line-height: 1.85; }
.src a { color: var(--brand-2); font-size: 12.5px; }

/* ---------- corpus ---------- */

#corpusOut:empty { display: none; }
.hit { border-bottom: 1px solid var(--line); padding: 13px 0; }
.hit:last-child { border-bottom: 0; }
.hit .meta { font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.hit .meta b { color: var(--ink); }
.hit .txt { font-size: 15px; }
.empty { color: var(--ink-2); font-size: 14px; }

/* ---------- misc ---------- */

dialog {
  max-width: 640px;
  width: calc(100% - 40px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  line-height: 1.9;
}
dialog::backdrop { background: rgba(23,32,28,.45); }
dialog button { font: inherit; margin-top: 14px; }

.foot {
  max-width: 1120px;
  margin: 10px auto 40px;
  padding: 0 18px;
  font-size: 12.5px;
  color: var(--ink-2);
}

@media print {
  .top, nav, .foot, .alert, #brief, .out-tools, .disclaimer, .cited { display: none !important; }
  body { background: #fff; }
  .panel { border: 0; padding: 0; }
  .cite { border: 0; background: none; color: inherit; padding: 0; }
}

/* ---- optional-field hint, and the lawyer's note ---- */
.opt { color: var(--ink-2); font-weight: 400; font-size: 12px; }
.help {
  display: block;
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
  font-weight: 400;
}

/* ---- superseded texts ----
 * Repeal is inferred from later instruments (tools/fetch_corpus.py), never
 * published by qanoon.om, so this reads as "check this", not "this is dead".
 */
.cite.stale {
  background: #fdf4e3;
  border-color: #e8d3a4;
  color: #8a6100;
}
.cite.stale:hover { background: #f8e9cc; }
.stale {
  font-size: 12px;
  color: #8a6100;
  background: #fdf4e3;
  border: 1px solid #e8d3a4;
  border-radius: 4px;
  padding: 0 5px;
  white-space: nowrap;
}

/* ---- law matches above the article hits ---- */
.lawhits { display: flex; flex-direction: column; gap: 6px; margin-bottom: 22px; }
.lawhit {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 9px 12px;
  border: 1px solid var(--line, #dde3e6);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
}
.lawhit:hover { background: #f4f8f6; }
.lawhit span { font-size: 12px; color: var(--ink-2); }

/* ---- signed-in identity in the header ---- */
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who__name { opacity: .9; }
.who form { margin: 0; }
.linkish {
  font: inherit;
  background: none;
  border: 0;
  color: #fff;
  opacity: .8;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
}
.linkish:hover { opacity: 1; }

/* ---- login ---- */
.login-page { background: var(--bg); }
.login { max-width: 420px; margin: 8vh auto; padding: 0 18px; }
.login__brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 20px;
  color: var(--brand);
  text-align: center;
}
.login__brand .sub { color: var(--ink-2); opacity: 1; }
.login__form h2 { margin-top: 0; }
.login__form .actions { margin-top: 18px; }
.login__form .go { width: 100%; }
.login__foot {
  margin-top: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-2);
}
