/* ==========================================================================
   Orea — chat
   A working tool first: matte surfaces, ivory ink, one family of shapes.
   The brand lives in the details (each wolf's gem, the wordmark), never in
   effects; motion only reports state.
   Shapes: rows and controls 6px, panels 8–10px, the composer 10px.
   Type: one Arabic family (DW Sans Arabic) for the interface and the
   replies; Sora only for the Latin brand names (the wordmark, the wolves).
   ========================================================================== */
:root {
  --bg: #0e1118;          /* the reading room */
  --bg-side: #10141c;     /* the drawer */
  --raised: #191f29;      /* composer, menus, dialogs */
  --fill: #1c2028;        /* your messages, pressed rows */
  --fill-2: #252a34;
  --hover: rgba(237, 231, 221, 0.055);
  --line: rgba(237, 231, 221, 0.075);
  --line-2: rgba(237, 231, 221, 0.13);
  --line-3: rgba(237, 231, 221, 0.24);
  --fg: #ede7dd;          /* ivory ink */
  --fg-2: #c6cbd3;
  --muted: #a4adbb;
  --ivory: #f2ece2;       /* the one accent: primary actions, focus, selection */
  --on-ivory: #0b0d11;
  --danger: #ff9e92;
  --font: "DW Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --latin: "Sora", "Noto Kufi Arabic", system-ui, sans-serif;
  /* type roles: what a line is for, not how big it is */
  --fs-read: 16px;        /* replies, your messages, the composer */
  --fs-ui: 14px;          /* rows, buttons, menus */
  --fs-meta: 12.5px;      /* times, groups, descriptions, status */
  --fs-display: 26px;     /* the greeting, the only display line */
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --side-w: 272px;
  --col: 720px;
  color-scheme: dark only;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: var(--fs-ui); line-height: 1.6;
  -webkit-font-smoothing: antialiased; overflow: hidden; caret-color: var(--ivory);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { display: block; max-width: 100%; }
::selection { background: rgba(242, 236, 226, 0.24); color: #fff; }
:focus-visible { outline: 2px solid var(--dw-focus,#d7bd9d); outline-offset: 3px; }
* { scrollbar-width: thin; scrollbar-color: rgba(237, 231, 221, 0.16) transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.ic { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width:var(--orea-icon-stroke,1.5); stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: 100%; transition: grid-template-columns 0.3s var(--ease); }
.app.collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app.collapsed .sidebar { visibility: hidden; opacity: 0; }

/* ---------- buttons ---------- */
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; flex: none; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 19px; transition: background 0.16s, color 0.16s; }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.icon-btn:active { background: var(--fill); }
.btn { min-height: 42px; padding: 8px 16px; border-radius: 6px; border: 1px solid transparent; font-size: var(--fs-ui); font-weight: 500; line-height: 1.5; transition: background 0.16s, border-color 0.16s; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--ivory); color: var(--on-ivory); }
.btn--primary:hover { background: #fff; }
.btn--ghost { background: transparent; border-color: var(--line-2); color: var(--fg); }
.btn--ghost:hover { background: var(--hover); border-color: var(--line-3); }
.btn--danger { background: transparent; border-color: rgba(255, 158, 146, 0.32); color: var(--danger); }
.btn--danger:hover { background: rgba(255, 158, 146, 0.08); }

/* ---------- sidebar ---------- */
.sidebar { min-width: 0; overflow: hidden; display: flex; flex-direction: column; padding: 10px 10px 8px; background: var(--bg-side); border-inline-end: 1px solid var(--line); transition: opacity 0.2s, visibility 0.2s; }
.sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 40px; margin-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; height: 36px; padding: 0 8px; border-radius: 10px; text-decoration: none; transition: background 0.15s; }
.brand:hover { background: var(--hover); }
.brand img { width: 20px; height: auto; flex: none; }
/* the wordmark: plain ivory, and the dot of the i is a cut gem */
.wm { font-family: var(--latin); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; direction: ltr; white-space: nowrap; color: var(--fg); }
.wm__i { position: relative; }
.wm__i::before { content: ""; position: absolute; left: 50%; top: 0.05em; width: 0.4em; height: 0.37em; transform: translateX(-50%); background: url("/assets/img/gems/hunter.svg") center / contain no-repeat; }

.side-nav { display: grid; gap: 2px; padding-bottom: 8px; }
.side-row { display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; text-align: start; font-size: var(--fs-ui); color: var(--fg-2); transition: background 0.16s, color 0.16s; }
.side-row:hover { background: var(--hover); color: var(--fg); }
.side-row .ic { font-size: 17px; color: var(--muted); }
.side-row:hover .ic { color: var(--fg-2); }
.side-row span { flex: 1; }
.side-row kbd { font: 11px var(--mono); color: var(--muted); opacity: 0; transition: opacity 0.15s; }
.side-row:hover kbd { opacity: 1; }
.side-search { cursor: text; }
.side-search:focus-within { background: var(--hover); }
.side-search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: transparent; font-size: var(--fs-ui); color: var(--fg); }
.side-search input::placeholder { color: var(--muted); opacity: 1; }
.side-search input::-webkit-search-cancel-button { filter: invert(1) opacity(0.45); }

.history { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 4px 4px 12px; border-top: 1px solid var(--line); }
.history h3 { margin: 16px 10px 4px; font-size: var(--fs-meta); font-weight: 500; color: var(--muted); }
.history__empty { margin: 14px 10px; color: var(--muted); font-size: var(--fs-meta); }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 6px; transition: background 0.16s; }
.chat-item:hover, .chat-item:focus-within { background: var(--hover); }
.chat-item.active { background: var(--fill); }
.chat-item__link { flex: 1; min-width: 0; display: flex; align-items: center; height: 36px; padding: 0 10px; border: 0; background: none; text-align: start; font-size: var(--fs-ui); color: var(--fg-2); }
.chat-item__title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.active .chat-item__link { color: var(--fg); }
.chat-item__tools { display: flex; gap: 0; padding-inline-end: 4px; opacity: 0; transition: opacity 0.15s; }
.chat-item:hover .chat-item__tools, .chat-item:focus-within .chat-item__tools, .chat-item.active .chat-item__tools { opacity: 1; }
.chat-item__tools button { width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 15px; }
.chat-item__tools button:hover { color: var(--fg); background: var(--hover); }
.chat-item__rename { flex: 1; min-width: 0; height: 32px; margin: 2px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line-3); background: var(--bg); outline: 0; font-size: var(--fs-ui); }

.sidebar__foot { padding-top: 8px; border-top: 1px solid var(--line); }
.account { width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: 10px; background: transparent; text-align: start; transition: background 0.15s; }
.account:hover { background: var(--hover); }
.account__avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--fill-2); color: var(--fg); font-weight: 600; font-size: 13.5px; }
.account__meta { flex: 1; min-width: 0; display: grid; line-height: 1.35; }
.account__meta b { font-weight: 500; font-size: var(--fs-ui); }
.account__meta small { color: var(--muted); font-size: var(--fs-meta); }
.account .ic { font-size: 18px; color: var(--muted); }
.scrim { display: none; }

/* ---------- main and the contact header ---------- */
.main { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; height: 100%; }
.topbar { position: relative; z-index: 6; flex: none; height: 56px; display: flex; align-items: center; gap: 4px; padding: 0 10px; }
.topbar__end { margin-inline-start: auto; display: flex; gap: 2px; }
#openSidebar, .only-collapsed { display: none; }
.app.collapsed #openSidebar, .app.collapsed .only-collapsed { display: inline-grid; }

.model-picker { position: relative; min-width: 0; }
.contact { display: flex; align-items: center; gap: 10px; min-width: 0; height: 44px; padding: 0 8px 0 10px; border: 0; border-radius: 12px; background: transparent; text-align: start; transition: background 0.15s; }
.contact:hover, .contact[aria-expanded="true"] { background: var(--hover); }
.contact__face { width: 30px; height: 30px; flex: none; border-radius: 50%; overflow: hidden; }
.contact__face img, .gem { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08); }
.contact__meta { display: grid; min-width: 0; line-height: 1.25; }
.contact__name { font-family: var(--latin); font-weight: 600; font-size: 15px; letter-spacing: -0.01em; direction: ltr; text-align: right; color: var(--fg); }
.contact__status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; }
.contact__status.is-live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ivory); animation: live 1.2s ease-in-out infinite; }
@keyframes live { 50% { opacity: 0.3; } }
.contact__chev { font-size: 15px; color: var(--muted); transition: transform 0.2s var(--ease); }
.contact[aria-expanded="true"] .contact__chev { transform: rotate(180deg); }

/* the model menu: a plain list, each wolf with its gem, a check on the one you talk to */
.menu {
  position: absolute; top: calc(100% + 6px); inset-inline-start: 0; z-index: 30; width: 320px; padding: 6px;
  background: var(--raised); border: 1px solid var(--line-2); border-radius: 8px;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.75);
  transform-origin: top right; animation: pop 0.16s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.menu__item { width: 100%; display: grid; grid-template-columns: 30px minmax(0, 1fr) 18px; align-items: center; gap: 12px; min-height: 44px; padding: 9px 10px; border: 0; border-radius: 6px; background: transparent; text-align: start; transition: background 0.16s; }
.menu__item:hover, .menu__item:focus-visible { background: var(--hover); }
.menu__item .gem { width: 30px; height: 30px; }
.menu__text { display: grid; line-height: 1.4; min-width: 0; }
.menu__name { font-family: var(--latin); font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; direction: ltr; text-align: right; }
.menu__text small { color: var(--muted); font-size: var(--fs-meta); }
.menu__check { font-size: 17px; color: var(--ivory); opacity: 0; }
.menu__item[aria-checked="true"] .menu__check { opacity: 1; }

/* ---------- thread ---------- */
.thread { position: relative; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; }
.messages { width: min(var(--col), 100%); margin: 0 auto; padding: 16px 24px 36px; display: flex; flex-direction: column; gap: 26px; }
.day { align-self: center; font-size: var(--fs-meta); color: var(--muted); }

/* a new conversation opens on the wolf you are talking to */
.empty { display: none; }
.main.is-empty .thread { flex: 0 0 auto; margin-top: auto; overflow: visible; }
.main.is-empty .composer-wrap { margin-bottom: auto; }
.main.is-empty .messages { display: none; }
.main.is-empty .empty { display: grid; justify-items: center; text-align: center; padding: 0 20px 26px; }
.empty__orea { --orea-h: 92px; display: flex; justify-content: center; margin-bottom: 18px; }
.empty__orea img { height: var(--orea-h); width: auto; filter: drop-shadow(0 14px 16px rgba(0, 0, 0, 0.55)); }
.empty__orea img.is-in { animation: wolf-in 0.32s var(--ease); }
@keyframes wolf-in { from { opacity: 0; transform: translateY(4px) scale(0.97); } }
.empty__greet { margin: 0; font-size: var(--fs-display); font-weight: 500; line-height: 1.45; color: var(--fg); text-wrap: balance; }
.empty__model { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 10px; margin: 6px 0 0; color: var(--muted); font-size: var(--fs-ui); }
#profileName { font-family: var(--latin); font-weight: 600; font-size: 13.5px; color: var(--fg-2); direction: ltr; }
.empty__sep { width: 3px; height: 3px; border-radius: 50%; background: var(--line-3); align-self: center; }

/* your messages: a quiet bubble on the left (the end of the line in Arabic) */
.msg { animation: msg-in 0.22s var(--ease) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg--user { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.msg--user .bubble { max-width: min(80%, 560px); padding: 9px 16px; border-radius: 20px; border-end-end-radius: 6px; background: var(--fill); color: var(--fg); white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-read); line-height: 1.8; }
.msg--user .msg__images { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.msg--user .msg__images img { width: 128px; height: 128px; object-fit: cover; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line-2); }
.msg__foot { display: flex; align-items: center; gap: 4px; min-height: 30px; }
.msg--user .msg__time { order: 2; padding-inline-start: 6px; }
.msg__time { font-size: var(--fs-meta); color: var(--muted); font-variant-numeric: tabular-nums; }

/* the wolf's replies: no bubble, the full width of the column, its gem and name above */
.msg--bot { display: grid; gap: 6px; }
.msg__meta { display: flex; align-items: center; gap: 8px; min-height: 26px; }
.msg__meta b { font-family: var(--latin); font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em; direction: ltr; color: var(--fg); }
.msg__avatar { position: relative; width: 24px; height: 24px; flex: none; border-radius: 50%; }
.msg__avatar .gem { display: block; }
/* while it writes, a thin ring turns around the gem */
.msg__avatar.is-writing::after { content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 1.5px solid transparent; border-top-color: var(--ivory); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.msg__body { min-width: 0; }
.wait-slot:empty, .think-slot:empty, .err-slot:empty { display: none; }
.typing-dots { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--fg-2); opacity: 0.25; animation: dot 1.1s ease-in-out infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot { 30% { opacity: 0.9; } }
.msg__actions { display: flex; gap: 0; opacity: 0; transition: opacity 0.15s; }
.msg--bot .msg__actions { margin-top: 6px; margin-inline-start: -7px; }
.msg:hover .msg__actions, .msg:focus-within .msg__actions, .msg--bot.last .msg__actions { opacity: 1; }
.msg.streaming .msg__actions { visibility: hidden; }
.msg__actions button { width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 16px; transition: background 0.15s, color 0.15s; }
.msg__actions button:hover { background: var(--hover); color: var(--fg); }
.msg__actions button[aria-pressed="true"] { color: var(--ivory); }
.msg__error { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; width: fit-content; max-width: 100%; margin-top: 4px; padding: 8px; padding-inline-start: 14px; border-radius: 12px; border: 1px solid rgba(255, 158, 146, 0.28); background: rgba(255, 158, 146, 0.06); color: #ffd6d0; font-size: var(--fs-ui); }
.msg__error .btn { height: 30px; padding: 0 12px; font-size: var(--fs-meta); border-color: rgba(255, 214, 208, 0.3); color: #ffe4df; }
.msg__error .btn:hover { background: rgba(255, 214, 208, 0.08); border-color: rgba(255, 214, 208, 0.5); }
.msg--bot.has-error .msg__actions { display: none; }
.edit-box { width: min(100%, 620px); display: grid; gap: 8px; padding: 10px; border-radius: 18px; background: var(--fill); border: 1px solid var(--line-2); }
.edit-box textarea { width: 100%; min-height: 60px; max-height: 40vh; resize: none; border: 0; outline: 0; background: transparent; line-height: 1.8; font-size: var(--fs-read); }
.edit-box div { display: flex; gap: 8px; justify-content: flex-end; }

/* thinking */
.think-box { margin-bottom: 12px; font-family: var(--font); }
.think-box summary { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; margin-inline-start: -10px; border-radius: 8px; list-style: none; cursor: pointer; color: var(--muted); font-size: 13px; transition: background 0.15s, color 0.15s; }
.think-box summary:hover { background: var(--hover); color: var(--fg-2); }
.think-box summary::-webkit-details-marker { display: none; }
.think-box summary .ic { font-size: 14px; transition: transform 0.2s var(--ease); }
.think-box[open] summary .ic { transform: rotate(180deg); }
.think-box__body { margin-top: 6px; padding-inline-start: 14px; border-inline-start: 1px solid var(--line-2); color: var(--muted); font-size: 13.5px; line-height: 1.85; white-space: pre-wrap; }
.think-box__body > div:empty::before { content: '\200b'; }   /* a blank line keeps its height */
.shimmer { color: var(--fg-2); animation: think-pulse 1.4s ease-in-out infinite; }
@keyframes think-pulse { 50% { opacity: 0.45; } }
.caret { display: inline-block; width: 2px; height: 1.05em; margin-inline-start: 2px; vertical-align: -0.15em; background: var(--fg); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* markdown: replies read at a comfortable measure */
.md { overflow-wrap: anywhere; color: var(--fg); font-size: var(--fs-read); line-height: 1.95; }
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
/* a reply is drawn in parts (text, blocks, widgets) so a running widget is never redrawn by the words after it */
.md > .md-seg { display: contents; }
.md > .md-seg:first-child > *:first-child { margin-top: 0; }
.md > .md-seg:last-child > *:last-child { margin-bottom: 0; }
.md p { margin: 0 0 16px; }
.md h2, .md h3, .md h4 { margin: 28px 0 8px; line-height: 1.6; font-weight: 600; color: #fff; }
.md h2 { font-size: 1.2em; } .md h3 { font-size: 1.08em; } .md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 16px; padding-inline-start: 22px; }
.md li { margin: 2px 0; padding-inline-start: 2px; }
.md li::marker { color: var(--muted); }
.md strong { font-weight: 600; color: #fff; }
.md a { color: var(--fg); text-decoration-color: var(--line-3); text-underline-offset: 4px; }
.md a:hover { text-decoration-color: var(--fg); }
.md code { font-family: var(--mono); font-size: 0.82em; padding: 2px 6px; border-radius: 6px; background: var(--fill); direction: ltr; unicode-bidi: isolate; }
.md blockquote { margin: 0 0 14px; padding: 2px 16px; border-inline-start: 1px solid var(--line-3); color: var(--fg-2); }
.md hr { border: 0; border-top: 1px solid var(--line-2); margin: 22px 0; }
.table-wrap { overflow-x: auto; margin: 4px 0 16px; border: 1px solid var(--line-2); border-radius: 12px; }
.md table { border-collapse: collapse; width: 100%; font-size: var(--fs-ui); line-height: 1.6; font-variant-numeric: tabular-nums; }
.md th, .md td { padding: 9px 14px; text-align: start; border-bottom: 1px solid var(--line); }
.md th { font-weight: 600; color: var(--fg-2); background: rgba(237, 231, 221, 0.03); }
.md tr:last-child td { border-bottom: 0; }
.codeblock { margin: 4px 0 16px; border-radius: 12px; overflow: hidden; background: #0a0b0e; border: 1px solid var(--line-2); line-height: 1.7; }
.codeblock__bar { display: flex; align-items: center; justify-content: space-between; height: 36px; padding: 0 6px 0 14px; border-bottom: 1px solid var(--line); font: 12px var(--mono); color: var(--muted); direction: ltr; }
.codeblock__copy { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: var(--fs-meta) var(--font); transition: background 0.15s, color 0.15s; }
.codeblock__copy:hover { background: var(--hover); color: var(--fg); }
.codeblock pre { margin: 0; padding: 14px 16px; overflow-x: auto; text-align: left; }
.codeblock code { font: 13.5px/1.7 var(--mono); background: none; padding: 0; color: #dcd6cc; }
.t-k { color: #e6b88a; } .t-s { color: #b9d3a3; } .t-n { color: #9ccfe6; } .t-c { color: #7c776f; font-style: italic; } .t-f { color: #f2ece2; }

.to-bottom { position: sticky; bottom: 14px; display: grid; place-items: center; width: 36px; height: 36px; margin: -50px auto 14px; border: 1px solid var(--line-2); border-radius: 50%; background: var(--raised); box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.7); color: var(--fg-2); font-size: 17px; z-index: 5; transition: color 0.15s, border-color 0.15s; }
.to-bottom:hover { color: var(--fg); border-color: var(--line-3); }

/* ---------- composer ---------- */
.composer-wrap { position: relative; z-index: 2; flex: none; display: flex; flex-direction: column; width: min(var(--col), 100%); margin: 0 auto; padding: 0 20px calc(16px + env(safe-area-inset-bottom)); }
.composer {
  display: grid; gap: 4px; padding: 12px 12px 10px; border-radius: 10px;
  background: var(--raised); border: 1px solid var(--line-2);
  box-shadow: 0 12px 32px -20px rgba(0, 0, 0, 0.9);
  transition: border-color 0.15s;
}
.composer:focus-within { border-color: #b69b7c; }
.composer textarea { width: 100%; min-height: 30px; max-height: 40vh; padding: 4px 8px; border: 0; outline: 0; resize: none; background: transparent; font-size: max(16px, var(--fs-read)); line-height: 1.75; }
.composer textarea::placeholder { color: var(--muted); opacity: 1; }
.composer__bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer__tools, .composer__send { display: flex; align-items: center; gap: 4px; }
.tool-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 6px; border: 0; background: transparent; color: var(--muted); font-size: 18px; transition: background 0.16s, color 0.16s; }
.tool-btn:hover { background: var(--hover); color: var(--fg); }
.tool-btn.listening { color: var(--on-ivory); background: var(--ivory); animation: listen 1.4s ease-in-out infinite; }
@keyframes listen { 50% { box-shadow: 0 0 0 5px rgba(242, 236, 226, 0.12); } }
.toggle { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 6px 10px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--fg-2); font-size: 13px; white-space: nowrap; transition: background 0.16s, color 0.16s, border-color 0.16s; }
.toggle .ic { font-size: 16px; }
.toggle:hover { background: var(--hover); color: var(--fg); }
.toggle[aria-pressed="true"] { background: #c8ac8a1c; border-color: #c8ac8a66; color: #e1c5a3; }
.send-btn { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: var(--ivory); color: var(--on-ivory); font-size: 17px; transition: background 0.16s, color 0.16s; }
.send-btn .ic { stroke-width:var(--orea-icon-stroke,1.5); }
.send-btn:not(:disabled):hover { background: #fff; }
.send-btn:not(:disabled):active { transform: translateY(1px); }
.send-btn:disabled { background: var(--fill-2); color: var(--muted); cursor: default; }
.send-btn .ic-stop { display: none; fill: currentColor; stroke: none; }
.main.streaming .send-btn .ic-send { display: none; }
.main.streaming .send-btn .ic-stop { display: block; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 4px 6px; }
.attachment { position: relative; width: 60px; height: 60px; border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line-2); }
.attachment img { width: 100%; height: 100%; object-fit: cover; }
.attachment button { position: absolute; top: 3px; inset-inline-end: 3px; width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: rgba(0, 0, 0, 0.72); color: #fff; font-size: 12px; }

/* openers: first messages to start from, listed under the composer */
.suggestions { display: none; }
.main.is-empty .suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 8px; margin-top: 14px; }
.suggestion { display: grid; gap: 4px; padding: 12px 14px; border: 0; border-radius: 6px; background: transparent; text-align: start; transition: background 0.16s; }
.suggestion:hover { background: var(--hover); }
.suggestion b { font-weight: 500; font-size: var(--fs-ui); color: var(--fg-2); }
.suggestion span { font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggestion:hover b { color: var(--fg); }
/* once you start writing, the openers step aside */
.main.is-empty .composer-wrap:has(textarea:not(:placeholder-shown)) .suggestions { display: none; }

.dropzone { position: absolute; inset: 10px; z-index: 40; display: grid; place-items: center; border-radius: 20px; border: 1.5px dashed var(--line-3); background: rgba(14, 16, 20, 0.92); font-size: 17px; color: var(--fg-2); pointer-events: none; }

/* ---------- dialog ---------- */
.dialog { padding: 0; border: 0; background: transparent; color: var(--fg); max-width: min(520px, calc(100vw - 24px)); width: 100%; }
.dialog::backdrop { background: rgba(5, 6, 8, 0.66); }
.dialog[open] { animation: pop 0.18s var(--ease); }
.dialog__card { display: grid; gap: 18px; padding: 20px; border-radius: 18px; background: var(--raised); border: 1px solid var(--line-2); box-shadow: 0 30px 60px -24px rgba(0, 0, 0, 0.8); max-height: calc(100dvh - 40px); overflow-y: auto; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; }
.dialog__head h2 { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.5; }
.dialog__foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.field { display: grid; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span { font-size: var(--fs-ui); font-weight: 500; color: var(--fg-2); }
.field textarea { width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--bg); outline: 0; font-size: var(--fs-ui); line-height: 1.8; resize: vertical; transition: border-color 0.15s; }
.field textarea:focus { border-color: var(--line-3); }
.field small { color: var(--muted); font-size: var(--fs-meta); line-height: 1.7; }
.field-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* settings: how visual the chat is, and its memory */
.field--choice { gap: 8px; }
.field--choice legend { font-size: var(--fs-ui); font-weight: 500; color: var(--fg-2); margin-bottom: 6px; padding: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { background: var(--hover); }
.choice:has(input:checked) { border-color: var(--line-3); background: var(--fill); }
.choice input { margin-top: 5px; accent-color: var(--ivory); }
.choice span { display: grid; gap: 2px; }
.choice b { font-weight: 500; font-size: var(--fs-ui); }
.switch { display: flex; gap: 10px; align-items: center; font-size: var(--fs-ui); color: var(--fg-2); cursor: pointer; }
.switch input { accent-color: var(--ivory); width: 16px; height: 16px; }
.memory-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; max-height: 220px; overflow-y: auto; }
.memory-list:empty::before { content: 'لا شيء محفوظ بعد. اطلب منه «تذكّر أنّ…» أو أخبره بتفضيل دائم.'; color: var(--muted); font-size: var(--fs-meta); }
.memory-list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: var(--fs-ui); line-height: 1.6; }
.memory-list li span { min-width: 0; overflow-wrap: anywhere; }
.memory-list li small { color: var(--muted); font-size: 11.5px; margin-inline-end: 6px; }
.memory-list button { flex: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; }
.memory-list button:hover { color: var(--danger); background: var(--hover); }
#watchList:empty::before { content: attr(data-empty-label); }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; z-index: 60; transform: translate(-50%, 12px); opacity: 0; pointer-events: none; padding: 9px 16px; border-radius: 12px; background: var(--ivory); color: var(--on-ivory); font-size: var(--fs-ui); font-weight: 500; box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.7); transition: opacity 0.2s, transform 0.2s var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
/* centred on the conversation, not on the window */
@media (min-width: 861px) { .app:not(.collapsed) ~ .toast { left: calc(50% - var(--side-w) / 2); } }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .app, .app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 50; width: min(300px, 86vw);
    border-inline-end: 1px solid var(--line-2); box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
    transform: translateX(100%); opacity: 1 !important;
    /* closed, the drawer leaves the tab order once it has slid away */
    visibility: hidden !important; transition: transform 0.28s var(--ease), visibility 0s linear 0.28s;
  }
  html[dir=ltr] .sidebar { transform: translateX(-100%); }
  html[dir=rtl] .sidebar { transform: translateX(100%); }
  .app.side-open .sidebar { transform: none; visibility: visible !important; transition: transform 0.28s var(--ease); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(5, 6, 8, 0.6); opacity: 0; pointer-events: none; transition: opacity 0.28s; }
  .app.side-open .scrim { opacity: 1; pointer-events: auto; }
  #openSidebar, .only-collapsed { display: inline-grid; }
  .topbar { padding: 0 6px; gap: 2px; }
  .contact { padding: 0 6px; gap: 9px; }
  .messages { padding: 12px 16px 28px; gap: 22px; }
  .composer-wrap { padding: 0 10px calc(10px + env(safe-area-inset-bottom)); }
  /* phones: the writing box stays docked at the bottom; the greeting centres in the space above,
     and the openers sit right above the box, within reach of the thumb */
  .main.is-empty .thread { flex: 1 1 auto; min-height: 0; margin-top: 0; display: flex; flex-direction: column; justify-content: center; overflow-y: auto; }
  .main.is-empty .composer-wrap { margin-bottom: 0; }
  .main.is-empty .suggestions { order: -1; margin: 0 0 10px; gap: 6px; }
  .suggestion { padding: 9px 12px; background: var(--raised); border: 1px solid var(--line); }
  .suggestion span { display: none; }
  .suggestion b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  :root { --fs-display: 22px; }
  .empty__orea { --orea-h: 78px; margin-bottom: 14px; }
  .empty__model { font-size: var(--fs-meta); }
  .msg__actions { opacity: 1; }
  .menu { width: min(320px, calc(100vw - 20px)); }
}
/* phones: the model menu opens as a plate under the header, never past the screen edge */
@media (max-width: 560px) {
  .menu { position: fixed; top: 56px; inset-inline: 10px; width: auto; }
}
@media (max-width: 380px) {
  .toggle span { display: none; }
  .toggle { width: 34px; padding: 0; justify-content: center; }
  /* the model's name and its line stack instead of leaving the dot at a line end */
  .empty__model { flex-direction: column; align-items: center; gap: 0; }
  .empty__sep { display: none; }
  .suggestion b { white-space: normal; }
}
/* short screens (landscape phones): the greeting shrinks so the composer always stays in view */
@media (max-height: 560px) {
  .topbar { height: 50px; }
  .contact { height: 42px; }
  .menu { top: 50px; max-height: calc(100svh - 62px); overflow-y: auto; }
  .main.is-empty .thread { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
  .main.is-empty .empty { padding-bottom: 12px; }
  :root { --fs-display: 20px; }
  .empty__orea { --orea-h: 56px; margin-bottom: 8px; }
  .empty__model { margin-top: 2px; }
  .main.is-empty .suggestions { margin-top: 8px; }
  .composer { padding: 6px 8px 6px; }
  .messages { padding-top: 10px; padding-bottom: 16px; gap: 18px; }
}
@media (max-height: 440px) {
  .empty__model, .main.is-empty .suggestions { display: none; }
}
/* large desktops: a wider column and larger type, so the room is not a strip in the middle */
@media (min-width: 1680px) {
  :root { --side-w: 296px; --col: 800px; --fs-read: 17.5px; --fs-ui: 15px; --fs-meta: 13px; --fs-display: 30px; }
  .topbar { height: 62px; }
  .msg--user .bubble { max-width: min(80%, 640px); }
  .empty__orea { --orea-h: 112px; }
}
@media (min-width: 2200px) {
  :root { --side-w: 330px; --col: 920px; --fs-read: 19px; --fs-ui: 16px; --fs-meta: 14px; --fs-display: 34px; }
  .topbar { height: 70px; }
  .msg--user .bubble { max-width: min(80%, 720px); }
  .codeblock code { font-size: 15px; }
  .empty__orea { --orea-h: 130px; }
}
@media (pointer: coarse) {
  .icon-btn, .tool-btn { min-width: 44px; min-height: 44px; }
  .send-btn { width: 44px; height: 44px; }
  .toggle { min-height: 44px; }
  .btn { min-height: 44px; }
  .side-row, .chat-item__link { min-height: 44px; }
  .msg__actions button { width: 40px; height: 40px; }
  .chat-item__tools button { width: 40px; height: 40px; }
  .suggestion { min-height: 44px; }
  .codeblock__copy { height: 36px; }
  .composer textarea { min-height: 40px; padding-block: 7px; }
}
@media (pointer: coarse) and (max-width: 380px) {
  .toggle { width: 40px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* وضع الهاتف الداكن/الفاتح لا يغيّر ألوان الموقع: المتصفّحات (Samsung Internet وChrome) لا تعيد تلوين صفحة تعلن أنّها داكنة. */
@media (prefers-color-scheme: dark) { :root { color-scheme: dark only; } }

/* install-as-app button: shown by install.js only where the browser can install the site */
[data-install][hidden] { display: none !important; }

/* Chat shares the workbench palette and keeps its original conversation controls. */
:root{--bg:#181a1e;--bg-side:#14171b;--raised:#272d35;--fill:#2b323c;--fill-2:#373f4c;--fg:#edf1f6;--fg-2:#c6ceda;--muted:#b0bac8;--ivory:#e6edf5;--line:#bdcce014;--line-2:#bdcce02b;--line-3:#bdcce04d;--latin:'DW Sans Arabic',system-ui,sans-serif}
.composer{border-color:#566174;border-radius:14px;background:#242a33;box-shadow:none}
.composer:focus-within{border-color:#b69b7c}.icon-btn,.tool-btn{border-radius:7px}.send-btn{border-radius:8px}.side-row,.chat-item__link{border-radius:7px}.side-row:hover,.chat-item__link:hover{background:#241c14}.chat-item.is-active .chat-item__link{background:#30261c}
.embedded-chat{--side-w:220px;--col:760px}.embedded-chat .app{height:100dvh;min-height:0}.embedded-chat .sidebar{background:#16191e;border-color:#333b47}.embedded-chat .sidebar__head{min-height:50px;padding-top:14px}.chat-history-title{font:500 13px/1.6 var(--font);color:#d3dce7}.embedded-chat .sidebar__head .icon-btn{width:30px;min-height:30px}.embedded-chat .side-nav{padding-top:8px}.embedded-chat .dw-suite-links,.embedded-chat .dw-account-trigger{display:none!important}.embedded-chat .dw-suite-bar{min-height:38px;height:38px;padding-inline:24px;background:#181c22;border-bottom:1px solid #343c48}.embedded-chat .dw-context-trigger{font-size:11px;min-height:32px}.embedded-chat .topbar{height:50px;min-height:50px;background:#181a1e;border-color:#323944}.embedded-chat .empty__title{font-size:26px}.embedded-chat .empty__orea{--orea-h:70px}.embedded-chat .sidebar__foot .account{border-radius:7px}.embedded-chat .thread{scrollbar-gutter:stable}
@media(max-width:760px){.embedded-chat .dw-suite-bar{padding-inline:16px}.embedded-chat .topbar{height:48px;min-height:48px}.embedded-chat .empty__title{font-size:23px}.embedded-chat .composer{border-radius:12px}.embedded-chat .empty__orea{--orea-h:60px}}

/* writing box: tools on the left, send on the right, in every language; the typed text stays right-to-left in Arabic */
html[dir=rtl] form.composer{direction:ltr}
html[dir=rtl] form.composer :is(textarea,.attachments){direction:rtl}
