/* «مكتبة الوسائط», THE MEDIA LIBRARY (2026-10-09) — medialib.js draws it.
   Only what the library adds on top of the console theme (console-theme.css
   tokens): the meter, the grid of files, the folder chips, the sheet. Logical
   properties throughout, so Arabic and English read the same way round. */
.ml-root { display: flex; flex-direction: column; gap: var(--s3, 12px); min-width: 0; }
.ml-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3, 12px); flex-wrap: wrap; }
.ml-head-t h2 { margin: 0; font-size: 22px; }
.ml-head-t .section-sub { margin: 4px 0 0; max-width: 640px; }
.ml-head .ml-meter { min-inline-size: 260px; max-inline-size: 360px; flex: 1 1 260px; }
.ml-ic { inline-size: 18px; block-size: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.ml-hint { color: var(--muted); font-size: var(--t-sm, 13px); margin: 0; }
.ml-say { margin: 0; font-size: var(--t-sm, 13px); min-block-size: 0; }
.ml-say:empty { display: none; }
.ml-say.ok { color: var(--ok); }
.ml-say.bad { color: var(--danger, var(--bad, #b4232b)); }

/* The meter: a quiet bar, warn at 90%, the danger colour once full. */
.ml-meter { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-sm, 13px); color: var(--ink-2, var(--ink)); }
.ml-meter-l { display: flex; justify-content: space-between; gap: var(--s2, 8px); flex-wrap: wrap; }
.ml-meter-free { color: var(--muted); }
.ml-meter-t { block-size: 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.ml-meter-f { display: block; block-size: 100%; background: var(--accent); border-radius: inherit; transition: inline-size 240ms cubic-bezier(0.23, 1, 0.32, 1); }
.ml-meter.warn .ml-meter-f { background: var(--warn); }
.ml-meter.bad .ml-meter-f { background: var(--danger, var(--bad, #b4232b)); }
.ml-meter.bad .ml-meter-l { color: var(--danger, var(--bad, #b4232b)); font-weight: 600; }
.ml-meter.big { font-size: var(--t-md, 15px); }
.ml-meter.big .ml-meter-t { block-size: 12px; }

/* Tools: search on one side, the upload buttons on the other. */
.ml-tools { display: flex; flex-wrap: wrap; gap: var(--s2, 8px); align-items: center; justify-content: space-between; }
.ml-search-w { position: relative; display: flex; align-items: center; flex: 1 1 240px; max-inline-size: 420px; }
.ml-search-w .ml-ic { position: absolute; inset-inline-start: 12px; color: var(--muted); pointer-events: none; }
.ml-search { inline-size: 100%; min-block-size: 44px; padding-inline-start: 38px; }
.ml-acts { display: flex; flex-wrap: wrap; gap: var(--s2, 8px); align-items: center; }
.ml-acts button, .ml-from { display: inline-flex; align-items: center; gap: 6px; }
.ml-acts button.on { background: var(--accent-weak); }

/* Pick tabs (the sheet only; the panel's rail is the page's tabs). */
.ml-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-block-end: 1px solid var(--line); }
.ml-tabs::-webkit-scrollbar { display: none; }
.ml-tab { background: none; border: 0; border-block-end: 3px solid transparent; min-block-size: 44px; padding: 0 12px;
  color: var(--muted); font-weight: 600; white-space: nowrap; cursor: pointer; }
.ml-tab:hover { color: var(--ink); }
.ml-tab.on { color: var(--accent-press); border-block-end-color: var(--accent); font-weight: 700; }

/* Folders as chips: the active one filled. */
.ml-folders { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ml-fchip { display: inline-flex; align-items: center; gap: 6px; min-block-size: 36px; padding: 4px 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2, var(--ink));
  font-size: var(--t-sm, 13px); font-weight: 600; cursor: pointer; unicode-bidi: plaintext;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease; }
.ml-fchip .ml-ic { inline-size: 15px; block-size: 15px; }
.ml-fchip:hover { background: var(--accent-weak); }
.ml-fchip.on { background: var(--accent); color: var(--on-accent, var(--accent-ink, #fff)); border-color: var(--accent); }
.ml-fchip.add { border-style: dashed; color: var(--accent-press); }
.ml-fchip.tool { padding: 4px 10px; }
.ml-fchip.danger { color: var(--danger, var(--bad, #b4232b)); }
.ml-fcount { font-size: var(--t-xs, 12px); opacity: .8; font-variant-numeric: tabular-nums; }

/* The bulk bar. */
.ml-bulk { display: flex; flex-wrap: wrap; gap: var(--s2, 8px); align-items: center; padding: var(--s2, 8px) var(--s3, 12px);
  border-radius: var(--r-btn, 10px); background: var(--accent-weak); border: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.ml-bulk strong { margin-inline-end: auto; }
.ml-select { min-block-size: 40px; }
.ml-bulk .btn-danger { display: inline-flex; align-items: center; gap: 6px; }

/* The grid. Square thumbnails, the name under them. */
.ml-zone { position: relative; min-block-size: 160px; border-radius: var(--r-card, 14px); }
.ml-grid { display: grid; gap: var(--s3, 12px); grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.ml-root.pick .ml-grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); }
.ml-tile { display: flex; flex-direction: column; gap: 6px; padding: 0; text-align: start; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-card, 14px); overflow: hidden; cursor: pointer; color: inherit;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 160ms cubic-bezier(0.23, 1, 0.32, 1); min-inline-size: 0; }
.ml-tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ml-tile:active { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) {
  .ml-tile:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgb(0 0 0 / .06); }
}
.ml-tile.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.ml-thumb { position: relative; display: grid; place-items: center; aspect-ratio: 1; inline-size: 100%; flex: none; background:
  repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 16px 16px; overflow: hidden; }
.ml-thumb img { inline-size: 100%; block-size: 100%; object-fit: contain; display: block; }
.ml-thumb.doc { background: var(--surface-2); }
/* «فيديو» (2026-10-12): a clip's first frame, with a play mark over it. */
.ml-thumb video { inline-size: 100%; block-size: 100%; object-fit: contain; display: block; pointer-events: none; background: #000; }
.ml-play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.ml-play .ml-ic { inline-size: 34px; block-size: 34px; padding: 8px; border-radius: 50%; color: #fff;
  background: rgba(0, 0, 0, .55); fill: currentColor; stroke: none; }
.ml-video { inline-size: 100%; max-block-size: 60vh; background: #000; border-radius: 10px; }
.ml-doc { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; color: var(--accent-press); }
.ml-doc .ml-ic { inline-size: 40px; block-size: 40px; stroke-width: 1.4; }
.ml-doc b { font-size: var(--t-xs, 12px); letter-spacing: .04em; }
.ml-doc.big .ml-ic { inline-size: 72px; block-size: 72px; }
.ml-badge { position: absolute; inset-block-start: 6px; inset-inline-start: 6px; display: grid; place-items: center;
  inline-size: 26px; block-size: 26px; border-radius: 999px; background: var(--surface); color: var(--accent-press);
  border: 1px solid var(--line); }
.ml-badge .ml-ic { inline-size: 14px; block-size: 14px; }
.ml-check { position: absolute; inset-block-start: 6px; inset-inline-end: 6px; display: grid; place-items: center;
  inline-size: 26px; block-size: 26px; border-radius: 999px; background: var(--surface); border: 2px solid var(--line);
  color: transparent; }
.ml-check.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent, var(--accent-ink, #fff)); }
.ml-check .ml-ic { inline-size: 14px; block-size: 14px; stroke-width: 2.6; }
/* `inline-size` set, not left to stretch: a <button> sizes this box to its
   content, and a long name then pushed the caption past the tile's edge. */
.ml-meta { display: flex; flex-direction: column; gap: 2px; padding: 0 10px 10px; min-inline-size: 0;
  inline-size: 100%; box-sizing: border-box; }
.ml-name { font-size: var(--t-sm, 13px); font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; unicode-bidi: plaintext; }
.ml-sub { font-size: var(--t-xs, 12px); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ml-skel { aspect-ratio: 1 / 1.25; background: var(--surface-2); animation: ml-pulse 1.2s ease-in-out infinite alternate; }
@keyframes ml-pulse { from { opacity: .55; } to { opacity: 1; } }
.ml-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 16px; text-align: center;
  color: var(--muted); border: 2px dashed var(--line); border-radius: var(--r-card, 14px); }
.ml-empty .ml-ic { inline-size: 32px; block-size: 32px; color: var(--accent-press); }
.ml-empty strong { color: var(--ink); }
.ml-empty p { margin: 0; font-size: var(--t-sm, 13px); }
.ml-dropcover { position: absolute; inset: 0; display: none; place-items: center; border-radius: inherit;
  background: color-mix(in srgb, var(--accent-weak) 88%, transparent); border: 2px dashed var(--accent);
  color: var(--accent-press); font-weight: 700; z-index: 3; pointer-events: none; }
.ml-zone.drag .ml-dropcover { display: grid; }
.ml-more { display: flex; justify-content: center; }
.ml-fail { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2, 8px); }

/* The sheet. */
.ml-back { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 16px;
  background: rgb(14 10 22 / .48); }
.ml-sheet { inline-size: min(560px, 100%); max-block-size: min(88vh, 900px); display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink); border-radius: 18px; border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgb(0 0 0 / .25); overflow: hidden;
  animation: ml-in 200ms cubic-bezier(0.23, 1, 0.32, 1); }
.ml-back.wide .ml-sheet { inline-size: min(980px, 100%); }
@keyframes ml-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.ml-sheet-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s2, 8px);
  padding: 14px 18px; border-block-end: 1px solid var(--line); }
.ml-sheet-h h2 { margin: 0; font-size: 18px; unicode-bidi: plaintext; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-x { min-inline-size: 44px; display: inline-grid; place-items: center; }
.ml-sheet-b { padding: 16px 18px; overflow: auto; display: flex; flex-direction: column; gap: var(--s3, 12px); }
.ml-confirm { margin: 0; line-height: 1.8; unicode-bidi: plaintext; }
.ml-row-end { display: flex; flex-wrap: wrap; gap: var(--s2, 8px); justify-content: flex-end; align-items: center; }
.ml-row-end button { display: inline-flex; align-items: center; gap: 6px; }
.ml-input { inline-size: 100%; min-block-size: 44px; }

/* One file: preview beside its words. */
.ml-detail { display: grid; gap: var(--s4, 16px); grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; }
.ml-detail-l, .ml-detail-r { display: flex; flex-direction: column; gap: var(--s3, 12px); min-inline-size: 0; }
.ml-preview { display: grid; place-items: center; min-block-size: 220px; max-block-size: 420px; border-radius: var(--r-card, 14px);
  border: 1px solid var(--line); background: var(--surface-2); overflow: hidden; }
.ml-preview img { max-inline-size: 100%; max-block-size: 420px; object-fit: contain; display: block; }
.ml-preview.checker { background: repeating-conic-gradient(var(--surface-2) 0% 25%, var(--surface) 0% 50%) 50% / 18px 18px; }
.ml-facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: var(--t-sm, 13px); }
.ml-facts dt { color: var(--muted); }
.ml-facts dd { margin: 0; }
.ml-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--t-sm, 13px); color: var(--ink-2, var(--ink)); font-weight: 600; }
.ml-field small { font-weight: 400; }
.ml-uses h3 { margin: 0 0 4px; font-size: var(--t-md, 15px); }
.ml-uses ul { margin: 0; padding-inline-start: 18px; font-size: var(--t-sm, 13px); line-height: 1.8; unicode-bidi: plaintext; }

/* The storage page. */
.ml-storage { display: grid; gap: var(--s3, 12px); grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); align-items: start; }
.ml-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card, 14px); padding: var(--s4, 16px);
  display: flex; flex-direction: column; gap: var(--s3, 12px); }
.ml-card h3 { margin: 0; font-size: var(--t-md, 15px); }
.ml-counts { display: flex; gap: var(--s4, 16px); }
.ml-counts div { display: flex; flex-direction: column; }
.ml-counts strong { font-size: 22px; }
.ml-counts span { color: var(--muted); font-size: var(--t-sm, 13px); }
.ml-srow { display: grid; grid-template-columns: 120px 1fr auto; gap: 10px; align-items: center; font-size: var(--t-sm, 13px); }
.ml-srow-t { block-size: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.ml-srow-f { display: block; block-size: 100%; background: var(--accent); border-radius: inherit; }
.ml-srow-v { color: var(--muted); white-space: nowrap; }

@media (max-width: 720px) {
  .ml-detail { grid-template-columns: 1fr; }
  .ml-back { padding: 0; align-items: end; }
  .ml-sheet, .ml-back.wide .ml-sheet { inline-size: 100%; max-block-size: 92vh; border-radius: 18px 18px 0 0; }
  .ml-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
  .ml-srow { grid-template-columns: 90px 1fr; }
  .ml-srow-v { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .ml-sheet { animation: none; }
  .ml-skel { animation: none; }
  .ml-tile, .ml-meter-f { transition: none; }
}
.pl-media { max-width: 1180px; }
