/* دفترك — النمط العام. سمة فاتحة هادئة، RTL أولًا، الجوال أولًا.
   القاعدة = تخطيط هاتف بعمود واحد؛ شبكة سطح المكتب الثلاثية خلف @media (min-width: 900px). */

:root {
  --bg: #f6f6f4;
  --panel: #ffffff;
  --sidebar: #f0f0ec;
  --border: #e4e4df;
  --border-strong: #d2d2cb;
  --text: #23231e;
  --muted: #74746c;
  --accent: #0e7264;
  --accent-strong: #0a5b50;
  --accent-weak: #e4f0ed;
  --danger: #b3372f;
  --danger-weak: #f8edec;
  --radius: 10px;
  --tabbar-h: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* تغطية لوحة المفاتيح الطافية (iOS) — يضبطها bindKeyboardInsets في app.js؛ 0 وهي مغلقة */
  --kb: 0px;
}

* { box-sizing: border-box; }

/* قاعدة الإخفاء يجب أن تغلب أي display لاحق */
[hidden] { display: none !important; }

html, body { height: 100%; }

html { -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue",
    "Geeza Pro", "Noto Naskh Arabic", Tahoma, Arial, sans-serif;
}

h1, h2, h3, h4 { font-weight: 700; }

button { font: inherit; touch-action: manipulation; }

input, textarea {
  font: inherit;
  font-size: 16px; /* ≥16px يمنع تكبير iOS عند التركيز */
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 12px;
}
input { min-height: 44px; }

input:focus, textarea:focus {
  outline: 2px solid var(--accent-weak);
  border-color: var(--accent);
}

/* ---------- أزرار ---------- */

.btn {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 16px;
  min-height: 44px; /* مساحة لمس مريحة على الهاتف */
  cursor: pointer;
}
.btn:hover { background: #f1f1ed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #eaeae5; }
.btn.danger { color: var(--danger); border-color: #e3c6c3; background: transparent; }
.btn.danger:hover { background: var(--danger-weak); }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn.wide { width: 100%; padding: 10px; }
.btn:disabled { opacity: .45; cursor: default; }

.error { color: var(--danger); font-size: 13.5px; margin: 0; text-align: center; }
.muted { color: var(--muted); }
.hint { font-size: 12.5px; color: var(--muted); }

/* ---------- صفحة الدخول ---------- */

.login-page {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(12px + env(safe-area-inset-top, 0px))
    calc(12px + env(safe-area-inset-right, 0px))
    calc(12px + var(--safe-bottom))
    calc(12px + env(safe-area-inset-left, 0px));
}

.login-wrap {
  margin: auto;
  width: min(100%, 390px);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(30, 30, 20, .05);
}

.login-card h1 {
  margin: 0;
  text-align: center;
  font-size: 28px;
  color: var(--accent);
}

.login-sub {
  margin: -8px 0 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--muted);
}

/* فشل الإقلاع (شبكة لا 401): رسالة وزر إعادة محاولة بدل صفحة بيضاء صامتة */
.boot-error {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
}

/* ---------- الهيكل العام (هاتف: عمود واحد + شريط تبويبات سفلي) ---------- */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  /* العرض الأفقي على هاتف بنتوء: لا تُدفَن أزرار الحواف (سهم الرجوع) تحت الحاجز */
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  background: var(--panel);
}

.topbar {
  flex: 0 0 auto;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.brand { font-size: 18px; font-weight: 700; color: var(--accent); }

.topbar-end { display: flex; align-items: center; gap: 12px; }

.user-name { color: var(--muted); font-size: 13.5px; }

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* على الهاتف تظهر لوحة واحدة فقط بحسب data-view — والتوجيه عبر الـ hash هو مصدر الحقيقة */
.sidebar, .notes-pane, .main-pane {
  display: none;
  flex: 1;
  min-height: 0;
  flex-direction: column;
}
#app[data-view="folders"] .sidebar { display: flex; }
#app[data-view="notes"] .notes-pane { display: flex; }
#app[data-view="note"] .main-pane,
#app[data-view="chat"] .main-pane,
#app[data-view="memory"] .main-pane { display: flex; }

/* الشريط العلوي العام يظهر في مستوى المجلدات فقط؛ لكل مستوى آخر شريطه اللاصق */
#app[data-view="notes"] .topbar,
#app[data-view="note"] .topbar,
#app[data-view="chat"] .topbar,
#app[data-view="memory"] .topbar { display: none; }

/* زر الرجوع — سهم يشير إلى اليمين (اتجاه الرجوع في RTL) */
.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  border-radius: 10px;
  cursor: pointer;
}
.back-btn:active { background: var(--accent-weak); }
.back-btn svg { width: 24px; height: 24px; }

/* ---------- الشريط الجانبي (على الهاتف: شاشة المجلدات) ---------- */

.sidebar {
  background: var(--sidebar);
  padding: 12px 14px 92px; /* خلوص سفلي: الزر العائم لا يغطي عدّاد آخر مجلد ولا رابط التصدير */
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.sidebar .search-box { display: none; } /* البحث على الهاتف داخل شاشة الملاحظات */

.search-box input { width: 100%; background: #fff; }

.folder-list { display: flex; flex-direction: column; gap: 2px; }

.folder {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  min-height: 48px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}
.folder:hover { background: #e7e7e2; }
.folder.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.folder .count { font-size: 12px; color: var(--muted); }
.folder.active .count { color: var(--accent); }

.new-folder { display: flex; flex-direction: column; gap: 8px; }
.new-folder form { display: flex; gap: 6px; }
.new-folder input { flex: 1; min-width: 0; }

.sidebar-foot { margin-top: auto; padding: 8px 4px 2px; }

.muted-link {
  color: var(--muted);
  font-size: 12.5px;
  text-decoration: none;
  display: inline-block;
  padding: 10px 0;
}
.muted-link:hover { color: var(--accent); text-decoration: underline; }

/* ---------- عمود الملاحظات (على الهاتف: شاشة قائمة الملاحظات) ---------- */

.notes-pane { background: var(--panel); }

.notes-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.notes-head h2 {
  margin: 0;
  font-size: 17px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#qc-toggle { display: none; } /* على الهاتف يحل محله الزر العائم */

.m-search {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.m-search input { width: 100%; }

.search-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #fbfbf8;
  color: var(--muted);
  font-size: 13.5px;
}
#search-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* الالتقاط السريع — على الهاتف: ورقة سفلية فوق كل شيء */
.quick-capture {
  position: fixed;
  inset-inline: 0;
  bottom: var(--kb); /* فوق لوحة مفاتيح iOS الطافية — يبقى زرا حفظ/إلغاء في المتناول */
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 14px max(16px, env(safe-area-inset-right, 0px))
    calc(14px + var(--safe-bottom)) max(16px, env(safe-area-inset-left, 0px));
  box-shadow: 0 -10px 30px rgba(30, 30, 20, .18);
}
.quick-capture textarea { resize: vertical; min-height: 96px; }

.sheet-head { font-weight: 700; font-size: 16px; }

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(25, 25, 18, .35);
}

.row-end {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.notes-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 92px; /* خلوص للزر العائم (56px + هوامشه) — آخر ملاحظة تظل قابلة للنقر */
}

.note-item {
  padding: 12px 16px;
  min-height: 44px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  touch-action: manipulation;
}
.note-item:hover { background: #fafaf7; }
.note-item.active { background: var(--accent-weak); }

.note-item .t {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.note-item .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.note-item .snippet {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 4px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.empty-list { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 13.5px; }

/* ---------- اللوحة الرئيسية والتبويبات ---------- */

.main-pane { background: var(--panel); }

.tabs {
  display: none; /* تبويبات سطح المكتب — يحل محلها شريط التبويبات السفلي على الهاتف */
  flex: 0 0 auto;
  gap: 4px;
  padding: 8px 18px 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  border: none;
  background: none;
  padding: 8px 16px 10px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tab-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.empty-state {
  margin: auto;
  padding: 40px 24px;
  color: var(--muted);
  text-align: center;
  max-width: 420px;
}

/* ---------- محرر الملاحظة (على الهاتف: شاشة كاملة + شريط إجراءات لاصق) ---------- */

.note-editor {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 66px; /* مساحة لشريط الإجراءات الثابت */
}

.editor-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.note-title {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-size: 18px;
  font-weight: 700;
  padding: 4px 6px;
}
.note-title:focus { outline: none; border: none; }

.editor-actions {
  position: fixed;
  inset-inline: 0;
  /* --kb يرفع الشريط فوق لوحة مفاتيح iOS الطافية — الحفظ هو الفعل الأساسي أثناء الكتابة */
  bottom: max(calc(var(--tabbar-h) + var(--safe-bottom)), var(--kb));
  z-index: 30;
  display: flex;
  gap: 8px;
  padding: 10px max(14px, env(safe-area-inset-right, 0px))
    10px max(14px, env(safe-area-inset-left, 0px));
  background: var(--panel);
  border-top: 1px solid var(--border);
}
.editor-actions .btn { flex: 1; }

.note-meta {
  padding: 6px 16px;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.note-body {
  flex: 1;
  min-height: 0;
  border: none;
  border-radius: 0;
  resize: none;
  padding: 14px 16px;
  line-height: 1.9;
  background: var(--panel);
  /* سحب لأسفل وأنت في أعلى النص لا يتسلسل للمستند فيشعل «اسحب للتحديث» ويفقد التحرير */
  overscroll-behavior: contain;
}
.note-body:focus { outline: none; }

.preview {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 16px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ---------- عرض الماركداون ---------- */

/* رمز طويل بلا فواصل (رابط، معرّف لاتيني) يلتف بدل أن يجرّ المعاينة/الذاكرة أفقيًا */
.md { overflow-wrap: break-word; }
.md h2, .md h3, .md h4, .md h5 { margin: 16px 0 6px; line-height: 1.45; }
.md h2 { font-size: 1.3em; }
.md h3 { font-size: 1.15em; }
.md h4, .md h5 { font-size: 1.05em; }
.md p { margin: 6px 0; }
.md ul, .md ol { margin: 6px 0; padding-inline-start: 24px; }
.md li { margin: 3px 0; }
.md a { color: var(--accent); }
.md code {
  background: #f1f1ed;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: .9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  direction: ltr;
  unicode-bidi: embed;
}
.md pre {
  background: #f6f6f2;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
}
.md pre code { background: none; border: none; padding: 0; }

/* ---------- المحادثة ---------- */

.chat-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.pane-title { margin: 0; font-size: 17px; margin-inline-end: auto; }

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg { display: flex; }
.msg.user { justify-content: flex-start; }
.msg.assistant, .msg.error { justify-content: flex-start; }

.msg .bubble {
  max-width: 85%;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.msg.user .bubble {
  background: var(--accent-weak);
  border-radius: 12px;
  padding: 8px 14px;
}

.msg.assistant .bubble { padding: 2px 2px; }
.msg.assistant .bubble.md { white-space: normal; }

.msg.error .bubble {
  background: var(--danger-weak);
  color: var(--danger);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 13.5px;
}

.tool-chip {
  align-self: flex-start;
  font-size: 12.5px;
  color: var(--muted);
  background: #f1f1ed;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 14px;
}

.chat-form {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}
.chat-form textarea { flex: 1; min-width: 0; resize: none; }

/* ---------- الذاكرة ---------- */

.memory-panel {
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 28px;
}

.memory-toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel);
  padding: 10px 0;
  min-height: 56px;
  margin-bottom: 8px;
}
.memory-toolbar h2 { margin: 0; font-size: 17px; }
.memory-actions { display: flex; gap: 8px; }

.memory-view {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  min-height: 220px;
  background: #fdfdfb;
}

.memory-text {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  line-height: 1.9;
}

.memory-versions { margin-top: 18px; color: var(--muted); font-size: 13.5px; }
.memory-versions summary { cursor: pointer; padding: 11px 0; } /* ‏‎≈44px هدف لمس */
.memory-versions ul { margin: 8px 0; padding-inline-start: 22px; }
.memory-versions li { margin: 2px 0; }

/* ---------- شريط التبويبات السفلي والزر العائم (هاتف فقط) ---------- */

.tabbar {
  flex: 0 0 auto;
  display: flex;
  z-index: 40;
  background: var(--panel);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}

.tabbar-btn {
  flex: 1;
  height: var(--tabbar-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  padding: 0;
  color: var(--muted);
  font-size: 11.5px;
  cursor: pointer;
}
.tabbar-btn svg { width: 23px; height: 23px; }
.tabbar-btn.active { color: var(--accent); font-weight: 600; }

.fab {
  position: fixed;
  z-index: 45;
  /* الصفحة RTL دائمًا: نهاية السطر = يسار الشاشة، فنعوّض حاجز العرض الأفقي الأيسر */
  inset-inline-end: calc(18px + env(safe-area-inset-left, 0px));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 18px);
  width: 56px;
  height: 56px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 18px rgba(14, 114, 100, .38);
  cursor: pointer;
}
.fab svg { width: 26px; height: 26px; }
.fab:active { background: var(--accent-strong); }
#app[data-view="folders"] .fab,
#app[data-view="notes"] .fab { display: flex; }

/* ---------- التنبيهات ---------- */

.toast-holder {
  position: fixed;
  /* --kb: تنبيه «فتح الملاحظة» ذو المهلة لا يختفي خلف لوحة المفاتيح المفتوحة */
  bottom: max(calc(var(--tabbar-h) + var(--safe-bottom) + 14px), calc(var(--kb) + 14px));
  inset-inline-start: calc(12px + env(safe-area-inset-right, 0px));
  inset-inline-end: calc(12px + env(safe-area-inset-left, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
}

.toast {
  background: #26251f;
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}

.toast-action {
  background: none;
  border: none;
  color: #86d8ca;
  cursor: pointer;
  font-weight: 600;
  padding: 8px 10px;
  min-height: 44px; /* فعل واحد بمهلة 6 ثوانٍ — هدف لمس كامل لا ~35px */
  min-width: 44px;
}
.toast-action:hover { text-decoration: underline; }

/* ==========================================================================
   سطح المكتب (≥900px + مؤشر دقيق): الشبكة الثلاثية كما كانت تمامًا.
   شرط pointer: fine يطابق isDesktop() في app.js حرفيًا — هاتف كبير بالعرض
   الأفقي (iPhone Pro Max ‏≈926px) يبقى على مسار الهاتف: خط ≥16px في الحقول
   (لا تكبير iOS عند التركيز) وأهداف لمس 44px
   ========================================================================== */

@media (min-width: 900px) and (pointer: fine) {

  input, textarea { font-size: inherit; }
  input { min-height: 0; }
  .btn { min-height: 0; }
  .new-folder input { padding: 5px 10px; font-size: 13.5px; }
  .muted-link { padding: 0; }
  .login-card { padding: 36px 32px; }
  .login-page { padding: 0; }
  .login-wrap { width: min(92vw, 390px); }

  #app { padding-top: 0; }
  .topbar { padding: 0 20px; }
  .topbar, #app[data-view] .topbar { display: flex; }

  .layout {
    display: grid;
    grid-template-columns: 230px 320px 1fr;
  }

  #app .sidebar, #app .notes-pane, #app .main-pane { display: flex; }

  .sidebar {
    border-inline-end: 1px solid var(--border);
    padding: 14px 12px;
  }
  .sidebar .search-box { display: block; }
  .folder { padding: 7px 12px; min-height: 0; }

  .notes-pane { border-inline-end: 1px solid var(--border); }
  .notes-head { padding: 12px 14px; min-height: 0; }
  .notes-head h2 { font-size: 15.5px; flex: none; }
  #qc-toggle { display: inline-block; }
  .notes-head { justify-content: space-between; }

  .quick-capture {
    position: static;
    z-index: auto;
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    padding: 12px 14px;
    background: #fbfbf8;
  }
  .sheet-backdrop { display: none !important; }

  .note-item { padding: 10px 16px; min-height: 0; }
  .notes-list { padding-bottom: 0; } /* لا زر عائم على سطح المكتب — لا حاجة للخلوص */

  .tabs { display: flex; }
  .tabbar { display: none; }
  .fab,
  #app[data-view="folders"] .fab,
  #app[data-view="notes"] .fab { display: none; }
  .m-only { display: none !important; }

  .note-editor { padding-bottom: 0; }
  .editor-toolbar { padding: 12px 18px; gap: 8px; min-height: 0; }
  .note-title { font-size: 19px; }
  .editor-actions {
    position: static;
    display: flex;
    gap: 8px;
    padding: 0;
    border: none;
    background: none;
  }
  .editor-actions .btn { flex: 0 0 auto; }
  .note-meta { padding: 6px 24px; }
  .note-body { padding: 20px 24px; }
  .preview { padding: 20px 24px; }

  .chat-toolbar { padding: 10px 18px; min-height: 0; }
  .chat-messages { padding: 20px 24px; }
  .msg .bubble { max-width: 82%; }
  .chat-form { padding: 12px 18px; align-items: stretch; }

  .memory-panel { padding: 20px 26px; }
  .memory-toolbar { position: static; padding: 0; min-height: 0; margin-bottom: 12px; }
  .memory-text { min-height: 340px; }
  .memory-versions summary { padding: 0; }

  .toast-holder {
    bottom: 24px;
    inset-inline-start: 24px;
    inset-inline-end: auto;
  }
  .toast-action { padding: 0; min-height: 0; min-width: 0; }
}
