/* Arabic AI Atlas: a survey-plate look. Cool sheet, ink-blue type, colour reserved for entry types. */
:root {
  --paper: #E6ECEA;
  --sheet: #F5F8F7;
  --ink: #15203A;
  --muted: #55627A;
  --rule: #C3CDC9;
  --rule-strong: #8A99A8;
  --chip: #FFFFFF;
  --chip-on: #15203A;
  --chip-on-ink: #F5F8F7;
  --node-ink: #FFFFFF;
  --shadow: 0 12px 32px rgba(21, 32, 58, .18), 0 2px 6px rgba(21, 32, 58, .10);
  --font: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --gutter: 168px;
  --cols: var(--gutter) repeat(6, minmax(0, 1fr)) minmax(0, 1.9fr);
  --sea: #D9E3E6; --sea-line: #B4C5CB; --grat: #BFCDD2; --land-x: #EDF1EF; --border-x: #D3DBD8;
  --ch0: #D3DCE9; --ch1: #B2C1D8; --ch2: #8EA2C3; --ch3: #6981AA; --ch4: #4B6390;
  --hatch-bg: #E4E9EC; --hatch-line: #A3B0BF; --halo: rgba(245, 248, 247, .92); --bubble-stroke: #FFFFFF;
  --ctry-line: #FFFFFF;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1724; --sheet: #142032; --ink: #E3E9F0; --muted: #98A6BA; --rule: #26354B; --rule-strong: #4A5D78;
    --chip: #1A283D; --chip-on: #E3E9F0; --chip-on-ink: #0E1724;
    --shadow: 0 14px 36px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
    --sea: #0A111D; --sea-line: #182740; --grat: #16233A; --land-x: #152031; --border-x: #1E2B40;
    --ch0: #22324C; --ch1: #2A3F62; --ch2: #35517F; --ch3: #44659C; --ch4: #5A7EB8;
    --hatch-bg: #172336; --hatch-line: #33445E; --halo: rgba(10, 17, 29, .9); --bubble-stroke: #0E1724;
    --ctry-line: #0E1724;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E1724; --sheet: #142032; --ink: #E3E9F0; --muted: #98A6BA; --rule: #26354B; --rule-strong: #4A5D78;
  --chip: #1A283D; --chip-on: #E3E9F0; --chip-on-ink: #0E1724;
  --shadow: 0 14px 36px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .35);
  --sea: #0A111D; --sea-line: #182740; --grat: #16233A; --land-x: #152031; --border-x: #1E2B40;
  --ch0: #22324C; --ch1: #2A3F62; --ch2: #35517F; --ch3: #44659C; --ch4: #5A7EB8;
  --hatch-bg: #172336; --hatch-line: #33445E; --halo: rgba(10, 17, 29, .9); --bubble-stroke: #0E1724;
  --ctry-line: #0E1724;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  overflow-x: hidden;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 6px 10px; z-index: 50; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }

/* masthead */
.masthead {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 24px;
  padding: 28px 32px 22px; border-bottom: 1px solid var(--rule-strong);
}
.masthead h1 { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 18px; line-height: 1.1; }
.masthead h1 .ar { font-size: 40px; font-weight: 600; letter-spacing: 0; }
.masthead h1 .en { font-size: 22px; font-weight: 400; color: var(--muted); }
.lede { margin: 10px 0 0; max-width: 64ch; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn {
  border: 1px solid var(--rule-strong); background: var(--chip); border-radius: 6px;
  padding: 7px 14px; cursor: pointer; font-weight: 500; text-decoration: none; display: inline-block; line-height: 1.3;
}
.btn:hover { border-color: var(--ink); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; cursor: pointer; color: var(--muted); font-size: 13px; }

/* layout */
.layout { display: grid; grid-template-columns: 296px minmax(0, 1fr); align-items: start; }
.rail {
  position: sticky; top: 0; max-height: 100vh; overflow-y: auto;
  padding: 20px 22px 32px 32px; border-right: 1px solid var(--rule);
}
main { padding: 0 32px 40px 24px; min-width: 0; outline: none; }

/* filters */
.field-label, legend { display: block; font-size: 13px; font-weight: 600; margin: 0 0 6px; padding: 0; }
#q {
  width: 100%; font: inherit; font-size: 16px; padding: 9px 12px; border-radius: 6px;
  border: 1px solid var(--rule-strong); background: var(--chip); color: var(--ink);
}
#q::placeholder { color: var(--muted); }
fieldset { border: 0; margin: 18px 0 0; padding: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--chip); cursor: pointer; font-size: 13px; line-height: 1.5;
}
.chip:hover { border-color: var(--rule-strong); }
.chip[aria-pressed="true"] { background: var(--chip-on); color: var(--chip-on-ink); border-color: var(--chip-on); }
.chip.empty { opacity: .45; }
.chip-n { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-n { color: inherit; opacity: .75; }
.swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex-shrink: 0; }
.toggle { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 14px; font-weight: 500; cursor: pointer; }
.toggle input { width: 16px; height: 16px; accent-color: var(--ink); }
.result-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--rule); font-size: 13px; }
#result-count { font-weight: 600; }

.fold > summary { display: none; }
#fold-n { font-weight: 400; color: var(--muted); margin-left: 6px; }

/* agent panel */
.agent { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--rule-strong); }
.agent h2 { font-size: 16px; margin: 0 0 6px; }
.agent p { font-size: 13px; color: var(--muted); margin: 8px 0 6px; }
/* most-wanted panel */
.wanted { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--rule-strong); }
.wanted summary { font-size: 16px; font-weight: 600; cursor: pointer; }
.wanted summary #wanted-n { font-weight: 400; font-size: 13px; color: var(--muted); margin-left: 4px; }
.wanted-intro { font-size: 13px; color: var(--muted); margin: 8px 0 6px; }
.wanted h3 { font-size: 13px; margin: 14px 0 4px; }
.wanted-list { list-style: none; margin: 0; padding: 0; }
.wanted-list li { padding: 7px 0; border-top: 1px solid var(--rule); }
.wanted-list li:first-child { border-top: 0; }
.wanted-list a { display: block; font-size: 14px; font-weight: 500; color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 2px; overflow-wrap: anywhere; }
.wanted-list a:hover { text-decoration-thickness: 2px; }
.wanted-list .why { display: block; font-size: 12.5px; line-height: 1.4; color: var(--muted); margin-top: 2px; }

.cmd { position: relative; background: var(--sheet); border: 1px solid var(--rule); border-radius: 6px; padding: 10px 10px 36px; }
.cmd code { display: block; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.cmd .btn { position: absolute; right: 8px; bottom: 6px; }


/* view toggle */
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 6px; overflow: hidden; background: var(--chip); }
.seg button { border: 0; background: transparent; padding: 7px 14px; cursor: pointer; font-weight: 500; line-height: 1.3; }
.seg button + button { border-left: 1px solid var(--rule-strong); }
.seg button[aria-pressed="true"] { background: var(--chip-on); color: var(--chip-on-ink); }

/* map view: a survey plate with a double neat line */
.mapview { position: relative; margin-top: 22px; }
main.is-map .plate { display: none; }
.map-frame {
  position: relative; width: 100%; background: var(--sea); overflow: hidden;
  border: 1px solid var(--rule-strong); outline: 1px solid var(--rule-strong); outline-offset: 3px;
}
svg.map { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
svg.map:active { cursor: grabbing; }
.sea { fill: var(--sea); }
.graticule { fill: none; stroke: var(--grat); stroke-width: .6; vector-effect: non-scaling-stroke; }
.water .wl { fill: none; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.water .wl-0, .water .wl-2 { stroke: var(--sea-line); }
.water .wl-1, .water .wl-3 { stroke: var(--sea); }
.water .wl-0 { opacity: .45; }
.water .wl-2 { opacity: .9; }
.land { fill: var(--land-x); }
.borders-foreign { fill: none; stroke: var(--border-x); stroke-width: .7; vector-effect: non-scaling-stroke; }
.borders-arab { fill: none; stroke: var(--ctry-line); stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.ctry { stroke: none; vector-effect: non-scaling-stroke; transition: fill .2s, opacity .2s; }
.ctry.unlisted { fill: url(#hatch); }
.hatch-bg { fill: var(--hatch-bg); }
.hatch-line { stroke: var(--hatch-line); stroke-width: 1.4; }
.ctry.listed { fill: var(--ch0); cursor: pointer; }
.ctry.listed[data-step="none"] { fill: url(#hatch); }
.ctry.listed[data-step="1"] { fill: var(--ch1); }
.ctry.listed[data-step="2"] { fill: var(--ch2); }
.ctry.listed[data-step="3"] { fill: var(--ch3); }
.ctry.listed[data-step="4"] { fill: var(--ch4); }
.ctry.is-dimmed { opacity: .5; }
.ctry.listed.is-hover, .ctry.is-selected { stroke: var(--ink); stroke-width: 1.6; }
.ctry.listed.is-hover { opacity: 1; }
.ctry-pt.listed { stroke: var(--ink); stroke-width: 1; }
.ctry-pt.unlisted { fill: var(--hatch-line); }

.mark .bubble { stroke: var(--bubble-stroke); stroke-width: 1.2; fill-opacity: .85; cursor: pointer; transition: fill-opacity .15s; }
.mark .bubble:hover { fill-opacity: 1; stroke: var(--ink); }
.mark .leader { stroke: var(--ink); stroke-width: .9; opacity: .55; }
.mark .leader-dot { fill: var(--ink); opacity: .7; }
.mark [hidden] { display: none; }
.mark .label { cursor: pointer; outline: none; }
.mark text { paint-order: stroke; stroke: var(--halo); stroke-width: 3.4px; stroke-linejoin: round; fill: var(--ink); }
.mark .l-ar { font-weight: 700; }
.mark .l-en { font-size: 10.5px; fill: var(--muted); }
.mark .l-n { font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mark.is-empty .l-n { font-weight: 400; fill: var(--muted); }
.mark.is-dimmed { opacity: .45; }
.mark.is-hover .l-ar, .mark .label:focus-visible .l-ar { text-decoration: underline; text-underline-offset: 3px; }
.mark.mobile .l-n { font-size: 10px; }

.legend {
  position: absolute; left: 10px; bottom: 10px; width: 236px; pointer-events: none;
  font-size: 11.5px; color: var(--muted); line-height: 1.35;
  background: color-mix(in srgb, var(--sheet) 90%, transparent); border: 1px solid var(--rule); padding: 9px 11px 8px;
}
.legend:empty { display: none; }
.legend { transition: opacity .2s; }
.legend.is-zoomed { opacity: 0; }
.legend p { margin: 0; }
.lg-h { color: var(--ink); font-weight: 600; margin-top: 8px !important; }
.lg-h:first-child { margin-top: 0 !important; }
.lg-steps { display: flex; gap: 2px; margin-top: 4px; }
.lg-step { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lg-step i { display: block; height: 9px; background: var(--ch0); }
.lg-step[data-step="1"] i { background: var(--ch1); }
.lg-step[data-step="2"] i { background: var(--ch2); }
.lg-step[data-step="3"] i { background: var(--ch3); }
.lg-step[data-step="4"] i { background: var(--ch4); }
.lg-step.is-void { opacity: .35; }
.lg-hatch { display: flex; align-items: center; gap: 6px; margin-top: 6px !important; }
.lg-hatch i { width: 22px; height: 9px; background: repeating-linear-gradient(45deg, var(--hatch-bg) 0 3px, var(--hatch-line) 3px 4.4px); }
.lg-size-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 4px; }
.lg-sizes circle { fill: none; stroke: var(--muted); stroke-width: 1; }
.lg-sizes text { fill: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.ghost { font-size: 12px; font-weight: 500; fill: var(--muted); opacity: .75; paint-order: stroke; stroke: var(--halo); stroke-width: 3px; pointer-events: none; }
.ghost[hidden] { display: none; }
.lg-size-t { font-variant-numeric: tabular-nums; padding-bottom: 2px; }

.map-reset { position: absolute; right: 12px; top: 12px; z-index: 3; }
.has-panel .map-reset { right: calc(min(380px, 34%) + 12px); }
.map-msg { position: absolute; inset: auto 16px 16px; margin: 0; color: var(--muted); }
.map-msg:empty { display: none; }

.map-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(380px, 34%); z-index: 4;
  background: var(--sheet); border-left: 1px solid var(--rule-strong);
  display: flex; flex-direction: column; min-height: 0;
}
.mp-head { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--rule); }
.mp-title { margin: 0; display: flex; flex-direction: column; line-height: 1.2; grid-column: 1; }
.mp-title .ar { font-size: 26px; font-weight: 700; text-align: left; }
.mp-title .en { font-size: 13px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.mp-n { margin: 6px 0 0; font-size: 13px; font-weight: 600; grid-column: 1; }
.mp-close { grid-column: 2; grid-row: 1; align-self: start; }
.mp-body { overflow-y: auto; padding: 4px 16px 16px; flex: 1; overscroll-behavior: contain; }
.mp-sec h3 { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.mp-sec h3 .n { color: var(--muted); font-weight: 400; font-variant-numeric: tabular-nums; }
.mp-none { color: var(--muted); font-size: 13.5px; }

.dock {
  display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap;
  margin-top: 10px; padding: 8px 4px 8px 0; border-bottom: 1px solid var(--rule);
}
.dock.is-dimmed .dock-list { opacity: .5; }
.dock-note { font-size: 11px; color: var(--muted); }
.dock.is-selected .dock-head .en { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.dock-head { margin: 0; display: flex; flex-direction: column; line-height: 1.2; min-width: 120px; }
.dock-head .ar { font-weight: 700; font-size: 17px; text-align: left; }
.dock-head .en { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dock-list { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; flex: 1; }
.dock-item {
  display: inline-flex; align-items: center; gap: 4px; min-width: 128px;
  border: 0; background: transparent; padding: 0 8px 0 0; cursor: pointer; text-align: left; border-radius: 6px;
}
.dock-item:hover { background: var(--chip); }
.dock-item svg { flex-shrink: 0; }
.di-txt { display: flex; flex-direction: column; }
.dock-item .bubble { stroke: var(--bubble-stroke); stroke-width: 1.2; fill-opacity: .85; }
.dock-item .over { fill: none; stroke: var(--muted); stroke-dasharray: 2 2; }
.di-t { font-size: 12.5px; font-weight: 600; line-height: 1.1; }
.di-n { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.2; }
.dock-all { margin-left: 4px; }
.dock-none { color: var(--muted); font-size: 13px; }

.map-tip {
  position: absolute; left: 0; top: 0; z-index: 20; pointer-events: none; width: 250px;
  background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: var(--shadow);
  padding: 10px 12px; font-size: 13px;
}
.map-tip p { margin: 0; }
.tt-name { display: flex; align-items: baseline; gap: 8px; }
.tt-name .ar { font-size: 18px; font-weight: 700; }
.tt-name .en { color: var(--muted); }
.tt-n { font-weight: 600; margin-top: 2px !important; }
.tt-types { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1px 12px; }
.tt-types li { display: flex; align-items: center; gap: 6px; }
.tt-types .n, .tt-top .n { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.tt-h { margin-top: 8px !important; font-weight: 600; font-size: 12px; color: var(--muted); }
.tt-top { margin: 2px 0 0; padding: 0 0 0 18px; }
.tt-top li { padding-left: 2px; }
.tt-top li span:first-child { overflow-wrap: anywhere; }
.tt-top li { display: list-item; }
.tt-top li .n { float: right; margin-left: 8px; }
.tt-hint, .tt-note { margin-top: 8px !important; font-size: 12px; color: var(--muted); }

/* tree view: a lineage plate, same neat line as the map */
.treeview { margin-top: 22px; }
main.is-tree .plate { display: none; }
.tree-note { margin: 0 0 10px; max-width: 80ch; font-size: 13px; color: var(--muted); }
.tn-phone { display: none; }
.tree-frame {
  position: relative; width: 100%; height: min(78vh, 880px); min-height: 480px; overflow: hidden; background: var(--sheet);
  border: 1px solid var(--rule-strong); outline: 1px solid var(--rule-strong); outline-offset: 3px;
}
svg.tree { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
svg.tree:active { cursor: grabbing; }
.tree-reset { position: absolute; right: 12px; top: 12px; z-index: 3; }
.bands line { stroke: var(--rule); stroke-width: 1; vector-effect: non-scaling-stroke; }
.links path { fill: none; stroke: var(--rule-strong); stroke-width: 1; vector-effect: non-scaling-stroke; transition: opacity .2s; }
.links path.is-dimmed { opacity: .25; }
.tn { cursor: default; outline: none; transition: opacity .2s; }
.tn.has-kids { cursor: pointer; }
.tn.is-dimmed { opacity: .25; }
.tn-hit { fill: transparent; stroke: none; }
.tn:hover .tn-hit { fill: var(--chip); }
.tn:focus-visible .tn-hit { stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.tn-entry .tn-mark { stroke: var(--sheet); stroke-width: 1; }
.tn-ext .tn-mark { fill: var(--sheet); stroke: var(--muted); stroke-width: 1.4; }
.tn-family .tn-mark { fill: var(--sheet); stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }
.tn-family .tn-dot { fill: var(--ink); }
.tn.is-folded .tn-mark { stroke: var(--ink); stroke-width: 1.6; }
.tn-label { font-size: 12px; font-weight: 500; fill: var(--ink); unicode-bidi: plaintext; }
.tn-ext .tn-label { font-weight: 400; fill: var(--muted); }
.tn-family .tn-label { font-size: 14px; font-weight: 600; }
.tn-family .l-sep, .tn-family .l-n { fill: var(--muted); font-weight: 400; }
.tn-family .l-ar { font-weight: 600; }
.tn-label .l-badge { font-size: 11px; font-weight: 600; fill: var(--muted); font-variant-numeric: tabular-nums; }
.tn:hover .l-name, .tn:hover .l-en, .tn:focus-visible .l-name, .tn:focus-visible .l-en { text-decoration: underline; text-underline-offset: 3px; }

/* the plate */
.status { padding: 40px 0; color: var(--muted); max-width: 60ch; }
.plate { margin-top: 0; }
.plate-head, .band { display: grid; grid-template-columns: var(--cols); }
.plate-head {
  position: sticky; top: 0; z-index: 5; background: var(--paper);
  border-bottom: 1px solid var(--rule-strong);
}
.colhead { padding: 18px 10px 10px; border-left: 1px solid var(--rule); display: flex; flex-direction: column; min-width: 0; }
.colhead .ar { font-size: 30px; font-weight: 300; line-height: 1.4; text-align: left; }
.colhead .en { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.colhead .n { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }

.band { border-bottom: 1px solid var(--rule); }
.bandhead { margin: 0; padding: 14px 12px 14px 0; font-size: 16px; font-weight: 600; display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
.bandhead .ar { text-align: left; font-size: 15px; font-weight: 400; color: var(--muted); }
.bandhead .n { font-size: 13px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 4px; }
.keys { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 6px; }
.key { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 400; color: var(--muted); }

.cell { border-left: 1px solid var(--rule); padding: 12px 8px; min-width: 0; }
.cellhead { display: none; }
.nodes { display: flex; flex-wrap: wrap; gap: 5px; align-content: flex-start; }
.none { color: var(--rule-strong); padding-left: 4px; }

/* --s is 0..1 on a log scale of downloads */
.node {
  --pad: calc(4px + var(--s) * 4px);
  display: inline-block; max-width: 100%;
  background: var(--c); color: var(--node-ink);
  font-size: calc(11.5px + var(--s) * 4px); font-weight: calc(500 + var(--s) * 100);
  line-height: 1.25; padding: var(--pad) calc(var(--pad) + 4px);
  border-radius: 5px; text-decoration: none; overflow-wrap: anywhere; unicode-bidi: plaintext;
}
.node:hover { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--c); }
.node:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.more {
  border: 1px dashed var(--rule-strong); background: transparent; border-radius: 5px;
  padding: 3px 9px; font-size: 12.5px; cursor: pointer; color: var(--muted);
}
.more:hover { color: var(--ink); border-color: var(--ink); }

/* orgs and agent skills */
.extra { margin-top: 36px; }
.extra h2 { font-size: 20px; font-weight: 600; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--rule-strong); }
.extra .count { font-weight: 400; color: var(--muted); font-size: 15px; margin-left: 6px; }
.roster { list-style: none; margin: 0; padding: 0; columns: 4 220px; column-gap: 24px; }
.roster li { break-inside: avoid; padding: 3px 0; display: flex; align-items: baseline; gap: 8px; }
.roster .node { font-size: 13px; padding: 2px 8px; }
.roster .where { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* card */
.card {
  position: fixed; z-index: 30; width: 340px; max-width: calc(100vw - 16px);
  background: var(--sheet); color: var(--ink); border: 1px solid var(--rule-strong);
  border-top: 4px solid var(--c); border-radius: 8px; box-shadow: var(--shadow); padding: 12px 16px 14px;
}
.card-type { margin: 0; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.card h3 { margin: 2px 0 8px; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.card dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 13.5px; }
.card .row { display: contents; }
.card dt { color: var(--muted); }
.card dd { margin: 0; overflow-wrap: anywhere; }
.card .notes { margin: 10px 0 0; font-size: 13.5px; line-height: 1.55; }
.card .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 6px; font-size: 14px;
  transition: opacity .18s, transform .18s; z-index: 40;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.foot { border-top: 1px solid var(--rule-strong); padding: 18px 32px 28px; font-size: 13px; color: var(--muted); }
.foot p { margin: 2px 0; }

/* medium: filters move above the plate */
@media (max-width: 1240px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--rule); padding: 18px 24px; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 0 32px; }
  .agent { margin-top: 0; border-top: 0; padding-top: 0; }
  main { padding: 0 24px 40px; }
  :root { --gutter: 128px; }
  .colhead .ar { font-size: 24px; }
}

/* small: the grid becomes a stacked list grouped by band, then country */
@media (max-width: 899px) {
  body { font-size: 15px; }
  .masthead { flex-direction: column; align-items: stretch; padding: 18px 16px 16px; gap: 14px; }
  .masthead h1 .ar { font-size: 30px; }
  .masthead h1 .en { font-size: 18px; }
  .actions .btn { flex: 1; }
  .rail { display: block; padding: 16px; }
  .fold > summary {
    display: list-item; cursor: pointer; margin-top: 12px; padding: 8px 0; font-weight: 600; font-size: 15px;
    border-bottom: 1px solid var(--rule);
  }
  .agent { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--rule-strong); }
  main { padding: 0 16px 32px; }
  .plate-head { display: none; }
  .band { display: block; border-bottom: 0; }
  .bandhead {
    position: sticky; top: 0; z-index: 4; background: var(--paper);
    flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 10px;
    padding: 18px 0 8px; border-bottom: 1px solid var(--rule-strong); font-size: 19px;
  }
  .bandhead .n { margin: 0 0 0 auto; }
  .keys { flex-basis: 100%; margin-top: 2px; }
  .cell { border-left: 0; padding: 10px 0 12px; border-bottom: 1px solid var(--rule); }
  .cell.is-empty { display: none; }
  .cellhead { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; font-size: 14px; font-weight: 600; }
  .cellhead .ar { font-weight: 400; color: var(--muted); }
  .cellhead .n { margin-left: auto; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
  .node { font-size: calc(13px + var(--s) * 2px); }
  .roster { columns: 1; }
  .foot { padding: 16px; }
  .seg { flex: 1.2; }
  .seg button { flex: 1; }
  main.is-map .plate { display: block; }
  .mapview { margin: 14px -16px 4px; }
  .map-frame { outline: 0; border-left: 0; border-right: 0; }
  svg.map { touch-action: auto; cursor: default; }
  .map-panel, .map-reset, .legend { display: none !important; }
  .dock { padding: 8px 16px 10px; gap: 6px; flex-direction: column; align-items: stretch; }
  .dock-head { flex-direction: row; align-items: baseline; gap: 8px; }
  .dock-list { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 2px; }
  .dock-item { min-width: 0; flex-shrink: 0; }
  .dock-all { display: none; }
  .actions { flex-wrap: wrap; }
  .seg { flex: 1 1 100%; }
  .treeview { margin: 14px -16px 4px; }
  .tree-note { padding: 0 16px; }
  .tn-desk { display: none; }
  .tn-phone { display: inline; }
  .tree-frame { height: auto; min-height: 0; overflow: hidden; outline: 0; border-left: 0; border-right: 0; }
  svg.tree { height: auto; touch-action: auto; cursor: default; }
  .tree-reset { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .toast, .ctry, .mark .bubble, .tn, .links path { transition: none; }
}
