/* Law-AI tester page: Arabic first, right to left, light and dark. No inline styles (the CSP forbids them). */
:root {
  --bg: #f5f4ef; --surface: #ffffff; --surface-2: #f0eee6; --text: #1c1b18; --muted: #66635a;
  --border: #dedad0; --accent: #1f4f8f; --accent-text: #ffffff; --accent-soft: #e6edf8;
  --ok: #1d6f3a; --ok-bg: #e3f2e8; --warn: #7d5300; --warn-bg: #fbf0d4;
  --bad: #a8261e; --bad-bg: #fbe4e1; --info: #1f4f8f; --info-bg: #e6edf8;
  --banner: #fff3c8; --banner-text: #4a3500; --banner-border: #e8c766;
  --radius: 10px;
  --arabic: "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151513; --surface: #1e1e1b; --surface-2: #282824; --text: #ecebe6; --muted: #a09d93;
    --border: #3a3934; --accent: #8fb0ff; --accent-text: #0e1424; --accent-soft: #1e2840;
    --ok: #7fd49a; --ok-bg: #1b3324; --warn: #f0c46a; --warn-bg: #3a2d12;
    --bad: #ff9188; --bad-bg: #3d1d1a; --info: #9cb9ff; --info-bg: #1e2740;
    --banner: #3a2f10; --banner-text: #f6dc93; --banner-border: #6b5520;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.7 var(--arabic); }
[hidden] { display: none !important; }
h1 { font-size: 20px; margin: 0; line-height: 1.4; }
h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 14px 0 6px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
[lang="en"] { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

.demo-banner { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 4px 14px;
  justify-content: center; align-items: baseline; padding: 8px 16px; text-align: center;
  background: var(--banner); color: var(--banner-text); border-bottom: 1px solid var(--banner-border); font-size: 14px; }
.demo-banner strong { font-weight: 700; }
.demo-banner [lang="en"] { font-size: 13px; }

.top { max-width: 820px; margin: 0 auto; padding: 18px 16px 4px; display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.top .sub { color: var(--muted); margin: 2px 0 0; }
.tag { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }

main { max-width: 820px; margin: 0 auto; padding: 8px 16px 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 0; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row.between { justify-content: space-between; margin-top: 4px; }
.field { margin: 12px 0; }
.label { display: block; font-weight: 600; margin-bottom: 6px; }

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; width: 100%; }
textarea { resize: vertical; min-height: 44px; }
input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.login .row input { flex: 1; min-width: 180px; width: auto; }
.primary { background: var(--accent); color: var(--accent-text); border: 0; border-radius: var(--radius); padding: 9px 18px; font-weight: 700; }
.primary:disabled, .ghost:disabled { opacity: .55; cursor: progress; }
.ghost { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; }
.ghost.danger { color: var(--bad); }
.link { background: none; border: 0; color: var(--accent); padding: 4px 0; text-decoration: underline; }
.link.quiet { color: var(--muted); font-size: 14px; }
.row.leave { justify-content: flex-end; margin: 4px 0 0; }
.chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 12px; font-size: 14px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex-wrap: wrap; }
.seg button { background: var(--surface); border: 0; padding: 8px 16px; border-inline-start: 1px solid var(--border); }
.seg button:first-child { border-inline-start: 0; }
.seg button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.error { background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad); border-radius: var(--radius); padding: 8px 12px; white-space: pre-wrap; }
.notice { border-radius: var(--radius); padding: 10px 12px; margin: 10px 0; border: 1px solid var(--border); background: var(--surface-2); }
.notice.ok { border-color: var(--ok); background: var(--ok-bg); }
.notice.warn { border-color: var(--warn); background: var(--warn-bg); }
.notice.bad { border-color: var(--bad); background: var(--bad-bg); }
.notice.info { border-color: var(--info); background: var(--info-bg); }

.badge { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* the run */
.run-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.history { margin: 6px 0; }
.history details { border-inline-start: 3px solid var(--border); padding: 2px 12px; margin: 6px 0; }
.history summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.history .q { margin: 4px 0; }
.history .a { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 4px 10px; margin: 4px 0; }

.progress { display: flex; gap: 14px; align-items: center; }
.spinner { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.progress .stage { font-weight: 600; }

.turn { border: 2px solid var(--accent); }
.turn .q { margin: 14px 0 6px; }
.turn .q-text { font-weight: 600; display: block; margin-bottom: 6px; }
.turn .prompt { font-weight: 700; margin: 10px 0; }
.sheet { white-space: pre-line; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; background: var(--surface-2); max-height: 520px; overflow: auto; }
.role-note { font-size: 14px; }

.memo { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 16px; background: var(--surface-2); overflow-wrap: anywhere; }
.turn .memo { max-height: 560px; overflow: auto; }
.memo h1 { font-size: 19px; margin: 12px 0 6px; }
.memo h2 { font-size: 17px; margin: 14px 0 6px; }
.memo h3, .memo h4 { font-size: 16px; }
.memo blockquote { margin: 8px 0; padding: 4px 12px; border-inline-start: 4px solid var(--accent); background: var(--surface); border-radius: 6px; }
.memo code { font-family: var(--mono); font-size: 13px; }
.memo pre { background: var(--surface); border-radius: 8px; padding: 8px 10px; overflow-x: auto; white-space: pre-wrap; }
.memo ul, .memo ol { padding-inline-start: 22px; }
.tbl { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; }
th, td { padding: 5px 8px; border-bottom: 1px solid var(--border); text-align: start; vertical-align: top; }
th { color: var(--muted); font-size: 14px; }

.issues { list-style: none; padding: 0; margin: 6px 0; }
.issues li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.issues li:last-child { border-bottom: 0; }
.issues .why { color: var(--muted); font-size: 14px; display: block; }
ul.plain { margin: 4px 0; padding-inline-start: 20px; }
ul.plain li { margin: 3px 0; }
details > summary { cursor: pointer; font-weight: 600; }
.cost { color: var(--muted); font-size: 14px; }

.feedback .thumbs { display: flex; gap: 10px; flex-wrap: wrap; }
.thumb { display: inline-flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 14px; }
.thumb svg { width: 20px; height: 20px; fill: currentColor; }
.thumb.down svg { transform: rotate(180deg); }
.thumb[aria-pressed="true"].up { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 700; }
.thumb[aria-pressed="true"].down { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); font-weight: 700; }

.foot { max-width: 820px; margin: 0 auto; padding: 0 16px 28px; color: var(--muted); font-size: 13px; }

.card { scroll-margin-top: 96px; }
.id { unicode-bidi: isolate; direction: ltr; white-space: nowrap; }
.story { white-space: pre-wrap; margin: 6px 0; }

@media (max-width: 560px) {
  body { font-size: 15px; }
  .demo-banner { padding: 5px 10px; font-size: 12.5px; line-height: 1.5; }
  .demo-banner [lang="en"] { font-size: 11.5px; }
  .top { padding-top: 12px; }
  .card { padding: 12px; }
  .row > .primary, .row > .ghost { flex: 1 1 auto; }
  .memo { padding: 4px 10px; }
}

.feedback .issues { border: 0; padding: 0; margin: .5rem 0; display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.feedback .issue { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
