:root {
  color-scheme: light;
  --bg: #f2f5f8;
  --surface: #ffffff;
  --ink: #152e45;
  --muted: #496075;
  --subtle: #53687a;
  --blue: #194fd7;
  --line: #d8e1e9;
  --soft: #edf2fa;
  --drop-bg: #f8faff;
  --drop-line: #aabed7;
  --preview-bg: #edf2f6;
  --card-line: #b0c2d7;
  --notice-bg: #fff1d7;
  --notice-ink: #65450d;
  --notice-line: #a2690e;
  --primary-bg: #194fd7;
  --primary-hover: #123ead;
  --primary-ink: #ffffff;
  --secondary-hover: #dce6f5;
  --disabled-bg: #e0e6ee;
  --disabled-ink: #647487;
  --focus: #b35d00;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111a24;
  --surface: #182533;
  --ink: #e8eff7;
  --muted: #b3c3d2;
  --subtle: #a3b5c7;
  --blue: #98baff;
  --line: #344558;
  --soft: #24354a;
  --drop-bg: #1c2c3e;
  --drop-line: #5e7692;
  --preview-bg: #101d2b;
  --card-line: #59708c;
  --notice-bg: #382b16;
  --notice-ink: #f9d99c;
  --notice-line: #d59b38;
  --primary-bg: #9bbaff;
  --primary-hover: #b5ccff;
  --primary-ink: #142743;
  --secondary-hover: #324863;
  --disabled-bg: #263647;
  --disabled-ink: #a3b5c7;
  --focus: #ffd18a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-block-start: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow-wrap: break-word;
}
header, main, footer { max-width: 1240px; margin-inline: auto; }
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 26px 32px;
  border-block-end: 1px solid var(--line);
}
a { color: var(--blue); }
.brand {
  font-size: 24px;
  font-weight: 750;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  direction: ltr;
  unicode-bidi: isolate;
}
.brand span { font-size: 12px; letter-spacing: 2px; margin-inline-start: 12px; }
.header-tools { display: flex; align-items: center; justify-content: flex-end; gap: 24px; flex-wrap: wrap; }
nav { display: flex; gap: 24px; flex-wrap: wrap; }
nav a { text-decoration: none; color: var(--ink); font-size: 14px; }
nav a:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 4px; }
.preferences { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.language-picker { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.language-picker label { color: var(--muted); }
select {
  max-width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
option { background: var(--surface); color: var(--ink); }
#theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; }
#theme-icon { line-height: 1; font-size: 18px; }
main { padding-inline: 32px; }
.intro { padding: 48px 0 26px; }
.eyebrow { font-size: 12px; font-weight: 750; letter-spacing: 2px; color: var(--blue); }
h1 { font-size: clamp(36px, 5vw, 62px); line-height: 1.08; letter-spacing: -2px; margin: 14px 0 20px; }
h2 { font-size: 23px; line-height: 1.3; }
h3 { font-size: 17px; }
.intro p:last-child { color: var(--muted); font-size: 18px; }
.notice {
  padding: 16px 20px;
  background: var(--notice-bg);
  border-inline-start: 4px solid var(--notice-line);
  border-radius: 4px;
  margin-block-end: 24px;
  color: var(--notice-ink);
}
.workspace { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; min-width: 0; }
.sectionhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sectionhead h2 { font-size: 18px; }
.tag { font-size: 12px; background: var(--soft); padding: 5px 9px; border-radius: 6px; }
.drop {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 12px;
  border: 2px dashed var(--drop-line);
  border-radius: 10px;
  background: var(--drop-bg);
  cursor: pointer;
  text-align: center;
}
.drop:focus-within { border-color: var(--blue); outline: 3px solid var(--focus); outline-offset: 4px; }
.drop span:last-of-type { font-size: 14px; color: var(--muted); }
.uploadicon { font-size: 30px; color: var(--blue); }
input[type="file"] { max-width: 100%; min-width: 0; font: inherit; font-size: 14px; color: var(--muted); }
input[type="file"]::file-selector-button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  margin-inline-end: 10px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--secondary-hover); }
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
#file-name { max-width: 100%; overflow-wrap: anywhere; }
#preview { width: 100%; max-height: 240px; object-fit: contain; margin-block-start: 16px; background: var(--preview-bg); border-radius: 8px; }
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; margin: 20px 0; }
input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; margin: 3px 0 0; accent-color: var(--blue); }
button {
  max-width: 100%;
  border: 0;
  border-radius: 7px;
  padding: 12px 16px;
  background: var(--primary-bg);
  color: var(--primary-ink);
  font: 600 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--primary-hover); }
.secondary { background: var(--soft); color: var(--ink); }
.secondary:hover:not(:disabled) { background: var(--secondary-hover); }
button:disabled { background: var(--disabled-bg); color: var(--disabled-ink); cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.small { font-size: 13px; color: var(--subtle); }
.empty { font-size: 23px; font-weight: 650; margin-block-start: 44px; }
#output { min-height: 220px; }
hr { border: 0; border-block-start: 1px solid var(--line); margin: 26px 0; }
dl { display: grid; grid-template-columns: 1fr 1fr; font-size: 14px; gap: 12px; }
dd { margin: 0; font-weight: 650; }
#method, #guide { padding: 52px 0; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.cards article { border-block-start: 2px solid var(--card-line); padding-block-start: 16px; min-width: 0; }
.cards b { color: var(--blue); font-size: 28px; }
.cards p { color: var(--muted); }
.evidence { display: grid; grid-template-columns: 1fr 1.3fr; gap: 30px; }
.evidence > div { min-width: 0; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
caption { text-align: start; font-weight: 700; margin-block-end: 14px; }
th, td { text-align: start; padding: 12px 8px; border-block-end: 1px solid var(--line); overflow-wrap: anywhere; }
.sources { padding: 32px 0; }
footer { border-block-start: 1px solid var(--line); padding: 24px 32px; font-size: 13px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
html[lang="ar"] body { font-family: "Noto Sans Arabic", "Geeza Pro", Tahoma, "Segoe UI", sans-serif; line-height: 1.8; }
html[lang="ar"] button { font-family: inherit; }
html[lang="ar"] h1 { line-height: 1.4; letter-spacing: 0; }
html[lang="ar"] h2, html[lang="ar"] h3 { line-height: 1.6; }
html[lang="ar"] .eyebrow { letter-spacing: 0; }
bdi { unicode-bidi: isolate; }

@media (max-width: 1060px) {
  header { align-items: flex-start; }
  .header-tools { gap: 16px; }
  nav { gap: 16px; }
}
@media (max-width: 780px) {
  header { gap: 16px; flex-direction: column; }
  header, main, footer { padding-inline: 20px; }
  .header-tools { width: 100%; justify-content: space-between; }
  .workspace, .cards, .evidence { grid-template-columns: 1fr; }
  .panel { padding: 20px; }
  .intro { padding-block-start: 30px; }
  .brand span { margin-inline-start: 6px; }
  dl { grid-template-columns: 1fr; }
  dd { margin-block-start: -8px; }
  .sectionhead { align-items: flex-start; flex-wrap: wrap; }
  footer { flex-direction: column; }
  h1 { letter-spacing: -1px; }
}
@media (max-width: 420px) {
  .header-tools { align-items: flex-start; flex-direction: column; }
  .preferences { width: 100%; justify-content: space-between; }
  .language-picker { gap: 6px; }
  #theme-toggle { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

.guide-steps { grid-template-columns: repeat(4, 1fr); }
.legal {
  margin-block-start: 32px;
  padding: 20px 24px;
  background: var(--notice-bg);
  border-inline-start: 4px solid var(--notice-line);
  border-radius: 8px;
  color: var(--notice-ink);
}
.legal h3 { margin-block: 0 4px; font-size: 17px; }
.legal p { margin-block: 0 16px; }
.legal p:last-child { margin-block-end: 0; }
@media (max-width: 1060px) { .guide-steps { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 780px) { .guide-steps { grid-template-columns: 1fr; } }

#gate {
  max-width: min(560px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
}
#gate::backdrop { background: rgb(10 20 30 / 0.7); }
#gate h2 { margin-block: 0 12px; }
#gate ul { padding-inline-start: 20px; }
#gate li { margin-block-end: 8px; }
#gate .actions { flex-wrap: wrap; }
