/* دردشة أوبتس البسيطة — حبر أسود وأبيض وفضي، بلا ذهبي. اتجاه منطقي (يمين/يسار يتبع اللغة). */

/* الخط: Noto Sans Arabic (متغيّر، رخصة OFL) من ملفات الموقع نفسه، بلا أي خادم خارجي. مقصوص لأوزان 300-700 ولأحرف العربية واللاتينية المستعملة (tools/make_fonts.py): 56+22 ك.ب بدل 197. ملفان منفصلان حتى ما ينحمّل غير المستعمل. */
@font-face { font-family: "Noto Sans Arabic Variable"; font-style: normal; font-display: swap; font-weight: 300 700; src: url(NotoSansArabic-arabic.4e87edad.woff2) format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+200C-200F, U+2010-2011, U+25CC, U+FD3E-FD3F, U+FDF2, U+FE70-FEFF; }
@font-face { font-family: "Noto Sans Arabic Variable"; font-style: normal; font-display: swap; font-weight: 300 700; src: url(NotoSansArabic-latin.9b4f9e57.woff2) format("woff2");
  unicode-range: U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2010-2027, U+2030-203A, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF; }

:root {
  --font: "Noto Sans Arabic Variable", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, system-ui, sans-serif;
  --fs: 16px;
  --ease: cubic-bezier(.2, .8, .2, 1); --dur: .18s;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px;
  --mute-on-panel: #a2a2ab;
  --bg: #0b0b0c; --side: #101012; --panel: #17171a; --panel2: #1d1d21; --line: #26262b; --line2: #3a3a41;
  --text: #ececee; --mute: #9a9aa3; --silver: #c9cad1; --accent: #f4f4f6; --on-accent: #0b0b0c;
  --danger: #e08a8a; --ok: #a9c7ab; --code: #131316; --shadow: #000a;
  --k1: #b8bcc8; --k2: #8f939e; --k3: #d9dbe2; --k4: #7d818b;
  --r: 16px; --side-w: 272px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #fafafa; --side: #f1f1f3; --panel: #ffffff; --panel2: #ececef; --line: #dcdce1; --line2: #b9b9c1;
  --text: #16161a; --mute: #63636c; --silver: #3c3d44; --accent: #121214; --on-accent: #ffffff;
  --danger: #a33a3a; --ok: #2f6b37; --code: #f3f3f5; --shadow: #0002;
  --k1: #3d4250; --k2: #6a6e79; --k3: #1d1f26; --k4: #8a8d96;
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root[data-theme="system"] {
    --bg: #fafafa; --side: #f1f1f3; --panel: #ffffff; --panel2: #ececef; --line: #dcdce1; --line2: #b9b9c1;
    --text: #16161a; --mute: #63636c; --silver: #3c3d44; --accent: #121214; --on-accent: #ffffff;
    --danger: #a33a3a; --ok: #2f6b37; --code: #f3f3f5; --shadow: #0002;
    --k1: #3d4250; --k2: #6a6e79; --k3: #1d1f26; --k4: #8a8d96;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  font-size: var(--fs); line-height: 1.65; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, select { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, textarea:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--silver); outline-offset: 2px; }
[hidden] { display: none !important; }
.sp { flex: 1; }
.kbd { margin-inline-start: auto; font-size: 11px; color: var(--mute); font-family: inherit; }

.app { display: flex; height: 100dvh; }

/* الشريط الجانبي */
.side { width: var(--side-w); flex: none; background: var(--side); border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; }
.logo { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--silver); display: grid; place-items: center; font-weight: 700; font-size: 13px; color: var(--accent); }
.brand-name { font-weight: 700; letter-spacing: .08em; font-size: 17px; }
.new-chat { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; color: var(--accent); background: var(--panel); }
.new-chat:hover { border-color: var(--line2); }
.search { margin-top: 10px; }
.search input { width: 100%; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.list { flex: 1; overflow-y: auto; margin-top: 8px; scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
.group-title { font-size: 12px; color: var(--mute); padding: 12px 10px 4px; }
.item { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 6px; border-radius: 10px; color: var(--silver); cursor: pointer; width: 100%; text-align: start; min-height: 38px; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.item .open { flex: 1; min-width: 0; text-align: start; padding: 7px 4px; border-radius: 8px; color: inherit; }
.item .open:focus-visible { outline-offset: -2px; }
.item span.t { display: block; min-width: 0; }
/* العنوان: اتجاه النص حسب لغته (bdi) حتى يقصّ من آخره، والمحاذاة تتبع اتجاه الواجهة فتصير القائمة مرتبة */
.item span.t bdi { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
[dir="rtl"] .item span.t bdi { text-align: right; } [dir="ltr"] .item span.t bdi { text-align: left; }
.item .snip { font-size: 12px; color: var(--mute); }
.item .snip { display: block; font-size: 12px; color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item:hover, .item.on { background: var(--panel2); color: var(--accent); }
.item .ia { opacity: 0; color: var(--mute); min-width: 30px; min-height: 30px; display: grid; place-items: center; font-size: 14px; border-radius: 8px; }
.item .ia:hover { color: var(--accent); }
.item:hover .ia, .item:focus-within .ia, .item.on .ia { opacity: 1; }
@media (hover: none) { .item .ia { opacity: .7; } }
.item input.rn { flex: 1; min-width: 0; font: inherit; font-size: 14px; background: var(--bg); color: var(--text); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 6px; }
.empty { color: var(--mute); font-size: 14px; padding: 10px; }
.empty-list { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; padding: 28px 12px; }
.empty-list strong { color: var(--silver); font-weight: 600; }
.user { border-top: 1px solid var(--line); padding: 12px 8px 4px; margin-top: 8px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; flex: none; }
.user .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .plan { display: block; font-size: 12px; color: var(--mute); }
.lnk { color: var(--mute); font-size: 13px; padding: 4px 6px; border-radius: 6px; }
.lnk:hover { color: var(--accent); }

/* المحتوى */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
.top { display: flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 52px; }
.burger { display: none; width: 40px; height: 40px; border-radius: 10px; font-size: 20px; }
.model-wrap { position: relative; min-width: 0; }
.model-btn { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px; color: var(--silver); font-weight: 600; max-width: 52vw; }
.model-btn #modelName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn:hover { background: var(--panel); }
.model-menu { position: absolute; inset-inline-start: 0; top: calc(100% + 4px); z-index: 20; min-width: 230px; max-height: 50vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 12px 32px var(--shadow); }
.model-menu button { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; padding: 8px 10px; border-radius: 8px; color: var(--silver); }
.model-menu button:hover, .model-menu button.on { background: var(--panel2); color: var(--accent); }
.model-menu button.on::after { content: "✓"; margin-inline-start: auto; }
.model-menu .mm-note { font-size: 12px; color: var(--mute); padding: 6px 10px; }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); padding: 0 6px; }
.conn i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.conn.wait i { background: var(--mute); animation: pulse 1.2s ease-in-out infinite; }
.conn.bad i { background: var(--danger); }
.conn.good #connText { display: none; }
.ib { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; color: var(--silver); flex: none; }
.ib.sm { width: 34px; height: 34px; border-radius: 10px; }
.ib:hover { background: var(--panel2); }
.banner { margin: 0 auto 4px; max-width: 760px; width: calc(100% - 32px); padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); font-size: 14px; color: var(--silver); display: flex; align-items: center; gap: 10px; }
.banner .bar { flex: 1; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; position: relative; min-width: 60px; }
.banner .bar::after { content: ""; position: absolute; inset-block: 0; width: 40%; background: var(--silver); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { inset-inline-start: -40%; } to { inset-inline-start: 100%; } }
.banner.bad { border-color: var(--danger); }

.stage { flex: 1; overflow-y: auto; overflow-x: hidden; }
.hero { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0 20px 14vh; text-align: center; }
.hero h1 { font-size: clamp(26px, 4.4vw, 38px); font-weight: 500; margin: 0 0 26px; }
.hero h1 .hl { background: linear-gradient(90deg, #8d8d96, var(--accent) 45%, #8d8d96); -webkit-background-clip: text; background-clip: text; color: transparent; }
#heroSlot { width: 100%; max-width: 760px; }
.hero .composer-wrap { max-width: 760px; width: 100%; padding: 0; }
.jump { position: absolute; inset-inline-start: 50%; transform: translateX(-50%); bottom: 130px; width: 36px; height: 36px; border-radius: 50%; background: var(--panel); border: 1px solid var(--line2); color: var(--silver); display: grid; place-items: center; box-shadow: 0 6px 18px var(--shadow); z-index: 5; }
[dir="rtl"] .jump { transform: translateX(50%); }

/* الرسائل */
.msgs { max-width: 760px; margin: 0 auto; padding: 18px 18px 8px; }
.msg { margin: 0 0 20px; animation: rise .28s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
[dir="rtl"] .msg.user { align-items: flex-start; }
.msg.user .bub { background: var(--panel2); padding: 10px 16px; border-radius: 18px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user .uacts { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; margin-top: 2px; }
.msg.user:hover .uacts, .msg.user:focus-within .uacts { opacity: 1; }
@media (hover: none) { .msg.user .uacts { opacity: .8; } }
.msg.bot .bub { overflow-wrap: anywhere; }
.bub p { margin: 0 0 .7em; } .bub p:last-child { margin-bottom: 0; }
.bub ul, .bub ol { margin: .3em 0 .8em; padding-inline-start: 1.4em; }
.bub code { background: var(--code); border-radius: 6px; padding: 1px 6px; font-family: Consolas, "Cascadia Mono", monospace; font-size: .92em; direction: ltr; unicode-bidi: isolate; }
.bub .codebox { border: 1px solid var(--line); border-radius: 12px; margin: .4em 0 .9em; overflow: hidden; background: var(--code); direction: ltr; }
.bub .codebar { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 4px 12px; font-size: 12px; color: var(--mute); border-bottom: 1px solid var(--line); font-family: Consolas, monospace; }
.bub .codebar button { font-size: 12px; color: var(--mute); padding: 2px 8px; border-radius: 6px; }
.bub .codebar button:hover { color: var(--accent); background: var(--panel2); }
.bub pre { margin: 0; padding: 12px 14px; overflow-x: auto; text-align: left; }
.bub pre code { background: none; padding: 0; font-size: 13.5px; line-height: 1.55; }
.tk-k { color: var(--k3); font-weight: 600; } .tk-s { color: var(--k1); } .tk-c { color: var(--k4); font-style: italic; } .tk-n { color: var(--k2); }
.bub a { color: var(--silver); text-decoration: underline; text-underline-offset: 3px; }
.bub h3, .bub h4 { font-size: 1.05em; margin: .9em 0 .4em; }
.bub blockquote { margin: .4em 0; padding-inline-start: 12px; border-inline-start: 3px solid var(--line2); color: var(--mute); }
.bub hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }
.bub .tbl { overflow-x: auto; margin: .4em 0 .9em; }
.bub table { border-collapse: collapse; font-size: 14px; min-width: 50%; }
.bub th, .bub td { border: 1px solid var(--line); padding: 6px 10px; text-align: start; }
.bub th { background: var(--panel2); font-weight: 600; }
.bub .math { font-family: "Cambria Math", "STIX Two Math", serif; font-style: italic; direction: ltr; unicode-bidi: isolate; padding: 0 2px; }
.note { color: var(--danger); font-size: 14px; }
.errbox { border: 1px solid var(--line2); border-radius: 12px; padding: 10px 14px; font-size: 14px; background: var(--panel); }
.errbox b { display: block; margin-bottom: 2px; }
.errbox details { color: var(--mute); font-size: 12px; margin-top: 6px; }
.errbox .acts { margin-top: 8px; }

/* التفكير والأدوات */
.think { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 4px; }
.think-head { display: inline-flex; align-items: center; gap: 8px; color: var(--mute); font-size: 14px; padding: 2px 0; min-height: 28px; }
.think-head .chev { opacity: .7; transition: transform .2s; }
.think-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.think-head:not(.live) .dots { display: none; }
.think-head .tm { font-variant-numeric: tabular-nums; opacity: .8; }
.think-head.live .tw { background: linear-gradient(90deg, var(--mute) 0%, var(--accent) 50%, var(--mute) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shine 1.6s linear infinite; }
@keyframes shine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.think-body { margin: 6px 0 10px; padding-inline-start: 12px; border-inline-start: 2px solid var(--line); color: var(--mute); font-size: 13.5px; white-space: pre-wrap; line-height: 1.7; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--silver); opacity: .35; animation: pulse 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .18s; } .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }
.steps { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; margin-bottom: 6px; }
.steps:empty { display: none; }
.tool { display: inline-flex; align-items: center; gap: 7px; padding: 3px 12px 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--silver); font-size: 13px; animation: rise .22s ease-out both; }
.tool.run svg { animation: pulse 1.2s ease-in-out infinite; }
.tool .tt { font-variant-numeric: tabular-nums; color: var(--mute); font-size: 12px; }
.tool.ok .td { color: var(--ok); } .tool.bad .td { color: var(--danger); }
.status-line { font-size: 13px; color: var(--mute); margin: 2px 0 6px; }
.caret { display: inline-block; width: 7px; height: 1.05em; vertical-align: text-bottom; margin-inline-start: 3px; background: var(--silver); border-radius: 2px; animation: caret 1s steps(2, start) infinite; }
@keyframes caret { to { visibility: hidden; } }
.stats { display: flex; align-items: center; gap: 4px; color: var(--mute); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.stats span { opacity: .75; margin-inline-start: 4px; }
.sb { min-width: 28px; height: 28px; border-radius: 7px; display: inline-grid; place-items: center; color: var(--mute); font-size: 14px; padding: 0 6px; }
.sb:hover { background: var(--panel2); color: var(--text); }

/* بطاقات تطلب ردّك (توضيح / موافقة / صلاحية) */
.ask { border: 1px solid var(--line2); border-radius: 14px; padding: 12px 14px; margin: 6px 0 10px; background: var(--panel); animation: rise .22s ease-out both; }
.ask .ask-h { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mute); margin-bottom: 6px; }
.ask .ask-h::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.ask.done .ask-h::before { animation: none; background: var(--ok); }
.ask.gone .ask-h::before { animation: none; background: var(--mute); }
.ask .q { font-weight: 600; margin: 4px 0 8px; }
.ask .opts { display: flex; flex-direction: column; gap: 6px; }
.ask .opt { text-align: start; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.ask .opt:hover:not(:disabled) { border-color: var(--line2); }
.ask .opt.on { border-color: var(--accent); background: var(--panel2); }
.ask .opt:disabled { opacity: .55; cursor: default; }
.ask .free { display: flex; gap: 6px; margin-top: 6px; }
.ask .free input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.ask pre.cmd { direction: ltr; text-align: left; background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; overflow-x: auto; font-size: 13px; margin: 6px 0; white-space: pre-wrap; }
.ask.ap .ap-title { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 2px 0 4px; }
.ask.ap .ap-count { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line2); color: var(--mute); direction: ltr; }
.ask.ap .ap-why { font-size: 14px; color: var(--mute); margin: 0 0 6px; line-height: 1.6; }
.ask.ap pre.cmd { max-height: 160px; overflow: auto; word-break: break-all; }
.ask.ap .ap-more { margin: 4px 0 2px; font-size: 13px; color: var(--mute); }
.ask.ap .ap-more summary { cursor: pointer; width: fit-content; }
.ask.ap .ap-raw { direction: ltr; text-align: left; font-family: ui-monospace, Consolas, monospace; font-size: 12px; margin-top: 4px; word-break: break-word; opacity: .9; }
.ask.ap .ap-hint { margin-top: 6px; font-size: 12px; }
.ask.ap-del, .ask.ap-net, .ask.ap-sys, .ask.ap-git, .ask.ap-proc { border-color: var(--line2); }
.ask.ap-del .ap-title span:first-child::before, .ask.ap-net .ap-title span:first-child::before, .ask.ap-sys .ap-title span:first-child::before, .ask.ap-git .ap-title span:first-child::before { content: "⚠ "; opacity: .8; }
.ask .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ask .result { font-size: 13px; color: var(--mute); margin-top: 6px; }
.ask .qblock + .qblock { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }

/* وسائط وملفات داخل الرد */
.media { margin: .5em 0 .9em; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--code); max-width: 520px; }
.media img, .media video { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #000; cursor: zoom-in; }
.media video { cursor: auto; }
.media .mbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12.5px; color: var(--mute); }
.media .mbar .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }
.media .mbar a, .media .mbar button { color: var(--silver); font-size: 12.5px; text-decoration: none; padding: 2px 8px; border-radius: 6px; }
.media .mbar a:hover, .media .mbar button:hover { background: var(--panel2); }
.media .merr { padding: 14px; font-size: 13px; color: var(--mute); }
.fcard { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.fcard .ic { width: 34px; height: 34px; border-radius: 8px; background: var(--panel2); display: grid; place-items: center; flex: none; }
.pv { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin: .5em 0 .9em; background: #fff; }
.pv iframe { display: block; width: 100%; height: 420px; border: 0; background: #fff; }
.pv .mbar { background: var(--code); }

/* صندوق الكتابة */
.composer-wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 16px 14px; }
.composer { background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 8px 10px 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.composer:focus-within { border-color: var(--line2); }
.composer textarea { width: 100%; background: transparent; border: 0; resize: none; color: var(--text); font: inherit; max-height: 200px; min-height: 28px; padding: 8px 8px 0; outline: none; line-height: 1.6; }
.composer textarea::placeholder { color: var(--mute); }
.tools { display: flex; align-items: center; gap: 4px; }
.ib.rec { color: #fff; background: #3a2323; }
.send { background: var(--accent); color: var(--on-accent); }
.send:hover { background: var(--accent); opacity: .9; }
.send:disabled { background: var(--panel2); color: var(--mute); cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 6px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--panel2); border-radius: 999px; padding: 3px 10px; font-size: 13px; color: var(--silver); max-width: 100%; }
.chip img { width: 22px; height: 22px; border-radius: 5px; object-fit: cover; }
.chip .cn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.chip button { color: var(--mute); }
.foot { text-align: center; color: var(--mute); font-size: 12px; padding: 6px 0 0; }
.editing { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--mute); padding: 0 12px 4px; }

/* أزرار عامة */
.btn { display: inline-block; padding: 11px 14px; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 700; text-align: center; text-decoration: none; }
.btn.sm { padding: 7px 14px; font-size: 14px; font-weight: 600; border-radius: 10px; }
.btn.ghost { background: transparent; color: var(--silver); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--line2); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
.field { width: 100%; padding: 11px 12px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--text); font: inherit; margin-top: 10px; }

/* شاشة الدخول */
.gate { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: var(--bg); z-index: 50; }
.card { width: min(380px, 100%); text-align: center; }
.card .logo { width: 52px; height: 52px; font-size: 20px; margin: 0 auto 18px; }
.card h1 { font-size: 24px; margin: 0 0 8px; }
.card p { color: var(--mute); margin: 0 0 22px; }
.card .btn { display: block; width: 100%; margin-top: 10px; }
.card .err { color: var(--danger); font-size: 14px; min-height: 1.4em; margin-top: 10px; }

/* النوافذ (إعدادات، ملفات، استوديو) */
.modal { position: fixed; inset: 0; z-index: 70; background: #0008; display: grid; place-items: center; padding: 16px; }
.sheet { width: min(520px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 60px var(--shadow); overflow: hidden; }
.sheet.wide { width: min(720px, 100%); }
.sheet.tall { height: min(720px, calc(100dvh - 32px)); }
.sheet-head { display: flex; align-items: center; gap: 6px; padding: 12px 14px 8px 18px; }
.sheet-head h2 { font-size: 17px; margin: 0; flex: 1; }
.sheet-head .sp + .ib, .sheet-head h2 + .sp { flex: none; }
.sheet-body { padding: 4px 18px 16px; overflow-y: auto; flex: 1; }
.sheet-foot { padding: 0 18px 12px; min-height: 22px; font-size: 13px; color: var(--mute); }
.tabs { display: flex; gap: 4px; padding: 0 14px 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { padding: 7px 12px; border-radius: 9px; color: var(--mute); font-size: 14px; white-space: nowrap; }
.tabs button.on { background: var(--panel2); color: var(--accent); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.row.col { flex-direction: column; align-items: stretch; }
.row-in { display: flex; justify-content: space-between; gap: 12px; }
.row select { min-width: 160px; max-width: 60%; padding: 7px 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); color: var(--text); }
.row select, .grid3 select { appearance: none; -webkit-appearance: none; padding-inline-end: 30px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%239a9aa3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
[dir="rtl"] .row select, [dir="rtl"] .grid3 select { background-position: left 10px center; }
.row .val { color: var(--silver); text-align: end; }
.hint { color: var(--mute); font-size: 13px; margin: 6px 0 4px; }
.meter { height: 6px; background: var(--panel2); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; width: 0; background: var(--silver); border-radius: 6px; }
.acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.saved { font-size: 13px; }
input.sw { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: 22px; background: var(--line2); position: relative; cursor: pointer; flex: none; margin: 0; transition: background .15s; }
input.sw::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--bg); transition: inset-inline-start .15s; }
input.sw:checked { background: var(--accent); }
input.sw:checked::after { inset-inline-start: 21px; }
input.sw:disabled { opacity: .5; }

/* الملفات */
.crumbs { padding: 0 18px 8px; font-size: 12.5px; color: var(--mute); overflow-x: auto; white-space: nowrap; text-align: start; }
.files-body { flex: 1; min-height: 0; display: flex; border-top: 1px solid var(--line); }
.flist { width: 100%; overflow-y: auto; padding: 6px; }
.fview:not([hidden]) ~ .flist, .files-body.viewing .flist { display: none; }
.frow { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 10px; text-align: start; font-size: 14px; }
.frow:hover { background: var(--panel2); }
.frow .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }
.frow .fs { color: var(--mute); font-size: 12px; font-variant-numeric: tabular-nums; }
.fview { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.fview .mbar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.fview .mbar .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }
.fview .mbar a, .fview .mbar button { color: var(--silver); text-decoration: none; padding: 3px 8px; border-radius: 6px; font-size: 13px; }
.fview .mbar a:hover, .fview .mbar button:hover { background: var(--panel2); }
.fview .fbody { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; background: var(--code); }
.fview iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.fview img, .fview video { max-width: 100%; max-height: 100%; }
.fview pre { place-self: stretch; margin: 0; padding: 12px; font-size: 13px; white-space: pre-wrap; direction: ltr; text-align: left; }

/* الاستوديو */
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { padding: 6px 14px; border-radius: 8px; color: var(--mute); }
.seg button.on { background: var(--panel2); color: var(--accent); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.grid3 label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--mute); }
.grid3 select { padding: 7px 8px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); color: var(--text); }
.st-note { font-size: 13.5px; color: var(--silver); margin-top: 10px; min-height: 1.2em; }
.st-out .media { max-width: 100%; margin-top: 12px; }
.progress { height: 4px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--silver); width: 0; transition: width .5s; }

.lightbox { position: fixed; inset: 0; z-index: 90; background: #000e; display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; }
.toast { position: fixed; inset-inline: 0; bottom: 90px; margin: 0 auto; width: max-content; max-width: 90vw; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: 14px; z-index: 95; }

.scrim { display: none; }
@media (max-width: 760px) {
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; transform: translateX(var(--hide, 100%)); transition: transform .2s; width: min(84vw, 300px); }
  [dir="rtl"] .side { --hide: 100%; }
  [dir="ltr"] .side { --hide: -100%; }
  .side.open { transform: none; box-shadow: 0 0 40px var(--shadow); }
  .scrim.on { display: block; position: fixed; inset: 0; background: #0009; z-index: 30; }
  .burger { display: grid; place-items: center; }
  .hero { padding-bottom: 8vh; }
  .composer-wrap { padding: 0 10px 10px; }
  .msgs { padding: 14px 14px 8px; }
  .kbd { display: none; }
  .conn #connText { display: none; }
  .modal { padding: 0; place-items: end stretch; }
  .sheet, .sheet.wide { width: 100%; border-radius: 18px 18px 0 0; max-height: 92dvh; }
  .sheet.tall { height: 92dvh; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .row select { min-width: 0; max-width: 55%; }
  .pv iframe { height: 340px; }
  .jump { bottom: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .dots i { opacity: .8; } .caret { opacity: .8; }
}

/* ---------- لوحة المعاينة (2026-10-24) ---------- */
:root { --pane-w: min(46vw, 820px); }
.pane { position: fixed; inset-block: 0; inset-inline-end: 0; z-index: 60; width: var(--pane-w); display: flex; flex-direction: column;
  background: var(--bg); border-inline-start: 1px solid var(--line); box-shadow: 0 0 28px #0004;
  transform: translateX(100%); opacity: .6; transition: transform .22s cubic-bezier(.2,.8,.2,1), opacity .22s ease; will-change: transform; }
[dir="rtl"] .pane { transform: translateX(-100%); }
.pane.in, [dir="rtl"] .pane.in { transform: none; opacity: 1; }
.main { transition: margin .22s cubic-bezier(.2,.8,.2,1); }
.app.pane-open .main { margin-inline-end: var(--pane-w); }
.app.resizing, .app.resizing * { cursor: col-resize !important; user-select: none; }
.app.resizing .pane, .app.resizing .main { transition: none; }
.app.resizing iframe { pointer-events: none; }
.pane-resize { position: absolute; inset-block: 0; inset-inline-start: -5px; width: 10px; cursor: col-resize; z-index: 2; touch-action: none; }
.pane-resize::after { content: ""; position: absolute; inset-block: 0; inset-inline-start: 4px; width: 2px; background: transparent; transition: background .15s; }
.pane-resize:hover::after, .pane-resize:focus-visible::after, .app.resizing .pane-resize::after { background: var(--silver); }
.skel { background: linear-gradient(90deg, var(--panel2) 25%, var(--line) 50%, var(--panel2) 75%); background-size: 200% 100%; animation: optes-shimmer 1.2s ease-in-out infinite; }
@keyframes optes-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.pane-skel { display: flex; flex-direction: column; gap: 10px; padding: 18px; place-self: start stretch; }
.pane-skel .line { height: 12px; border-radius: 6px; }
.pane-skel .line:nth-child(3n) { width: 70%; }
.pv-img-skel { width: min(80%, 640px); aspect-ratio: 4 / 3; border-radius: 12px; }
.othumb img, .pv-img { opacity: 0; transition: opacity .25s ease; }
.othumb img.ld, .pv-img.ld { opacity: 1; }
.pane-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); min-height: 48px; }
.pane-head h2 { margin: 0; font-size: 14px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-head .sp { flex: 1; }
.pane-head a.ib { display: inline-grid; place-items: center; text-decoration: none; color: inherit; }
.pane-head .txt { width: auto; padding: 0 10px; font-size: 12.5px; }
.pane-kind { font-size: 11.5px; color: var(--mute); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.pane-body { flex: 1; min-height: 0; overflow: auto; display: grid; place-items: center; background: var(--code); }
.pane-note { padding: 24px; text-align: center; color: var(--mute); font-size: 14px; max-width: 420px; line-height: 1.7; }
.pv-img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; padding: 12px; box-sizing: border-box; }
.pv-video { width: 100%; max-height: 100%; background: #000; }
.pv-audio-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; width: min(90%, 460px); }
.pv-audio-wrap audio { width: 100%; }
.pv-frame { width: 100%; height: 100%; border: 0; background: #fff; place-self: stretch; }
.pv-code { place-self: stretch; margin: 0; border-radius: 0; overflow: auto; }
.pv-code pre { margin: 0; padding: 12px; direction: ltr; text-align: left; font-size: 13px; }
.oic { font-size: 30px; opacity: .8; }
.oic.big { font-size: 52px; }
.ogrid { list-style: none; margin: 0; padding: 12px; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); place-self: start stretch; }
.ocard { display: flex; flex-direction: column; width: 100%; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  background: var(--panel); color: inherit; cursor: pointer; text-align: start; }
.ocard:hover, .ocard:focus-visible { border-color: var(--silver); }
.othumb { display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--panel2); overflow: hidden; }
.othumb img { width: 100%; height: 100%; object-fit: cover; }
.ometa { display: flex; align-items: center; gap: 6px; padding: 8px 10px; font-size: 12px; }
.onm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: start; }
.okd { color: var(--mute); font-size: 11px; white-space: nowrap; }
.pane-strip { display: flex; gap: 8px; overflow-x: auto; padding: 8px 10px; border-top: 1px solid var(--line); }
.sthumb { flex: 0 0 auto; width: 56px; height: 56px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; opacity: .7; cursor: pointer; background: none; }
.sthumb.on, .sthumb:hover { opacity: 1; border-color: var(--silver); }
.sthumb img { width: 100%; height: 100%; object-fit: cover; }
.pdf-pages { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 16px; place-self: start stretch; }
.pdf-page { background: #fff; box-shadow: 0 2px 10px #0004; max-width: 100%; }
.outs { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; border-radius: 10px; background: #fff2; color: #fff; font-size: 34px; cursor: pointer; }
.lb-nav:hover { background: #fff4; }
.lb-nav.prev { inset-inline-start: 12px; }
.lb-nav.next { inset-inline-end: 12px; }
@media (max-width: 900px) {
  .pane { width: 100%; border: 0; padding-bottom: env(safe-area-inset-bottom); }
  .pane-resize { display: none; }
  .app.pane-open .main { margin-inline-end: 0; }
  .pane-head { padding-top: max(8px, env(safe-area-inset-top)); }
  .ogrid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; padding: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .pane, .main, .othumb img, .pv-img { transition: none; }
  .skel { animation: none; }
}

/* إبلاغ عن مشكلة */
.sec-h { margin: 12px 0 0; font-size: 15px; font-weight: 600; }
#rpDesc { width: 100%; box-sizing: border-box; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; line-height: 1.6; resize: vertical; min-height: 110px; }
#rpDesc:focus-visible { outline: 2px solid var(--line2); outline-offset: 1px; }
.rp-count { margin: 4px 0 0; text-align: left; min-height: 1em; }
.rp-count.bad { color: var(--danger); }
.rp-tech { margin: 6px 0 2px; font-size: 13px; color: var(--mute); }
.rp-tech summary { cursor: pointer; width: fit-content; }
.rp-tech pre { white-space: pre-wrap; word-break: break-word; background: var(--code); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 12px; margin: 6px 0 0; text-align: start; max-height: 170px; overflow: auto; }
.rp-res { margin-top: 10px; font-size: 14px; line-height: 1.7; }
.rp-res.ok { color: var(--ok); }
.rp-res.bad { color: var(--danger); }
.rp-res b { font-family: ui-monospace, Consolas, monospace; direction: ltr; unicode-bidi: isolate; }

/* شريط معاينة الصفحة اللي بناها الوكيل */
.sitebar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0 10px; padding: 8px 12px; border: 1px solid var(--line2); border-radius: 12px; background: var(--panel); font-size: 14px; animation: rise .22s ease-out both; }
.sitebar .sb-ic { color: var(--silver); }
.sitebar .sb-name { color: var(--mute); font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 1; white-space: nowrap; }
.sitebar .sb-note { flex-basis: 100%; font-size: 12px; color: var(--mute); }


/* ======================================================================================================================
   صقل 2026-10-28 (web-polish): خط محلي، نظام تباعد/حركة موحّد، إعدادات بتبويبات جانبية، حالات تحميل وفراغ، لمس مريح، حركة أقل.
   كل شي تحت يعتمد على المتغيرات فوق (الحبر/الفضي، بلا ذهبي). الاتجاه منطقي (inline-start/end) فيشتغل RTL و LTR.
   ====================================================================================================================== */

/* حجم الخط من الإعدادات */
:root[data-fs="s"] { --fs: 15px; }
:root[data-fs="l"] { --fs: 17.5px; }
:root[data-fs="xl"] { --fs: 19px; }

/* تخطّي إلى المحتوى (يظهر بالتبويب فقط) */
.skip { position: fixed; inset-block-start: 8px; inset-inline-start: 8px; z-index: 200; padding: 8px 14px; border-radius: var(--r-sm); background: var(--accent); color: var(--on-accent); font-weight: 600; text-decoration: none; transform: translateY(-160%); transition: transform var(--dur) var(--ease); }
.skip:focus { transform: none; }

/* شاشة الإقلاع بدل الصفحة الفاضية قبل ما يرد /me */
.splash { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: var(--bg); }
.splash[hidden] { display: none; }
.splash .logo { width: 52px; height: 52px; font-size: 20px; animation: pulse 1.4s ease-in-out infinite; }
.noscript { position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--bg); color: var(--text); }

/* ألوان الحالة: لا تعتمد على اللون وحده (نص/أيقونة معه دائماً) */
.meter.hot i { background: var(--danger); }
.meter { transition: background var(--dur); }
.meter i { transition: width .5s var(--ease); min-width: 0; }

/* لمس مريح: كل هدف ≥ 44px على الشاشات اللمسية */
@media (pointer: coarse) {
  .ib, .ib.sm { min-width: 44px; min-height: 44px; }
  .item { min-height: 48px; }
  .item .ia { min-width: 44px; min-height: 44px; opacity: .8; }
  .search input { min-height: 44px; font-size: 16px; }
  .btn.sm { min-height: 44px; display: inline-grid; place-items: center; }
  .model-btn, .tabs button, .lnk, .seg button, .sb { min-height: 44px; }
  .burger { width: 44px; height: 44px; }
  .item .open { min-height: 44px; display: flex; align-items: center; }
  .sheet-head .ib { min-width: 44px; min-height: 44px; }
  .row select, .grid3 select { min-height: 44px; font-size: 16px; }
  input.sw { width: 48px; height: 28px; border-radius: 28px; }
  input.sw::after { width: 22px; height: 22px; top: 3px; inset-inline-start: 3px; }
  input.sw:checked::after { inset-inline-start: 23px; }
  .tool { min-height: 32px; }
  textarea, input[type="text"], input[type="email"], input[type="password"], input[type="search"] { font-size: 16px; }   /* iOS ما يكبّر الصفحة عند التركيز */
}

/* ---------- الإعدادات: بطاقات + تبويبات جانبية ---------- */
.sheet.set { width: min(880px, 100%); height: min(640px, calc(100dvh - 32px)); }
.set-layout { display: flex; flex: 1; min-height: 0; border-top: 1px solid var(--line); }
.set-layout .tabs { flex-direction: column; gap: 2px; padding: 10px; width: 210px; flex: none; border: 0; border-inline-end: 1px solid var(--line); overflow-y: auto; background: var(--side); }
.set-layout .tabs button { display: flex; align-items: center; gap: 10px; text-align: start; padding: 9px 12px; border-radius: var(--r-sm); color: var(--mute); font-size: 14.5px; white-space: normal; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.set-layout .tabs button:hover { background: var(--panel2); color: var(--text); }
.set-layout .tabs button.on { background: var(--panel2); color: var(--accent); font-weight: 600; }
.set-layout .tabs .ti { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.set-layout .sheet-body { padding: 6px 22px 22px; scroll-behavior: smooth; }
.grp { font-size: 12.5px; font-weight: 600; letter-spacing: .02em; color: var(--mute); margin: 20px 4px 8px; }
.grp:first-child { margin-top: 12px; }
.card-set { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--bg); padding: 0 16px; }
.card-set .row:last-child { border-bottom: 0; }
.card-set .row.col .acts { margin-top: 8px; }
.row .lbl { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sub { display: block; color: var(--mute); font-size: 12.5px; line-height: 1.5; font-weight: 400; }
.note-p { margin: 4px 0; color: var(--silver); font-size: 14px; line-height: 1.7; }
.note-p.err { color: var(--danger); }
.val.big { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--accent); }
.row { min-height: 48px; }
.row .val, .usage-row small, .plan-price .amt { font-variant-numeric: tabular-nums; }
.foot-row { border-bottom: 0 !important; padding: 8px 0 12px; min-height: 0; }
.keys .kbd { margin-inline-start: 0; padding: 2px 8px; border: 1px solid var(--line2); border-radius: 6px; font-size: 12px; background: var(--panel); }
.profile { display: flex; align-items: center; gap: 14px; padding: 12px 4px 4px; }
.avatar.lg { width: 52px; height: 52px; font-size: 20px; font-weight: 700; border: 1px solid var(--line2); }
.profile .who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.profile strong { font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-plan { display: inline-block; width: fit-content; font-size: 12px; padding: 1px 10px; border-radius: 999px; border: 1px solid var(--line2); color: var(--silver); }
.usage-row { gap: 4px; }
.usage-row .sub { margin-top: 2px; }

/* الخطط بالدينار */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.plan-card { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; background: var(--bg); display: flex; flex-direction: column; gap: 4px; transition: border-color var(--dur); }
.plan-card.on { border-color: var(--accent); background: var(--panel2); }
.plan-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.plan-price { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.plan-price .amt { font-size: 17px; font-weight: 700; color: var(--accent); }
.plan-price .per { font-size: 12.5px; color: var(--mute); }
.plan-price.yr .amt { font-size: 14.5px; font-weight: 600; color: var(--silver); }
.topups { margin-top: 12px; font-size: 14px; }
.topups ul { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.topups li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* الأجهزة */
.dev-list { padding: 0; overflow: hidden; }
.dev { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dev:last-child { border-bottom: 0; }
.dev-h, .dev-p { display: flex; align-items: center; gap: 10px; }
.dev-n { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dev-n strong, .dev-n > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-sub { margin-top: 8px; padding-inline-start: 18px; display: flex; flex-direction: column; gap: 8px; }
.dev-p { padding: 6px 0; border-top: 1px dashed var(--line); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--mute); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px #a9c7ab33; }
.cc-h { padding: 14px 0 0; }
#ccCard { padding-bottom: 14px; }
#ccCard .acts { margin-top: 12px; }

/* هياكل التحميل (skeleton) */
.skel-lines { display: grid; gap: 12px; padding: 14px 16px; }
.skel-lines i, .skel { display: block; height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--panel2) 25%, var(--line) 50%, var(--panel2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skel-lines i:nth-child(2) { width: 70%; } .skel-lines i:nth-child(3) { width: 45%; }
.sk-item { pointer-events: none; padding: 12px 10px; }
.sk-item .skel { width: 100%; height: 12px; }
.sk-item:nth-child(odd) .skel { width: 78%; } .sk-item:nth-child(3n) .skel { width: 60%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* حركة دقيقة: نافذة تفتح، زر يضغط */
.modal:not([hidden]) { animation: fadeIn .16s ease-out both; }
.modal:not([hidden]) .sheet { animation: sheetIn .22s var(--ease) both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
.btn, .ib, .new-chat, .model-btn, .tabs button, .seg button { transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease), transform .08s ease; }
.btn:active:not(:disabled), .ib:active, .new-chat:active { transform: scale(.97); }
.btn:hover:not(:disabled):not(.ghost) { filter: brightness(.92); }
:root[data-theme="light"] .btn:hover:not(:disabled):not(.ghost) { filter: brightness(1.18); }
body.modal-open { overflow: hidden; }
.toast { animation: toastIn .2s var(--ease) both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* بطاقة الدخول */
.gate .card { padding: 8px 0; }
.gate .card .logo { box-shadow: 0 0 0 6px var(--panel); }
.field:focus-visible, .row select:focus-visible { outline: 2px solid var(--silver); outline-offset: 1px; }

/* موبايل: الإعدادات ورقة سفلية، التبويبات شريط أفقي */
@media (max-width: 760px) {
  .sheet.set { height: min(92dvh, 760px); }
  .set-layout { flex-direction: column; }
  .set-layout .tabs { flex-direction: row; width: auto; border-inline-end: 0; border-bottom: 1px solid var(--line); padding: 6px 10px; gap: 4px; background: transparent; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; flex: none; }
  .set-layout .tabs::-webkit-scrollbar { display: none; }
  .set-layout .tabs button { flex: none; white-space: nowrap; padding: 8px 12px; }
  .set-layout .tabs .ti { display: none; }
  .set-layout .sheet-body { padding: 4px 14px 22px; }
  .card-set { padding: 0 12px; }
  .row select { max-width: 52%; min-width: 0; }
  .plans-grid { grid-template-columns: 1fr 1fr; }
  .top { padding-top: max(8px, env(safe-area-inset-top)); }
  .composer-wrap { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .sheet-foot { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) { .plans-grid { grid-template-columns: 1fr; } }

/* حركة أقل: من إعداد النظام أو من إعدادات التطبيق */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skel-lines i, .skel { animation: none; }
}
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }

/* وضع التباين العالي بالنظام */
@media (forced-colors: active) {
  .meter { border: 1px solid CanvasText; } .meter i { background: Highlight; } .dot.on { background: Highlight; } input.sw:checked { background: Highlight; }
}

.gate .legal { margin: 18px 0 4px; font-size: 12.5px; color: var(--mute); line-height: 1.9; }
.gate .legal a { color: var(--silver); text-decoration: underline; text-underline-offset: 3px; }
