/* Khayli · خيلي — shared tokens + components (Desert-stone default, .night = Night stable) */
:root, .ds {
  --bg: #F4EFE6; --surface: #FFFCF7; --surface2: #EBE4D7; --line: #DDD3C2;
  --ink: #1C2421; --muted: #575B54; --faint: #6E6A60;
  --accent: #1F4A3D; --accent-ink: #FFFCF7; --accent-soft: #DCE6DF;
  --gold: #7D6222; --gold-bright: #B8954A; --gold-soft: #F1E7CF;
  --partial: #2F5A84; --partial-soft: #E1E9F2;
  --unknown: #6E6A60; --unknown-soft: #ECE8E0;
  --conflict: #A24E22; --conflict-soft: #F6E3D6;
  --lowdata: #5A5F70; --lowdata-soft: #E6E6EA;
  --shadow: 0 1px 2px rgba(28,36,33,.06), 0 8px 24px rgba(28,36,33,.06);
}
.night {
  --bg: #0F1416; --surface: #172024; --surface2: #1E292E; --line: #2A363D;
  --ink: #F1EADC; --muted: #B4AD9F; --faint: #9D978A;
  --accent: #8FC2AC; --accent-ink: #0F1416; --accent-soft: #1F3530;
  --gold: #D4B46A; --gold-bright: #D4B46A; --gold-soft: #2E2817;
  --partial: #8DB4DE; --partial-soft: #1C2A3A;
  --unknown: #A39D90; --unknown-soft: #23292C;
  --conflict: #E59A6E; --conflict-soft: #3A2419;
  --lowdata: #B0B4C4; --lowdata-soft: #252830;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
body { margin: 0; }
.ar { font-family: 'IBM Plex Sans Arabic', 'Readex Pro', system-ui, sans-serif; }
.disp { font-family: 'Amiri', 'IBM Plex Sans Arabic', serif; }
.lat { font-family: 'Cormorant Garamond', Georgia, serif; }
.num { font-variant-numeric: tabular-nums; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ---------- phone shell ---------- */
.ph { width: 390px; height: 844px; position: relative; overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; display: flex; flex-direction: column; font-size: 15px; line-height: 1.6; }
.ph[dir="ltr"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 10px; min-height: 64px; }
.topbar h1 { margin: 0; font-size: 22px; font-weight: 600; line-height: 1.3; }
.topbar .sub { font-size: 13px; color: var(--muted); }
.scroll { flex: 1; overflow: hidden; padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.iconbtn { width: 48px; height: 48px; border-radius: 24px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; flex: none; cursor: pointer; }
.iconbtn svg, .ic { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-sm { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[dir="rtl"] .flip { transform: scaleX(-1); }

/* tab bar (RTL order follows DOM order, first = right) */
.tabbar { display: flex; justify-content: space-around; align-items: stretch; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px 22px; }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center;
  font-size: 11.5px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tab.on { color: var(--accent); }
.tab.on .dot { width: 4px; height: 4px; border-radius: 2px; background: var(--gold-bright); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 4px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.h2 { font-size: 17px; font-weight: 600; margin: 0; line-height: 1.4; }
.h3 { font-size: 15px; font-weight: 600; margin: 0; }
.eyebrow { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: .02em; }
.divider { height: 1px; background: var(--line); }
a.link { color: var(--accent); font-weight: 600; text-decoration: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px; border-radius: 14px;
  font: inherit; font-weight: 600; font-size: 15px; border: 1px solid transparent; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.quiet { background: transparent; color: var(--accent); }
.btn.block { width: 100%; }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: 14px; border-radius: 12px; }

/* chips — status never by colour alone: icon + label */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.c-verified { background: var(--gold-soft); color: var(--gold); }
.c-partial { background: var(--partial-soft); color: var(--partial); }
.c-unknown { background: var(--unknown-soft); color: var(--unknown); border: 1px dashed var(--unknown); }
.c-conflict { background: var(--conflict-soft); color: var(--conflict); }
.c-low { background: var(--lowdata-soft); color: var(--lowdata); }
.c-neutral { background: var(--surface2); color: var(--ink); }
.c-accent { background: var(--accent-soft); color: var(--accent); }

/* completeness bar (fills from the reading start: right in RTL) */
.bar { height: 8px; border-radius: 4px; background: var(--surface2); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; background: var(--gold-bright); border-radius: 4px; }
.bar > i.p { background: var(--partial); }

/* horse card */
.hcard { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 10px; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.hcard .ph-img { width: 88px; height: 88px; border-radius: 14px; object-fit: cover; flex: none; background: var(--surface2); }
.namear { font-size: 17px; font-weight: 600; line-height: 1.35; }
.nameen { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 16px; font-weight: 600; color: var(--muted); direction: ltr; unicode-bidi: isolate; }
.cc { font-family: 'IBM Plex Sans Arabic', sans-serif; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--muted); direction: ltr; unicode-bidi: isolate; }

/* pedigree nodes */
.pnode { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 9px; display: flex; flex-direction: column; gap: 0; position: relative; text-decoration: none; color: inherit; min-height: 48px; justify-content: center; }
.pnode .an { font-size: 13px; font-weight: 600; line-height: 1.35; }
.pnode .en { font-family: 'Cormorant Garamond', Georgia, serif; font-size: 13.5px; font-weight: 600; color: var(--muted); line-height: 1.15; direction: ltr; unicode-bidi: isolate; text-align: start; }
.pnode .meta { font-size: 10.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.pnode .conf { position: absolute; top: 6px; inset-inline-end: 6px; width: 16px; height: 16px; }
.pnode.verified { border-color: color-mix(in srgb, var(--gold-bright) 55%, var(--line)); }
.pnode.partial { border-color: var(--partial); border-style: solid; }
.pnode.unknown { background: transparent; border: 1.5px dashed var(--unknown); color: var(--unknown); }
.pnode.conflict { border: 1.5px solid var(--conflict); background: var(--conflict-soft); }
.pnode.rep { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--partial); }
.pnode.sire { }
.pnode.subject { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pnode.subject .en, .pnode.subject .meta { color: color-mix(in srgb, var(--accent-ink) 80%, transparent); }

/* inputs */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink); }
.input { min-height: 52px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); padding: 0 14px; font: inherit; color: var(--ink); display: flex; align-items: center; gap: 10px; width: 100%; }
.input.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input .ph-t { color: var(--faint); }
.seg { display: flex; background: var(--surface2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg span, .seg a { flex: 1; text-align: center; padding: 8px 4px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); text-decoration: none; min-height: 40px; display: flex; align-items: center; justify-content: center; }
.seg .on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* list rows */
.lrow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); min-height: 56px; }
.lrow:last-child { border-bottom: 0; }
.ico-tile { width: 40px; height: 40px; border-radius: 12px; background: var(--surface2); display: flex; align-items: center; justify-content: center; color: var(--accent); flex: none; }

/* sheet */
.scrim { position: absolute; inset: 0; background: rgba(15,20,22,.42); }
.sheet { position: absolute; inset-inline: 0; bottom: 0; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 20px 28px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 -10px 40px rgba(0,0,0,.18); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); align-self: center; }

/* banners */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: 13px; line-height: 1.55; }
.banner.offline { background: var(--surface2); color: var(--ink); }
.banner.low { background: var(--lowdata-soft); color: var(--lowdata); }
.banner.conflict { background: var(--conflict-soft); color: var(--conflict); }
.banner.info { background: var(--partial-soft); color: var(--partial); }

/* stat */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 24px; font-weight: 600; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }
.ghosted { opacity: .45; filter: grayscale(1); }

/* photo placeholders (Higgs renders drop in here) */
.pimg { display: flex; align-items: center; justify-content: center; color: rgba(28,36,33,.38); overflow: hidden; position: relative; }
.pimg svg { width: 46%; height: 46%; stroke: currentColor; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.t-chestnut { background: #D8B796; } .t-bay { background: #A98C70; color: rgba(255,252,247,.55); } .t-grey { background: #CFCAC0; } .t-dusk { background: #26343C; color: rgba(241,234,220,.5); } .t-dawn { background: #E2CDAE; }
.night .t-chestnut { background: #5A4331; color: rgba(241,234,220,.45); } .night .t-bay { background: #3E3226; } .night .t-grey { background: #3A3935; color: rgba(241,234,220,.45); }

/* logo */
.logo-mark { flex: none; }
.wordmark-ar { font-family: 'Amiri', serif; font-weight: 700; line-height: 1.7; display: block; padding-block: .05em; }
.wordmark-en { font-family: 'Cormorant Garamond', Georgia, serif; font-weight: 600; letter-spacing: .28em; line-height: 1.4; direction: ltr; display: block; }
.offline-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px; background: var(--surface2); font-size: 12px; font-weight: 600; color: var(--muted); }

/* primary lockup: mark + Arabic wordmark on one line (RTL: mark on the right) */
.lockup { display: inline-flex; align-items: center; gap: .16em; direction: rtl; line-height: 1; }
.lockup img { height: 1.02em; width: auto; flex: none; transform: translateY(-.04em); }
.lockup span { font-family: 'Amiri', serif; font-weight: 700; line-height: 1.25; }
