@font-face {
  font-family: 'Vazirmatn';
  src: url('/fonts/Vazirmatn-Variable.woff2') format('woff2 supports variations'),
       url('/fonts/Vazirmatn-Variable.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f6f7f9;
  --bg-2: #ffffff;
  --bg-3: #eef0f4;
  --text: #16191d;
  --text-2: #5c636e;
  --border: #dfe3ea;
  --accent: #2f6df6;
  --accent-soft: rgba(47, 109, 246, .1);
  --ok: #12a150;
  --danger: #e0334b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 20, 28, .05), 0 8px 24px rgba(16, 20, 28, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --bg-2: #161a21; --bg-3: #1d222b;
    --text: #e8eaee; --text-2: #98a1ae; --border: #272d38;
    --accent: #5b8dff; --accent-soft: rgba(91, 141, 255, .14);
    --ok: #35c979; --danger: #ff6b81;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --bg-2: #161a21; --bg-3: #1d222b;
  --text: #e8eaee; --text-2: #98a1ae; --border: #272d38;
  --accent: #5b8dff; --accent-soft: rgba(91, 141, 255, .14);
  --ok: #35c979; --danger: #ff6b81;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text-2); font-size: .84rem; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
kbd {
  font-family: inherit; font-size: .78rem; padding: 1px 6px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg-3);
}

/* ── اسپلش ── */
.splash {
  position: fixed; inset: 0; z-index: 999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--bg); color: var(--accent);
  transition: opacity .35s ease, visibility .35s;
}
.splash.gone { opacity: 0; visibility: hidden; }
.splash-mark { animation: rise 1.1s ease-in-out infinite alternate; }
.splash-name { color: var(--text); font-weight: 700; font-size: 1.05rem; letter-spacing: .3px; }
@keyframes rise { from { transform: translateY(5px); opacity: .65 } to { transform: translateY(-5px); opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .splash-mark { animation: none } }

/* ── سربرگ ── */
.head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px clamp(14px, 4vw, 32px);
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  position: sticky; top: 0; z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.02rem;
}
.brand svg { color: var(--accent); flex: none; }
.head-actions { margin-inline-start: auto; display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--bg-3); color: var(--text); border: 1px solid var(--border);
  border-radius: 11px; cursor: pointer; transition: border-color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

/* ── چیدمان ── */
.wrap {
  max-width: 880px; margin: 0 auto;
  padding: clamp(16px, 4vw, 30px) clamp(14px, 4vw, 32px) 40px;
  display: flex; flex-direction: column; gap: 18px;
}

/* ── ناحیهٔ رهاکردن ── */
.drop {
  border: 2px dashed var(--border);
  border-radius: 20px;
  background: var(--bg-2);
  padding: clamp(26px, 7vw, 48px) 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}
.drop:hover, .drop:focus-visible { border-color: var(--accent); outline: none; }
.drop.over {
  border-color: var(--accent); background: var(--accent-soft);
  transform: scale(1.008);
}
.drop-icon { color: var(--accent); margin-bottom: 10px; }
.drop-title { font-weight: 800; font-size: 1.12rem; }
.drop-sub { color: var(--text-2); font-size: .87rem; margin-top: 6px; }
.drop-meta { color: var(--text-2); font-size: .78rem; margin-top: 12px; }

/* ── کارت ── */
.card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px clamp(14px, 3vw, 20px);
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: .98rem; font-weight: 800; }
.card-head > :nth-child(2) { margin-inline-start: auto; }

/* ── صف آپلود ── */
.queue { display: flex; flex-direction: column; gap: 12px; }
.q-item { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--bg); }
.q-top { display: flex; align-items: center; gap: 10px; }
.q-name { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.q-pct { font-variant-numeric: tabular-nums; font-weight: 800; font-size: .88rem; color: var(--accent); flex: none; }
.q-bar { height: 7px; border-radius: 99px; background: var(--bg-3); overflow: hidden; margin-top: 9px; }
.q-fill { height: 100%; width: 0; border-radius: 99px; background: var(--accent); transition: width .18s ease; }
.q-item.done .q-fill { background: var(--ok); }
.q-item.err .q-fill { background: var(--danger); }
.q-item.done .q-pct { color: var(--ok); }
.q-item.err .q-pct { color: var(--danger); }
.q-info { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 7px; font-size: .76rem; color: var(--text-2); }

/* ── فهرست فایل‌ها ── */
.list { display: flex; flex-direction: column; gap: 8px; }
.f-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg);
}
.f-ico {
  width: 40px; height: 40px; flex: none; border-radius: 11px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
  overflow: hidden;
}
.f-ico img { width: 100%; height: 100%; object-fit: cover; }
.f-main { min-width: 0; flex: 1; }
.f-name {
  font-weight: 600; font-size: .88rem; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text); text-decoration: none;
}
.f-name:hover { color: var(--accent); }
.f-sub { font-size: .74rem; color: var(--text-2); }
.f-acts { display: flex; gap: 6px; flex: none; }
.btn-ghost {
  background: transparent; color: var(--text-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 6px 11px; font-size: .78rem; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--accent); border-color: var(--accent); }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); }

/* کنش‌های هر فایل: آیکون + متن؛ روی صفحهٔ کوچک فقط آیکون */
.act {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 11px;
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border); border-radius: 10px;
  font-family: inherit; font-size: .78rem; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s, background .15s;
}
.act svg { flex: none; }
.act:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.act:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.act.danger:hover { color: var(--danger); border-color: var(--danger); background: transparent; }
.act.ok { color: var(--ok); border-color: var(--ok); }
.act.dl:hover { color: var(--ok); border-color: var(--ok); background: transparent; }
.empty { color: var(--text-2); font-size: .86rem; text-align: center; padding: 20px 0; }

/* ── پاورقی و توست ── */
.foot { text-align: center; padding: 0 0 28px; }
.app-version { color: var(--text-2); font-size: .78rem; }
.toast {
  position: fixed; inset-inline: 0; bottom: 22px; margin: 0 auto; width: fit-content; max-width: 90vw;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 11px;
  font-size: .86rem; font-weight: 600; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .22s, transform .22s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 620px) {
  /* فقط آیکون — متن دکمه‌ها پنهان می‌شود تا ردیف نشکند */
  .act span { display: none; }
  .act { padding: 0; width: 36px; justify-content: center; }
  .f-acts { gap: 6px; }
  .card-head > :nth-child(2) { margin-inline-start: 0; }
}
@media (max-width: 380px) {
  .f-ico { display: none; }
}

/* ── دیالوگ ── */
.modal-back {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(8, 10, 14, .55);
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .18s ease;
}
.modal-back.in { opacity: 1; }
.modal {
  width: min(430px, 100%);
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  padding: 24px 22px 18px;
  text-align: center;
  transform: translateY(12px) scale(.97);
  transition: transform .2s cubic-bezier(.2, .8, .3, 1);
}
.modal-back.in .modal { transform: none; }
.modal-ico {
  width: 50px; height: 50px; margin: 0 auto 12px;
  display: grid; place-items: center; border-radius: 15px;
  background: var(--accent-soft); color: var(--accent);
}
.modal-ico.danger { background: rgba(224, 51, 75, .12); color: var(--danger); }
:root[data-theme="dark"] .modal-ico.danger { background: rgba(255, 107, 129, .14); }
.modal-title { margin: 0 0 8px; font-size: 1.06rem; font-weight: 800; }
.modal-body { color: var(--text-2); font-size: .88rem; line-height: 1.9; }
.modal-body p { margin: 0; overflow-wrap: anywhere; }
.modal-input {
  width: 100%; margin-top: 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 11px;
  padding: 11px 12px; font-family: inherit; font-size: max(16px, .82rem);
  text-align: start;
}
.modal-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.modal-acts { display: flex; gap: 9px; margin-top: 20px; }
.mbtn {
  flex: 1; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--border);
  font-family: inherit; font-size: .88rem; font-weight: 700;
  cursor: pointer; background: var(--bg-3); color: var(--text);
  transition: filter .15s, border-color .15s, background .15s;
}
.mbtn:hover { filter: brightness(1.08); }
.mbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mbtn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.mbtn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.mbtn.plain:hover { border-color: var(--accent); color: var(--accent); }

/* ── توست: حالت موفق و خطا ── */
.toast.ok { background: var(--ok); color: #fff; }
.toast.err { background: var(--danger); color: #fff; }

@media (max-width: 420px) {
  .modal { padding: 20px 16px 16px; border-radius: 16px; }
  .modal-acts { flex-direction: column-reverse; }
  .mbtn { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .modal-back, .modal { transition: none; }
}
