/* TSM Image AI — console styling. No external assets, no CDN. */

:root {
  --bg: #020617;
  --bg-elev: #0F172A;
  --bg-soft: #111C33;
  --border: #1E293B;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --accent: #2563EB;
  --accent-soft: #1D4ED8;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
}

:root[data-theme="light"] {
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --bg-soft: #eef1f7;
  --border: #dde3ee;
  --text: #101827;
  --muted: #5b6577;
  --shadow: 0 6px 20px rgba(16, 24, 39, .08);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.skip-link {
  position: fixed; z-index: 200; inset: 8px auto auto 8px; transform: translateY(-150%);
  padding: 9px 13px; border-radius: 9px; background: var(--accent); color: white;
  text-decoration: none; transition: transform .15s;
}
.skip-link:focus { transform: translateY(0); }
:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 84%, white); outline-offset: 2px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; }
h3 { font-size: 15px; margin-bottom: 14px; letter-spacing: .01em; }
p { margin: 0 0 8px; }
code { font-family: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------------------------------------------------------------- layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 26px; padding: 0 6px; }
.brand h1 { font-size: 17px; line-height: 1.1; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #06B6D4);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; letter-spacing: .04em; color: #fff;
}
.brand-version { font-size: 11.5px; color: var(--muted); }

.new-chat-btn {
  width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px;
  background: transparent; color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; transition: background .2s, border-color .2s, transform .2s;
}
.new-chat-btn:hover { background: var(--bg-soft); border-color: var(--accent); }
.new-chat-btn:active { transform: scale(.98); }

.sidebar-label {
  margin: 20px 10px 7px; color: var(--muted); font-size: 11px;
  font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.conversation-nav { min-height: 120px; flex: 1; overflow: hidden; }
.conversation-list { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; max-height: 34vh; }
.conversation-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 25px 25px;
  align-items: center; border-radius: 9px;
}
.conversation-row:hover, .conversation-row.active { background: var(--bg-soft); }
.conversation-item {
  width: 100%; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  padding: 9px 10px; text-align: start; font: inherit; font-size: 13px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conversation-item:hover { background: var(--bg-soft); color: var(--text); }
.conversation-row.active .conversation-item { color: var(--text); font-weight: 600; }
.conversation-menu {
  width: 24px; height: 24px; display: grid; place-items: center; opacity: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--muted);
  font: inherit; font-size: 12px; cursor: pointer;
}
.conversation-row:hover .conversation-menu, .conversation-menu:focus-visible { opacity: 1; }
.conversation-menu:hover { color: var(--text); background: var(--bg-elev); }
.conversation-menu.danger:hover { color: var(--err); }
.conversation-empty { padding: 8px 10px; color: var(--muted); font-size: 12px; }

.tools-nav { border-top: 1px solid var(--border); padding-top: 10px; }
.tools-nav summary {
  list-style: none; display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; border-radius: 9px; color: var(--muted); font-size: 12.5px;
  cursor: pointer;
}
.tools-nav summary::-webkit-details-marker { display: none; }
.tools-nav summary:hover { background: var(--bg-soft); color: var(--text); }
.tools-nav[open] summary { color: var(--text); }
.tools-nav .nav { max-height: 31vh; overflow-y: auto; margin-top: 5px; }
.admin-nav { border-top: 0; }
.account-nav-item {
  width: 100%; flex: 0 0 auto; margin-top: 5px; border: 0; cursor: pointer;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 550; }
.nav-item .ico { width: 18px; text-align: center; font-size: 13px; opacity: .9; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 14px; margin-top: 14px;
  font-size: 12.5px; color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.status-dot.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-dot.err { background: var(--err); box-shadow: 0 0 8px var(--err); }
.docs-link { color: var(--accent); text-decoration: none; width: 100%; }
.docs-link:hover { text-decoration: underline; }

.content { flex: 1; padding: 22px 28px 44px; min-width: 0; }

.topbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 22px;
}
.topbar h2 { font-size: 22px; }
.topbar p { font-size: 13.5px; margin: 2px 0 0; }
.topbar-actions { display: flex; gap: 8px; }
.mobile-menu-btn {
  display: none; width: 38px; height: 38px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg-elev); color: var(--text); font: inherit;
}
.connection-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 10px; color: var(--muted);
  background: var(--bg-elev); font-size: 12px; white-space: nowrap;
}
.connection-chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.connection-chip.online i { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.connection-chip.offline { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--border)); }
.connection-chip.offline i { background: var(--err); }
.offline-banner {
  align-items: center; justify-content: space-between; gap: 14px; margin: -8px 0 18px;
  padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--border));
  border-radius: 12px; background: color-mix(in srgb, var(--warn) 10%, var(--bg-elev));
  color: var(--text); font-size: 13px;
}
.offline-banner:not([hidden]) { display: flex; }
.request-progress {
  position: fixed; inset: 0 0 auto; z-index: 110; height: 3px;
  pointer-events: none; opacity: 0; overflow: hidden;
}
.request-progress::after {
  content: ""; display: block; width: 34%; height: 100%; transform: translateX(-110%);
  border-radius: 999px; background: linear-gradient(90deg, var(--accent), #06B6D4);
}
.request-progress.active { opacity: 1; }
.request-progress.active::after { animation: request-run 1.05s ease-in-out infinite; }
@keyframes request-run { to { transform: translateX(310%); } }
.btn.busy { pointer-events: none; opacity: .72; }
.btn.busy::first-letter { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ----------------------------------------------------------------- views */
.view { display: none; animation: fade .18s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------- conversation */
.content:has(.chat-view.active) {
  height: 100vh; padding-bottom: 0; display: flex; flex-direction: column; overflow: hidden;
}
.content:has(.chat-view.active) .topbar { flex: 0 0 auto; margin-bottom: 0; }
.chat-view.active {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  width: min(920px, 100%); margin: 0 auto;
}
.chat-scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 34px 12px 24px; scroll-behavior: smooth;
}
.chat-empty {
  min-height: 56vh; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; padding: 30px 12px;
}
.assistant-orb {
  width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center;
  margin-bottom: 22px; position: relative; overflow: hidden;
  background: linear-gradient(145deg, #0F172A, var(--accent), #06B6D4);
  color: white; box-shadow: 0 18px 48px rgba(37, 99, 235, .3);
}
.assistant-orb::after {
  content: ""; position: absolute; inset: -70%; opacity: .45;
  background: linear-gradient(100deg, transparent 35%, white 50%, transparent 65%);
  animation: orb-shine 5s ease-in-out infinite;
}
.assistant-orb span { font-size: 14px; font-weight: 800; letter-spacing: .06em; z-index: 1; }
@keyframes orb-shine { 0%, 55% { transform: translateX(-35%); } 85%, 100% { transform: translateX(35%); } }
.chat-empty h3 { font-size: clamp(25px, 4vw, 36px); letter-spacing: -.03em; margin-bottom: 9px; }
.chat-empty > p { max-width: 570px; color: var(--muted); font-size: 14px; }
.prompt-suggestions {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px; width: min(620px, 100%); margin-top: 28px;
}
.prompt-suggestions button {
  min-height: 48px; border: 1px solid var(--border); border-radius: 14px;
  background: color-mix(in srgb, var(--bg-elev) 84%, transparent); color: var(--text);
  padding: 11px 14px; font: inherit; text-align: start; cursor: pointer;
  transition: transform .18s, border-color .18s, background .18s;
}
.prompt-suggestions button:hover {
  transform: translateY(-2px); border-color: var(--accent); background: var(--bg-soft);
}
.message-list { display: flex; flex-direction: column; gap: 22px; }
.chat-message { display: flex; gap: 12px; align-items: flex-start; animation: message-in .22s ease; }
@keyframes message-in { from { opacity: 0; transform: translateY(8px); } }
.chat-message.user { justify-content: flex-end; }
.message-avatar {
  width: 31px; height: 31px; flex: 0 0 auto; border-radius: 10px; display: grid;
  place-items: center; background: linear-gradient(135deg, var(--accent), #06B6D4);
  color: white; font-size: 9px; font-weight: 800;
}
.message-bubble {
  max-width: min(680px, 84%); padding: 12px 15px; border-radius: 17px;
  background: var(--bg-elev); border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .08); white-space: pre-wrap; word-break: break-word;
}
.chat-message.user .message-bubble {
  background: var(--accent); border-color: var(--accent); color: white;
  border-bottom-inline-end-radius: 5px;
}
.message-attachments { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.message-attachments img { width: 116px; height: 90px; object-fit: cover; border-radius: 10px; }
.message-actions {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.message-action {
  border: 1px solid var(--border); border-radius: 8px; background: transparent;
  color: var(--muted); padding: 5px 9px; font: inherit; font-size: 11.5px;
  text-decoration: none; cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.message-action.selected {
  color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.message-action:hover { color: var(--text); border-color: var(--accent); background: var(--bg-soft); }
.message-action.primary { color: white; border-color: var(--accent); background: var(--accent); }
.message-action.danger:hover { color: var(--err); border-color: var(--err); }
.message-bubble.pending { min-width: min(420px, 76vw); }
.message-bubble.pending > div:first-of-type {
  background: linear-gradient(90deg, var(--muted), var(--text), var(--muted));
  background-size: 220% 100%; background-clip: text; color: transparent;
  animation: pending-text 1.8s linear infinite;
}
@keyframes pending-text { to { background-position: -220% 0; } }
.message-progress { margin-top: 11px; }
.message-progress > span {
  display: block; height: 7px; overflow: hidden; border-radius: 999px; background: var(--bg-soft);
}
.message-progress i {
  display: block; height: 100%; border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #06B6D4); transition: width .35s ease;
}
.message-progress .indeterminate i { animation: progress-scan 1.3s ease-in-out infinite alternate; }
@keyframes progress-scan { from { transform: translateX(-85%); } to { transform: translateX(260%); } }

.composer-shell {
  flex: 0 0 auto; position: relative; padding: 8px 4px 13px;
  background: linear-gradient(180deg, transparent, var(--bg) 22%);
}
.composer-shell.dragging::before {
  content: "أفلت الصور هنا"; position: absolute; inset: -100px 0 0; z-index: 20;
  display: grid; place-items: center; border: 2px dashed var(--accent); border-radius: 20px;
  color: var(--text); font-size: 18px; font-weight: 700;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px);
}
.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 9px;
  border: 1px solid var(--border); border-radius: 22px;
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  box-shadow: 0 14px 45px rgba(0, 0, 0, .2); backdrop-filter: blur(20px);
  transition: border-color .2s, box-shadow .2s;
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 15px 48px rgba(37, 99, 235, .14); }
.composer textarea {
  flex: 1; min-height: 40px; max-height: 170px; resize: none; border: 0;
  outline: 0; background: transparent; color: var(--text); padding: 9px 4px;
  font: inherit; font-size: 15px; line-height: 1.5;
}
.composer textarea::placeholder { color: var(--muted); }

.account-login-required {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 16px;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.account-login-required p { color: var(--muted); margin: 8px 0 16px; line-height: 1.7; }
.auth-brand { display: none; }
.account-identity { display: flex; align-items: center; gap: 14px; padding: 16px; grid-column: 1 / -1; }
.account-identity > div:last-child { display: grid; gap: 5px; }
.account-identity span { color: var(--muted); }
.account-avatar {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 18px;
  background: linear-gradient(135deg, var(--accent), #06B6D4);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--accent) 25%, transparent);
}
.password-field { display: flex; position: relative; }
.password-field .input { width: 100%; padding-inline-end: 44px; }
.password-field button {
  position: absolute; inset-inline-end: 5px; top: 50%; translate: 0 -50%;
  border: 0; background: transparent; cursor: pointer; padding: 8px;
}
.password-strength { height: 6px; overflow: hidden; border-radius: 999px; background: var(--border); }
.password-strength span { display: block; width: 0; height: 100%; transition: width .2s; background: #ef4444; }
.password-strength span[data-score="2"] { background: #eab308; }
.password-strength span[data-score="3"] { background: #3b82f6; }
.password-strength span[data-score="4"] { background: #22c55e; }
.remember-row { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.session-row.current { border-color: color-mix(in srgb, #22c55e 45%, var(--border)); }
.session-device-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--bg-soft); }
.session-details { display: grid; gap: 3px; flex: 1; min-width: 0; }
.session-details > span { color: var(--muted); font-size: .78rem; overflow-wrap: anywhere; }
.product-nav { margin-top: 10px; }
.user-welcome {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  padding: 24px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 20px;
  background: radial-gradient(circle at 85% 20%, rgba(37,99,235,.18), transparent 35%), var(--bg-elev);
}
.user-welcome h3, .tools-page-heading h3 { font-size: clamp(1.4rem, 3vw, 2rem); margin: 3px 0 6px; }
.eyebrow { color: var(--accent); font-weight: 800; font-size: .72rem; letter-spacing: .16em; }
.status-compact { font-size: 1.15rem !important; color: var(--ok); }
.quick-action-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 10px; margin-top: 14px;
}
.quick-action-grid button {
  display: flex; align-items: center; gap: 10px; min-height: 58px; padding: 10px;
  border: 1px solid var(--border); border-radius: 13px; background: var(--bg-soft);
  color: var(--text); cursor: pointer; text-align: start;
}
.quick-action-grid button:hover { border-color: var(--accent); transform: translateY(-1px); }
.quick-action-grid button span, .tool-icon {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, var(--bg)); color: var(--accent); font-weight: 800;
}
.dashboard-list { display: grid; gap: 8px; margin-top: 12px; }
.dashboard-list button {
  display: flex; justify-content: space-between; gap: 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: 11px; background: var(--bg-soft); color: var(--text); cursor: pointer;
}
.dashboard-list button span { color: var(--muted); font-size: .78rem; }
.mini-gallery { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.mini-gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; }
.empty-state { color: var(--muted); text-align: center; padding: 28px 12px; grid-column: 1 / -1; }
.tools-page-heading { margin-bottom: 16px; }
.tool-catalogue {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(235px, 1fr)); gap: 12px; margin-bottom: 22px;
}
.tool-card {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 15px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--bg-elev);
}
.tool-card.offline { opacity: .68; }
.tool-card h4 { margin: 1px 0 5px; }
.tool-card p { color: var(--muted); font-size: .82rem; line-height: 1.55; }
.tool-card-footer {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.compact-welcome { padding-block: 18px; }
.upload-center-drop {
  min-height: 260px; display: grid; place-items: center; align-content: center; gap: 8px;
  border: 2px dashed var(--border); border-radius: 18px; background: var(--bg-soft); text-align: center;
}
.upload-center-drop.hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--bg-soft)); }
.upload-cloud { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; background: var(--accent); color: white; font-size: 1.6rem; }
.upload-options, .upload-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.upload-preview-list { display: grid; gap: 8px; margin-top: 14px; }
.upload-preview-item { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 12px; padding: 9px; border: 1px solid var(--border); border-radius: 12px; }
.upload-preview-item img, .pdf-preview { width: 52px; height: 52px; object-fit: cover; border-radius: 9px; }
.pdf-preview, .gallery-pdf { display: grid; place-items: center; background: #ef444422; color: #ef4444; font-weight: 800; }
.upload-preview-item div:nth-child(2) { display: grid; gap: 3px; }
.upload-preview-item span { color: var(--muted); font-size: .78rem; }
.upload-preview-item > button { border: 0; background: transparent; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.upload-progress { margin-top: 16px; }
.gallery-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 15px; }
.gallery-controls input { flex: 1; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 13px; }
.gallery-card { overflow: hidden; border: 1px solid var(--border); border-radius: 15px; background: var(--bg-elev); }
.gallery-card img, .gallery-pdf { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.gallery-card > div { padding: 10px 12px; display: grid; gap: 4px; }
.gallery-card > div > span { color: var(--muted); font-size: .76rem; }
.gallery-card .row { grid-template-columns: repeat(2, 1fr); display: grid; }
.personal-jobs-list { display: grid; gap: 10px; }
.personal-job {
  display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(140px, 2fr) auto auto;
  gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg-elev);
}
.personal-job > div:first-child { display: grid; gap: 4px; }
.personal-job > div:first-child span { color: var(--muted); font-size: .78rem; }
.job-progress { height: 7px; overflow: hidden; border-radius: 99px; background: var(--border); }
.job-progress i { display: block; height: 100%; background: var(--accent); }
.job-error { grid-column: 1 / -1; color: var(--err); white-space: pre-wrap; }
.product-model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 13px; }
.product-model-card { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--bg-elev); }
.product-model-card p { color: var(--muted); line-height: 1.6; font-size: .84rem; }
.product-model-card small, .model-card-head span { color: var(--muted); font-size: .78rem; }
.capability-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 7px; margin: 14px 0; }
.capability-grid span { display: flex; justify-content: space-between; padding: 7px; border-radius: 8px; background: var(--bg-soft); font-size: .76rem; color: var(--muted); }
.capability-grid b { color: var(--text); }
.preference-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.preference-grid > label { display: grid; gap: 7px; }
.preference-grid > label.check { display: flex; align-items: center; }
.preference-actions { grid-column: 1 / -1; }
.install-app-card {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
}
.install-app-card h3 { margin: 0 0 3px; }
.developer-console { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.composer-icon, .send-btn {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 13px; display: grid;
  place-items: center; font: inherit; font-size: 21px; cursor: pointer; transition: .18s;
}
.composer-icon { border: 1px solid var(--border); background: var(--bg-soft); color: var(--text); }
.composer-icon:hover { border-color: var(--accent); }
.send-btn { border: 0; background: var(--accent); color: white; font-weight: 800; }
.send-btn:hover:not(:disabled) { filter: brightness(1.12); transform: translateY(-1px); }
.send-btn:disabled { opacity: .35; cursor: default; }
.composer-meta {
  display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px 0;
  color: var(--muted); font-size: 11px;
}
.advanced-trigger { border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.advanced-trigger:hover { color: var(--text); }
/* Live-transport indicator: streaming, connecting, or polling. */
.live-chip { color: var(--muted); font-size: 11px; white-space: nowrap; }
.live-chip[data-state="online"] { color: var(--ok, #22c55e); }
.live-chip[data-state="connecting"] { opacity: 0.7; }
.chat-advanced-panel {
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  margin: 7px 8px 0; padding: 12px; border: 1px solid var(--border);
  border-radius: 14px; background: var(--bg-elev);
}
.chat-advanced-panel:not([hidden]) { display: grid; }
.chat-advanced-panel label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 11px; }
.chat-advanced-panel select, .chat-advanced-panel input {
  width: 100%; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg-soft); color: var(--text); padding: 8px; font: inherit;
}
.attachment-strip { display: flex; gap: 9px; overflow-x: auto; padding: 7px 9px; }
.attachment-card {
  width: 76px; height: 65px; flex: 0 0 auto; position: relative; border-radius: 11px;
  overflow: hidden; border: 1px solid var(--border); background: var(--bg-elev);
}
.attachment-card img { width: 100%; height: 100%; object-fit: cover; }
.attachment-remove {
  position: absolute; inset: 4px 4px auto auto; width: 20px; height: 20px;
  border: 0; border-radius: 50%; background: rgba(0, 0, 0, .72); color: white;
  cursor: pointer; line-height: 1;
}
.composer-note { margin: 5px 0 0; text-align: center; color: var(--muted); font-size: 10.5px; }

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }

/* ------------------------------------------------------------ stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.stat-card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: linear-gradient(180deg, var(--accent), #06B6D4);
}
.dashboard-heading, .panel-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 16px;
}
.dashboard-heading h3, .panel-heading h3 { margin: 0; }
.dashboard-controls { justify-content: flex-end; }
.dashboard-controls .input { width: auto; min-width: 105px; }
.toggle-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; }
.dashboard-primary-grid { grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr); }
.activity-chart { min-height: 220px; display: flex; align-items: end; gap: 7px; padding-top: 20px; }
.activity-day { flex: 1; min-width: 0; display: grid; grid-template-rows: 1fr auto; gap: 8px; height: 190px; }
.activity-bar-track { display: flex; align-items: end; height: 100%; border-radius: 8px; background: var(--bg-soft); overflow: hidden; }
.activity-bar { width: 100%; min-height: 2px; border-radius: 8px 8px 0 0; background: linear-gradient(180deg, #06B6D4, var(--accent)); }
.activity-day small { color: var(--muted); font-size: 10px; text-align: center; }
.health-grid { display: grid; gap: 9px; }
.health-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--bg-soft); }
.dashboard-alerts { display: grid; gap: 8px; margin-top: 14px; }
.dashboard-alert { padding: 10px 12px; border: 1px solid var(--warn); border-radius: 12px; color: var(--warn); font-size: 13px; }
.feedback-summary {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
  margin: 16px 0;
}
.feedback-summary > div {
  display: grid; gap: 3px; padding: 13px; border-radius: 12px; background: var(--bg-soft);
}
.feedback-summary strong { font-size: 22px; }
.feedback-summary span { color: var(--muted); font-size: 11.5px; }
.feedback-fill { background: linear-gradient(90deg, var(--ok), var(--accent)); }
.secret-dialog {
  width: min(540px, calc(100% - 32px)); border: 1px solid var(--border);
  border-radius: 18px; padding: 22px; background: var(--bg-elev); color: var(--text);
}
.secret-dialog::backdrop { background: rgba(0, 0, 0, .65); backdrop-filter: blur(5px); }
.dialog-close { float: inline-end; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.secret-value { display: block; margin: 16px 0; padding: 12px; border-radius: 10px; background: var(--bg-soft); overflow-wrap: anywhere; user-select: all; }
@media (max-width: 900px) {
  .dashboard-primary-grid { grid-template-columns: 1fr; }
  .dashboard-heading { align-items: flex-start; flex-direction: column; }
  .dashboard-controls { width: 100%; justify-content: flex-start; }
  .feedback-summary { grid-template-columns: 1fr; }
}
.stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-hint { font-size: 11.5px; color: var(--muted); }

/* --------------------------------------------------------------- controls */
.btn {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  padding: 8px 14px; border-radius: 9px; font: inherit; font-size: 13.5px;
  cursor: pointer; transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 550; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.block { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }

.input {
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  border-radius: 9px; padding: 8px 11px; font: inherit; font-size: 13.5px;
  min-width: 0; max-width: 100%;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea.input { width: 100%; resize: vertical; margin-top: 10px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }

.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.chip {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--muted);
  padding: 6px 12px; border-radius: 20px; font: inherit; font-size: 13px; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); }

/* -------------------------------------------------------------- dropzone */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 26px 16px; text-align: center; color: var(--muted);
  transition: border-color .15s, background .15s; margin-bottom: 12px;
}
.dropzone.hover { border-color: var(--accent); background: rgba(37, 99, 235, .08); }
.preview { margin-top: 14px; }
.preview img { max-width: 100%; max-height: 260px; border-radius: 10px; border: 1px solid var(--border); }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 550; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: var(--bg-soft); }
td.wrap { white-space: normal; word-break: break-word; max-width: 320px; }

.kv { display: grid; grid-template-columns: minmax(140px, auto) 1fr; gap: 7px 16px; font-size: 13.5px; }
.kv dt, .kv .k { color: var(--muted); }
.kv .v { word-break: break-word; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

.badge {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 20px; padding: 1px 9px; font-size: 12px; color: var(--muted); margin-left: 6px;
}
.pill { border-radius: 20px; padding: 2px 10px; font-size: 11.5px; font-weight: 600; display: inline-block; }
.pill.ok, .pill.success, .pill.completed { background: rgba(34, 197, 94, .15); color: var(--ok); }
.pill.failed, .pill.err { background: rgba(239, 68, 68, .15); color: var(--err); }
.pill.running { background: rgba(37, 99, 235, .18); color: #93C5FD; }
.pill.queued { background: rgba(245, 158, 11, .15); color: var(--warn); }
.pill.cancelled { background: var(--bg-soft); color: var(--muted); }

/* ----------------------------------------------------------------- bars */
.bar-list, .task-bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 76px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { background: var(--bg-soft); border-radius: 20px; height: 9px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg, var(--accent), #06B6D4); transition: width .4s ease; }
.bar-value { text-align: right; color: var(--muted); font-size: 12.5px; }

.progress { background: var(--bg-soft); border-radius: 20px; height: 7px; width: 90px; overflow: hidden; display: inline-block; vertical-align: middle; }
.progress > i { display: block; height: 100%; background: var(--accent); }

/* ------------------------------------------------------------ file grid */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.file-card { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-soft); }
.file-card img { width: 100%; height: 116px; object-fit: cover; display: block; background: var(--bg); }
.file-card .meta { padding: 8px 10px; font-size: 12px; }
.file-card .name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
.file-card .actions { display: flex; gap: 6px; padding: 0 10px 10px; }
.file-card .actions button, .file-card .actions a {
  flex: 1; text-align: center; font-size: 11.5px; padding: 4px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--muted);
  cursor: pointer; text-decoration: none;
}
.file-card .actions button:hover, .file-card .actions a:hover { color: var(--text); }

/* ---------------------------------------------------------- admin pages */
.admin-page-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  margin-bottom: 16px;
}
.admin-page-heading h3 { margin-bottom: 2px; }
.account-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.account-form {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.account-form h4 { margin: 0 0 2px; }
.account-panel { max-width: 920px; margin-inline: auto; }
.account-sessions { grid-column: 1 / -1; }
.session-list { display: grid; gap: 8px; }
.session-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px; border: 1px solid var(--border); border-radius: 12px;
}
html[data-auth-route] .sidebar { display: none; }
html[data-auth-route] .content { margin-inline-start: 0; }
html[data-auth-route] .topbar { display: none; }
html[data-auth-route] body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% 18%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 34%),
    radial-gradient(circle at 84% 82%, rgb(139 92 246 / .14), transparent 34%),
    var(--bg);
}
html[data-auth-route] #view-settings {
  min-height: 100vh; align-items: center; justify-content: center; padding: 24px;
}
html[data-auth-route] #view-settings.active { display: flex; }
html[data-auth-route] #view-settings > :not(.account-panel) { display: none; }
html[data-auth-route] .account-panel {
  width: min(100%, 480px); padding: clamp(22px, 5vw, 38px);
  border-radius: 24px; box-shadow: 0 28px 90px rgb(0 0 0 / .34);
  background: color-mix(in srgb, var(--bg-elev) 91%, transparent); backdrop-filter: blur(24px);
}
html[data-auth-route] .auth-brand {
  display: flex; align-items: center; gap: 15px; margin-bottom: 26px;
}
.auth-brand-mark {
  display: grid; place-items: center; flex: 0 0 auto; width: 58px; height: 58px;
  border-radius: 18px; background: linear-gradient(145deg, var(--accent), #06B6D4);
  color: white; font-size: 14px; font-weight: 850; letter-spacing: .06em;
  box-shadow: 0 15px 38px color-mix(in srgb, var(--accent) 34%, transparent);
}
.auth-brand h1 { margin: 1px 0 2px; font-size: 23px; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 12.5px; }
html[data-auth-route] .account-panel .admin-page-heading,
html[data-auth-route] #account-status,
html[data-auth-route] #account-login-required { display: none !important; }
html[data-auth-route] .account-forms { grid-template-columns: 1fr; }
html[data-auth-route] .account-form {
  padding: 0; border: 0; background: transparent; gap: 13px;
}
html[data-auth-route] .account-form h4 { font-size: 18px; }
.account-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12.5px; }
.auth-form-intro { margin: -6px 0 3px; }
.auth-submit { min-height: 46px; justify-content: center; font-weight: 700; }
.auth-links {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-size: 12.5px; margin-top: 2px;
}
.auth-links a, .account-form a { color: var(--accent); text-decoration: none; }
.auth-links a:hover, .account-form a:hover { text-decoration: underline; }
.auth-security-note {
  margin: 5px 0 0; padding: 10px 12px; border-radius: 10px;
  background: var(--bg-soft); color: var(--muted); font-size: 11.5px; line-height: 1.6;
}
html:not([data-auth-route]) #signup-form,
html:not([data-auth-route]) #forgot-form,
html:not([data-auth-route]) #reset-form { display: none; }
html[data-auth-route="login"] #signup-form,
html[data-auth-route="login"] #forgot-form,
html[data-auth-route="login"] #reset-form,
html[data-auth-route="signup"] #login-form,
html[data-auth-route="signup"] #forgot-form,
html[data-auth-route="signup"] #reset-form,
html[data-auth-route="forgot-password"] #login-form,
html[data-auth-route="forgot-password"] #signup-form,
html[data-auth-route="forgot-password"] #reset-form,
html[data-auth-route="reset-password"] #login-form,
html[data-auth-route="reset-password"] #signup-form,
html[data-auth-route="reset-password"] #forgot-form { display: none; }
@media (max-width: 760px) {
  .account-forms { grid-template-columns: 1fr; }
  html[data-auth-route] #view-settings { padding: 12px; }
  html[data-auth-route] .account-panel { border-radius: 19px; }
  .auth-links { align-items: flex-start; flex-direction: column; }
}
.admin-account-tools {
  max-width: 920px; margin: 14px auto 0; border: 1px solid var(--border);
  border-radius: 16px; background: var(--bg-elev); overflow: clip;
}
.admin-account-tools > summary {
  display: flex; justify-content: space-between; align-items: center; padding: 15px 18px;
  cursor: pointer; color: var(--muted); font-weight: 650; list-style: none;
}
.admin-account-tools > summary::-webkit-details-marker { display: none; }
.admin-account-tools > summary::after { content: "⌄"; transition: transform .18s; }
.admin-account-tools[open] > summary::after { transform: rotate(180deg); }
.admin-account-tools > .panel,
.admin-account-tools > .grid-2 { margin: 0 14px 14px; }
.model-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.model-card {
  position: relative; overflow: hidden; border: 1px solid var(--border);
  border-radius: 16px; background: var(--bg-elev); padding: 17px;
}
.model-card.default { border-color: color-mix(in srgb, var(--accent) 72%, var(--border)); }
.model-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--accent), #06B6D4);
}
.model-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.model-card h4 { margin: 0; font-size: 15px; }
.model-card .model-meta {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin: 14px 0; color: var(--muted); font-size: 12px;
}
.model-card .model-meta span {
  padding: 7px 8px; border-radius: 8px; background: var(--bg-soft);
}
.secret-reveal {
  margin-top: 14px; padding: 13px; border: 1px solid var(--warn);
  border-radius: 12px; background: color-mix(in srgb, var(--warn) 9%, var(--bg-elev));
}
.secret-reveal:not([hidden]) { display: block; }
.secret-reveal code {
  flex: 1; min-width: 240px; padding: 9px; border-radius: 8px;
  background: var(--bg); overflow-wrap: anywhere; user-select: all;
}
.log-output {
  min-height: 420px; max-height: 64vh; direction: ltr; text-align: left;
  font-size: 11.5px; line-height: 1.65;
}

/* ------------------------------------------------------ bidirectional text */
/* Arabic input: the field follows its own content via dir="auto", and the
   font stack falls back to a face with proper Arabic coverage. */
.bidi {
  font-family: "Segoe UI", "Noto Naskh Arabic", "Amiri", "Inter", system-ui, sans-serif;
  line-height: 1.9;
}
.bidi:placeholder-shown { text-align: start; }

.rtl { direction: rtl; text-align: right; }
.ltr { direction: ltr; text-align: left; }

.translation-box {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  padding: 12px 14px;
  font-size: 13px;
}
.translation-box .tr-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.translation-box .tr-label {
  flex-shrink: 0; width: 74px; color: var(--muted); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em; padding-top: 2px;
}
.translation-box .tr-value { flex: 1; word-break: break-word; }
.translation-box .tr-value.ar { direction: rtl; text-align: right; line-height: 1.9; }
.translation-box .tr-value.en { direction: ltr; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.translation-box .tr-terms { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.translation-box .tr-term {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 20px;
  padding: 1px 9px; font-size: 11px; color: var(--muted);
}

#gen-examples .chip { direction: rtl; font-family: "Segoe UI", "Noto Naskh Arabic", sans-serif; }

/* --------------------------------------------------------------- output */
.output {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; max-height: 320px; overflow: auto;
  font-family: ui-monospace, Menlo, monospace; font-size: 12.5px;
  white-space: pre-wrap; word-break: break-word; margin: 0;
}
.result { margin-top: 16px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { text-align: center; font-size: 11.5px; color: var(--muted); }
.swatch i { display: block; width: 62px; height: 46px; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 5px; }

/* ------------------------------------------------------------ auth chip */
#auth-chip { font-size: 13px; white-space: nowrap; }
#auth-panel { border-left: 3px solid var(--accent); }
#auth-key-input { letter-spacing: .04em; }

/* ---------------------------------------------------------------- toasts */
.toast-stack { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 9px; z-index: 60; }
.toast {
  background: var(--bg-elev); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: 9px; padding: 11px 15px; box-shadow: var(--shadow);
  font-size: 13.5px; max-width: 360px; animation: slide .2s ease;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------- resilient shell */
.mobile-bottom-nav, .sidebar-backdrop { display: none; }
.fatal-error {
  position: fixed; inset: 0; z-index: 120; padding: 22px; place-items: center;
  background: color-mix(in srgb, var(--bg) 76%, transparent); backdrop-filter: blur(14px);
}
.fatal-error:not([hidden]) { display: grid; }
.fatal-error > div {
  width: min(440px, 100%); padding: 28px; border: 1px solid var(--border);
  border-radius: 22px; background: var(--bg-elev); box-shadow: var(--shadow);
}
.fatal-error-icon {
  display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 16px;
  border-radius: 14px; background: color-mix(in srgb, var(--err) 16%, transparent);
  color: var(--err); font-size: 24px; font-weight: 800;
}
.fatal-error p { margin: 8px 0 20px; color: var(--muted); }

/* --------------------------------------------------------------- mobile */
@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar {
    width: min(86vw, 320px); height: var(--app-height, 100dvh); position: fixed; inset: 0 auto 0 0;
    z-index: 80; transform: translateX(-105%); transition: transform .24s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 75; border: 0; padding: 0;
    background: rgb(2 6 18 / .62); backdrop-filter: blur(3px);
  }
  body.menu-open .sidebar-backdrop { display: block; }
  .content {
    min-height: var(--app-height, 100dvh);
    padding: 14px 12px calc(82px + env(safe-area-inset-bottom));
  }
  .content:has(.chat-view.active) { height: var(--app-height, 100dvh); }
  .topbar { padding-inline-start: 44px; }
  .mobile-menu-btn {
    display: grid; place-items: center; position: absolute; inset-inline-start: 12px; top: 13px;
    cursor: pointer;
  }
  .topbar h2 { font-size: 17px; }
  .topbar p, #refresh-btn { display: none; }
  .connection-chip { padding-inline: 8px; }
  .connection-chip span { font-size: 0; }
  .connection-chip span::after { content: "اتصال"; font-size: 11px; }
  .connection-chip.offline span::after { content: "منقطع"; }
  .offline-banner { margin-top: -8px; }
  .chat-scroll { padding: 16px 2px 16px; }
  .chat-empty { min-height: 52vh; }
  .prompt-suggestions { grid-template-columns: 1fr; }
  .composer-shell { padding-bottom: calc(68px + max(9px, env(safe-area-inset-bottom))); }
  .composer-meta span, .composer-note { display: none; }
  .chat-advanced-panel { grid-template-columns: 1fr; max-height: 40vh; overflow-y: auto; }
  .message-bubble { max-width: 88%; }
  .user-welcome { align-items: flex-start; flex-direction: column; padding: 18px; }
  .user-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool-catalogue { grid-template-columns: 1fr; }
  .dashboard-list button { flex-direction: column; }
  .gallery-controls { align-items: stretch; flex-direction: column; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-options { align-items: flex-start; flex-direction: column; }
  .personal-job { grid-template-columns: 1fr auto; }
  .personal-job .job-progress, .personal-job .row, .job-error { grid-column: 1 / -1; }
  .preference-grid { grid-template-columns: 1fr; }
  .preference-actions { grid-column: 1; }
  .mobile-bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed;
    inset: auto 8px max(8px, env(safe-area-inset-bottom)) 8px; z-index: 70;
    min-height: 58px; padding: 5px; border: 1px solid var(--border);
    border-radius: 18px; background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
    box-shadow: 0 14px 44px rgb(0 0 0 / .28); backdrop-filter: blur(18px);
  }
  .mobile-bottom-nav button {
    display: grid; place-items: center; gap: 1px; min-width: 0; border: 0;
    border-radius: 13px; background: transparent; color: var(--muted); cursor: pointer;
  }
  .mobile-bottom-nav button span { font-size: 18px; line-height: 1; }
  .mobile-bottom-nav button small { font-size: 10px; }
  .mobile-bottom-nav button.active {
    color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent);
  }
  .toast-stack {
    right: 12px; left: 12px;
    bottom: calc(78px + env(safe-area-inset-bottom));
  }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
