/* Omni Remote - Telegram-mini-app look, same family as the Poozy/Pzorion apps */
@font-face { font-family: "Vazirmatn"; src: url("/assets/fonts/Vazirmatn-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("/assets/fonts/Vazirmatn-Medium.woff2") format("woff2"); font-weight: 500 600; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("/assets/fonts/Vazirmatn-Bold.woff2") format("woff2"); font-weight: 700 900; font-display: swap; }

:root {
  --accent: #4f7cff;
  --accent-2: #7c5cff;
  --accent-soft: rgba(79,124,255,.12);
  --bg: #eef1f7;
  --bg-chat: #e6ebf3;
  --surface: #ffffff;
  --surface-2: #f5f7fb;
  --hairline: rgba(20,22,28,.08);
  --text: #11131a;
  --text-dim: #5b6175;
  --text-faint: #8a90a1;
  --bubble-me: #4f7cff;
  --bubble-me-text: #fff;
  --bubble-ai: #ffffff;
  --code-bg: #f1f3f8;
  --term-bg: #0d1117;
  --term-fg: #d7dce5;
  --success: #12916a;
  --success-soft: rgba(18,145,106,.13);
  --danger: #d93b40;
  --danger-soft: rgba(217,59,64,.12);
  --warning: #b57a1e;
  --warning-soft: rgba(201,134,42,.15);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --bg-chat: #0c0f14; --surface: #181c24; --surface-2: #1e232d;
    --hairline: rgba(255,255,255,.07); --text: #eef1f6; --text-dim: #a3aab9; --text-faint: #717888;
    --bubble-me: #3d63d9; --bubble-ai: #1b2029; --code-bg: #12161d; --accent-soft: rgba(79,124,255,.18);
    --success: #34c08f; --danger: #ff6b6f; --warning: #e0a649;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --bg-chat: #0c0f14; --surface: #181c24; --surface-2: #1e232d;
  --hairline: rgba(255,255,255,.07); --text: #eef1f6; --text-dim: #a3aab9; --text-faint: #717888;
  --bubble-me: #3d63d9; --bubble-ai: #1b2029; --code-bg: #12161d; --accent-soft: rgba(79,124,255,.18);
  --success: #34c08f; --danger: #ff6b6f; --warning: #e0a649;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 15px/1.6 "Vazirmatn", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select { font-size: 16px !important; }
button, a, summary, .chip { touch-action: manipulation; }
button, .chip, summary, .keys, .topbar { -webkit-user-select: none; user-select: none; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg.ic { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.mono { font-family: var(--mono); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }

#app { height: var(--vvh, 100dvh); display: flex; flex-direction: column; max-width: 860px; margin: 0 auto;
  position: fixed; top: var(--vvt, 0px); left: 0; right: 0; }

/* --- top bar (Telegram header) --- */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 12px 10px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--hairline); position: relative; z-index: 5; min-height: 58px;
}
.topbar .grow { flex: 1; min-width: 0; }
.topbar h1 { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sub { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--text-dim); flex: none; }
.iconbtn:active { background: var(--accent-soft); }
.iconbtn.accent { color: var(--accent); }
.logo { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 4px 14px rgba(79,124,255,.35); }

/* --- scroll area --- */
.scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pad { padding: 14px 14px calc(96px + var(--safe-b)); }

.section-title { font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 18px 6px 8px; display: flex; align-items: center; gap: 8px; }
.section-title .count { background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 0 8px; font-size: 12px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--hairline); }
.list { overflow: hidden; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; text-align: start; position: relative; }
.row-item + .row-item::before { content: ""; position: absolute; top: 0; inset-inline-start: 66px; inset-inline-end: 0; border-top: 1px solid var(--hairline); }
.row-item:active { background: var(--surface-2); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; flex: none; position: relative;
  background: linear-gradient(135deg, #5b8cff, #8a6bff); font-size: 16px; }
.avatar.c1 { background: linear-gradient(135deg, #ff8a5b, #ff5b8c); }
.avatar.c2 { background: linear-gradient(135deg, #2fc29b, #3b9cff); }
.avatar.c3 { background: linear-gradient(135deg, #f5b73b, #ff7b3b); }
.avatar.c4 { background: linear-gradient(135deg, #8a6bff, #d35bff); }
.avatar .dot { position: absolute; bottom: 1px; inset-inline-end: 1px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--surface); background: var(--text-faint); }
.dot.busy { background: var(--warning); animation: pulse 1.4s infinite; }
.dot.idle { background: var(--success); }
.dot.wait { background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 8px; }
.row-title { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 12px; color: var(--text-faint); flex: none; }
.row-sub { font-size: 13px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--hairline); max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip.ok { background: var(--success-soft); color: var(--success); border-color: transparent; }
.chip.warn { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.chip.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 10px 6px; text-align: center; min-width: 0; }
.stat b { display: block; font-size: 19px; font-weight: 700; white-space: nowrap; line-height: 1.35; }
.stat b small { display: block; font-size: 11.5px; font-weight: 500; opacity: .8; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--text-dim); }
.hero { padding: 16px; display: flex; flex-direction: column; gap: 12px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: 0; }
.hero .stat { background: rgba(255,255,255,.14); border-radius: var(--radius-sm); }
.hero .stat span { color: rgba(255,255,255,.82); }
.hero-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; }
.hero-head small { opacity: .85; font-weight: 400; }

.empty { text-align: center; padding: 28px 16px; color: var(--text-dim); }
.empty svg.ic { width: 42px; height: 42px; color: var(--text-faint); margin-bottom: 6px; }

.fab { position: fixed; bottom: calc(20px + var(--safe-b)); inset-inline-start: max(20px, calc(50% - 410px)); z-index: 6;
  display: flex; align-items: center; gap: 8px; padding: 0 20px; height: 52px; border-radius: 26px; font-weight: 600;
  color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 8px 24px rgba(79,124,255,.4); }
.fab:active { transform: scale(.97); }

/* --- buttons + form --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 14px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--hairline); }
.btn.primary { background: var(--accent); color: #fff; border: 0; }
.btn.danger { color: var(--danger); background: var(--danger-soft); border: 0; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; }
.btn.sm { height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 11px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 0 4px 6px; }
.input { width: 100%; height: 46px; padding: 0 14px; border-radius: 13px; border: 1px solid var(--hairline); background: var(--surface-2); outline: none; }
textarea.input { height: auto; min-height: 80px; padding: 10px 14px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { flex: 1 1 auto; min-width: 64px; height: 38px; padding: 0 10px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--hairline); font-size: 13.5px; font-weight: 500; }
.seg button.on { background: var(--accent); color: #fff; border-color: transparent; }
.hint { font-size: 12px; color: var(--text-faint); margin: 6px 4px 0; }

/* --- login --- */
.login { flex: 1; display: grid; place-items: center; padding: 24px; }
.login .card { width: 100%; max-width: 380px; padding: 28px 22px; text-align: center; }
.login .logo { width: 64px; height: 64px; border-radius: 20px; margin: 0 auto 14px; }
.login .logo svg.ic { width: 32px; height: 32px; }
.login h2 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }
.err { color: var(--danger); font-size: 13.5px; min-height: 22px; margin-top: 8px; }

/* --- chat --- */
.chat { background: var(--bg-chat); }
.chat-bar { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--hairline); scrollbar-width: none; }
.chat-bar::-webkit-scrollbar { display: none; }
.chat-bar .chip { font-size: 13px; padding: 0 12px; height: 34px; cursor: pointer; flex: none; max-width: 230px; }
.chat-bar .chip svg.ic { width: 14px; height: 14px; }
.msgs { padding: 12px 10px 16px; display: flex; flex-direction: column; gap: 6px; }
.load-more { align-self: center; margin: 4px 0 10px; }
.msg { max-width: min(88%, 680px); padding: 8px 12px; border-radius: 18px; box-shadow: 0 1px 1px rgba(0,0,0,.06); word-wrap: break-word; overflow-wrap: anywhere; position: relative; }
.msg.me { align-self: flex-start; background: var(--bubble-me); color: var(--bubble-me-text); border-start-start-radius: 6px; }
.msg.me .me-text { white-space: pre-wrap; }
.msg.only-files { background: transparent; box-shadow: none; padding: 0; }
.msg.only-files .meta { color: var(--text-dim); opacity: 1; }
.msg.ai { align-self: flex-end; background: var(--bubble-ai); border-start-end-radius: 6px; }
.msg .meta { font-size: 11px; opacity: .6; margin-top: 2px; text-align: end; direction: ltr; display: flex; align-items: center; gap: 6px; justify-content: flex-start; }
.msg.me .meta { justify-content: flex-end; }
.msg .copy { width: 28px; height: 24px; display: grid; place-items: center; border-radius: 8px; margin-inline-end: auto; opacity: .9; }
.msg .copy svg.ic { width: 15px; height: 15px; }
.msg .copy:active { background: var(--accent-soft); }
.msg.ai .meta { text-align: start; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin-bottom: 0; }
.msg h1, .msg h2, .msg h3, .msg h4 { font-size: 15.5px; margin: 8px 0 4px; }
.msg ul, .msg ol { margin: 4px 0; padding-inline-start: 20px; }
.msg code { font-family: var(--mono); font-size: 12.5px; background: var(--code-bg); padding: 1px 5px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }
.msg.me code { background: rgba(255,255,255,.18); }
.msg pre { background: var(--code-bg); border-radius: 10px; padding: 8px 10px; overflow-x: auto; margin: 6px 0; direction: ltr; text-align: left; position: relative; }
.msg pre .pre-copy { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--text-faint); background: var(--code-bg); }
.msg pre .pre-copy svg.ic { width: 15px; height: 15px; }
.msg pre code { background: none; padding: 0; white-space: pre; }
.msg table { border-collapse: collapse; font-size: 13px; display: block; overflow-x: auto; margin: 6px 0; }
.msg td, .msg th { border: 1px solid var(--hairline); padding: 3px 8px; }
.msg a { color: var(--accent); }
.msg blockquote { margin: 4px 0; padding-inline-start: 10px; border-inline-start: 3px solid var(--accent); color: var(--text-dim); }

.event { align-self: flex-end; max-width: min(92%, 700px); width: fit-content; background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; font-size: 13px; overflow: hidden; }
.event > summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 7px 11px; cursor: pointer; min-width: 0; }
.event > summary::-webkit-details-marker { display: none; }
.event .ev-name { font-weight: 600; flex: none; }
.event .ev-sum { color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; direction: ltr; font-family: var(--mono); font-size: 12px; }
.event .ev-ic { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); }
.event .ev-ic svg.ic { width: 15px; height: 15px; }
.event.err .ev-ic { background: var(--danger-soft); color: var(--danger); }
.event.run .ev-ic { background: var(--warning-soft); color: var(--warning); }
.event pre { margin: 0; padding: 8px 11px; background: var(--code-bg); border-top: 1px solid var(--hairline); max-height: 340px; overflow: auto; font: 12px/1.5 var(--mono); direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-word; }
.event .label { font-size: 11px; color: var(--text-faint); padding: 6px 11px 0; background: var(--code-bg); }
.event.bash { align-self: flex-start; }
.event.bash .ev-ic { background: rgba(18,145,106,.14); color: var(--success); }
.event.think .ev-ic { background: var(--surface-2); color: var(--text-dim); }
.event.think pre { font-family: inherit; direction: auto; text-align: start; white-space: pre-wrap; }
.note { align-self: center; font-size: 12px; color: var(--text-dim); background: color-mix(in srgb, var(--surface) 70%, transparent); padding: 3px 12px; border-radius: 99px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.typing { align-self: flex-end; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); background: var(--bubble-ai); padding: 7px 12px; border-radius: 16px; }

/* --- terminal drawer --- */
.term { background: var(--term-bg); color: var(--term-fg); border-top: 1px solid var(--hairline); display: none; flex-direction: column; max-height: 52dvh; }
.term.open { display: flex; }
.term-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 12.5px; color: #9aa3b5; }
.term-head .grow { flex: 1; }
.term-head button { color: #c9d1e0; }
.term pre { margin: 0; padding: 4px 10px 8px; overflow: auto; flex: 1; font: 11.5px/1.4 var(--mono); direction: ltr; text-align: left; white-space: pre; }
.term pre.wrap { white-space: pre-wrap; word-break: break-all; }
.term-head button { width: 34px; height: 30px; border-radius: 8px; display: grid; place-items: center; }
.term-head button.on { background: rgba(79,124,255,.3); color: #fff; }
.keys { display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px 8px; scrollbar-width: none; direction: ltr; }
.keys::-webkit-scrollbar { display: none; }
.keys button { flex: none; height: 38px; min-width: 44px; padding: 0 10px; border-radius: 9px; background: #1f2633; color: #e3e8f2; font: 600 12.5px var(--mono); border: 1px solid rgba(255,255,255,.08); }
.keys button:active { background: var(--accent); }
.keys button.hot { background: var(--accent); border-color: transparent; }

/* --- composer --- */
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 8px calc(8px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--hairline); }
.composer textarea { flex: 1; min-height: 42px; max-height: 180px; resize: none; border: 0; outline: none; background: var(--surface-2); border-radius: 21px; padding: 9px 14px; line-height: 1.5; }
.composer.bash textarea { font-family: var(--mono); background: rgba(18,145,106,.10); }
.composer .send { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.composer .send svg.ic { transform: scaleX(-1); }
.composer .send:disabled { opacity: .5; }
.composer .tog { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--text-dim); flex: none; font: 700 17px var(--mono); }
.composer .tog.on { color: var(--success); background: rgba(18,145,106,.12); }
.readonly-bar { padding: 10px 12px calc(10px + var(--safe-b)); background: var(--surface); border-top: 1px solid var(--hairline); display: flex; gap: 8px; align-items: center; }
.readonly-bar .grow { flex: 1; font-size: 13px; color: var(--text-dim); }
.slash-pop { display: flex; gap: 6px; overflow-x: auto; padding: 6px 10px; background: var(--surface); border-top: 1px solid var(--hairline); scrollbar-width: none; }
.slash-pop button { flex: none; padding: 4px 12px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--hairline); font: 500 12.5px var(--mono); direction: ltr; }

/* --- bottom sheet --- */
.backdrop { position: fixed; inset: 0; background: rgba(8,10,16,.42); z-index: 20; opacity: 0; transition: opacity .2s; }
.backdrop.show { opacity: 1; }
.sheet { position: fixed; z-index: 21; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 620px; max-height: 88dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0; padding: 8px 16px calc(18px + var(--safe-b)); transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1); }
.sheet.show { transform: none; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--hairline); margin: 4px auto 10px; background: color-mix(in srgb, var(--text-faint) 45%, transparent); }
.sheet h3 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; text-align: start; padding: 11px 12px; border-radius: 13px; }
.opt:active, .opt.on { background: var(--accent-soft); }
.opt .t { flex: 1; min-width: 0; }
.opt .t b { display: block; font-weight: 600; font-size: 14.5px; }
.opt .t small { color: var(--text-dim); font-size: 12.5px; }
.opt .check { color: var(--accent); opacity: 0; }
.opt.on .check { opacity: 1; }
.opt .oi { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--surface-2); color: var(--accent); flex: none; }
.model-list { display: flex; flex-direction: column; gap: 2px; max-height: 46dvh; overflow-y: auto; margin: 0 -4px; }
.model-list .opt { padding: 9px 12px; }
.group-label { font-size: 12px; font-weight: 600; color: var(--text-faint); margin: 10px 8px 4px; }
.utable { width: 100%; border-collapse: collapse; font-size: 13px; }
.utable th { text-align: start; font-weight: 600; color: var(--text-dim); font-size: 12px; padding: 6px 4px; }
.utable td { padding: 7px 4px; border-top: 1px solid var(--hairline); }
.utable td:first-child { direction: ltr; text-align: left; font-family: var(--mono); font-size: 12px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.utable td.n { text-align: end; font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin: 6px 0 2px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; }
.actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 12px; }

#toast { position: fixed; bottom: calc(90px + var(--safe-b)); left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: rgba(20,24,32,.92); color: #fff; padding: 9px 16px; border-radius: 14px; font-size: 13.5px; z-index: 40; transition: all .22s; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

@media (min-width: 700px) {
  .msg { max-width: 76%; }
  .pad { padding-inline: 20px; }
}

/* model picker rows: Persian label + note, the raw id in mono below */
.model-list .opt.mopt { align-items: flex-start; }
.model-list .opt.mopt .check { margin-top: 4px; }
.mid { font: 11.5px var(--mono); direction: ltr; unicode-bidi: isolate; color: var(--text-faint); padding: 1px 0; }
.model-list .chips { align-items: center; gap: 6px; }

/* ---- composer extras ---- */
.composer { position: relative; }
.composer.drop { outline: 2px dashed var(--accent); outline-offset: -4px; }
.composer .send.stop { background: var(--danger); }
.composer .tog svg.ic { width: 22px; height: 22px; }
.attach-strip { display: none; gap: 8px; overflow-x: auto; padding: 8px 10px 2px; background: var(--surface); border-top: 1px solid var(--hairline); scrollbar-width: none; }
.att-chip { position: relative; flex: none; height: 64px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--hairline); display: flex; align-items: center; gap: 6px; padding: 0 10px 0 34px; max-width: 230px; overflow: hidden; }
.att-chip.img { width: 64px; padding: 0; }
.att-chip.img img { width: 100%; height: 100%; object-fit: cover; }
.att-ic { color: var(--accent); display: grid; }
.att-name { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.att-size { font-size: 11px; color: var(--text-faint); flex: none; }
.att-x { position: absolute; top: 3px; inset-inline-end: 3px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; }
.att-chip:not(.img) .att-x { inset-inline-end: auto; left: 4px; top: 50%; transform: translateY(-50%); }
.att-x svg.ic { width: 13px; height: 13px; }
.att-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.2); }
.att-prog i { display: block; height: 100%; background: var(--accent); transition: width .2s; }

/* ---- attachments inside messages ---- */
.att-imgs { display: grid; gap: 3px; border-radius: 14px; overflow: hidden; margin: -4px -8px 6px; max-width: 300px; }
.msg.only-files .att-imgs { margin: 0 0 2px; }
.att-imgs.n2, .att-imgs.n4 { grid-template-columns: 1fr 1fr; }
.att-imgs.n3 { grid-template-columns: 1fr 1fr 1fr; }
.att-imgs img { width: 100%; height: 100%; max-height: 300px; aspect-ratio: auto; object-fit: cover; display: block; cursor: zoom-in; background: rgba(0,0,0,.1); min-height: 80px; }
.att-imgs.n2 img, .att-imgs.n3 img, .att-imgs.n4 img { aspect-ratio: 1; }
.msg .att-file, .msg.me .att-file { color: inherit; }
.att-file { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin: 2px 0 6px; border-radius: 12px; background: rgba(255,255,255,.16); color: inherit; text-decoration: none; font-size: 13px; min-width: 0; }
.msg.only-files .att-file { background: var(--surface); border: 1px solid var(--hairline); color: var(--text); }
.att-file span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-actions { display: flex; align-items: center; gap: 8px; padding: 8px 11px; border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.ev-actions a { text-decoration: none; color: var(--text); }
.ev-img { max-width: 100%; max-height: 220px; border-radius: 10px; cursor: zoom-in; display: block; }

/* ---- image viewer ---- */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); display: grid; place-items: center; animation: fade .18s; }
.viewer img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.viewer-bar { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; display: flex; justify-content: space-between; }
.viewer-bar .iconbtn { color: #fff; background: rgba(255,255,255,.12); }
@keyframes fade { from { opacity: 0; } }

/* ---- empty chat ---- */
.hello { align-self: center; text-align: center; max-width: 340px; margin: 8vh auto 0; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-dim); font-size: 13.5px; }
.hello b { color: var(--text); font-size: 16px; }
.hello-ic { width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); margin-bottom: 6px; }
.hello-ic svg.ic { width: 32px; height: 32px; }
.sugg { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 10px; }
.sugg button { padding: 7px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--hairline); font-size: 13px; color: var(--text); }

/* ---- usage list (cards, readable at phone width) ---- */
.ulist { display: flex; flex-direction: column; gap: 8px; }
.urow { padding: 10px 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--hairline); }
.urow-top { display: flex; align-items: center; gap: 8px; }
.umodel { flex: 1; min-width: 0; font: 12.5px var(--mono); direction: ltr; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urow-top b { font-size: 15px; flex: none; }
.ufig { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-dim); }
.ufig b { color: var(--text); font-weight: 600; }

@media (max-width: 380px) {
  .topbar { gap: 6px; padding-inline: 8px; }
  .iconbtn { width: 38px; height: 38px; }
  .row-item { padding: 11px 12px; gap: 10px; }
  .avatar { width: 42px; height: 42px; }
  .composer .tog { width: 38px; }
  .msg { max-width: 92%; }
}
