/* IBM Plex Sans Arabic 1.005, the unmodified WOFF2 files of IBM's @ibm/plex-sans-arabic 1.1.0
   (SIL OFL 1.1, Reserved Font Name "Plex"; fonts/OFL.txt). */
@font-face { font-family: "Plex Arabic"; src: url("fonts/IBMPlexSansArabic-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("fonts/IBMPlexSansArabic-SemiBold.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --bg: #ffffff; --surface: #f5f5f7; --card: #fcfcfb; --ink: #0b0b0d; --muted: #52514e; --faint: #898781; --line: #e4e3ec;
  --grid: #e1e0d9; --axis: #c3c2b7; --accent: #2a78d6; --focus: #2a78d6; --code: #f2f2f5; --warn-bg: #fff6e5; --warn-line: #f0c36d;
  --s0: #2a78d6; --s1: #eb6834; --s2: #1baf7a; --s3: #eda100; --on-accent: #ffffff;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Plex Arabic", system-ui, -apple-system, "Segoe UI", "Noto Sans Arabic", "Geeza Pro", Tahoma, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e12; --surface: #15151b; --card: #1a1a19; --ink: #f0efec; --muted: #c3c2b7; --faint: #898781; --line: #2c2c37;
    --grid: #2c2c2a; --axis: #383835; --accent: #3987e5; --focus: #3987e5; --code: #20202a; --warn-bg: #2a2416; --warn-line: #7a5d1c;
    --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0e12; --surface: #15151b; --card: #1a1a19; --ink: #f0efec; --muted: #c3c2b7; --faint: #898781; --line: #2c2c37;
  --grid: #2c2c2a; --axis: #383835; --accent: #3987e5; --focus: #3987e5; --code: #20202a; --warn-bg: #2a2416; --warn-line: #7a5d1c;
  --s0: #3987e5; --s1: #d95926; --s2: #199e70; --s3: #c98500;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--surface); color: var(--ink); font: 400 16px/1.6 var(--sans); overflow-x: hidden; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); }
h2 { font-size: 1.12rem; }
h3 { font-size: .98rem; margin-top: 1rem; }
h3:first-child { margin-top: 0; }
p { margin: .4rem 0; }
a { color: var(--accent); overflow-wrap: anywhere; }
code { font-family: var(--mono); font-size: .85em; background: var(--code); padding: 0 .25em; border-radius: 4px; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; inset-inline-start: 1rem; top: -3rem; background: var(--card); padding: .5rem 1rem; border-radius: 8px; z-index: 10; }
.skip:focus { top: .5rem; }
[hidden] { display: none !important; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); text-decoration: none; font-weight: 600; }
.mark { width: 28px; height: 28px; }
.mark-ink { fill: var(--ink); }
.mark-accent { fill: var(--accent); }
.lang { font: inherit; font-size: .9rem; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 999px; padding: .3rem .9rem; cursor: pointer; }

.intro { padding: 1.6rem 0 1rem; max-width: 860px; }
.lede { font-size: 1.05rem; }
.note, .sub { color: var(--muted); font-size: .88rem; }
.warn { background: var(--warn-bg); border-inline-start: 4px solid var(--warn-line); padding: .5rem .8rem; border-radius: 6px; font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: .4rem 0 .6rem; }
.tile { background: var(--surface); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.tile-num { font-size: 1.5rem; font-weight: 600; margin: 0; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.tile-lab { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.35; }

.pick { display: flex; flex-wrap: wrap; gap: 6px; margin: .5rem 0; }
.chipb { font: inherit; font-size: .88rem; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: .2rem .75rem; cursor: pointer; }
.chipb[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.seg { display: inline-flex; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin: .3rem 0; flex-wrap: wrap; max-width: 100%; }
.segb { font: inherit; background: transparent; color: var(--ink); border: 0; border-radius: 8px; font-size: .88rem; padding: .3rem .8rem; cursor: pointer; }
.segb[aria-pressed="true"] { background: var(--card); box-shadow: 0 0 0 1px var(--line); font-weight: 600; }
.toggles { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: .4rem 0 .7rem; font-size: .88rem; color: var(--muted); }
.toggles label { display: inline-flex; align-items: center; gap: .35rem; cursor: pointer; }
.toggles input { margin: 0; }
i.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
i.swatch.value, i.swatch.s0 { background: var(--s0); } i.swatch.key, i.swatch.s1 { background: var(--s1); } i.swatch.other { background: var(--faint); } i.swatch.qr { background: var(--s2); }

.viewer { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.frame-wrap { margin: 0; min-width: 0; }
.frame { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; line-height: 0; }
.frame.narrow { max-width: 420px; margin-inline: auto; }
.frame img { display: block; width: 100%; height: auto; }
.frame svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.frame polygon { fill: transparent; stroke-width: 1.5; vector-effect: non-scaling-stroke; cursor: pointer; pointer-events: all; }
.frame polygon.value { stroke: var(--s0); }
.frame polygon.key { stroke: var(--s1); }
.frame polygon.other { stroke: var(--faint); }
.frame polygon.qr { stroke: var(--s2); }
.frame polygon:hover, .frame polygon.sel { fill: var(--s0); fill-opacity: .18; stroke-width: 3; }
.frame polygon.key:hover, .frame polygon.key.sel { fill: var(--s1); }
.frame polygon.linked { fill: var(--s1); fill-opacity: .18; stroke-width: 3; }
.side { min-width: 0; font-size: .92rem; }
.facts { display: grid; grid-template-columns: minmax(6rem, 9rem) minmax(0, 1fr); gap: .15rem .8rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; unicode-bidi: plaintext; }
#field-detail { min-height: 3.5rem; }
#field-detail select { display: block; width: 100%; max-width: 100%; font: inherit; font-size: .88rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: .25rem .4rem; margin: .2rem 0 .4rem; }
.side, .side * { min-width: 0; }
#field-detail p { margin: .15rem 0; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.qa { list-style: none; margin: 0; padding: 0; }
.qa li { border-top: 1px solid var(--line); padding: .35rem 0; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.qa .a { color: var(--muted); }

.chart { margin-top: .6rem; min-width: 0; }
.bars { display: grid; grid-template-columns: minmax(5.5rem, 10rem) minmax(0, 1fr); gap: .35rem .75rem; align-items: center; }
.bars .lab { font-size: .88rem; line-height: 1.25; overflow-wrap: anywhere; }
.track { position: relative; display: flex; flex-direction: column; gap: 2px; padding: 3px 0; border-inline-start: 1px solid var(--axis); }
.barrow { display: flex; align-items: center; gap: .4rem; height: 20px; min-width: 0; }
.bar { height: 18px; min-width: 2px; border-start-end-radius: 4px; border-end-end-radius: 4px; cursor: default; }
.bar.s0 { background: var(--s0); } .bar.s1 { background: var(--s1); }
.val { color: var(--muted); font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; unicode-bidi: isolate; }
.axis-row { display: grid; grid-template-columns: minmax(5.5rem, 10rem) minmax(0, 1fr); gap: 0 .75rem; font-size: .75rem; color: var(--faint); margin-top: .1rem; }
.ticks { display: flex; justify-content: space-between; padding-inline-end: 3rem; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .86rem; color: var(--muted); margin-top: .5rem; }
.legend .lg { display: inline-flex; align-items: center; gap: .4rem; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--ink); color: var(--card); font-size: .82rem; line-height: 1.35; padding: .35rem .6rem; border-radius: 6px; max-width: 300px; }

details { margin-top: .6rem; }
summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.tablewrap { overflow-x: auto; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th, td { text-align: start; padding: .35rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.n, th.n { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; unicode-bidi: isolate; }

#how ul { padding-inline-start: 1.2rem; margin: .3rem 0; }
#how li { margin: .3rem 0; }
.foot { color: var(--muted); font-size: .86rem; padding: 1rem 0 2rem; }
.foot p { margin: .3rem 0; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .viewer { grid-template-columns: minmax(0, 1fr); }
  .frame polygon { stroke-width: 1; }
  .frame polygon:hover, .frame polygon.sel, .frame polygon.linked { stroke-width: 2; }
  .card { padding: 14px 12px; }
  th, td { padding: .3rem .35rem; }
}
