:root {
  --bg: oklch(0.985 0.002 30);
  --panel: oklch(0.965 0.004 30);
  --hover: oklch(0.945 0.006 30);
  --selected: oklch(0.948 0.006 60);
  --line: oklch(0.89 0.006 30);
  --ink: oklch(0.22 0.012 30);
  --muted: oklch(0.45 0.012 30);
  --rubric: oklch(0.48 0.15 30);
  --rubric-ink: oklch(0.42 0.14 30);
  --mark: oklch(0.9 0.06 75);
  --focus: oklch(0.55 0.16 250);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --serif: "Noto Serif", Georgia, serif;
  --naskh: "Noto Naskh Arabic", "Geeza Pro", "Scheherazade New", serif;
  --header-h: 60px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 15px/1.5 var(--sans); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--rubric-ink); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top { height: var(--header-h); display: flex; align-items: center; gap: 28px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--bg); }
.brand { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.brand .ar { font-family: var(--naskh); font-weight: 400; font-size: 19px; color: var(--rubric); }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab { position: relative; height: 100%; padding: 0 12px; white-space: nowrap; border: 0; background: none; font: inherit; color: var(--muted); cursor: pointer; transition: color 150ms ease; }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 600; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--rubric); }
@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--ink); } }

.panel[hidden] { display: none; }

#panel-search { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; height: calc(100vh - var(--header-h)); }
.side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--bg); }
.searchbar { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.field { position: relative; }
.field svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
#q { width: 100%; height: 44px; padding: 0 40px 0 38px; font: 16px var(--sans); color: var(--ink); border: 1px solid oklch(0.82 0.008 30); border-radius: 8px; background: #fff; transition: border-color 150ms ease, box-shadow 150ms ease; }
#q::placeholder { color: oklch(0.5 0.01 30); }
#q:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px oklch(0.55 0.16 250 / 0.18); }
#q::-webkit-search-cancel-button { display: none; }
.kbd { position: absolute; right: 10px; top: 50%; translate: 0 -50%; min-width: 22px; padding: 1px 6px; font: 12px var(--sans); color: var(--muted); text-align: center; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); }
.meta-line { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; font-size: 13px; color: var(--muted); }

#results { flex: 1; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.hit { border-bottom: 1px solid var(--line); }
.hit-head { display: block; width: 100%; padding: 14px 20px; text-align: left; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; transition: background-color 150ms ease; }
@media (hover: hover) and (pointer: fine) { .hit-head:hover { background: var(--hover); } }
.hit-head:active { background: var(--selected); }
.hit[aria-current="true"] .hit-head { background: var(--selected); }
.hit[aria-current="true"] .snip-ar, .hit[aria-current="true"] .snip-la, .hit[aria-current="true"] .tag { display: none; }
.hit-title { margin: 0; font-size: 15px; font-weight: 620; text-wrap: balance; }
.hit-sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.snip-ar { margin-top: 8px; font: 19px/1.7 var(--naskh); direction: rtl; text-align: right; }
.snip-la { margin-top: 2px; font: 15px/1.55 var(--serif); }
.tag { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--rubric-ink); }
.tag.ok { color: oklch(0.4 0.1 150); }
.hit-title { display: block; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

.detail { padding: 4px 20px 18px; background: var(--selected); }
.status { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 10px; padding: 2px 8px; font-size: 12px; color: var(--rubric-ink); border: 1px solid oklch(0.48 0.15 30 / 0.35); border-radius: 999px; background: #fff; }
.status.ok { color: oklch(0.4 0.1 150); border-color: oklch(0.45 0.1 150 / 0.4); }
.lines { margin: 0; padding: 0; list-style: none; counter-reset: line; }
.lines li { display: grid; grid-template-columns: 22px 1fr; column-gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); counter-increment: line; }
.lines li::before { content: counter(line); grid-row: span 2; font-size: 11px; color: var(--muted); padding-top: 6px; font-variant-numeric: tabular-nums; }
.lines .ar { font: 19px/1.75 var(--naskh); direction: rtl; text-align: right; }
.lines .la { font: 15px/1.55 var(--serif); }
.rights { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.rights a { color: var(--muted); }
.empty { padding: 28px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { padding: 4px 10px; font: 13px var(--sans); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; transition: background-color 150ms ease, transform 120ms var(--ease-out); }
.chip:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .chip:hover { background: var(--hover); } }

#viewer { position: relative; min-height: 0; background: var(--panel); }
#viewer .mirador-viewer { grid-template-columns: 100% !important; }

.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.page h2 { margin: 0 0 6px; font-size: 22px; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
.page p { max-width: 70ch; text-wrap: pretty; }
.lede { color: var(--muted); margin: 0 0 20px; }
.convert { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.convert label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.convert textarea { width: 100%; min-height: 320px; padding: 12px 14px; font: 16px/1.6 var(--serif); color: var(--ink); border: 1px solid oklch(0.82 0.008 30); border-radius: 8px; background: #fff; resize: vertical; }
.convert textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px oklch(0.55 0.16 250 / 0.18); }
.convert textarea[readonly] { background: var(--panel); }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.btn { height: 36px; padding: 0 14px; font: 600 14px var(--sans); color: #fff; border: 0; border-radius: 8px; background: var(--rubric); cursor: pointer; transition: background-color 150ms ease, transform 120ms var(--ease-out); }
.btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--rubric-ink); } }
.btn.ghost { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.note { font-size: 13px; color: var(--muted); }

.holders { margin: 16px 0 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.holders li { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.holders .h { font-weight: 600; }
.holders .r { font-size: 13px; color: var(--muted); grid-column: 1 / -1; }
.holders a { font-size: 13px; white-space: nowrap; }

@media (max-width: 860px) {
  .top { gap: 12px; padding: 0 14px; overflow-x: auto; }
  .brand .ar { display: none; }
  .brand { font-size: 15px; }
  .tab { padding: 0 7px; font-size: 13.5px; }
  .tab[aria-selected="true"]::after { left: 7px; right: 7px; }
  #panel-search { grid-template-columns: 1fr; grid-template-rows: auto 62vh; height: auto; }
  .side { border-right: 0; max-height: none; }
  #results { max-height: 52vh; }
  #viewer { border-top: 1px solid var(--line); }
  .convert { grid-template-columns: 1fr; }
  .convert textarea { min-height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
}
