/* Pocket AI — visual identity: lapis + gold, IBM Plex Sans Arabic.
   "Liquid glass" language: one quiet aurora behind everything, translucent layers on top.
   Performance rules (weak laptops, Android WebView):
   - backdrop-filter only where content actually moves behind a layer: composer, top bar,
     modal/onboarding scrims, mobile sheets (sidebar, drawer), alerts, toast. Never on chat cards or list rows.
   - Panels over the static aurora (desktop sidebar, drawer, cards) use translucent fills only: the aurora
     is already soft, so a tint reads as frosted glass at no GPU cost.
   - The aurora moves with transform only (compositor), very slowly, and stops for reduced motion. */
@font-face { font-family: "Plex Arabic"; src: url(fonts/IBMPlexSansArabic-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url(fonts/IBMPlexSansArabic-Medium.ttf) format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url(fonts/IBMPlexSansArabic-SemiBold.ttf) format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url(fonts/IBMPlexSansArabic-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --font: "Plex Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, "Courier New", monospace;
  --gold: #E8B23A;
  --danger: #E5484D;
  --ok: #2FB67C;
  --r-sm: 10px; --r: 16px; --r-lg: 24px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.3, 1.4, .5, 1);
  --side-w: 272px;
  --gap: 10px; /* floating panels' distance from the window edge (desktop) */
  --blur: blur(20px) saturate(170%);
  --blur-sm: blur(12px) saturate(160%);
}
[data-theme="dark"] {
  --bg: #060913; --side: rgba(17, 22, 40, .58); --surface: #121829; --surface-2: rgba(255, 255, 255, .055); --surface-3: rgba(255, 255, 255, .1);
  --line: rgba(255, 255, 255, .075); --line-2: rgba(255, 255, 255, .13);
  --fg: #EEF1FA; --fg-2: #AEB5CF; --fg-3: #8189A8;
  --accent: #7D97FF; --accent-strong: #3F5FEA; --accent-soft: rgba(110, 140, 255, .16); --on-accent: #fff;
  --accent-grad: linear-gradient(180deg, #4766F0, #2F4BD6);
  --gold-ink: #F2C35B; --ok-ink: #45CF93;
  --user: linear-gradient(180deg, rgba(104, 134, 255, .24), rgba(80, 108, 245, .15)); --user-line: rgba(150, 172, 255, .2);
  --glass: rgba(18, 23, 42, .56);           /* panels over the aurora (no blur needed) */
  --glass-strong: rgba(15, 20, 36, .74);    /* floating layers that blur what's behind */
  --glass-solid: rgba(17, 22, 39, .94);     /* layers whose backdrop is already blurred (modal card) */
  --card: linear-gradient(180deg, rgba(255, 255, 255, .075), rgba(255, 255, 255, .04));
  --field: rgba(255, 255, 255, .05); --seg-on: rgba(255, 255, 255, .13);
  --sel: rgba(255, 255, 255, .085);
  --hi: rgba(255, 255, 255, .09);            /* inner top highlight */
  --rim-a: rgba(255, 255, 255, .2); --rim-b: rgba(255, 255, 255, .06);
  --sheen: rgba(255, 255, 255, .07);
  --scrim: rgba(3, 5, 12, .5); --gold-tint: 9%;
  --shadow: 0 24px 60px -12px rgba(0, 0, 0, .65), 0 0 0 1px rgba(255, 255, 255, .04);
  --shadow-sm: 0 6px 20px -8px rgba(0, 0, 0, .55);
  --code-bg: rgba(4, 6, 14, .6); --logo-cut: #0E1324;
  --aurora:
    radial-gradient(42% 52% at 6% 2%, rgba(64, 100, 255, .36), transparent 70%),
    radial-gradient(38% 46% at 98% 4%, rgba(84, 70, 230, .22), transparent 70%),
    radial-gradient(34% 40% at 72% 104%, rgba(232, 178, 58, .11), transparent 70%),
    radial-gradient(44% 50% at 2% 98%, rgba(36, 120, 225, .15), transparent 70%);
}
[data-theme="light"] {
  --bg: #EDF1F9; --side: rgba(255, 255, 255, .5); --surface: #FFFFFF; --surface-2: rgba(28, 42, 100, .05); --surface-3: rgba(28, 42, 100, .095);
  --line: rgba(28, 42, 100, .09); --line-2: rgba(28, 42, 100, .15);
  --fg: #10142B; --fg-2: #464E6E; --fg-3: #626A8A;
  --accent: #2347C5; --accent-strong: #1B3AA8; --accent-soft: rgba(35, 71, 197, .09); --on-accent: #fff;
  --accent-grad: linear-gradient(180deg, #3157DB, #1E3EB6);
  --gold-ink: #A8730A; --ok-ink: #18895A;
  --user: linear-gradient(180deg, rgba(52, 88, 228, .13), rgba(52, 88, 228, .085)); --user-line: rgba(35, 71, 197, .13);
  --glass: rgba(255, 255, 255, .52);
  --glass-strong: rgba(255, 255, 255, .72);
  --glass-solid: rgba(250, 251, 255, .9);
  --card: linear-gradient(180deg, rgba(255, 255, 255, .86), rgba(255, 255, 255, .64));
  --field: rgba(255, 255, 255, .78); --seg-on: #FFFFFF;
  --sel: rgba(255, 255, 255, .8);
  --hi: rgba(255, 255, 255, .95);
  --rim-a: rgba(255, 255, 255, .95); --rim-b: rgba(255, 255, 255, .35);
  --sheen: rgba(255, 255, 255, .55);
  --scrim: rgba(32, 44, 92, .2); --gold-tint: 16%;
  --shadow: 0 24px 60px -14px rgba(24, 36, 90, .28), 0 0 0 1px rgba(28, 42, 100, .05);
  --shadow-sm: 0 6px 18px -8px rgba(24, 36, 90, .2);
  --code-bg: rgba(255, 255, 255, .7); --logo-cut: #F2F5FC;
  --aurora:
    radial-gradient(42% 52% at 6% 0%, rgba(86, 122, 255, .30), transparent 70%),
    radial-gradient(38% 46% at 100% 2%, rgba(128, 118, 255, .2), transparent 70%),
    radial-gradient(34% 40% at 74% 104%, rgba(240, 186, 70, .2), transparent 70%),
    radial-gradient(44% 50% at 0% 100%, rgba(72, 168, 255, .17), transparent 70%);
}
/* No backdrop-filter (old WebView): floating layers become near-solid so text stays readable. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  [data-theme="dark"] { --glass-strong: rgba(15, 20, 36, .97); --glass-solid: rgb(17, 22, 39); }
  [data-theme="light"] { --glass-strong: rgba(250, 251, 255, .97); --glass-solid: rgb(250, 251, 255); }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; -webkit-font-smoothing: antialiased; }
body { overflow: hidden; }
/* the living background: one fixed layer, moved by transform only */
body::before { content: ""; position: fixed; inset: -12%; z-index: 0; pointer-events: none; background: var(--aurora); animation: aurora 70s ease-in-out infinite alternate; will-change: transform; }
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.hidden { display: none !important; }
.muted { color: var(--fg-2); }
.small { font-size: 12.5px; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brush { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--line-2); }
::-webkit-scrollbar-thumb:active { background-color: var(--fg-3); }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
kbd { font-family: var(--font); font-size: 11px; color: var(--fg-3); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 5px; direction: ltr; }

/* specular rim: a 1px light edge that fades around the shape (shared by the big glass layers) */
#sidebar::before, .drawer::before, .composer::before, .modal-card::before, .ob-card::after, .boot-card::before, .alert::before, .new-chat::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none; z-index: 0;
  background: linear-gradient(160deg, var(--rim-a), transparent 38%, transparent 62%, var(--rim-b));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude;
}

#app { position: relative; z-index: 1; display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- sidebar ---------- */
#sidebar { position: relative; width: var(--side-w); min-width: var(--side-w); margin: var(--gap); margin-inline-end: 0; border-radius: var(--r-lg); background: var(--side); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-sm); display: flex; flex-direction: column; transition: margin .3s var(--ease), transform .3s var(--ease); z-index: 30; overflow: hidden; }
#app.side-hidden #sidebar { margin-inline-start: calc(-1 * var(--side-w) - 2px); }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 10px 14px; }
.brand { display: flex; align-items: center; gap: 9px; }
.logo { width: 30px; height: 30px; filter: drop-shadow(0 3px 8px rgba(42, 63, 214, .25)); }
.wordmark { font-weight: 700; font-size: 17px; letter-spacing: -.2px; direction: ltr; }
.wordmark span { color: var(--accent); margin-inline-start: 3px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: var(--fg-2); transition: background .15s, color .15s, transform .12s; }
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-btn:active { transform: scale(.94); }
.new-chat { position: relative; overflow: hidden; margin: 2px 10px 0; display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); font-weight: 600; box-shadow: inset 0 1px 0 var(--hi), var(--shadow-sm); transition: transform .15s var(--ease), box-shadow .2s; }
.new-chat .i { color: var(--accent); }
.new-chat:hover { box-shadow: inset 0 1px 0 var(--hi), 0 10px 24px -10px color-mix(in srgb, var(--accent) 45%, transparent); }
.new-chat:active { transform: scale(.985); }
.new-chat kbd { margin-inline-start: auto; }
.search-box { margin: 10px 10px 4px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border-radius: 12px; color: var(--fg-3); background: var(--surface-2); border: 1px solid transparent; transition: background .15s, border-color .15s; }
.search-box:focus-within { background: var(--field); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.search-box input { flex: 1; min-width: 0; background: none; border: 0; outline: none; padding: 9px 0; color: var(--fg); }
.search-box input::placeholder { color: var(--fg-3); }
.space-nav { display: flex; flex-direction: column; padding: 6px 8px 2px; gap: 1px; }
.space-nav button, .side-btn { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 11px; color: var(--fg-2); text-align: start; transition: background .15s, color .15s; min-height: 38px; }
.space-nav button:hover, .side-btn:hover { background: var(--surface-2); color: var(--fg); }
.space-nav .count { margin-inline-start: auto; font-size: 11.5px; color: var(--fg-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; min-width: 22px; padding: 0 6px; text-align: center; line-height: 19px; font-variant-numeric: tabular-nums; }
.space-nav .count:empty { display: none; }
.space-nav .count.hot { color: var(--on-accent); background: var(--accent-grad); border-color: transparent; border-radius: 99px; padding: 0 7px; font-weight: 600; }
.side-label { font-size: 12px; font-weight: 600; color: var(--fg-3); padding: 14px 18px 4px; }
.chat-list { flex: 1; overflow-y: auto; padding: 0 8px 18px; }
.chat-group { font-size: 12px; font-weight: 600; color: var(--fg-3); padding: 14px 10px 4px; }
[dir="ltr"] .chat-item .t { text-align: left; }
.chat-item { display: flex; align-items: center; gap: 4px; padding: 7px 10px; border-radius: 11px; cursor: pointer; color: var(--fg-2); position: relative; min-height: 38px; transition: background .15s, color .15s; }
.chat-item:hover { background: var(--surface-2); color: var(--fg); }
.chat-item.active { background: var(--sel); color: var(--fg); box-shadow: inset 0 1px 0 var(--hi), 0 0 0 1px var(--line), 0 4px 12px -6px rgba(20, 30, 80, .18); }
.chat-item .t { unicode-bidi: plaintext; text-align: right; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.chat-item .pin-mark { width: 13px; height: 13px; color: var(--fg-3); }
.chat-item .acts { display: none; gap: 0; }
.chat-item:hover .acts, .chat-item.active .acts { display: flex; }
.chat-item .acts button { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--fg-3); }
.chat-item .acts button:hover { color: var(--fg); background: var(--surface-2); }
.chat-item .acts .i { width: 15px; height: 15px; }
.chat-empty { color: var(--fg-3); font-size: 13px; padding: 10px 12px; }
.side-foot { position: relative; border-top: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 1px; }
.privacy { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg-3); padding: 8px 10px 4px; }
.privacy .i { width: 15px; height: 15px; color: var(--ok-ink); }
#scrim { display: none; }

/* ---------- main ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }
/* the top bar floats; messages scroll under a soft, fading blur */
#topbar { position: relative; z-index: 4; display: flex; align-items: center; gap: 4px; padding: 10px 14px; min-height: 58px; margin-bottom: -58px; }
#topbar::before { content: ""; position: absolute; inset: 0 0 -14px; z-index: -1; pointer-events: none; -webkit-backdrop-filter: var(--blur-sm); backdrop-filter: var(--blur-sm);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent); mask-image: linear-gradient(to bottom, #000 55%, transparent); }
#btnToggleSide, #btnNewChatTop { display: none; }
#app.side-hidden #btnToggleSide, #app.side-hidden #btnNewChatTop { display: grid; }
.chat-title { flex: 1; text-align: center; font-weight: 600; font-size: 15px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }
.status-pill { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg-2); background: var(--glass); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); padding: 5px 12px; border-radius: 99px; }
.status-pill .bar { width: 64px; height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.status-pill .bar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .8s var(--ease); }
.status-pill.ok { color: var(--ok-ink); }

.messages { flex: 1; overflow-y: auto; min-height: 0; scroll-behavior: auto; padding-top: 58px; }
.thread { max-width: 780px; margin: 0 auto; padding: 8px 24px 76px; }

/* ---------- welcome ---------- */
.welcome { max-width: 760px; margin: 0 auto; padding: 8vh 24px 76px; text-align: center; animation: rise .5s var(--ease); }
.hero-logo { position: relative; width: 68px; height: 68px; --logo-cut: var(--bg); filter: drop-shadow(0 10px 26px rgba(58, 89, 230, .35)) drop-shadow(0 2px 10px rgba(232, 178, 58, .2)); }
.welcome h1 { font-size: 31px; font-weight: 700; margin: 18px 0 8px; letter-spacing: -.3px; }
.welcome .lead { text-wrap: balance; font-size: 16px; color: var(--fg-2); margin: 0 auto; max-width: 520px; line-height: 1.8; }
.trust { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 20px 0 32px; }
.trust > span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500; color: var(--fg); background: var(--glass); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); padding: 6px 13px; border-radius: 99px; }
.trust .i { width: 15px; height: 15px; color: var(--accent); }
.suggestions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; text-align: start; }
.sugg { position: relative; overflow: hidden; text-align: start; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-sm); cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s, border-color .2s; }
.sugg:hover { transform: translateY(-2px); border-color: var(--line-2); box-shadow: inset 0 1px 0 var(--hi), 0 16px 34px -14px rgba(20, 30, 90, .35); }
.sugg:active { transform: translateY(0) scale(.99); }
/* hover sheen: a soft light sweep across the glass */
.sugg::after, .new-chat::after, .btn.primary::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 30%, var(--sheen) 50%, transparent 70%); transform: translateX(-110%); transition: transform .8s var(--ease); }
.btn.primary::after { --sheen: rgba(255, 255, 255, .22); }
.sugg:hover::after, .new-chat:hover::after, .btn.primary:hover::after { transform: translateX(110%); }
/* glass icon tile, tinted by --tint */
.sugg .ic, .card .ic, .pc-ic, .alert .ic, .ob-icon, .pe-ic, .att .fi, .usb-out { --tint: var(--accent); --tint-ink: var(--accent);
  display: grid; place-items: center; flex: none; color: var(--tint-ink);
  background: linear-gradient(150deg, color-mix(in srgb, var(--tint) 24%, transparent), color-mix(in srgb, var(--tint) 9%, transparent));
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 30%, transparent), inset 0 0 0 1px color-mix(in srgb, var(--tint) 20%, transparent); }
.sugg .ic { width: 38px; height: 38px; border-radius: 12px; }
.sugg.gold .ic, .sugg.sun .ic, .card.reminder .ic, .pc-ic, .alert .ic, .pe-ic { --tint: var(--gold); --tint-ink: var(--gold-ink); }
.sugg span, .card .v, .d-item .v { unicode-bidi: plaintext; }
.sugg b { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 2px; }
.sugg span { font-size: 13.5px; color: var(--fg-2); line-height: 1.6; }

/* ---------- messages ---------- */
.msg { padding: 14px 0; animation: rise .3s var(--ease); }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
[dir="rtl"] .msg.user { align-items: flex-start; }
.msg.user .bubble { background: var(--user); border: 1px solid var(--user-line); box-shadow: inset 0 1px 0 var(--hi); padding: 10px 16px; border-radius: 20px 20px 7px 20px; /* physical: the bubble sits on the right in both directions and is itself dir=auto */ max-width: 82%; white-space: pre-wrap; word-wrap: break-word; line-height: 1.8; font-size: 15.5px; }
.msg.user .msg-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; max-width: 82%; }
.msg.user .msg-atts img { max-width: 220px; max-height: 220px; border-radius: 16px; cursor: zoom-in; box-shadow: var(--shadow-sm); }
.file-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); border-radius: 12px; padding: 8px 12px; font-size: 13.5px; }
.file-chip .i { color: var(--accent); }
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity .15s; min-height: 32px; align-items: center; }
.msg:hover .msg-actions, .msg.last .msg-actions { opacity: 1; }
.msg-actions button { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--fg-3); transition: background .15s, color .15s; }
.msg-actions button:hover { background: var(--surface-2); color: var(--fg); }
.msg-actions .i { width: 16px; height: 16px; }
.msg-actions .dev { font-size: 11.5px; color: var(--fg-3); padding: 0 8px; direction: ltr; }
.edit-box { width: 82%; max-width: 100%; background: var(--field); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 18px; padding: 10px 12px; box-shadow: 0 0 0 4px var(--accent-soft); }
.edit-box textarea { width: 100%; border: 0; outline: none; background: none; resize: none; line-height: 1.8; font-size: 15.5px; min-height: 60px; }
.edit-box .row { display: flex; justify-content: flex-end; gap: 6px; }

.content { line-height: 1.9; font-size: 16px; word-wrap: break-word; }
.content > :first-child { margin-top: 0; } .content > :last-child { margin-bottom: 0; }
.content p { margin: .5em 0 .8em; }
.content h1, .content h2, .content h3, .content h4 { margin: 1.1em 0 .5em; line-height: 1.5; font-weight: 700; }
.content h1 { font-size: 1.4em; } .content h2 { font-size: 1.25em; } .content h3 { font-size: 1.1em; }
.content ul, .content ol { padding-inline-start: 1.4em; margin: .4em 0 .9em; }
.content li { margin: .3em 0; }
.content li::marker { color: var(--accent); }
.content strong { font-weight: 600; }
.content a { color: var(--accent); }
.content blockquote { margin: .7em 0; padding: .2em 1em; border-inline-start: 3px solid var(--accent); color: var(--fg-2); }
.content code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); padding: .12em .4em; border-radius: 6px; direction: ltr; unicode-bidi: embed; }
.content pre { direction: ltr; text-align: left; background: var(--code-bg); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); border-radius: var(--r); margin: .9em 0; overflow: hidden; }
.content pre .code-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--fg-3); font-family: var(--font); }
.content pre .code-head button { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 8px; border-radius: 7px; color: var(--fg-2); }
.content pre .code-head button .i { width: 14px; height: 14px; }
.content pre .code-head button:hover { background: var(--surface-2); color: var(--fg); }
.content pre code { display: block; padding: 14px 16px; overflow-x: auto; background: none; font-size: 13.5px; line-height: 1.6; white-space: pre; }
.content table { border-collapse: separate; border-spacing: 0; margin: .9em 0; display: block; overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.content th, .content td { border-bottom: 1px solid var(--line); padding: 9px 14px; text-align: start; }
.content tr:last-child td { border-bottom: 0; }
.content th { background: var(--surface-2); font-weight: 600; font-size: .94em; }
.content hr { border: 0; border-top: 1px solid var(--line-2); margin: 1.3em 0; }
.tok-hl-k { color: #C792EA; } .tok-hl-s { color: #A5D6A7; } .tok-hl-c { color: #7D86A6; font-style: italic; } .tok-hl-n { color: #F5B83D; }
[data-theme="light"] .tok-hl-k { color: #7B3FE4; } [data-theme="light"] .tok-hl-s { color: #2E7D32; } [data-theme="light"] .tok-hl-n { color: #B26A00; } [data-theme="light"] .tok-hl-c { color: #626A8A; }
.cursor::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-inline-start: 4px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 1s infinite; vertical-align: middle; }

/* thinking */
.think { margin: 0 0 10px; }
.think summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--fg-3); user-select: none; }
.think summary::-webkit-details-marker { display: none; }
.think summary .i { width: 15px; height: 15px; }
.think summary:hover { color: var(--fg-2); }
.think .th-body { margin-top: 8px; padding-inline-start: 14px; border-inline-start: 2px solid var(--line-2); font-size: 13.5px; color: var(--fg-2); white-space: pre-wrap; max-height: 300px; overflow-y: auto; line-height: 1.75; }

/* live activity line ("بيحسب…") */
.activity { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--fg-2); margin: 2px 0 10px; }
.shimmer { background: linear-gradient(90deg, var(--fg-3) 0%, var(--fg) 45%, var(--fg-3) 90%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.6s linear infinite; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
.typing { padding: 6px 0; }

/* action cards (reminder / note / list / memory / confirm): glass without blur (they live in a long list) */
.card { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 13px 14px; margin: 4px 0 12px; max-width: 520px; box-shadow: inset 0 1px 0 var(--hi), var(--shadow-sm); animation: cardIn .45s var(--ease) both; }
.card .ic { width: 36px; height: 36px; border-radius: 11px; }
.card.list .ic, .card.ok .ic { --tint: var(--ok); --tint-ink: var(--ok-ink); }
.card .c { flex: 1; min-width: 0; }
.card .k { font-size: 12.5px; color: var(--fg-3); margin-bottom: 2px; }
.card .v { font-weight: 500; line-height: 1.7; white-space: pre-wrap; word-wrap: break-word; }
.card .chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.card .chips span { font-size: 13px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 10px; }
.card .link { font-size: 13px; font-weight: 500; color: var(--accent); margin-top: 6px; display: inline-block; }
.card .link:hover { text-decoration: underline; text-underline-offset: 3px; }
.card .btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.card.confirm { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); box-shadow: inset 0 1px 0 var(--hi), 0 0 0 4px var(--accent-soft), var(--shadow-sm); }
.card.confirm .btns .btn { min-width: 88px; height: 38px; }
.card .always { display: block; margin-top: 8px; font-size: 12.5px; color: var(--fg-3); }
.card .always:hover { color: var(--fg-2); text-decoration: underline; }
.card.confirm.resolved { box-shadow: inset 0 1px 0 var(--hi); border-color: var(--line); opacity: .78; }
/* download card: title, thin progress bar, quiet status line */
.card.dl { width: 100%; }
.card.dl.off .ic { --tint: var(--fg-3); --tint-ink: var(--fg-3); }
.card.dl.off .k { color: var(--fg-2); }
.card.dl .dl-bar { position: relative; height: 5px; border-radius: 5px; background: var(--surface-3); overflow: hidden; margin-top: 10px; }
.card.dl .dl-bar > div { position: relative; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--accent), var(--gold)); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 50%, transparent); transition: width .9s var(--ease); overflow: hidden; }
[dir="rtl"] .card.dl .dl-bar > div { margin-inline-start: 0; background: linear-gradient(-90deg, var(--accent), var(--gold)); }
.card.dl .dl-bar > div::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent); transform: translateX(-100%); animation: barGlint 2.4s ease-in-out infinite; }
.card.dl .dl-bar.busy > div { width: 100% !important; opacity: .55; animation: dlPulse 1.6s ease-in-out infinite; }
@keyframes dlPulse { 50% { opacity: .2; } }
.card.dl .dl-meta { font-size: 12.5px; color: var(--fg-3); margin-top: 6px; font-variant-numeric: tabular-nums; }
.card.dl .btns { margin-top: 8px; }
.card.dl .btn.ghost { padding-inline-start: 6px; }
@media (prefers-reduced-motion: reduce) { .card.dl .dl-bar.busy > div, .card.dl .dl-bar > div::after { animation: none; } }
/* visible memory: "فهمت إن…" */
.mem-chip { display: flex; align-items: flex-start; gap: 8px; width: fit-content; max-width: min(100%, 560px); font-size: 13px; line-height: 1.7; color: var(--fg-3); margin: 2px 0 12px; padding: 5px 12px; border-radius: 13px; background: color-mix(in srgb, var(--gold) 8%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 26%, var(--line)); box-shadow: inset 0 1px 0 var(--hi); animation: rise .3s var(--ease); }
.mem-chip .i { width: 14px; height: 14px; color: var(--gold-ink); margin-top: 4px; }
.mem-chip .mt { min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-wrap: break-word; }
.mem-chip .f { color: var(--fg-2); }
.mem-edit { flex: none; font-size: 12.5px; color: var(--fg-3); padding-inline-start: 10px; margin-inline-start: 2px; border-inline-start: 1px solid color-mix(in srgb, var(--gold) 26%, var(--line)); border-radius: 0; line-height: 1.7; }
.mem-edit:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.mem-item.hl { border-color: color-mix(in srgb, var(--gold) 60%, var(--line)); background: color-mix(in srgb, var(--gold) 9%, transparent); animation: memHl 1.6s var(--ease); }
.note-line { font-size: 13px; color: var(--fg-3); margin: 6px 0; }
.err-card { display: flex; gap: 10px; align-items: center; background: color-mix(in srgb, var(--danger) 9%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--line)); box-shadow: inset 0 1px 0 var(--hi); border-radius: var(--r); padding: 10px 14px; margin: 6px 0 12px; font-size: 14px; max-width: 560px; }
.err-card .btn { margin-inline-start: auto; }

/* images */
.gen-image { position: relative; display: inline-block; margin: 4px 0 12px; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); max-width: min(100%, 520px); animation: cardIn .5s var(--ease) both; }
.gen-image img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.gen-image .tools { position: absolute; bottom: 10px; inset-inline-start: 10px; display: flex; gap: 6px; }
.gen-image .tools button, .gen-image .tools a { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: rgba(10, 12, 24, .45); border: 1px solid rgba(255, 255, 255, .18); color: #fff; -webkit-backdrop-filter: var(--blur-sm); backdrop-filter: var(--blur-sm); }
.img-wait { position: relative; width: min(100%, 420px); border-radius: 20px; overflow: hidden; margin: 4px 0 12px; background: var(--card); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); }
.img-wait::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 60%; background: linear-gradient(90deg, rgba(74, 114, 240, 0) 0%, rgba(74, 114, 240, .14) 28%, rgba(232, 178, 58, .16) 50%, rgba(74, 114, 240, .14) 72%, rgba(74, 114, 240, 0) 100%); animation: sweep 2.4s ease-in-out infinite; }
.img-wait .lbl { position: absolute; inset: auto 0 0 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.img-wait .lbl b { font-weight: 600; font-size: 14px; }
.img-wait .lbl span { font-size: 12.5px; color: var(--fg-2); }
.img-wait .pbar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.img-wait .pbar > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width 1s linear; }
.img-wait .brush { position: absolute; top: 50%; left: 50%; translate: -50% -70%; width: 44px; height: 44px; color: var(--accent); opacity: .7; animation: float 2.4s ease-in-out infinite; }

/* ---------- composer: the one glass layer the conversation scrolls under ---------- */
#composerWrap { position: relative; z-index: 4; padding: 0 24px 12px; margin-top: -52px; pointer-events: none; }
#composerWrap > * { pointer-events: auto; }
.banner { position: relative; max-width: 780px; margin: 0 auto 8px; display: flex; align-items: center; gap: 10px; font-size: 13.5px; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line); border-radius: 14px; padding: 9px 12px 9px 14px; box-shadow: inset 0 1px 0 var(--hi), var(--shadow-sm); animation: rise .3s var(--ease); }
.banner .i { color: var(--gold-ink); }
.banner .x { margin-inline-start: auto; }
.composer { position: relative; max-width: 780px; margin: 0 auto; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid var(--line-2); border-radius: var(--r-lg); padding: 10px 10px 8px;
  box-shadow: inset 0 1px 0 var(--hi), 0 14px 40px -16px rgba(16, 24, 70, .35); transition: border-color .2s, box-shadow .3s var(--ease); }
.composer > * { position: relative; z-index: 1; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 42%, var(--line-2));
  box-shadow: inset 0 1px 0 var(--hi), 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent), 0 16px 44px -16px color-mix(in srgb, var(--accent) 38%, transparent); }
.composer textarea { display: block; width: 100%; background: none; border: 0; outline: none; resize: none; font-size: 16px; line-height: 1.7; padding: 4px 8px; max-height: 220px; min-height: 30px; overflow-y: auto; }
.composer textarea::placeholder { color: var(--fg-3); }
.composer-row { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.composer-row .spacer { flex: 1; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 13px; border-radius: 99px; color: var(--fg-2); background: var(--surface-2); border: 1px solid var(--line); font-size: 13.5px; transition: background .15s, color .15s, border-color .15s, transform .12s; }
.chip-btn:hover { background: var(--surface-3); color: var(--fg); }
.chip-btn:active { transform: scale(.96); }
.chip-btn.on { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: 0 0 14px -4px color-mix(in srgb, var(--accent) 50%, transparent); }
.chip-btn .i { width: 16px; height: 16px; }
.send-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-grad); color: var(--on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 6px 16px -4px color-mix(in srgb, var(--accent-strong) 70%, transparent); transition: opacity .15s, transform .15s var(--spring), box-shadow .2s, filter .15s; }
.send-btn:hover:not(:disabled) { filter: brightness(1.08); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 8px 22px -4px color-mix(in srgb, var(--accent-strong) 80%, transparent); }
.send-btn:active:not(:disabled) { transform: scale(.9); }
.send-btn:disabled { background: var(--surface-3); color: var(--fg-3); box-shadow: none; }
.send-btn .i { width: 18px; height: 18px; stroke-width: 2.2; }
.send-btn.stop { background: var(--fg); box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .4); }
.send-btn.stop .sq { width: 11px; height: 11px; border-radius: 3px; background: var(--bg); }
.disclaimer { text-align: center; font-size: 11.5px; color: var(--fg-3); padding-top: 8px; }
.attach-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 2px; }
.attach-bar:not(:empty) { margin-bottom: 8px; }
.att { position: relative; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; padding: 6px 10px 6px 6px; font-size: 13px; max-width: 240px; }
.att img { width: 40px; height: 40px; object-fit: cover; border-radius: 9px; }
.att .fi { width: 40px; height: 40px; border-radius: 9px; }
.att .n { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att .x { position: absolute; top: -6px; inset-inline-end: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--fg); color: var(--bg); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.att .x .i { width: 12px; height: 12px; stroke-width: 2.5; }
.att.uploading { opacity: .55; }
.aspect-bar { display: flex; gap: 6px; padding: 0 2px 8px; flex-wrap: wrap; align-items: center; }
.aspect-bar .lbl { font-size: 12.5px; color: var(--fg-3); margin-inline-end: 4px; }
.aspect-bar button { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg-2); }
.aspect-bar button.on { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent); background: var(--accent-soft); }
.aspect-bar .shape { display: inline-block; border: 1.6px solid currentColor; border-radius: 3px; }

/* ---------- drawer (my day / reminders / notes / lists) ---------- */
.drawer { position: relative; width: 384px; min-width: 384px; margin: var(--gap); margin-inline-start: 0; border-radius: var(--r-lg); background: var(--side); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-sm); display: flex; flex-direction: column; margin-inline-end: calc(-384px - var(--gap) - 2px); opacity: 0; transition: margin .32s var(--ease), opacity .25s; z-index: 25; overflow: hidden; }
#app.drawer-open .drawer { margin-inline-end: var(--gap); opacity: 1; }
.drawer > * { position: relative; z-index: 1; }
.drawer-head { display: flex; align-items: center; gap: 6px; padding: 12px 12px 10px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; flex: 1; background: var(--surface-2); border: 1px solid var(--line); padding: 3px; border-radius: 14px; }
.tabs button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 6px; border-radius: 11px; font-size: 13.5px; color: var(--fg-2); transition: background .2s, color .2s, box-shadow .2s; }
.tabs button:hover:not(.on) { color: var(--fg); }
.tabs button .i { width: 16px; height: 16px; }
.tabs button.on { background: var(--seg-on); color: var(--fg); box-shadow: inset 0 1px 0 var(--hi), 0 2px 8px -2px rgba(16, 24, 60, .22); font-weight: 600; }
.drawer-body { flex: 1; overflow-y: auto; padding: 14px; }
.d-add { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px; margin-bottom: 16px; }
.d-add input, .d-add textarea { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 11px; padding: 8px 10px; outline: none; transition: border-color .15s, box-shadow .15s; }
.d-add input:focus, .d-add textarea:focus { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 0 0 3px var(--accent-soft); }
.d-add textarea { resize: vertical; min-height: 64px; line-height: 1.7; }
.d-add .row { display: flex; gap: 8px; align-items: center; }
.d-add .row input { flex: 1; }
.d-sec { font-size: 12px; font-weight: 600; color: var(--fg-3); margin: 14px 2px 8px; }
.d-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 14px; border: 1px solid var(--line); margin-bottom: 8px; background: var(--card); box-shadow: inset 0 1px 0 var(--hi); transition: border-color .15s; }
.d-item:hover { border-color: var(--line-2); }
.d-item .c { flex: 1; min-width: 0; }
.d-item .v { line-height: 1.7; white-space: pre-wrap; word-wrap: break-word; }
.d-item .v.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.d-item .m { font-size: 12px; color: var(--fg-3); margin-top: 3px; }
.d-item .acts { display: flex; gap: 0; opacity: 0; transition: opacity .15s; }
.d-item:hover .acts, .d-item:focus-within .acts { opacity: 1; }
.d-item .acts button { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: var(--fg-3); }
.d-item .acts button:hover { background: var(--surface-2); color: var(--fg); }
.d-item .acts .i { width: 15px; height: 15px; }
.d-item.fired { border-color: color-mix(in srgb, var(--gold) 55%, var(--line)); background: color-mix(in srgb, var(--gold) 9%, transparent); }
.d-empty { text-align: center; color: var(--fg-3); padding: 30px 14px; line-height: 1.8; font-size: 14px; }
.d-empty .i { width: 34px; height: 34px; color: var(--fg-3); opacity: .55; margin-bottom: 8px; }
.d-empty b { display: block; color: var(--fg-2); font-weight: 500; }
.list-card { border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 12px; overflow: hidden; background: var(--card); box-shadow: inset 0 1px 0 var(--hi); }
.list-card .lh { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: var(--surface-2); font-weight: 600; }
.list-card .lh .n { flex: 1; }
.list-card .lh .p { font-size: 12px; color: var(--fg-3); font-weight: 400; }
.li { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-top: 1px solid var(--line); }
.li .t { flex: 1; line-height: 1.6; }
.li.done .t { text-decoration: line-through; color: var(--fg-3); }
.li .del { opacity: 0; color: var(--fg-3); width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; }
.li:hover .del, .li .del:focus-visible { opacity: 1; }
.li .del .i { width: 14px; height: 14px; }
.cb { width: 21px; height: 21px; border-radius: 7px; border: 1.6px solid var(--line-2); background: var(--field); display: grid; place-items: center; flex: none; color: transparent; transition: all .2s var(--ease); }
.cb .i { width: 13px; height: 13px; stroke-width: 3; }
.li.done .cb { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: 0 0 10px -2px color-mix(in srgb, var(--ok) 70%, transparent); }
.li-add { display: flex; border-top: 1px solid var(--line); }
.li-add input { flex: 1; border: 0; outline: none; background: none; padding: 9px 12px; }

/* ---------- buttons / forms ---------- */
.btn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); font-size: 14px; font-weight: 500; transition: background .15s, border-color .15s, transform .12s, box-shadow .2s, filter .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-3); border-color: var(--line-2); }
.btn:active { transform: scale(.97); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn.primary { background: var(--accent-grad); border-color: transparent; color: var(--on-accent); font-weight: 600; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 6px 16px -6px color-mix(in srgb, var(--accent-strong) 70%, transparent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; border-color: transparent; box-shadow: none; color: var(--fg-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--fg); }
.btn .i { width: 16px; height: 16px; }
.linkish { color: var(--fg-3); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; }
.linkish:hover { color: var(--fg-2); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.boot { background: var(--bg); overflow: hidden; }
.boot::before { content: ""; position: absolute; inset: -12%; background: radial-gradient(36% 40% at 50% 46%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%), var(--aurora); animation: aurora 26s ease-in-out infinite alternate; pointer-events: none; }
.boot-card { position: relative; width: min(440px, 90vw); text-align: center; padding: 36px 30px 28px; border-radius: 28px; background: var(--glass); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow); }
.boot-card > * { position: relative; z-index: 1; }
.boot-logo { position: relative; width: 84px; height: 84px; margin: 0 auto 22px; }
.boot-logo svg { position: relative; width: 84px; height: 84px; z-index: 1; animation: breathe 2.6s ease-in-out infinite; }
.boot-logo .glow { position: absolute; inset: -22px; border-radius: 50%; background: radial-gradient(circle, rgba(245, 184, 61, .3), rgba(61, 90, 254, .2) 45%, transparent 70%); animation: glow 2.6s ease-in-out infinite; }
.boot-card h2 { font-size: 21px; font-weight: 600; margin: 0 0 18px; }
.progress { position: relative; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; width: 240px; margin: 0 auto 22px; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12); }
.progress > div { position: relative; height: 100%; width: 3%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--gold)); box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 60%, transparent); transition: width 1s var(--ease); overflow: hidden; }
[dir="rtl"] .progress > div { background: linear-gradient(-90deg, var(--accent), var(--gold)); }
.progress > div::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent); transform: translateX(-100%); animation: barGlint 2s ease-in-out infinite; }
.boot-card p:empty { display: none; }
.boot-tip { text-wrap: balance; min-height: 56px; color: var(--fg-2); line-height: 1.8; font-size: 15px; transition: opacity .4s; margin: 0 0 10px; }
.boot-tip.fade { opacity: 0; }
.boot-error { margin-top: 10px; text-align: start; background: var(--field); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.boot-error b { display: block; margin-bottom: 4px; }
.boot-error details { margin-top: 10px; font-size: 12px; color: var(--fg-3); }
.boot-error pre { white-space: pre-wrap; direction: ltr; text-align: left; font-family: var(--mono); font-size: 11.5px; max-height: 160px; overflow: auto; }
.usb-out { width: 72px; height: 72px; border-radius: 22px; margin: 0 auto 18px; --tint: var(--fg-2); --tint-ink: var(--fg-2); }
.usb-out .i { width: 34px; height: 34px; }

/* the scrim does the blurring; the card itself is a near-solid pane (one blur, not two) */
.modal-wrap { background: var(--scrim); -webkit-backdrop-filter: blur(8px) saturate(120%); backdrop-filter: blur(8px) saturate(120%); animation: fade .18s; padding: 20px; }
.modal-card { position: relative; background: var(--glass-solid); border: 1px solid var(--line); border-radius: 26px; width: min(600px, 100%); max-height: 86vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: inset 0 1px 0 var(--hi), var(--shadow); animation: pop .26s var(--ease); }
.modal-card > * { position: relative; z-index: 1; }
.modal-card.sm { width: min(420px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 22px 10px; flex: none; }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 700; flex: 1; }
.modal-body { padding: 6px 22px 22px; overflow-y: auto; min-height: 0; }
.modal-sub { color: var(--fg-2); font-size: 14px; line-height: 1.75; margin: 0 0 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dialog-input { width: 100%; background: var(--field); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.dialog-input:focus { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 0 0 4px var(--accent-soft); }

.set-sec { padding: 14px 0; border-top: 1px solid var(--line); }
.set-sec:first-child { border-top: 0; padding-top: 4px; }
.set-sec > h4 { margin: 0 0 6px; font-size: 13px; color: var(--fg-3); font-weight: 600; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; }
.set-row .lbl { flex: 1; min-width: 0; }
.set-row .lbl b { display: block; font-weight: 500; }
.set-row .lbl small { display: block; color: var(--fg-3); font-size: 12.5px; margin-top: 2px; line-height: 1.6; }
.set-col { padding: 9px 0; }
.set-col .lbl b { display: block; font-weight: 500; margin-bottom: 2px; }
.set-col .lbl small { display: block; color: var(--fg-3); font-size: 12.5px; margin-bottom: 8px; line-height: 1.6; }
.set-sec input[type=text], .set-sec textarea { width: 100%; background: var(--field); border: 1px solid var(--line-2); border-radius: 12px; padding: 8px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.set-row input[type=text] { width: 220px; }
.set-sec textarea { min-height: 80px; resize: vertical; line-height: 1.7; }
.set-sec input:focus, .set-sec textarea:focus { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); box-shadow: 0 0 0 4px var(--accent-soft); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 13px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 6px 14px; border-radius: 10px; font-size: 13.5px; color: var(--fg-2); transition: background .2s, color .2s; }
.seg button:hover:not(.on) { color: var(--fg); }
.seg button.on { background: var(--seg-on); color: var(--fg); box-shadow: inset 0 1px 0 var(--hi), 0 2px 8px -2px rgba(16, 24, 60, .22); font-weight: 600; }
.opt-cards { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: start; padding: 11px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); transition: border-color .15s, background .15s, box-shadow .2s; }
.opt:hover { border-color: var(--line-2); }
.opt.on { border-color: color-mix(in srgb, var(--accent) 65%, transparent); background: var(--accent-soft); box-shadow: inset 0 1px 0 var(--hi), 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.opt .radio { width: 18px; height: 18px; border-radius: 50%; border: 1.8px solid var(--line-2); background: var(--field); flex: none; margin-top: 3px; display: grid; place-items: center; }
.opt.on .radio { border-color: var(--accent); }
.opt.on .radio::after { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px color-mix(in srgb, var(--accent) 60%, transparent); }
.opt b { display: block; font-weight: 600; font-size: 14px; }
.opt small { display: block; color: var(--fg-2); font-size: 12.5px; line-height: 1.6; margin-top: 2px; }
.opt > span:nth-child(2) { flex: 1; min-width: 0; }
.opt .tag { align-self: center; flex: none; font-size: 11.5px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 99px; padding: 2px 10px; }
details.adv > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; color: var(--fg-2); font-weight: 500; padding: 4px 0; }
details.adv > summary::-webkit-details-marker { display: none; }
details.adv > summary .chev { margin-inline-start: auto; color: var(--fg-3); transition: transform .2s; }
details.adv[open] > summary .chev { transform: rotate(180deg); }
.toggle { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .tg { width: 44px; height: 26px; background: var(--surface-3); border-radius: 99px; position: relative; transition: background .25s; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .12); }
.toggle .tg::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .3s var(--spring); box-shadow: 0 2px 5px rgba(0, 0, 0, .25), inset 0 -1px 0 rgba(0, 0, 0, .05); }
.toggle input:checked + .tg { background: var(--accent-grad); }
.toggle input:checked + .tg::after { transform: translateX(18px); }
[dir="rtl"] .toggle input:checked + .tg::after { transform: translateX(-18px); }
.toggle input:focus-visible + .tg { outline: 2px solid var(--accent); outline-offset: 2px; }
.mem-item { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 8px; background: var(--surface-2); }
.mem-item .c { flex: 1; line-height: 1.7; }
.mem-item button { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 9px; color: var(--fg-3); }
.mem-item button:hover { background: var(--surface-2); color: var(--fg); }
.mem-item .i { width: 15px; height: 15px; }
.mem-add { display: flex; gap: 8px; margin-bottom: 14px; }
.mem-add input { flex: 1; }
.log-item { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.log-item .m { color: var(--fg-3); font-size: 12px; }

.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(5, 6, 12, .82); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); display: grid; place-items: center; cursor: zoom-out; animation: fade .15s; }
.lightbox img { max-width: 94vw; max-height: 94vh; border-radius: 16px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); }
.toast { position: fixed; bottom: 104px; left: 50%; transform: translateX(-50%); background: color-mix(in srgb, var(--fg) 86%, transparent); -webkit-backdrop-filter: var(--blur-sm); backdrop-filter: var(--blur-sm); color: var(--bg); padding: 9px 18px; border-radius: 99px; font-size: 14px; font-weight: 500; z-index: 300; box-shadow: var(--shadow); animation: rise .25s var(--ease); }
.drop-hint { position: fixed; inset: 12px; z-index: 250; border: 2px dashed var(--accent); border-radius: 28px; background: color-mix(in srgb, var(--bg) 70%, transparent); -webkit-backdrop-filter: var(--blur-sm); backdrop-filter: var(--blur-sm); display: grid; place-items: center; font-size: 18px; font-weight: 600; color: var(--accent); pointer-events: none; }

/* reminder alerts */
.alerts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 10px; width: min(420px, 92vw); }
.alert { position: relative; display: flex; gap: 12px; background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line)); border-radius: 22px; padding: 14px; box-shadow: inset 0 1px 0 var(--hi), var(--shadow); animation: drop .4s var(--spring); }
.alert > * { position: relative; z-index: 1; }
.alert .ic { width: 42px; height: 42px; border-radius: 13px; animation: ring 1.2s ease-in-out 2; }
.alert .c { flex: 1; }
.alert .k { font-size: 12.5px; color: var(--fg-3); }
.alert .v { font-weight: 600; font-size: 15.5px; line-height: 1.6; margin: 2px 0 10px; }
.alert .btns { display: flex; gap: 8px; }

/* ---------- first-run onboarding ---------- */
.invisible { visibility: hidden; }
.onboard-wrap { z-index: 150; padding: 16px; background: var(--scrim); -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); animation: fade .25s; overflow-y: auto; }
.onboard-wrap.leaving { animation: fadeOut .22s forwards; }
.ob-card { position: relative; width: min(480px, 100%); background: var(--glass-solid); border: 1px solid var(--line); border-radius: 30px; box-shadow: inset 0 1px 0 var(--hi), var(--shadow); padding: 18px 28px 22px; display: flex; flex-direction: column; animation: pop .3s var(--ease); overflow: hidden; }
.ob-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 200px; background: radial-gradient(110% 100% at 50% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%); pointer-events: none; }
.ob-top { position: relative; display: flex; align-items: center; gap: 4px; min-height: 32px; }
.ob-top .spacer { flex: 1; }
.ob-dots { display: flex; gap: 6px; align-items: center; }
.ob-dots i { width: 7px; height: 7px; border-radius: 99px; background: var(--surface-3); transition: width .35s var(--spring), background .3s; }
.ob-dots i.done { background: color-mix(in srgb, var(--accent) 50%, var(--surface-3)); }
.ob-dots i.on { width: 24px; background: var(--accent-grad); box-shadow: 0 0 10px -2px color-mix(in srgb, var(--accent) 70%, transparent); }
.ob-link { font-size: 13px; color: var(--fg-3); padding: 6px 11px; border-radius: 9px; transition: color .15s, background .15s; }
.ob-link:hover { color: var(--fg); background: var(--surface-2); }
.ob-body { position: relative; min-height: 352px; display: flex; flex-direction: column; }
.ob-step { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 10px 0 4px; flex: 1; animation: fade .25s; }
.ob-step.fwd { animation: obIn .32s var(--ease); }
.ob-step.bwd { animation: obInBack .32s var(--ease); }
.ob-hero { margin: 18px 0 6px; }
.ob-logo { width: 78px; height: 78px; filter: drop-shadow(0 12px 26px rgba(58, 89, 230, .35)) drop-shadow(0 2px 10px rgba(232, 178, 58, .2)); }
.ob-icon { width: 56px; height: 56px; border-radius: 18px; margin: 12px 0 4px; }
.ob-icon .i { width: 26px; height: 26px; stroke-width: 1.7; }
.ob-icon.ok { --tint: var(--ok); --tint-ink: var(--ok-ink); }
.ob-step h2 { font-size: 23px; font-weight: 700; margin: 12px 0 6px; letter-spacing: -.2px; line-height: 1.5; }
.ob-sub { text-wrap: balance; margin: 0 0 4px; color: var(--fg-2); font-size: 15px; line-height: 1.8; max-width: 360px; }
.ob-label { align-self: stretch; text-align: start; font-size: 13.5px; font-weight: 600; color: var(--fg-2); margin: 30px 2px 8px; }
.ob-input { align-self: stretch; height: 52px; padding: 0 16px; font-size: 16px; background: var(--field); border: 1px solid var(--line-2); border-radius: 15px; outline: none; box-shadow: inset 0 1px 0 var(--hi); transition: border-color .15s, box-shadow .2s, background .15s; }
.ob-input::placeholder { color: var(--fg-3); }
.ob-input:focus { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-2)); box-shadow: 0 0 0 4px var(--accent-soft), 0 8px 24px -10px color-mix(in srgb, var(--accent) 50%, transparent); }
.ob-group { align-self: stretch; text-align: start; margin-top: 18px; }
.ob-group + .ob-group { margin-top: 16px; }
.ob-glabel { font-size: 13px; font-weight: 600; color: var(--fg-3); margin: 0 2px 8px; }
.ob-tiles { display: grid; gap: 8px; }
.ob-tiles.three { grid-template-columns: repeat(3, 1fr); }
.ob-tiles.two { grid-template-columns: repeat(2, 1fr); }
.ob-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-align: start; padding: 12px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); transition: border-color .15s, background .15s, box-shadow .2s, transform .15s var(--ease); min-height: 76px; }
.ob-tile:hover { border-color: var(--line-2); background: var(--surface-3); }
.ob-tile:active { transform: scale(.98); }
.ob-tile b { font-weight: 600; font-size: 14px; line-height: 1.5; }
.ob-tile small { font-size: 12.5px; color: var(--fg-3); line-height: 1.6; unicode-bidi: plaintext; }
.ob-tile.on { border-color: color-mix(in srgb, var(--accent) 70%, transparent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 70%, transparent), 0 6px 18px -8px color-mix(in srgb, var(--accent) 55%, transparent); }
.ob-tile.on b { color: var(--accent); }
.ob-tiles.two .ob-tile { gap: 2px; min-height: 0; }
.ob-bars { display: flex; flex-direction: column; gap: 3px; width: 34px; height: 17px; }
.ob-bars i { display: block; height: 3px; border-radius: 3px; background: var(--fg-3); opacity: .45; }
.ob-bars i:nth-child(1) { width: 100%; } .ob-bars i:nth-child(2) { width: 82%; } .ob-bars i:nth-child(3) { width: 58%; }
.ob-tile.on .ob-bars i { background: var(--accent); opacity: .9; }
.ob-points { list-style: none; padding: 0; margin: 18px 0 0; align-self: stretch; display: flex; flex-direction: column; gap: 12px; text-align: start; }
.ob-points li { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; line-height: 1.75; color: var(--fg); }
.ob-points .ic { width: 34px; height: 34px; border-radius: 11px; flex: none; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); color: var(--accent); }
.ob-points .ic .i { width: 17px; height: 17px; }
.ob-try { align-self: stretch; display: flex; gap: 12px; align-items: flex-start; text-align: start; margin-top: 20px; padding: 13px 15px; border-radius: 16px; background: color-mix(in srgb, var(--gold) 10%, transparent); border: 1px solid color-mix(in srgb, var(--gold) 38%, var(--line)); box-shadow: inset 0 1px 0 var(--hi); }
[data-theme="dark"] .ob-try { background: color-mix(in srgb, var(--gold) 7%, transparent); border-color: color-mix(in srgb, var(--gold) 30%, var(--line)); }
.ob-try > .i { width: 20px; height: 20px; color: var(--gold-ink); margin-top: 3px; }
.ob-try b { display: block; font-weight: 600; font-size: 14.5px; line-height: 1.6; }
.ob-try span { display: block; font-size: 13px; color: var(--fg-2); line-height: 1.7; margin-top: 1px; }
.ob-foot { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 22px; }
.ob-foot .btn { height: 48px; border-radius: 15px; font-size: 15px; }
.ob-next { min-width: 140px; padding: 0 22px; }
.ob-back { padding: 0 12px; }
.ob-chev { width: 16px; height: 16px; stroke-width: 2.2; transform: rotate(-90deg); }
.ob-back .ob-chev { transform: rotate(90deg); }
[dir="rtl"] .ob-chev { transform: rotate(90deg); }
[dir="rtl"] .ob-back .ob-chev { transform: rotate(-90deg); }
@keyframes obIn { from { opacity: 0; transform: translateX(var(--ob-shift, 18px)); } to { opacity: 1; transform: none; } }
@keyframes obInBack { from { opacity: 0; transform: translateX(calc(-1 * var(--ob-shift, 18px))); } to { opacity: 1; transform: none; } }
[dir="rtl"] .ob-step { --ob-shift: -18px; }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes memHl { from { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 30%, transparent); } to { box-shadow: 0 0 0 0 transparent; } }
@media (max-width: 520px) {
  .onboard-wrap { padding: 12px 12px max(12px, env(safe-area-inset-bottom)); align-items: end; }
  .ob-card { padding: 14px 18px 18px; border-radius: 28px; }
  .ob-body { min-height: 0; }
  .ob-step h2 { font-size: 21px; }
  .ob-hero { margin-top: 10px; }
  .ob-logo { width: 64px; height: 64px; }
  .ob-tiles.three { grid-template-columns: 1fr; }
  .ob-tiles.three .ob-tile { flex-direction: row; align-items: center; min-height: 0; gap: 12px; padding: 11px 14px; }
  .ob-tiles.three .ob-bars { width: 26px; height: 15px; justify-content: center; }
  .ob-label { margin-top: 24px; }
  .ob-foot .btn { height: 50px; }
  .ob-next { flex: 1; }
  .ob-link { min-height: 40px; }
}

/* ---------- animation ---------- */
@keyframes aurora { 0% { transform: translate3d(0, 0, 0) scale(1); } 50% { transform: translate3d(2.5%, 1.5%, 0) scale(1.05); } 100% { transform: translate3d(-2%, 2.5%, 0) scale(1.02); } }
@keyframes cardIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes barGlint { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes sweep { from { transform: translateX(-100%); } to { transform: translateX(170%); } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes glow { 0%, 100% { opacity: .55; transform: scale(.94); } 50% { opacity: 1; transform: scale(1.06); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-6px) rotate(6deg); } }
@keyframes ring { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- small screens (also Android WebView) ---------- */
@media (max-width: 900px) {
  :root { --gap: 0px; }
  /* sheets slide over the conversation, so here they do blur what's behind */
  #sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: min(var(--side-w), 86vw); min-width: 0; transform: translateX(-100%); box-shadow: var(--shadow); margin: 0 !important; border-radius: 0; border-start-end-radius: 26px; border-end-end-radius: 26px; border-block: 0; border-inline-start: 0;
    background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); visibility: hidden; transition: transform .3s var(--ease), visibility 0s .3s; }
  [dir="rtl"] #sidebar { transform: translateX(100%); }
  #app.side-open #sidebar { transform: none; visibility: visible; transition: transform .3s var(--ease); }
  #app.side-open #scrim { display: block; position: fixed; inset: 0; background: rgba(6, 9, 20, .4); z-index: 20; animation: fade .2s; }
  #btnToggleSide, #btnNewChatTop { display: grid; }
  .drawer { position: fixed; inset-block: 0; inset-inline-end: 0; width: min(400px, 100vw); min-width: 0; margin: 0 !important; border-radius: 0; border: 0; opacity: 1; transform: translateX(100%); transition: transform .3s var(--ease), visibility 0s .3s; visibility: hidden; box-shadow: var(--shadow);
    background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); }
  [dir="rtl"] .drawer { transform: translateX(-100%); }
  #app.drawer-open .drawer { transform: none; visibility: visible; transition: transform .3s var(--ease); }
  .drawer-head { padding-top: max(12px, env(safe-area-inset-top)); }
  .thread { padding: 4px 16px 70px; }
  #composerWrap { padding: 0 10px max(8px, env(safe-area-inset-bottom)); margin-top: -46px; }
  .composer { border-radius: 22px; padding: 8px 8px 6px; }
  .suggestions { grid-template-columns: 1fr; gap: 8px; }
  .sugg { align-items: center; padding: 11px 12px; }
  .sugg .ic { width: 36px; height: 36px; }
  .sugg > span:last-child { min-width: 0; }
  .sugg span span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12.5px; }
  .trust { margin: 14px 0 22px; }
  .welcome { padding: 4vh 18px 70px; }
  .welcome h1 { font-size: 25px; }
  .msg-actions { opacity: 1; }
  #btnThink { display: none; }
  /* touch targets ≥ 40px */
  .icon-btn { width: 42px; height: 42px; }
  .chip-btn { height: 40px; padding: 0 14px; }
  .send-btn { width: 42px; height: 42px; }
  .msg-actions button { width: 40px; height: 40px; }
  .chat-item { min-height: 46px; }
  .chat-item .acts button { width: 40px; height: 40px; }
  .space-nav button, .side-btn { min-height: 44px; }
  .d-item .acts { opacity: 1; }
  .d-item .acts button, .mem-item button { width: 40px; height: 40px; }
  .li .del { opacity: .6; width: 40px; height: 40px; }
  .li { min-height: 44px; }
  .btn.sm { height: 40px; }
  .card.confirm .btns .btn { height: 42px; }
  .tabs button { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 12px; min-height: 48px; }
  .tabs button .i { width: 18px; height: 18px; }
  .seg button { min-height: 40px; }
  .modal-wrap { padding: 12px; align-items: end; }
  .modal-card { max-height: 90vh; border-radius: 28px; }
  .modal-head { padding: 16px 18px 8px; }
  .modal-body { padding: 6px 18px 20px; }
  .set-row input[type=text] { width: 160px; }
  .toast { bottom: 120px; }
}

/* web sources under an answer */
.sources { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 10px; font-size: 12.5px; animation: rise .3s var(--ease); }
.sources .k { display: inline-flex; align-items: center; gap: 5px; color: var(--fg-3); margin-inline-end: 2px; }
.sources .k .i { width: 13px; height: 13px; }
.sources a { color: var(--fg-2); text-decoration: none; background: var(--card); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); border-radius: 99px; padding: 3px 11px; direction: ltr; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: color .15s, border-color .15s; }
.sources a:hover { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
@media (max-width: 900px) { .sources a { padding: 8px 13px; } }
/* ---------- day planner ("يومي"): timeline card, drawer view, welcome peek ---------- */
.k-task { --kc: var(--accent); }
.k-event { --kc: var(--gold); }
.k-habit { --kc: var(--ok); }
.k-break { --kc: var(--fg-3); }
.space-nav .myday .i { color: var(--gold-ink); }
.plan-card { display: block; padding: 14px 14px 8px; max-width: 560px; }
.pc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pc-ic { width: 38px; height: 38px; border-radius: 12px; }
.pc-t { flex: 1; min-width: 0; }
.pc-t b { display: block; font-weight: 700; font-size: 15.5px; line-height: 1.5; }
.pc-t small { display: block; color: var(--fg-3); font-size: 12.5px; }
.pc-prog { position: relative; width: 44px; height: 44px; display: grid; place-items: center; flex: none; }
.pc-prog svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
[dir="rtl"] .pc-prog svg { transform: rotate(-90deg) scaleY(-1); }
.pc-prog circle { fill: none; stroke: var(--surface-3); stroke-width: 3.4; }
.pc-prog circle.v { stroke: var(--accent); stroke-linecap: round; transition: stroke-dasharray .5s var(--ease); filter: drop-shadow(0 0 3px color-mix(in srgb, var(--accent) 50%, transparent)); }
.pc-prog.all circle.v { stroke: var(--ok); }
.pc-prog span { font-size: 11.5px; font-weight: 600; color: var(--fg-2); direction: ltr; }
.plan-card .link { margin: 6px 4px 0; }

.tl { --tc: 50px; --rc: 16px; display: flex; flex-direction: column; }
.plan-big .tl { --tc: 58px; --rc: 18px; }
.tl-row { position: relative; display: grid; grid-template-columns: var(--tc) var(--rc) minmax(0, 1fr); min-height: var(--h); }
.plan-big .tl-row { grid-template-columns: var(--tc) var(--rc) minmax(0, 1fr) 30px; }
.tl-time { font-size: 12px; color: var(--fg-3); padding-top: 10px; padding-inline-end: 8px; text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tl-rail { position: relative; display: flex; justify-content: center; }
.tl-rail::before { content: ""; position: absolute; top: 0; bottom: 0; width: 2px; background: var(--line-2); }
.tp-time.now { color: var(--danger); font-weight: 600; }
.tl > :first-child .tl-rail::before { top: 14px; }
.tl > :last-child .tl-rail::before { bottom: auto; height: 14px; }
.tl-rail i { position: relative; z-index: 1; margin-top: 12px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--kc); transition: background .2s; }
[data-theme="dark"] .tl-rail i { background: #1A2034; }
.tl-row.done .tl-rail i { background: var(--kc); }
/* timeline blocks: tinted glass (translucent tint, no blur) */
.tl-block { position: relative; display: flex; align-items: flex-start; gap: 10px; text-align: start; margin: 3px 0; padding: 8px 12px 8px 10px; border-radius: 13px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--kc) 15%, transparent), color-mix(in srgb, var(--kc) 8%, transparent)); border: 1px solid color-mix(in srgb, var(--kc) 24%, transparent); border-inline-start: 3px solid var(--kc);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 22%, transparent);
  transition: transform .15s var(--ease), background .2s, opacity .25s; overflow: hidden; }
[dir="rtl"] .tl-block { padding: 8px 10px 8px 12px; }
.tl-block:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--kc) 21%, transparent), color-mix(in srgb, var(--kc) 12%, transparent)); }
.tl-block:active { transform: scale(.985); }
.k-event .tl-block { background: linear-gradient(180deg, color-mix(in srgb, var(--gold) var(--gold-tint), transparent), color-mix(in srgb, var(--gold) calc(var(--gold-tint) * .5), transparent)); border-color: color-mix(in srgb, var(--gold) 36%, transparent); border-inline-start-color: var(--gold); }
.k-break .tl-block { background: var(--surface-2); border: 1px dashed var(--line-2); border-inline-start: 3px solid var(--line-2); box-shadow: none; }
.k-break .tl-main b { font-weight: 500; color: var(--fg-2); }
.tl-main { flex: 1; min-width: 0; }
.tl-main b { display: block; font-weight: 600; font-size: 14.5px; line-height: 1.5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: start; }
[dir="ltr"] .tl-main b { text-align: left; } [dir="rtl"] .tl-main b { text-align: right; }
.tl-main small { display: block; font-size: 12px; color: var(--fg-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-check { width: 22px; height: 22px; border-radius: 50%; border: 1.8px solid color-mix(in srgb, var(--kc) 55%, var(--line-2)); display: grid; place-items: center; flex: none; color: transparent; margin-top: 2px; background: var(--field); transition: background .2s, border-color .2s, color .2s; }
.tl-check .i { width: 13px; height: 13px; stroke-width: 3; }
.tl-block:hover .tl-check { border-color: var(--ok); }
.done .tl-check { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: 0 0 10px -2px color-mix(in srgb, var(--ok) 70%, transparent); }
.tl-row.done .tl-block { opacity: .6; }
.tl-row.done .tl-main b, .tl-anyrow.done .tl-anyitem span[dir] { text-decoration: line-through; text-decoration-color: var(--fg-3); color: var(--fg-2); }
.tl-row.past .tl-block { opacity: .82; }
.just-done .tl-check { animation: checkPop .45s var(--ease); }
.just-done .tl-block, .just-done .tl-anyitem { animation: doneGlow .65s var(--ease); }
.tl-now { position: absolute; inset-inline: 0; height: 2px; background: var(--danger); box-shadow: 0 0 8px color-mix(in srgb, var(--danger) 60%, transparent); pointer-events: none; }
.tl-now::before, .tl-nowline::before { content: ""; position: absolute; inset-inline-start: -1px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.tl-nowrow { display: grid; grid-template-columns: var(--tc) minmax(0, 1fr); align-items: center; height: 20px; }
.tl-nowrow .tl-time { color: var(--danger); font-weight: 600; font-size: 11.5px; padding-top: 0; }
.tl-nowline { position: relative; height: 2px; background: var(--danger); border-radius: 2px; margin-inline-start: calc(var(--rc) / 2 - 4px); box-shadow: 0 0 8px color-mix(in srgb, var(--danger) 60%, transparent); }
.tl-gap { position: relative; padding: 5px 0; padding-inline-start: calc(var(--tc) + var(--rc) + 12px); font-size: 12px; color: var(--fg-3); }
.tl-gap::before { content: ""; position: absolute; top: 0; bottom: 0; inset-inline-start: calc(var(--tc) + var(--rc) / 2 - 1px); border-inline-start: 2px dashed var(--line-2); }
.tl-any { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.tl-anyh { font-size: 12px; font-weight: 600; color: var(--fg-3); margin: 0 4px 2px; }
.tl-anyrow { display: flex; align-items: center; }
.tl-anyitem { --kc: var(--accent); flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 7px 6px; text-align: start; border-radius: 11px; font-size: 14.5px; }
.tl-anyitem:hover { background: var(--surface-2); }
.tl-anyitem .tl-check { margin: 0; }
.tl-del { width: 28px; height: 28px; align-self: center; display: grid; place-items: center; border-radius: 8px; color: var(--fg-3); opacity: 0; transition: opacity .15s, background .15s; }
.tl-row:hover .tl-del, .tl-anyrow:hover .tl-del, .tl-del:focus-visible { opacity: 1; }
.tl-del:hover { background: var(--surface-2); color: var(--danger); }
.tl-del .i { width: 14px; height: 14px; }
@media (hover: none) { .tl-del { opacity: .55; } }
.leaving { animation: fadeOut .2s forwards; }
@keyframes checkPop { 0% { transform: scale(.6); } 55% { transform: scale(1.28); } 100% { transform: scale(1); } }
@keyframes doneGlow { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 45%, transparent); } 100% { box-shadow: 0 0 0 10px transparent; } }

/* drawer: my day */
.day-nav { display: flex; align-items: center; gap: 6px; margin: 0 0 12px; }
.dn-t { flex: 1; text-align: center; min-width: 0; }
.dn-t b { display: block; font-size: 17px; font-weight: 700; line-height: 1.5; }
.dn-t small { color: var(--fg-3); font-size: 12.5px; }
.dn-prev { transform: rotate(90deg); } .dn-next { transform: rotate(-90deg); }
[dir="rtl"] .dn-prev { transform: rotate(-90deg); } [dir="rtl"] .dn-next { transform: rotate(90deg); }
.dn-back { text-align: center; margin: -4px 0 12px; }
.dn-back .chip-btn { height: 32px; font-size: 12.5px; }
.plan-prog { background: var(--card); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); border-radius: var(--r); padding: 10px 12px 11px; margin-bottom: 14px; }
.pp-t { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.5px; color: var(--fg-2); margin-bottom: 8px; }
.pp-t b { color: var(--fg); font-weight: 600; font-size: 13px; }
.pp-bar { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.pp-bar > div { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--gold)); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 50%, transparent); transition: width .5s var(--ease); }
[dir="rtl"] .pp-bar > div { background: linear-gradient(-90deg, var(--accent), var(--gold)); }
.plan-prog.all .pp-bar > div { background: var(--ok); }
.plan-prog.all .pp-t span { color: var(--ok-ink); font-weight: 600; }
.plan-empty { text-align: center; padding: 26px 12px 8px; }
.pe-ic { width: 68px; height: 68px; border-radius: 22px; margin: 0 auto 14px; }
.pe-ic .i { width: 32px; height: 32px; stroke-width: 1.6; }
.plan-empty b { display: block; font-size: 16.5px; font-weight: 700; margin-bottom: 6px; }
.plan-empty p { color: var(--fg-2); margin: 0 auto 16px; line-height: 1.8; max-width: 290px; font-size: 14px; }
.plan-empty .btn { height: 44px; padding: 0 18px; border-radius: 13px; }
.plan-add { margin: 16px 0 0; }
.plan-add #planTime { flex: 0 0 104px; min-width: 0; color: var(--fg-2); }
.plan-add .btn { width: 40px; padding: 0; flex: none; }
.drawer .tabs button { gap: 5px; padding: 7px 4px; font-size: 13px; white-space: nowrap; }

/* phone without a brain yet: a calm note on the welcome screen (no alarm colors: nothing is broken) */
.brain-note { display: flex; gap: 12px; align-items: flex-start; text-align: start; margin: -12px 0 16px; padding: 14px 16px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-sm); animation: cardIn .45s var(--ease) both; }
.brain-note .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; color: var(--gold-ink);
  background: linear-gradient(150deg, rgba(232, 178, 58, .24), rgba(232, 178, 58, .09)); box-shadow: inset 0 0 0 1px rgba(232, 178, 58, .2); }
.brain-note .ic .i { width: 19px; height: 19px; }
.brain-note b { display: block; font-size: 15px; font-weight: 600; margin-bottom: 3px; }
.brain-note p { margin: 0; font-size: 13.5px; line-height: 1.75; color: var(--fg-2); }
.phone * { -webkit-tap-highlight-color: transparent; } /* Android WebView: no blue flash on taps */
.card.nobrain .ic { --tint: var(--gold); --tint-ink: var(--gold-ink); }
@media (max-width: 900px) { .brain-note { margin-top: -8px; } }

/* welcome: what's next today */
.today-peek { position: relative; text-align: start; margin: -12px 0 14px; padding: 12px 16px 10px; border-radius: 18px; cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--gold) calc(var(--gold-tint) * .7), transparent), color-mix(in srgb, var(--gold) calc(var(--gold-tint) * .25), transparent)), var(--card); border: 1px solid color-mix(in srgb, var(--gold) calc(var(--gold-tint) * 2), var(--line)); box-shadow: inset 0 1px 0 var(--hi), var(--shadow-sm); transition: transform .2s var(--ease), box-shadow .2s; animation: rise .4s var(--ease); }
.today-peek:hover { transform: translateY(-2px); box-shadow: inset 0 1px 0 var(--hi), 0 16px 34px -14px rgba(20, 30, 90, .3); }
.tp-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.tp-head .i { width: 17px; height: 17px; color: var(--gold-ink); }
.tp-head b { font-weight: 600; font-size: 14px; }
.tp-head span { margin-inline-start: auto; font-size: 12.5px; color: var(--fg-3); }
.tp-row { display: flex; align-items: center; gap: 10px; padding: 3px 0; font-size: 14.5px; }
.tp-time { width: 74px; flex: none; color: var(--fg-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.tp-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--kc); flex: none; box-shadow: 0 0 6px color-mix(in srgb, var(--kc) 60%, transparent); }
.tp-title { font-weight: 500; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-all { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 500; color: var(--accent); margin-top: 4px; }
.tp-chev { width: 14px; height: 14px; transform: rotate(-90deg); }
[dir="rtl"] .tp-chev { transform: rotate(90deg); }
@media (max-width: 900px) {
  .today-peek { margin-top: -8px; }
  .plan-big .tl-row { grid-template-columns: var(--tc) var(--rc) minmax(0, 1fr) 40px; }
  .tl-del { width: 40px; height: 40px; }
  .dn-back .chip-btn { height: 40px; }
  .plan-add .btn { width: 44px; height: 44px; }
  .drawer .tabs button { flex-direction: column; gap: 2px; padding: 6px 2px; font-size: 12px; min-height: 48px; }
}
@media (max-width: 520px) {
  .plan-card { padding: 12px 10px 6px; }
  .tl { --tc: 44px; --rc: 14px; }
  .plan-big .tl { --tc: 52px; --rc: 16px; }
  .tl-time { font-size: 11.5px; padding-inline-end: 6px; }
}

/* ---------- Connect your phone (settings) ---------- */
.rm-status { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin: 4px 0 10px; border-radius: 14px; background: var(--field); border: 1px solid var(--line); font-size: 13.5px; color: var(--fg-2); line-height: 1.6; }
.rm-status .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--fg-3); }
.rm-status.on .dot { background: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent); }
.rm-status.on { color: var(--fg); }
.rm-status.wait .dot { background: var(--accent); animation: dlPulse 1.4s ease-in-out infinite; }
.rm-status.warn .dot { background: var(--gold); }
.rm-devices { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.rm-dev { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: inset 0 1px 0 var(--hi); }
.rm-ic { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); }
.rm-ic .i { width: 19px; height: 19px; }
.rm-meta { flex: 1; min-width: 0; }
.rm-meta b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rm-meta small { display: block; color: var(--fg-3); font-size: 12.5px; }
.rm-safe { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 0; font-size: 12.5px; color: var(--fg-3); line-height: 1.7; text-align: start; }
.rm-safe .i { flex: none; width: 15px; height: 15px; margin-top: 3px; color: var(--ok-ink); }
.rm-dev-only { margin-top: 8px; }

/* pairing code */
.modal-card.rm-modal { width: min(440px, 100%); }
.rm-pair { text-align: center; }
.rm-qr { width: min(264px, 70vw); margin: 4px auto 18px; padding: 12px; border-radius: 22px; background: #fff; box-shadow: 0 18px 40px -18px rgba(16, 24, 64, .45), 0 0 0 1px rgba(16, 24, 64, .06); transition: filter .3s, opacity .3s; }
.rm-qr svg { display: block; width: 100%; height: auto; }
.rm-qr.expired { filter: blur(6px) grayscale(1); opacity: .35; }
.rm-steps { list-style: none; margin: 0 auto 6px; padding: 0; display: flex; flex-direction: column; gap: 10px; text-align: start; max-width: 340px; }
.rm-steps li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; line-height: 1.7; color: var(--fg-2); }
.rm-steps .n { flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; }
.rm-steps li > .i { flex: none; width: 20px; height: 20px; margin-top: 3px; color: var(--accent); }
.rm-expiry { margin: 10px 0 0; font-variant-numeric: tabular-nums; }
.rm-pair .rm-safe { justify-content: center; }
.rm-done { display: grid; place-items: center; width: 72px; height: 72px; margin: 18px auto 14px; border-radius: 50%; background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok-ink); animation: pop .3s var(--spring); }
.rm-done .i { width: 36px; height: 36px; stroke-width: 2.2; }
.rm-done-t { margin: 0 0 6px; font-size: 19px; font-weight: 600; }

/* phone: pairing / waiting screens and the reconnect banner */
.remote-screen { z-index: 150; padding: 16px; }
.remote-card { padding: 30px 24px 24px; }
.remote-card h2 { margin-bottom: 10px; }
.remote-card > .muted { line-height: 1.8; margin: 0 0 18px; }
.remote-card .rm-steps { margin-bottom: 14px; }
.rm-note { font-size: 13px; color: var(--gold-ink); background: color-mix(in srgb, var(--gold) var(--gold-tint), transparent); border-radius: 12px; padding: 10px 12px; line-height: 1.7; }
.progress .indet { width: 36% !important; animation: indet 1.6s ease-in-out infinite; }
@keyframes indet { from { transform: translateX(-120%); } to { transform: translateX(320%); } }
[dir="rtl"] .progress .indet { animation-direction: reverse; }
.rm-wait { display: flex; justify-content: center; gap: 7px; margin-top: 6px; }
.rm-wait span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); opacity: .3; animation: dlPulse 1.4s ease-in-out infinite; }
.rm-wait span:nth-child(2) { animation-delay: .2s; } .rm-wait span:nth-child(3) { animation-delay: .4s; }
.remote-banner { position: fixed; z-index: 140; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); max-width: calc(100vw - 24px); padding: 8px 16px; border-radius: 999px; background: var(--glass-strong); backdrop-filter: var(--blur-sm); -webkit-backdrop-filter: var(--blur-sm); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: 13px; color: var(--fg-2); text-align: center; animation: pop .26s var(--ease); }
@media (prefers-reduced-motion: reduce) { .progress .indet, .rm-wait span, .rm-status.wait .dot { animation: none; } }
