:root {
  --bg: #f6f2ea; --panel: #fffdf8; --panel-2: #f0eadf; --line: #e3dacb;
  --text: #221d16; --muted: #7a6f5f; --accent: #c9821b; --accent-ink: #fff;
  --accent-soft: #f6e4c4; --user: #2a241b; --user-ink: #f7f1e6;
  --ok: #2f8f5b; --warn: #c27a12; --bad: #c0412f; --code: #f1ebe0;
  --shadow: 0 1px 2px rgba(40,30,10,.06), 0 8px 24px rgba(40,30,10,.06);
  --radius: 14px;
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120f; --panel: #1c1915; --panel-2: #24201b; --line: #332d25;
    --text: #efe8dc; --muted: #9a8f7e; --accent: #e8a33d; --accent-ink: #1a1712;
    --accent-soft: #3a2c16; --user: #e8a33d; --user-ink: #1a1712;
    --code: #262119; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.7 var(--font); display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre { font-family: var(--mono); font-size: 13px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand b { display: block; font-size: 17px; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 12px; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.logo.big { width: 64px; height: 64px; border-radius: 18px; font-size: 32px; margin: 0 auto 12px; }
.top-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 4px 12px; font-size: 13px; cursor: pointer; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.pill.ok .dot { background: var(--ok); }
.pill.status { cursor: default; }
.icon-btn { border: 0; background: transparent; cursor: pointer; border-radius: 8px; padding: 6px 8px; font-size: 16px; line-height: 1; }
.icon-btn:hover { background: var(--panel-2); }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }

/* layout */
.layout { flex: 1; display: grid; grid-template-columns: 300px minmax(0, 1fr) 320px; min-height: 0; }
.layout.no-files { grid-template-columns: 300px minmax(0, 1fr); }
.layout.no-files .files { display: none; }
.side, .files { background: var(--panel); overflow-y: auto; padding: 14px; }
.side { border-inline-end: 1px solid var(--line); }
.files { border-inline-start: 1px solid var(--line); }
.side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.side-head h3, .group h3 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }

.sessions ul { list-style: none; margin: 0 0 18px; padding: 0; max-height: 200px; overflow-y: auto; }
.sessions li { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.sessions li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sessions li:hover { background: var(--panel-2); }
.sessions li.on { background: var(--accent-soft); }
.sessions li .del { opacity: 0; font-size: 12px; padding: 2px 6px; }
.sessions li:hover .del { opacity: .7; }
.sessions li .busy { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }

.group { margin-bottom: 18px; }
.group header { margin-bottom: 8px; }
.group header small { display: block; color: var(--muted); font-size: 12px; }
.cards { display: grid; gap: 6px; }
.card { display: flex; gap: 10px; align-items: flex-start; text-align: start; width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 9px 10px; cursor: pointer; transition: border-color .15s, transform .15s; }
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card .ic { font-size: 20px; line-height: 1.3; }
.card b { font-size: 14px; display: flex; gap: 6px; align-items: center; }
.card small { display: block; color: var(--muted); font-size: 12px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.badge { font-size: 10px; background: var(--accent-soft); color: var(--accent); padding: 0 6px; border-radius: 6px; font-weight: 600; }

/* chat */
.chat { display: flex; flex-direction: column; min-height: 0; position: relative; }
.messages { flex: 1; overflow-y: auto; padding: 24px clamp(16px, 4vw, 48px) 12px; }
.empty { text-align: center; max-width: 560px; margin: 8vh auto 0; }
.empty h1 { margin: 0 0 6px; font-size: 26px; }
.empty p { color: var(--muted); margin: 0 0 20px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.quick button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: 14px; }
.quick button:hover { border-color: var(--accent); }

.msg { max-width: 820px; margin: 0 auto 14px; }
.msg.user { display: flex; justify-content: flex-start; }
.msg.user .bubble { background: var(--user); color: var(--user-ink); border-radius: 16px 16px 4px 16px; padding: 9px 14px; max-width: 85%; white-space: pre-wrap; word-break: break-word; }
.msg.assistant .md { word-break: break-word; }
.md p { margin: 0 0 .6em; }
.md p:last-child { margin-bottom: 0; }
.md pre { background: var(--code); padding: 10px 12px; border-radius: 10px; overflow-x: auto; direction: ltr; text-align: left; }
.md code { background: var(--code); padding: 1px 5px; border-radius: 5px; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; margin: .5em 0; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 4px 10px; }
.md a { color: var(--accent); }
.md ul, .md ol { padding-inline-start: 1.4em; margin: .3em 0 .6em; }
.md h1, .md h2, .md h3 { line-height: 1.35; margin: .8em 0 .4em; }
.md h1 { font-size: 20px; } .md h2 { font-size: 18px; } .md h3 { font-size: 16px; }
.md blockquote { margin: .5em 0; padding-inline-start: 12px; border-inline-start: 3px solid var(--accent); color: var(--muted); }
.filelink { color: var(--accent); cursor: pointer; text-decoration: underline dotted; }
.live { white-space: pre-wrap; }
.caret::after { content: '▍'; animation: pulse 1s infinite; color: var(--accent); }

.tool { max-width: 820px; margin: 0 auto 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); font-size: 13px; }
.tool summary { cursor: pointer; padding: 6px 10px; display: flex; gap: 8px; align-items: center; list-style: none; }
.tool summary::-webkit-details-marker { display: none; }
.tool summary .t-name { font-weight: 600; }
.tool summary .t-arg { color: var(--muted); font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; flex: 1; text-align: left; }
.tool summary .t-st { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; flex: none; }
.tool.done summary .t-st { background: var(--ok); animation: none; }
.tool.err summary .t-st { background: var(--bad); animation: none; }
.tool pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--line); max-height: 260px; overflow: auto; direction: ltr; text-align: left; white-space: pre-wrap; word-break: break-all; font-size: 12px; }
.tool.sub { margin-inline-start: max(0px, calc(50% - 410px + 24px)); opacity: .85; }
.result-line { max-width: 820px; margin: 0 auto 18px; color: var(--muted); font-size: 12px; display: flex; gap: 12px; }
.notice { max-width: 820px; margin: 0 auto 14px; padding: 10px 14px; border-radius: 10px; font-size: 14px; white-space: pre-wrap; }
.notice.error { background: color-mix(in srgb, var(--bad) 12%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.notice.info { background: var(--accent-soft); }
.thinking { max-width: 820px; margin: 0 auto 12px; color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .2s; } .thinking i:nth-child(3) { animation-delay: .4s; }
@keyframes pulse { 50% { opacity: .25; } }

/* launcher */
.launcher { margin: 0 clamp(16px, 4vw, 48px) 8px; max-width: 820px; align-self: center; width: calc(100% - 2 * clamp(16px, 4vw, 48px)); background: var(--panel); border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.launcher-head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.launcher-head div { flex: 1; }
.launcher-head small { display: block; color: var(--muted); font-size: 12px; }
.launcher-icon { font-size: 26px; }
.launcher textarea, .launcher input[type=text], .launcher input[type=url] { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 10px; resize: vertical; }
.launcher-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.drop { border: 2px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; cursor: pointer; color: var(--muted); }
.drop.over, .drop:hover { border-color: var(--accent); color: var(--text); }
.drop-list { margin: 8px 0 0; padding: 0; list-style: none; font-size: 13px; }

/* composer */
.composer { padding: 10px clamp(16px, 4vw, 48px) 16px; }
.composer-row { max-width: 820px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 8px; box-shadow: var(--shadow); }
.composer-row:focus-within { border-color: var(--accent); }
.composer textarea { flex: 1; border: 0; background: transparent; resize: none; outline: none; max-height: 220px; padding: 6px 4px; }
.attachments { max-width: 820px; margin: 0 auto 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; font-size: 12px; direction: ltr; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0; }
.chip.up { opacity: .6; }

/* files */
.tabs { display: flex; gap: 4px; margin-bottom: 10px; background: var(--panel-2); padding: 3px; border-radius: 10px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 4px; cursor: pointer; font-size: 13px; }
.tabs button.on { background: var(--panel); box-shadow: var(--shadow); }
#fileList { list-style: none; margin: 0; padding: 0; }
#fileList li { display: flex; gap: 8px; align-items: center; padding: 7px 8px; border-radius: 9px; cursor: pointer; }
#fileList li:hover { background: var(--panel-2); }
#fileList li .fi { font-size: 18px; }
#fileList li div { min-width: 0; flex: 1; }
#fileList li b { display: block; font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; text-align: right; }
#fileList li small { color: var(--muted); font-size: 11px; }
#fileList li.new b::after { content: ' • جديد'; color: var(--accent); font-size: 11px; }
#fileList .none { color: var(--muted); font-size: 13px; cursor: default; }

/* dialogs */
.dlg { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); color: var(--text); padding: 16px 18px; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.dlg.wide { width: min(1100px, calc(100vw - 32px)); height: min(88vh, 900px); display: none; flex-direction: column; }
.dlg.wide[open] { display: flex; }
.dlg::backdrop { background: rgba(10,8,5,.45); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.dlg-head > div { display: flex; gap: 6px; align-items: center; }
.dlg-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlg label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.dlg input:not([type=color]), .dlg select { display: block; width: 100%; margin-top: 4px; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 7px 10px; color: var(--text); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.colors { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.colors input[type=color] { width: 40px; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--bg); cursor: pointer; }
.colors input:not([type=color]) { margin: 0; flex: 1; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.pv-body { flex: 1; min-height: 0; border-radius: 10px; overflow: auto; background: var(--panel-2); display: grid; place-items: center; }
.pv-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.pv-body img, .pv-body video { max-width: 100%; max-height: 100%; }
.pv-body pre { align-self: stretch; justify-self: stretch; margin: 0; padding: 14px; white-space: pre-wrap; direction: auto; }
.health { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.health li { display: flex; justify-content: space-between; gap: 8px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.health code { direction: ltr; }

.only-mobile { display: none; }
@media (max-width: 1100px) {
  .layout, .layout.no-files { grid-template-columns: 270px minmax(0, 1fr); }
  .files { position: fixed; inset: 57px 0 0 auto; inset-inline-start: auto; inset-inline-end: 0; width: 320px; z-index: 5; box-shadow: var(--shadow); }
  [dir=rtl] .files { left: 0; right: auto; }
  .layout.no-files .files { display: none; }
}
@media (max-width: 760px) {
  .only-mobile { display: inline-block; }
  .layout, .layout.no-files { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 57px 0 0 0; z-index: 6; display: none; }
  .side.open { display: block; }
  .brand small, #identityLabel { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .files { width: 100%; }
}

/* account menu */
.acct-wrap { position: relative; }
.acct-pill { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line); background: var(--panel-2); border-radius: 999px; padding: 3px 10px 3px 4px; cursor: pointer; font-size: 13px; max-width: 180px; }
.acct-pill #accName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--c, var(--accent)); overflow: hidden; flex: none; }
.mini-av img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 2px; }
.acct-menu { position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.acct-menu .acct-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.acct-menu .acct-head b { display: block; }
.acct-menu .acct-head small { color: var(--muted); font-size: 11px; direction: ltr; display: block; text-align: end; overflow: hidden; text-overflow: ellipsis; }
.acct-menu button { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 7px 10px; border-radius: 9px; cursor: pointer; font-size: 14px; }
.acct-menu button:hover { background: var(--panel-2); }
@media (max-width: 760px) { .acct-pill #accName { display: none; } }

.acct-menu .user-head { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 10px; }

a.btn { color: inherit; text-decoration: none; display: inline-flex; align-items: center; }
a.btn.primary { color: var(--accent-ink); }

/* chat rename */
#sessionList li .ren { opacity: 0; }
#sessionList li:hover .ren, #sessionList li.on .ren { opacity: .7; }
#sessionList li input.rename { flex: 1; min-width: 0; font: inherit; padding: 2px 6px; border: 1px solid var(--accent); border-radius: 6px; background: var(--panel); color: inherit; }
/* files: scope, selection, download */
.tabs.scope { margin-bottom: 6px; }
.file-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0 6px; font-size: 12px; color: var(--muted); }
.file-bar label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
#fileList li .sel { flex: none; margin: 0; cursor: pointer; }
#fileList li .dl { flex: none; opacity: .55; text-decoration: none; padding: 4px 6px; border-radius: 6px; font-size: 14px; }
#fileList li .dl:hover { opacity: 1; background: var(--panel); }
#fileList li.picked { background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* flat line icons (icons.js swaps every UI emoji for these) */
.fi-ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; display: inline-block; }
.card .ic, .launcher .l-icon, #lIcon { color: var(--accent); }
.card .ic .fi-ic { width: 1.25em; height: 1.25em; stroke-width: 1.8; }
#fileList li .fi { color: var(--muted); display: inline-flex; }
.tool summary .fi-ic { color: var(--muted); }

/* action colours: delete = red, download = project accent */
.icon-btn.del, .fi-trash, .btn .fi-trash { color: var(--bad); }
.icon-btn.del:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }
#fileList li .dl, #fileList li .dl:visited, #pvDl { color: var(--accent); opacity: 1; }
#fileList li .dl:hover { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.sessions li:hover .del, .sessions li.on .del { opacity: 1; }

/* ===================== PWA · iPhone · iPad ===================== */
html, body { height: 100dvh; }
body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
.mtabs { display: none; }
button, a, label, summary { -webkit-tap-highlight-color: transparent; }
/* touch screens have no hover: keep row actions visible */
@media (hover: none) {
  .sessions li .del, #sessionList li .ren { opacity: 1; }
  .card:hover { transform: none; }
}

/* iPad portrait / small laptops: files slide over the chat */
@media (max-width: 1100px) and (min-width: 761px) {
  .files { top: calc(57px + env(safe-area-inset-top)); bottom: 0; height: auto; box-shadow: -12px 0 40px rgba(0,0,0,.25); animation: slideIn .18s ease-out; }
}
@keyframes slideIn { from { transform: translateX(-24px); opacity: 0; } }

/* iPhone: one full-screen panel at a time + bottom tab bar */
@media (max-width: 760px) {
  body { font-size: 15px; }
  .topbar { padding: calc(8px + env(safe-area-inset-top)) 12px 8px; gap: 8px; }
  .brand b { font-size: 16px; }
  #toggleSide, #filesToggle, #healthPill, #identityBtn { display: none !important; }
  .layout, .layout.no-files { display: block; position: relative; flex: 1; min-height: 0; }
  .layout > .side, .layout > .chat, .layout > .files { position: absolute; inset: 0; width: auto; height: auto; display: none; box-shadow: none; border: 0; z-index: auto; animation: none; }
  body[data-mtab="side"] .layout > .side,
  body[data-mtab="files"] .layout > .files { display: block !important; padding: 14px 14px 20px; }
  body[data-mtab="chat"] .layout > .chat { display: flex; }
  .sessions ul { max-height: none; }
  .sessions li { padding: 10px 12px; font-size: 15px; }
  .sessions li .icon-btn { padding: 8px 10px; font-size: 17px; }
  #fileList li { padding: 11px 8px; }
  #fileList li .dl { padding: 8px 10px; font-size: 18px; }
  #fileList li .sel { width: 20px; height: 20px; }
  .tabs button { padding: 7px 4px; }
  .messages { padding: 14px 12px 8px; }
  .empty { margin-top: 4vh; }
  .empty h1 { font-size: 22px; }
  .msg.user .bubble { max-width: 92%; }
  .composer { padding: 6px 10px 8px; }
  .composer-row { border-radius: 22px; padding: 6px 6px 6px 8px; }
  .composer textarea { font-size: 16px; max-height: 140px; }   /* 16px = iOS won't zoom on focus */
  .composer .btn { border-radius: 16px; }
  .launcher { margin: 0 10px 8px; width: auto; }
  .launcher-foot { flex-wrap: wrap; }
  .launcher-foot .btn { flex: 1; }
  .mtabs { display: flex; flex: none; background: var(--panel); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .mtabs button { flex: 1; position: relative; border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 0 3px; font-size: 11px; cursor: pointer; border-radius: 10px; }
  .mtabs button .fi-ic { width: 22px; height: 22px; }
  .mtabs button.on { color: var(--accent); }
  .mtabs .mt-dot { position: absolute; top: 4px; inset-inline-end: calc(50% - 18px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
  /* dialogs become full-screen sheets */
  .dlg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 18px 18px 0 0; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto; }
  .dlg.wide { width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; padding-top: calc(10px + env(safe-area-inset-top)); }
  .dlg-head { flex-wrap: wrap; }
  .dlg-head > b { flex: 1 1 100%; font-size: 13px; direction: ltr; text-align: right; }
  .acct-menu { position: fixed; top: calc(56px + env(safe-area-inset-top)); inset-inline: 10px; min-width: 0; }
}
.install-hint { margin-top: 18px !important; background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; font-size: 13px; color: var(--text) !important; }
/* iOS zooms into any field under 16px — keep inputs at 16px on touch phones */
@media (max-width: 760px) and (pointer: coarse) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), textarea, select { font-size: 16px !important; }
}

/* app mark (same as the PWA icon): dark stroke on the accent tile */
.logo svg { width: 100%; height: 100%; fill: none; stroke: #1a1712; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; display: block; }
.logo { background: #e8a33d; }
a.pill.nav-pill { color: var(--text); text-decoration: none; }
a.pill.nav-pill:hover { border-color: var(--accent); }
@media (max-width: 760px) { a.pill.nav-pill { display: none; } }
.topic-bar { display: flex; align-items: center; gap: 6px; padding: 6px 14px; font-size: 13px; color: var(--muted); background: var(--panel); border-bottom: 1px solid var(--line); text-decoration: none; }
.topic-bar b { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.topic-bar .go { color: var(--accent); flex: none; }
.topic-bar:hover { background: var(--panel-2); }
@media (max-width: 760px) { .topic-bar > span:first-of-type { display: none; } }

/* iPad (windowed apps / Stage Manager): iPadOS draws its close/minimise dots at the top-left,
   which is where our RTL action buttons sit — keep that corner free */
@media (min-width: 761px) {
  html.ios .topbar { padding-left: max(16px, calc(env(safe-area-inset-left) + 92px)); }
}
