/* UP — تصميم هادئ بمفهوم "المجلد": لسان المجلد يلوّن حالة الملف (أصفر = خاص، أخضر = مُشارَك) */
:root {
  --bg: #e8eef0; --surface: #fcfdfd; --ink: #12272e; --muted: #4b646c; --line: #cbd8dc;
  --primary: #0a6568; --primary-ink: #ffffff; --tab: #e9b23a; --shared: #0a6568;
  --danger: #a8231c; --ok: #1d6b3a; --warn-bg: #fff3d6; --focus: #1d4ed8;
  --radius: 14px; --shadow: 0 1px 2px rgba(18,39,46,.08), 0 6px 18px -8px rgba(18,39,46,.18);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1b20; --surface: #15272d; --ink: #e6f0f2; --muted: #9db4ba; --line: #2a4149;
    --primary: #4fc3c6; --primary-ink: #052326; --tab: #d9a431; --shared: #4fc3c6; --danger: #ff8a80; --ok: #7fd49a;
    --warn-bg: #3a3012; --focus: #8ab4ff; --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px -8px rgba(0,0,0,.6); }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); min-height: 100vh; display: flex; flex-direction: column;
  font: 400 1rem/1.7 "IBM Plex Sans Arabic", "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif; }
main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 1rem; }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5rem; font-weight: 700; }
h1 { font-size: clamp(1.7rem, 5vw, 2.6rem); } h2 { font-size: 1.25rem; } p { margin: 0 0 .75rem; }
a { color: var(--primary); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); } .small { font-size: .875rem; } .ltr { direction: ltr; unicode-bidi: plaintext; }

/* الرأس والتذييل */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .in { max-width: 980px; margin: 0 auto; padding: .5rem 1rem; display: flex; align-items: center; gap: .75rem; min-height: 60px; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.brand i { width: 30px; height: 22px; background: var(--tab); border-radius: 3px 8px 6px 6px; position: relative; display: inline-block; }
.brand i::before { content: ""; position: absolute; top: -5px; right: 0; width: 14px; height: 7px; background: var(--tab); border-radius: 4px 4px 0 0; }
.spacer { flex: 1; }
footer { padding: 1.25rem 1rem; text-align: center; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--line); }
footer a { display: inline-block; padding: .5rem .75rem; }

/* أزرار */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; min-width: 44px; padding: .5rem 1.1rem;
  border: 1.5px solid var(--primary); background: var(--primary); color: var(--primary-ink); border-radius: 12px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.big { min-height: 52px; font-size: 1.1rem; padding: .6rem 1.5rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; min-height: 44px; padding: .45rem .75rem; width: 100%; }
label { display: block; font-weight: 600; margin-bottom: .25rem; }
.field { margin-bottom: 1rem; }

/* الصفحة الرئيسية */
.hero { padding: 2rem 0 1.5rem; max-width: 640px; }
.hero p { font-size: 1.1rem; color: var(--muted); }
.steps { display: grid; gap: .75rem; margin: 1.5rem 0; padding: 0; list-style: none; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.steps b { display: block; }
.notice { background: var(--warn-bg); border: 1px solid var(--tab); border-radius: 12px; padding: .75rem 1rem; margin: 1rem 0; }
.notice.err { border-color: var(--danger); }

/* بطاقات المجلد */
.folder { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); border-top-right-radius: 0;
  padding: 1rem; margin-top: 14px; box-shadow: var(--shadow); }
.folder::before { content: ""; position: absolute; top: -13px; right: -1px; width: 76px; height: 13px; background: var(--tab); border-radius: 9px 9px 0 0; }
.folder.shared::before { background: var(--shared); }
.folder.panel::before { background: var(--line); }
.files { display: grid; gap: .25rem; padding: 0; margin: 0; list-style: none; }
.fname { font-weight: 600; word-break: break-word; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: .9rem; }
.badge { display: inline-block; padding: .05rem .6rem; border-radius: 99px; font-size: .82rem; font-weight: 600; border: 1px solid var(--line); }
.badge.on { color: var(--ok); border-color: var(--ok); } .badge.off { color: var(--muted); } .badge.bad { color: var(--danger); border-color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }

/* منطقة الرفع */
.drop { display: flex; flex-direction: column; align-items: center; gap: .6rem; text-align: center; padding: 1.5rem 1rem; border: 2px dashed var(--primary);
  border-radius: var(--radius); background: var(--surface); }
.drop.over { background: var(--warn-bg); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within .btn { outline: 3px solid var(--focus); outline-offset: 2px; }
.ups { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .5rem; }
.ups li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .6rem .8rem; display: grid; grid-template-columns: 1fr auto; gap: .25rem .75rem; align-items: center; }
.ups progress { grid-column: 1 / -1; width: 100%; height: 10px; accent-color: var(--primary); }
.ups .st { grid-column: 1; font-size: .85rem; color: var(--muted); }
.ups .st.err { color: var(--danger); }

/* حوار */
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); width: min(520px, calc(100vw - 1.5rem)); padding: 1.1rem; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8,20,24,.55); }
dialog menu { display: flex; flex-wrap: wrap; gap: .5rem; padding: 0; margin: 1rem 0 0; }
.copyrow { display: flex; gap: .5rem; margin: .5rem 0; } .copyrow input { flex: 1; direction: ltr; text-align: left; }

/* إدارة */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: right; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .85rem; color: var(--muted); }
.tbl-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .25rem .75rem; margin-bottom: 1.25rem; }
@media (max-width: 719px) {
  table, tbody, tr, td { display: block; width: 100%; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tr { border: 1px solid var(--line); border-radius: 12px; padding: .5rem .75rem; margin: .6rem 0; }
  td { border: 0; display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; word-break: break-word; }
  td::before { content: attr(data-label); color: var(--muted); font-size: .85rem; flex: none; }
  td.act { justify-content: flex-start; flex-wrap: wrap; } td.act::before { display: none; }
}
@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
  .steps { grid-template-columns: repeat(3, 1fr); }
  .files li .folder { display: grid; grid-template-columns: 1fr auto; gap: 1rem; align-items: center; }
  .files .actions { margin-top: 0; }
}

/* المشاهدة العامة */
.viewer { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-align: center; }
.viewer img, .viewer video { max-width: 100%; max-height: 75vh; border-radius: 8px; background: #000; }
.viewer audio { width: 100%; } .viewer iframe { width: 100%; height: 75vh; border: 0; border-radius: 8px; background: #fff; }
.viewer pre { text-align: right; white-space: pre-wrap; word-break: break-word; max-height: 70vh; overflow: auto; background: var(--bg); padding: .75rem; border-radius: 8px; font: .95rem/1.7 ui-monospace, Menlo, monospace; direction: auto; }
.legal h2 { margin-top: 1.5rem; } .legal li { margin-bottom: .35rem; }

#toast { position: fixed; inset-inline: 1rem; bottom: 1rem; max-width: 420px; margin-inline: auto; background: var(--ink); color: var(--bg); padding: .75rem 1rem; border-radius: 12px; z-index: 50; box-shadow: var(--shadow); }
@media (prefers-reduced-motion: no-preference) { .btn { transition: filter .15s; } .folder { transition: box-shadow .2s; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.vhead { display: flex; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; text-align: right; }
.viewer h1 { font-size: 1.4rem; }
.hero .small { margin-top: .75rem; }
main > h1 { font-size: 1.6rem; } .folder h1 { font-size: 1.4rem; } .narrow { max-width: 420px; margin-inline: auto; }
