/* زهر — واجهة المحادثة */
:root {
  --bg: #f7f7f5; --surface: #ffffff; --surface-2: #f1f1ee; --border: #e5e3dd; --border-2: #d6d3cb;
  --text: #1d1c1a; --muted: #6f6b63; --faint: #9b968c;
  --blue: #2f6bff; --pink: #ff5ca8; --grad: linear-gradient(135deg, #2f6bff 0%, #ff5ca8 100%);
  --user-bubble: #dde7fb; --user-bubble-text: #1b2a4a;
  --radius: 16px; --r-sm: 10px;
  --font: "IBM Plex Sans Arabic", "Segoe UI", system-ui, -apple-system, "Noto Sans Arabic", sans-serif;
  --font-display: "Noto Kufi Arabic", "IBM Plex Sans Arabic", sans-serif;
  --app-h: 100dvh; --kb: 0px; --sb: 272px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overscroll-behavior: none; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15.5px; line-height: 1.65; -webkit-text-size-adjust: 100%; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
pre, code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; direction: ltr; text-align: left; }

/* الأيقونات */
i[data-icon] { display: inline-block; width: 20px; height: 20px; flex: 0 0 auto; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
i[data-icon="menu"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M4 7h16M4 12h16M4 17h16'/%3E%3C/svg%3E"); }
i[data-icon="x"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
i[data-icon="send"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M5 12l7-7 7 7'/%3E%3C/svg%3E"); }
i[data-icon="stop"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Crect x='6' y='6' width='12' height='12' rx='2'/%3E%3C/svg%3E"); }
i[data-icon="mic"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3'/%3E%3C/svg%3E"); }
i[data-icon="clip"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12.5l-8.5 8.5a5 5 0 0 1-7-7l8.5-8.5a3.5 3.5 0 0 1 5 5L10.5 19a2 2 0 0 1-3-3l7.5-7.5'/%3E%3C/svg%3E"); }
i[data-icon="speaker"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 5L6 9H3v6h3l5 4zM15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13'/%3E%3C/svg%3E"); }
i[data-icon="copy"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='9' y='9' width='11' height='11' rx='2'/%3E%3Cpath d='M5 15V5a1 1 0 0 1 1-1h10'/%3E%3C/svg%3E"); }
i[data-icon="chat"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-8 8H4l2-3a8 8 0 1 1 15-5z'/%3E%3C/svg%3E"); }
i[data-icon="bell"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 21h4'/%3E%3C/svg%3E"); }
i[data-icon="brain"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4a3 3 0 0 0-3 3 3 3 0 0 0-2 3c0 1 .4 1.8 1 2.4A3 3 0 0 0 6 17a3 3 0 0 0 3 3h3V4zM15 4a3 3 0 0 1 3 3 3 3 0 0 1 2 3c0 1-.4 1.8-1 2.4A3 3 0 0 1 18 17a3 3 0 0 1-3 3h-3V4z'/%3E%3C/svg%3E"); }
i[data-icon="settings"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8v.1a1.7 1.7 0 0 0 1.5 1h.1a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z'/%3E%3C/svg%3E"); }
i[data-icon="logout"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 17l5-5-5-5M15 12H3M15 4h4a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-4'/%3E%3C/svg%3E"); }
i[data-icon="download"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v12M6 10l6 6 6-6M4 20h16'/%3E%3C/svg%3E"); }
i[data-icon="refresh"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 12a8 8 0 1 1-2.3-5.7M20 4v5h-5'/%3E%3C/svg%3E"); }
i[data-icon="check"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E"); }
i[data-icon="trash"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3'/%3E%3C/svg%3E"); }
i[data-icon="file"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5'/%3E%3C/svg%3E"); }
i[data-icon="image"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='2'/%3E%3Ccircle cx='9' cy='10' r='2'/%3E%3Cpath d='M21 16l-5-5-9 9'/%3E%3C/svg%3E"); }
i[data-icon="search"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E"); }
i[data-icon="link"] { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1'/%3E%3C/svg%3E"); }

/* الشعار */
.logo { width: 40px; height: 40px; border-radius: 11px; overflow: hidden; flex: 0 0 auto; box-shadow: 0 6px 18px rgba(47,107,255,.25); }
.logo svg { width: 100%; height: 100%; display: block; }
.logo-xl { width: 92px; height: 92px; border-radius: 26px; margin: 0 auto 18px; }
.logo-lg { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px; }
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: -.2px; }

/* شاشة الدخول */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { font-family: var(--font-display); font-size: 34px; margin: 0 0 6px; }
.tagline { color: var(--muted); margin: 0 0 26px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; padding: 12px 18px; font-weight: 600; border: 1px solid transparent; transition: transform .12s ease, box-shadow .12s ease, background .12s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--grad); color: #fff; width: 100%; box-shadow: 0 8px 22px rgba(255,92,168,.25); }
.btn-primary:hover { text-decoration: none; box-shadow: 0 10px 26px rgba(47,107,255,.3); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); }
.login-note { color: var(--muted); font-size: 13.5px; margin: 22px 0 10px; }
.magic { display: flex; gap: 8px; }
.magic input { flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 12px; padding: 11px 14px; background: var(--surface); font-size: 16px; direction: ltr; text-align: left; }
.magic input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,107,255,.15); }

/* الهيكل */
.app { display: flex; height: var(--app-h); width: 100%; overflow: hidden; }
.sidebar { width: var(--sb); flex: 0 0 var(--sb); background: var(--surface); border-inline-start: 0; border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding: calc(14px + var(--safe-t)) 12px calc(12px + var(--safe-b)); z-index: 30; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px; border-radius: 12px; border: 0; background: transparent; color: var(--text); font-weight: 500; text-align: start; position: relative; transition: background .12s; }
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--surface-2); font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; inset-inline-start: 0; top: 11px; bottom: 11px; width: 3px; border-radius: 3px; background: var(--grad); }
.pill { margin-inline-start: auto; background: var(--grad); color: #fff; font-size: 11.5px; font-style: normal; padding: 1px 8px; border-radius: 99px; font-weight: 700; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 10px 8px; border-top: 1px solid var(--border); margin-top: 6px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.avatar.fallback { background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.user-meta strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { color: var(--muted); font-size: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(8px + var(--safe-t)) 14px 8px; border-bottom: 1px solid var(--border); background: var(--bg); z-index: 5; min-height: 56px; }
.top-title { display: flex; align-items: center; gap: 10px; flex: 1; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 3px 10px; border-radius: 99px; }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; display: inline-block; }
.status-pill.thinking i { background: var(--pink); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .4; transform: scale(.8);} }

/* المحادثة */
.chat { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; position: relative; padding: 20px 0 12px; }
.intro { text-align: center; max-width: 560px; margin: 13vh auto 0; padding: 0 20px; }
.intro h2 { font-family: var(--font-display); font-size: 26px; margin: 0 0 6px; }
.intro p { color: var(--muted); margin: 0 0 18px; }
.suggestions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 9px 16px; font-size: 14px; transition: border-color .12s, transform .12s; }
.chip:hover { border-color: var(--blue); transform: translateY(-1px); }
.messages { max-width: 780px; margin: 0 auto; padding: 0 16px; display: flex; flex-direction: column; gap: 18px; }
.msg { display: flex; gap: 12px; align-items: flex-start; animation: rise .22s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }
.msg.user { flex-direction: row-reverse; }
.msg .zavatar { width: 34px; height: 34px; border-radius: 10px; overflow: hidden; flex: 0 0 auto; margin-top: 4px; }
.msg .zavatar svg { width: 100%; height: 100%; display: block; }
.bubble { max-width: min(78%, 640px); padding: 11px 16px; border-radius: 18px; }
.msg.user .bubble { background: var(--user-bubble); color: var(--user-bubble-text); border-start-end-radius: 6px; white-space: pre-wrap; word-break: break-word; }
.msg.assistant .body { max-width: 100%; min-width: 0; flex: 1; }
.msg.assistant .bubble { padding: 0; border-radius: 0; max-width: 100%; }
.msg.assistant .bubble > :first-child { margin-top: 0; }
.msg.assistant .bubble > ::last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 10px; }
.bubble h3, .bubble h4 { font-family: var(--font-display); margin: 14px 0 8px; font-size: 17px; }
.bubble ul, .bubble ol { padding-inline-start: 22px; margin: 0 0 10px; }
.bubble li { margin: 3px 0; }
.bubble code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 13.5px; }
.bubble pre { background: #1f2328; color: #e6e6e6; padding: 14px 16px; border-radius: 12px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; margin: 8px 0 12px; }
.bubble pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.bubble table { border-collapse: collapse; width: 100%; margin: 8px 0 12px; font-size: 14px; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 7px 10px; text-align: start; }
.bubble th { background: var(--surface-2); }
.bubble blockquote { border-inline-start: 3px solid var(--pink); margin: 6px 0 10px; padding: 2px 12px; color: var(--muted); }
.bubble hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.bubble img.msg-img { max-width: 320px; width: 100%; border-radius: 14px; border: 1px solid var(--border); display: block; margin: 6px 0; }
.msg.user .bubble .msg-img { margin: 0 0 6px; }
.bubble a { word-break: break-all; }
.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%,80%,100% { opacity: .25; transform: translateY(0);} 40% { opacity: 1; transform: translateY(-3px);} }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tool { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); border-radius: 99px; padding: 3px 10px; }
.tool i[data-icon] { width: 14px; height: 14px; }
.tool.done { color: #15803d; border-color: #bbf7d0; }
.artifact { display: inline-flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 14px; margin: 6px 0 10px; text-decoration: none; }
.artifact:hover { border-color: var(--blue); text-decoration: none; }
.artifact img { width: 54px; height: 54px; border-radius: 9px; object-fit: cover; }
.artifact small { display: block; color: var(--muted); }
.actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.msg:hover .actions, .msg:focus-within .actions, .msg.user .actions { opacity: 1; }
@media (hover: none) { .actions { opacity: 1; } }
.actions .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
.actions .icon-btn i { width: 16px; height: 16px; }
.actions .icon-btn.playing { color: var(--pink); }
.jump { position: sticky; bottom: 10px; margin: 0 auto 6px; display: block; background: var(--text); color: #fff; border: 0; border-radius: 99px; padding: 7px 14px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,.2); z-index: 2; }
.compacted-note { text-align: center; font-size: 12.5px; color: var(--faint); }

/* الإدخال */
.composer { padding: 6px 14px calc(8px + var(--safe-b) + var(--kb)); background: var(--bg); }
.bar { max-width: 780px; margin: 0 auto; display: flex; align-items: flex-end; gap: 4px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 24px; padding: 6px 6px 6px 8px; box-shadow: 0 8px 30px rgba(0,0,0,.06); transition: border-color .15s, box-shadow .15s; }
.bar:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(47,107,255,.12), 0 8px 30px rgba(0,0,0,.06); }
.bar textarea { flex: 1; min-width: 0; border: 0; background: transparent; resize: none; padding: 9px 6px; max-height: 160px; line-height: 1.5; font-size: 16px; outline: none; }
.bar textarea::placeholder { color: var(--faint); }
.send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center; flex: 0 0 auto; box-shadow: 0 6px 16px rgba(47,107,255,.3); transition: transform .12s; }
.send:active { transform: scale(.94); }
.send:disabled { background: var(--surface-2); color: var(--faint); box-shadow: none; }
.send.stop { background: var(--text); }
#micBtn.listening { color: var(--pink); background: #fff0f6; animation: pulse 1s infinite; }
.hint { max-width: 780px; margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--muted); }
.attachments { max-width: 780px; margin: 0 auto 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.attachments:empty { display: none; }
.att { position: relative; width: 64px; height: 64px; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.att img { width: 100%; height: 100%; object-fit: cover; }
.att button { position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; display: grid; place-items: center; }

/* اللوحات */
.sheet { position: fixed; inset: 0; z-index: 60; background: rgba(20,20,20,.4); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; height: var(--app-h); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-card { background: var(--surface); width: 100%; max-width: 720px; max-height: calc(var(--app-h) - 40px); border-radius: 22px 22px 0 0; display: flex; flex-direction: column; animation: up .22s ease; padding-bottom: var(--safe-b); }
@keyframes up { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-card header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.sheet-card h3 { margin: 0; font-family: var(--font-display); font-size: 19px; }
.sheet-body { overflow-y: auto; padding: 4px 18px 18px; -webkit-overflow-scrolling: touch; }
@media (min-width: 720px) { .sheet { align-items: center; } .sheet-card { border-radius: 22px; max-height: min(82vh, 760px); padding-bottom: 0; } }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tab { border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 7px 14px; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.tab.active { background: var(--text); color: #fff; border-color: var(--text); }
.tab.readonly { color: var(--faint); }
.editor { width: 100%; min-height: 320px; border: 1px solid var(--border); border-radius: 14px; padding: 14px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; line-height: 1.6; resize: vertical; background: var(--bg); direction: rtl; }
.editor:focus { outline: none; border-color: var(--blue); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: 0; }
.row label { font-weight: 500; }
.row small { display: block; color: var(--muted); font-weight: 400; }
select, input[type="datetime-local"], input[type="text"] { border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; background: var(--surface); font-size: 16px; }
select:focus, input:focus { outline: none; border-color: var(--blue); }
.switch { position: relative; width: 46px; height: 27px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-2); border-radius: 99px; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--grad); }
.switch input:checked + span::after { transform: translateX(-19px); }
.rem { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rem .when { font-size: 12.5px; color: var(--muted); }
.rem .txt { font-weight: 500; }
.rem .acts { margin-inline-start: auto; display: flex; gap: 2px; }
.add-rem { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-bottom: 14px; }
.add-rem input[name="text"] { grid-column: 1 / -1; }
.arch-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.arch-item summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.arch-item p { margin: 6px 0 0; color: var(--text); }
.toasts { position: fixed; bottom: calc(92px + var(--safe-b) + var(--kb)); left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: rise .2s ease; max-width: 90vw; }
.toast.reminder { background: var(--grad); }

/* موبايل */
#backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .2s; }
.only-mobile { display: none !important; }
@media (max-width: 900px) {
  .only-mobile { display: inline-grid !important; }
  .only-desktop { display: none !important; }
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; height: var(--app-h); transform: translateX(100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.2); border: 0; }
  .sidebar.open { transform: none; }
  #backdrop.show { opacity: 1; pointer-events: auto; }
  .messages { padding: 0 12px; gap: 16px; }
  .bubble { max-width: 86%; }
  .topbar { padding-top: calc(6px + var(--safe-t)); }
  .intro { margin-top: 4vh; }
}
@media (max-width: 900px) and (min-width: 1px) { .nav-item.active::before { display: none; } }
