/* Formal, quiet real-estate theme: ivory paper, ink navy, a single brass accent, serif display type. */
:root {
  --bg: #f6f3ee; --surface: #fff; --ink: #161b26; --muted: #6b6862; --line: #e3ddd2;
  --accent: #8c6a32; --accent-ink: #fff; --brand-a: #1f3a5f; --brand-b: #2f5d50; --brand-parent: #5b4b6b;
  --paper-2: color-mix(in srgb, var(--bg) 70%, var(--surface));
  --ok: #2f6b4f; --warn: #a06a12; --fail: #a23a2c;
  --radius: 4px; --radius-lg: 10px;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, "IBM Plex Sans Arabic", sans-serif;
  --arabic: "IBM Plex Sans Arabic", "Segoe UI", "Noto Sans Arabic", sans-serif;
  --shadow: 0 1px 2px rgba(22, 27, 38, .04), 0 8px 24px rgba(22, 27, 38, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1117; --surface: #151a22; --ink: #ece7de; --muted: #a09a90; --line: #2a303a;
    --accent: #cdae72; --accent-ink: #14110b; --ok: #7fbf9c; --warn: #e0b45c; --fail: #e58a7c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25); color-scheme: dark; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.65 var(--sans); min-height: 100vh; display: flex; flex-direction: column;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
[dir="rtl"] body, [dir="rtl"] button, [dir="rtl"] input, [dir="rtl"] textarea, [dir="rtl"] select { font-family: var(--arabic); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; top: 8px; inset-inline-start: 16px; transform: translateY(-300%); background: var(--surface); padding: 6px 10px; z-index: 20; }
.skip:focus { transform: none; }
html, body { overflow-x: clip; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }

/* ---- header ---- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.2) blur(10px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1040px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brandmark { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.monogram { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--accent);
  color: var(--accent); font: 600 20px/1 var(--serif); letter-spacing: 0; }
.wordmark { font: 600 13px/1 var(--sans); letter-spacing: .28em; text-transform: uppercase; }
[dir="rtl"] .wordmark { letter-spacing: 0; font-size: 15px; }
.top-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.link-btn { background: none; border: 0; padding: 8px 10px; color: var(--muted); cursor: pointer; font-size: 13.5px; }
.link-btn:hover { color: var(--ink); }
.lang-btn { background: none; border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px; margin-inline-start: 6px; }
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }
.inline-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }

.banner { display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--muted); }
.banner button, .btn { border: 1px solid var(--ink); background: var(--ink); color: var(--bg); border-radius: 999px; padding: 7px 18px; cursor: pointer; font-size: 13.5px; }
.banner button:hover, .btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---- waking ---- */
.waking { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(4px); }
.waking-card { display: flex; gap: 18px; align-items: flex-start; max-width: 460px; background: var(--surface);
  border: 1px solid var(--line); padding: 26px 28px; box-shadow: var(--shadow); border-radius: var(--radius-lg); }
.waking-title { font: 600 24px/1.2 var(--serif); margin: 0 0 6px; }
[dir="rtl"] .waking-title { font-family: var(--arabic); font-size: 19px; }
.waking-text { margin: 0; color: var(--muted); font-size: 14px; }
.waking-elapsed { margin: 10px 0 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.ring { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); border-top-color: var(--accent);
  animation: spin 1.1s linear infinite; flex: none; margin-top: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- intro ---- */
.shell { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px 24px; }
.intro { padding: 56px 0 8px; }
.eyebrow { margin: 0 0 18px; font-size: 11.5px; letter-spacing: .26em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
[dir="rtl"] .eyebrow { letter-spacing: 0; font-size: 13px; }
.display { font: 500 clamp(34px, 5.6vw, 58px)/1.06 var(--serif); letter-spacing: -.01em; margin: 0; max-width: 22ch; }
[dir="rtl"] .display { font: 600 clamp(28px, 4.6vw, 44px)/1.3 var(--arabic); max-width: 20ch; }
.lede { max-width: 62ch; color: var(--muted); font-size: 16.5px; margin: 20px 0 0; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin: 40px 0 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stats div { padding: 18px 16px 16px 0; }
.stats div + div { padding-inline-start: 16px; border-inline-start: 1px solid var(--line); }
.stats dt { order: 2; font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.stats dd { margin: 0 0 2px; font: 500 30px/1.1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.stats dd.small { font: 500 17px/1.6 var(--sans); }
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats div, .stats div + div { padding: 14px 0; border-inline-start: 0; border-bottom: 1px solid var(--line); }
  .stats div:nth-child(even) { padding-inline-start: 14px; border-inline-start: 1px solid var(--line); }
  .stats div:last-child { border-bottom: 0; }
}

.block { margin-top: 44px; }
.section-label { font: 600 11.5px/1 var(--sans); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); margin: 0 0 16px;
  display: flex; align-items: center; gap: 14px; }
[dir="rtl"] .section-label { letter-spacing: 0; font-size: 13px; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.brand-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.brand-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; position: relative; }
.brand-card::before { content: ""; position: absolute; inset-inline-start: 0; top: 18px; bottom: 18px; width: 2px; background: var(--brand-a); }
.brand-card.b1::before { background: var(--brand-b); } .brand-card.parent::before { background: var(--brand-parent); }
.brand-card h3 { font: 600 22px/1.2 var(--serif); margin: 0 0 4px; }
[dir="rtl"] .brand-card h3 { font: 600 18px/1.4 var(--arabic); }
.brand-card h3 a { color: var(--ink); text-decoration: none; }
.brand-card h3 a:hover { color: var(--accent); }
.brand-card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.brand-card .meta { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.brand-card .count { color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
@media (max-width: 760px) { .suggestions { grid-template-columns: 1fr; } }
.sugg { display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: start; padding: 16px 4px;
  background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.suggestions .sugg:nth-child(odd) { padding-inline-end: 22px; }
.suggestions .sugg:nth-child(even) { padding-inline-start: 22px; }
@media (max-width: 760px) { .suggestions .sugg:nth-child(n) { padding-inline: 4px; } }
.sugg .q { font-size: 15px; }
.sugg small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.sugg .arrow { color: var(--accent); transition: transform .2s ease; flex: none; }
[dir="rtl"] .sugg .arrow { transform: scaleX(-1); }
.sugg:hover .q { color: var(--accent); }
.sugg:hover .arrow { transform: translateX(4px); }
[dir="rtl"] .sugg:hover .arrow { transform: scaleX(-1) translateX(4px); }

.how { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; counter-reset: how; }
@media (max-width: 760px) { .how { grid-template-columns: 1fr 1fr; row-gap: 20px; } }
.how li { padding-inline-end: 20px; counter-increment: how; }
.how li::before { content: "0" counter(how); display: block; font: 500 13px/1 var(--serif); color: var(--accent); margin-bottom: 10px; letter-spacing: .06em; }
.how strong { display: block; font: 600 19px/1.25 var(--serif); margin-bottom: 6px; }
[dir="rtl"] .how strong { font: 600 16px/1.4 var(--arabic); }
.how span { font-size: 13.5px; color: var(--muted); }

/* ---- thread ---- */
.thread { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-direction: column; gap: 22px; }
.thread:empty { margin: 0; }
.msg.user { align-self: flex-end; max-width: min(78%, 640px); background: var(--ink); color: var(--bg); padding: 11px 16px;
  border-radius: 14px 14px 4px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
[dir="rtl"] .msg.user, .msg.user[dir="rtl"] { border-radius: 14px 14px 14px 4px; }
.msg.bot { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px 26px 18px; box-shadow: var(--shadow); overflow-wrap: anywhere; }
@media (max-width: 560px) { .msg.bot { padding: 18px 16px 14px; } .msg.user { max-width: 92%; } }
.msg.bot .tags { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  padding: 3px 10px; border: 1px solid currentColor; border-radius: 999px; color: var(--brand-a); }
[dir="rtl"] .tag { letter-spacing: 0; font-size: 12px; }
.tag.b1 { color: var(--brand-b); } .tag.parent { color: var(--brand-parent); }
.body { font-size: 15.5px; line-height: 1.72; }
.body p { margin: 0 0 10px; } .body ul { margin: 0 0 10px; padding-inline-start: 20px; } .body li { margin-bottom: 4px; }
.body strong { font-weight: 600; }
.cite { font-size: 10.5px; vertical-align: super; line-height: 0; text-decoration: none; padding: 1px 4px; margin-inline-start: 1px;
  border-radius: 3px; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); font-weight: 600; }
.cite:hover { background: var(--accent); color: var(--accent-ink); }
.typing:empty::after, .typing > :last-child::after { content: ""; display: inline-block; width: 7px; height: 15px; margin-inline-start: 3px;
  background: var(--accent); vertical-align: -2px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.notice { font-size: 13.5px; color: var(--muted); border-inline-start: 2px solid var(--accent); padding: 4px 12px; margin: 12px 0 0; }

.panel { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.panel-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
[dir="rtl"] .panel-label { letter-spacing: 0; font-size: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.check i { width: 14px; height: 14px; border-radius: 50%; display: inline-grid; place-items: center; font-style: normal; font-size: 9px; color: #fff; background: var(--ok); }
.check.warn i { background: var(--warn); } .check.fail i { background: var(--fail); }
.check b { font-weight: 500; color: var(--ink); }
.verdict { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ok); }
.verdict.warn { color: var(--warn); }

.facts { display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.fact { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.node { padding: 2px 9px; border-radius: 999px; background: var(--paper-2); border: 1px solid var(--line); font-size: 12.5px; }
.node.t-project { border-color: color-mix(in srgb, var(--brand-a) 40%, var(--line)); }
.node.t-place { border-color: color-mix(in srgb, var(--brand-b) 40%, var(--line)); }
.node.t-partner { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
.rel { color: var(--muted); font-style: italic; font-family: var(--serif); font-size: 15px; }
[dir="rtl"] .rel { font-family: var(--arabic); font-style: normal; font-size: 12.5px; }

details.panel summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::after { content: "+"; margin-inline-start: auto; color: var(--muted); font-size: 16px; line-height: 1; }
details.panel[open] summary::after { content: "–"; }
details.panel summary .panel-label { margin: 0; }
.sources ol { margin: 10px 0 0; padding-inline-start: 20px; font-size: 13.5px; }
.sources li { margin-bottom: 6px; }
.sources .meta { display: block; color: var(--muted); font-size: 12px; }
.trace { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; display: grid; gap: 6px; }
.trace li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; }
.trace .k { color: var(--ink); font-weight: 500; }
.trace .v { color: var(--muted); font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 11.5px; overflow-wrap: anywhere; }

.followups { display: flex; flex-wrap: wrap; gap: 8px; }
.followups button { background: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 13px; }
.followups button:hover { border-color: var(--accent); color: var(--accent); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-top: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 12px 14px; background: var(--bg); display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.card .price { font: 600 18px/1.3 var(--serif); }
.handoff { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.handoff a.ghost { border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; text-decoration: none; font-size: 13px; color: var(--ink); }
.handoff a.ghost:hover { border-color: var(--accent); color: var(--accent); }
.fb { display: flex; gap: 6px; margin-top: 14px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.fb button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 12px; cursor: pointer; font-size: 12px; color: var(--muted); }
.fb button:hover { color: var(--ink); border-color: var(--ink); }
.model { margin-inline-start: auto; }

/* ---- composer ---- */
.composer-wrap { position: sticky; bottom: 0; z-index: 5; background: linear-gradient(to top, var(--bg) 70%, transparent); padding: 18px 20px 14px; }
.composer { display: flex; gap: 10px; align-items: flex-end; max-width: 1000px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 8px 8px 8px 16px; box-shadow: var(--shadow); }
[dir="rtl"] .composer { padding: 8px 16px 8px 8px; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.composer textarea { flex: 1; resize: none; border: 0; background: transparent; padding: 8px 0; max-height: 160px; outline: none; font-size: 15px; }
.composer button { width: 40px; height: 40px; border: 0; border-radius: 10px; background: var(--ink); color: var(--bg); cursor: pointer; display: grid; place-items: center; flex: none; }
[dir="rtl"] .composer button svg { transform: scaleX(-1); }
.composer button:hover { background: var(--accent); color: var(--accent-ink); }
.composer button:disabled { opacity: .4; cursor: progress; }

.foot { border-top: 1px solid var(--line); background: var(--surface); }
.foot-inner { max-width: 1040px; margin: 0 auto; padding: 18px 20px 24px; font-size: 12px; color: var(--muted); }
.foot p { margin: 4px 0; }
.hosting { color: var(--ink); }
.hosting::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-inline-end: 8px; vertical-align: 1px; }

/* ---- dialogs ---- */
dialog { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink);
  width: min(560px, calc(100vw - 32px)); padding: 24px 26px; box-shadow: 0 24px 60px rgba(0, 0, 0, .18); }
dialog.wide { width: min(980px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(14, 17, 23, .45); backdrop-filter: blur(2px); }
.dialog-title { font: 600 26px/1.2 var(--serif); margin: 0 0 10px; }
[dir="rtl"] .dialog-title { font: 600 20px/1.4 var(--arabic); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.dialog-head p { margin: 0; font-size: 13.5px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 50%; width: 34px; height: 34px; cursor: pointer; font-size: 18px; line-height: 1; color: var(--muted); }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; margin-bottom: 12px; flex: 1; color: var(--muted); }
dialog input, dialog select { border: 1px solid var(--line); border-radius: var(--radius); padding: 9px 10px; background: var(--bg); color: var(--ink); }
dialog .row { display: flex; gap: 12px; }
dialog .check { flex-direction: row; align-items: flex-start; gap: 8px; }
.actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.actions.end { justify-content: flex-end; }
.form-msg { color: var(--fail); font-size: 13px; min-height: 1em; }
@media (max-width: 480px) { dialog .row { flex-direction: column; gap: 0; } }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 14px 0 8px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.graph-stage { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg); height: min(62vh, 560px); overflow: hidden; }
.graph-stage svg { width: 100%; height: 100%; display: block; cursor: grab; }
.graph-stage line { stroke: var(--line); stroke-width: 1; }
.graph-stage line.hi { stroke: var(--accent); stroke-width: 1.6; }
.graph-stage g.n { cursor: pointer; }
.graph-stage g.n circle { stroke: var(--surface); stroke-width: 1.5; }
.graph-stage g.n text { font: 500 10.5px var(--sans); fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; pointer-events: none; }
.graph-stage g.n.dim { opacity: .18; } .graph-stage line.dim { opacity: .12; }
.c-company { fill: var(--ink); background: var(--ink); } .c-project { fill: var(--brand-a); background: var(--brand-a); }
.c-place { fill: var(--brand-b); background: var(--brand-b); } .c-partner { fill: var(--accent); background: var(--accent); }
.c-person { fill: var(--brand-parent); background: var(--brand-parent); } .c-exchange { fill: var(--muted); background: var(--muted); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.fact .cite, .facts .cite { vertical-align: baseline; line-height: 1.3; font-size: 10.5px; }
@media (max-width: 600px) {
  .top-inner { padding: 10px 14px; gap: 8px; }
  .wordmark { display: none; }
  .top-actions { flex-wrap: nowrap; gap: 0; }
  .link-btn { padding: 6px 7px; font-size: 12.5px; white-space: nowrap; }
  .lang-btn { padding: 5px 10px; font-size: 12px; }
  .intro { padding-top: 36px; }
  .composer textarea::placeholder { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---- official brand logos (single-colour marks tinted through a mask) ---- */
.header-logos { display: inline-flex; align-items: center; gap: 14px; }
.logo { display: inline-block; background: var(--logo-color, var(--ink)); -webkit-mask: var(--logo) center / contain no-repeat;
  mask: var(--logo) center / contain no-repeat; }
.logo.text { background: none; -webkit-mask: none; mask: none; font: 600 14px/1 var(--sans); }
.logo-sm { height: 32px; width: 80px; }
.logo-md { height: 40px; width: 120px; -webkit-mask-position: left center; mask-position: left center; }
[dir="rtl"] .logo-md { -webkit-mask-position: right center; mask-position: right center; }
.logo-sep { width: 1px; height: 22px; background: var(--line); }
.brandmark .wordmark { padding-inline-start: 14px; border-inline-start: 1px solid var(--line); color: var(--muted); font-size: 11.5px; }
.brand-logo { display: inline-block; margin-bottom: 12px; }
.brand-card h3 { font-size: 17px; }
@media (max-width: 600px) { .logo-sm { width: 54px; height: 22px; } .header-logos { gap: 10px; } }
