/* المكوّنات المشتركة: شرائح، أزرار، بطاقات، مفاتيح، قوائم، Bottom Sheet، تنبيهات */
.chip {
  display: inline-flex; align-items: center; gap: 6px; flex: none; border: 1px solid transparent; border-radius: 999px;
  padding: 8px 18px; background: var(--surface-2); color: var(--text); font-size: .95rem; white-space: nowrap; transition: background var(--t), color var(--t);
}
.chip.is-on { background: var(--primary); color: var(--on-primary); }
.chip-add { color: var(--primary); background: transparent; border-color: var(--border); }
.chip-sm { padding: 5px 12px; font-size: .85rem; border-color: var(--border); color: var(--text-muted); }
.chip .ic-sm { margin-inline-end: -2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 24px; border-radius: var(--radius-btn);
  border: 1.5px solid transparent; font-weight: 600; font-size: 1rem; transition: filter var(--t), background var(--t);
}
.btn:active { filter: brightness(.92); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { display: flex; width: 100%; margin-top: 12px; }
.btn-text { border: 0; background: transparent; color: var(--primary); font-weight: 600; padding: 8px 10px; border-radius: 12px; display: inline-flex; align-items: center; gap: 6px; }
.btn-text:hover { background: color-mix(in srgb, var(--primary) 10%, transparent); }

.card { background: var(--surface); border-radius: var(--radius-card); box-shadow: 0 1px 2px color-mix(in srgb, var(--text) 5%, transparent); }
.notice { display: flex; gap: 8px; align-items: center; padding: 10px 14px; background: var(--surface-tint); border-radius: 16px; font-size: .88rem; color: var(--text-muted); margin-bottom: 12px; }

/* القوائم داخل بطاقة */
.list-card { overflow: hidden; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 18px; min-height: 58px; width: 100%; background: none; border: 0; text-align: start; cursor: pointer; }
.row + .row { border-top: 1px solid var(--border); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 1rem; }
.row-sub { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.row-chev { color: var(--text-muted); }
.row-ic { color: var(--primary); }
.row-slider { flex-direction: column; align-items: stretch; gap: 8px; cursor: default; }
.row-head { display: flex; justify-content: space-between; align-items: center; }
.row-head .val { color: var(--primary); font-weight: 600; }
.row-seg { flex-direction: column; align-items: stretch; gap: 10px; cursor: default; }
.section-title { color: var(--primary); font-size: .95rem; font-weight: 700; padding: 18px 8px 8px; }

/* مفتاح Material 3 */
.switch { position: relative; flex: none; width: 52px; height: 32px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 16px; background: var(--surface-tint); border: 2px solid var(--text-muted); transition: background var(--t), border-color var(--t); }
.switch .thumb { position: absolute; top: 50%; inset-inline-start: 6px; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; background: var(--text-muted); transition: all var(--t); }
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track .thumb { inset-inline-start: calc(100% - 30px); width: 24px; height: 24px; margin-top: -12px; background: var(--on-primary); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* شريط التمرير */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--surface-tint); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-tint); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: var(--primary); border: 0; }
input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--primary); border: 0; }

/* مفتاح اختيار مقسّم */
.seg { display: flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 999px; padding: 9px 8px; font-size: .88rem; color: var(--text-muted); transition: all var(--t); }
.seg button.is-on { background: var(--primary); color: var(--on-primary); font-weight: 600; }

/* القوائم المنبثقة */
#layer { position: relative; z-index: 100; }
.scrim { position: fixed; inset: 0; background: color-mix(in srgb, #000 38%, transparent); animation: fade-in var(--t) both; z-index: 100; }
.scrim.clear { background: transparent; }
@keyframes fade-in { from { opacity: 0; } }
.menu {
  position: fixed; z-index: 101; min-width: 230px; max-width: calc(100vw - 24px); padding: 8px; border-radius: 20px; background: var(--surface);
  border: 1px solid var(--border); box-shadow: 0 8px 28px color-mix(in srgb, #000 22%, transparent); animation: pop var(--t) cubic-bezier(.2, .8, .3, 1) both;
}
@keyframes pop { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: none; } }
.menu-item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px; padding: 0 14px; border: 0; border-radius: 14px; background: none; text-align: start; font-size: .97rem; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: 0; }
.menu-item .ic { color: var(--text-muted); }
.menu-item.is-danger { color: var(--danger); } .menu-item.is-danger .ic { color: var(--danger); }
.menu-item .tick { margin-inline-start: auto; color: var(--primary); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 8px; }

/* Bottom Sheet */
.sheet {
  position: fixed; z-index: 101; bottom: 0; inset-inline: 0; margin-inline: auto; width: 100%; max-width: var(--maxw); max-height: 88dvh; overflow: auto;
  background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px 20px calc(24px + var(--safe-b)); animation: sheet-up 260ms cubic-bezier(.2, .8, .3, 1) both;
}
.sheet.is-closing { animation: sheet-down 180ms ease-in both; }
@keyframes sheet-up { from { transform: translateY(100%); } }
@keyframes sheet-down { to { transform: translateY(100%); } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 14px; }
.sheet-title { font-size: 1.1rem; font-weight: 700; text-align: center; margin-bottom: 12px; }

/* نافذة حوار */
.dialog { position: fixed; z-index: 101; inset-inline: 16px; top: 50%; margin: auto; max-width: 420px; transform: translateY(-50%); background: var(--surface); border-radius: 28px; padding: 24px; animation: pop var(--t) both; }
.dialog h3 { font-size: 1.15rem; margin-bottom: 8px; }
.dialog p { color: var(--text-muted); font-size: .95rem; white-space: pre-line; }
.dialog .field { margin-top: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.dialog-stack { display: grid; gap: 10px; margin-top: 16px; }
.dialog-stack .btn { width: 100%; }

/* Toast */
.toast-wrap { position: fixed; z-index: 120; inset-inline: 0; bottom: calc(24px + var(--safe-b)); display: flex; justify-content: center; pointer-events: none; padding-inline: 16px; }
body.has-fab .toast-wrap { bottom: calc(84px + var(--safe-b)); }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px; max-width: 480px; padding: 12px 18px; border-radius: 16px;
  background: var(--text); color: var(--bg); font-size: .95rem; animation: toast-in 220ms ease-out both; box-shadow: 0 4px 16px rgb(0 0 0 / .25);
}
.toast.is-out { animation: toast-out 180ms ease-in both; }
.toast button { background: none; border: 0; color: color-mix(in srgb, var(--primary) 55%, var(--bg)); font-weight: 700; padding: 4px 6px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(12px); } }

/* الزر العائم */
.fab {
  position: fixed; z-index: 25; bottom: calc(20px + var(--safe-b)); inset-inline-end: var(--col-pad); display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 22px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-weight: 600; font-size: 1rem;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 45%, transparent), 0 2px 6px rgb(0 0 0 / .18); transition: transform var(--t);
}
.fab:active { transform: scale(.96); }

/* الحالة الفارغة */
.empty { text-align: center; padding: 56px 28px; color: var(--text-muted); }
.empty h2 { color: var(--text); font-size: 1.25rem; margin-bottom: 8px; }

/* الفاصل الزخرفي */
.ornament { color: var(--primary); opacity: .75; display: flex; justify-content: center; }
.ornament svg { width: min(260px, 70%); height: 28px; }


/* شريط الأزرار العائمة: زران جنباً إلى جنب بدل التكدّس فوق بعضهما */
.fab-bar { position: fixed; z-index: 25; bottom: calc(16px + var(--safe-b)); inset-inline-end: var(--col-pad); display: flex; gap: 10px; align-items: center; }
.fab-bar .fab { position: static; height: 52px; padding: 0 18px; font-size: .95rem; }
.fab-bar .fab-ai { background: var(--surface); color: var(--primary); border: 1.5px solid var(--primary); box-shadow: 0 3px 10px rgb(0 0 0 / .12); }
@media (max-width: 380px) { .fab-bar .fab-ai span { display: none; } .fab-bar .fab-ai { padding: 0 14px; } }
