/* =========================================================================
   Lamha design system
   Bright by conviction. Logical properties everywhere so RTL is native,
   not a patch. One file, no framework, no build step.
   ========================================================================= */

:root {
  /* ---- brand ---------------------------------------------------------- */
  --brand-50:  #eef4ff;
  --brand-100: #dbe7ff;
  --brand-200: #bed3ff;
  --brand-300: #92b5ff;
  --brand-400: #5f8dff;
  --brand-500: #3b6cf6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;

  /* ---- accents: used sparingly, always at full confidence -------------- */
  --violet: #7c3aed;
  --violet-soft: #f3ebff;
  --mint:   #0ea472;
  --mint-soft: #e2f8ef;
  --amber:  #d97706;
  --amber-soft: #fef3da;
  --rose:   #e11d48;
  --rose-soft: #ffe8ed;
  --sky:    #0891b2;
  --sky-soft: #e0f6fb;

  /* ---- surfaces ------------------------------------------------------- */
  --bg:        #f5f7fd;
  --bg-tint:   radial-gradient(1100px 520px at 12% -12%, #e6edff 0%, rgba(230,237,255,0) 62%),
               radial-gradient(900px 480px at 100% 0%, #f0e9ff 0%, rgba(240,233,255,0) 58%);
  --surface:   #ffffff;
  --surface-2: #f7f9fe;
  --surface-3: #eef2fb;

  /* ---- ink ------------------------------------------------------------ */
  --ink:    #0f172a;
  --ink-2:  #475569;
  --ink-3:  #8592ab;
  --ink-on-brand: #ffffff;

  --line:      #e5eaf4;
  --line-soft: #eef2f9;
  /* Form fields get their own, stronger edge. --line is 1.21:1 on white, which
     is effectively invisible; a field boundary needs 3:1 (WCAG 1.4.11). #8490a4
     is 3.23:1 on white and 3.01:1 on the --bg tint fields often sit on. */
  --field-line:       #8490a4;
  --field-line-hover: #64748b;

  /* ---- shape ---------------------------------------------------------- */
  --r-xs: 7px;
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* ---- space ---------------------------------------------------------- */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 44px; --s9: 64px;

  /* ---- depth ---------------------------------------------------------- */
  --sh-1: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.04);
  --sh-2: 0 2px 4px rgba(15,23,42,.04), 0 8px 20px rgba(15,23,42,.06);
  --sh-3: 0 4px 10px rgba(15,23,42,.06), 0 22px 46px rgba(15,23,42,.10);
  --sh-brand: 0 6px 18px rgba(37,99,235,.28);

  --ring: 0 0 0 4px rgba(37,99,235,.18);
  --ring-danger: 0 0 0 4px rgba(225,29,72,.16);

  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-ar: "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", "Dubai",
             Tahoma, system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --nav-h: 66px;
}

/* =========================================================================
   Reset
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

/* Author `display` rules outrank the UA sheet's [hidden], so restate it here.
   Without this, hiding a styled element with el.hidden silently does nothing. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background-color: var(--bg);
  background-image: var(--bg-tint);
  background-repeat: no-repeat;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

html[dir="rtl"] body { font-family: var(--font-ar); }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 700; letter-spacing: -0.015em; }
h1 { font-size: 30px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3 { letter-spacing: 0; }

p { margin: 0 0 var(--s3); color: var(--ink-2); }
p:last-child { margin-bottom: 0; }

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video, svg { max-width: 100%; display: block; }

button, input, select, textarea { font: inherit; color: inherit; }

hr { border: 0; border-top: 1px solid var(--line); margin: var(--s6) 0; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-xs);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; inset-inline-start: var(--s4); top: -60px;
  background: var(--surface); padding: var(--s3) var(--s5);
  border-radius: var(--r); box-shadow: var(--sh-3); z-index: 200;
  transition: top .15s ease;
}
.skip-link:focus { top: var(--s3); }

/* =========================================================================
   Layout
   ========================================================================= */

.wrap { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: var(--s5); }
.wrap-narrow { max-width: 880px; }

.page { padding-block: var(--s7) var(--s9); }

.stack   > * + * { margin-block-start: var(--s4); }
.stack-lg > * + * { margin-block-start: var(--s6); }

.row { display: flex; align-items: center; gap: var(--s3); }
.row-wrap { flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.grow { flex: 1 1 auto; min-width: 0; }
.spacer { flex: 1 1 auto; }

.muted { color: var(--ink-2); }
.dim   { color: var(--ink-3); }
.tiny  { font-size: 12.5px; }
.small { font-size: 13.5px; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.center { text-align: center; }

/* Numbers and share links stay left-to-right even inside Arabic text. */
.ltr-num { direction: ltr; unicode-bidi: isolate; }

/* =========================================================================
   Top navigation
   ========================================================================= */

.nav {
  position: sticky; top: 0; z-index: 60;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(14px);
  border-block-end: 1px solid var(--line-soft);
}

.nav-inner {
  height: var(--nav-h);
  display: flex; align-items: center; gap: var(--s5);
}

.brand { display: inline-flex; align-items: center; gap: var(--s3); text-decoration: none; }
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-500), var(--violet));
  /* The svg inherits the link colour (brand blue), which vanishes on this tile. */
  color: #fff;
  box-shadow: var(--sh-brand);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 18px; height: 18px; }

/* The app mark, public/assets/brand/logo.svg. It carries its own gradient tile,
   so it takes no background here: set on a .brand-mark it would draw a tile
   inside a tile. Same 34px footprint and the same soft brand glow as the tile
   it replaced. */
.brand-logo {
  width: 34px; height: 34px; flex: none; display: block;
  border-radius: 6px;
  filter: drop-shadow(0 5px 12px rgba(59,108,246,.26));
}

.brand-word { font-weight: 800; font-size: 19px; color: var(--ink); letter-spacing: -0.02em; }
html[dir="rtl"] .brand-word { letter-spacing: 0; }

.nav-links { display: flex; align-items: center; gap: var(--s2); }

.nav-link {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-pill);
  color: var(--ink-2); font-weight: 550; font-size: 14.5px;
}
.nav-ico { width: 17px; height: 17px; flex: none; }
.nav-link:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav-link.is-active { background: var(--brand-50); color: var(--brand-700); }

/* Rendered for admins only: the panel's violet, so it reads as a door out of the app. */
.nav-link-admin { color: var(--violet); white-space: nowrap; }
.nav-link-admin:hover { background: var(--violet-soft); color: var(--violet); }
/* Between the phone layout and a wide screen the bar is full: the extra tab
   goes to its icon alone (the link keeps its name in aria-label and title). */
@media (max-width: 960px) { .nav-link-admin span { display: none; } }

.nav-right { display: flex; align-items: center; gap: var(--s3); margin-inline-start: auto; }

.lang-switch {
  display: inline-flex; background: var(--surface-3);
  border-radius: var(--r-pill); padding: 3px;
}
.lang-switch a {
  padding: 5px 12px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.lang-switch a:hover { text-decoration: none; color: var(--ink); }
.lang-switch a.is-active { background: var(--surface); color: var(--brand-700); box-shadow: var(--sh-1); }

.avatar {
  width: 34px; height: 34px; border-radius: var(--r-pill); flex: none;
  background: linear-gradient(140deg, var(--brand-400), var(--violet));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 14px; text-transform: uppercase;
}

.nav-storage { display: flex; flex-direction: column; gap: 4px; min-width: 132px; }
.nav-storage .bar { height: 5px; }

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 10px 18px; border-radius: var(--r-pill);
  border: 1px solid transparent; background: var(--surface-3); color: var(--ink);
  font-size: 14.5px; font-weight: 600; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s ease, box-shadow .15s ease, transform .1s ease, color .15s ease;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn svg { width: 17px; height: 17px; flex: none; }

.btn-primary { background: var(--brand-600); color: var(--ink-on-brand); box-shadow: var(--sh-brand); }
.btn-primary:hover { background: var(--brand-700); }

.btn-soft { background: var(--brand-50); color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); }

.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }

.btn-outline { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: var(--sh-1); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--brand-200); }

.btn-danger { background: var(--rose); color: #fff; }
.btn-danger:hover { background: #be123c; }

.btn-danger-soft { background: var(--rose-soft); color: var(--rose); }
.btn-danger-soft:hover { background: #ffd9e1; }

.btn-sm { padding: 7px 13px; font-size: 13.5px; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-block { width: 100%; }

.icon-btn {
  width: 34px; height: 34px; padding: 0; border-radius: var(--r-sm);
  display: inline-grid; place-items: center; flex: none;
  background: transparent; border: 1px solid transparent; color: var(--ink-2); cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.is-danger:hover { background: var(--rose-soft); color: var(--rose); }
.icon-btn svg { width: 17px; height: 17px; }

/* =========================================================================
   Cards and panels
   ========================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card-pad { padding: var(--s6); }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4);
  padding: var(--s5) var(--s6);
  border-block-end: 1px solid var(--line-soft);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .sub { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-3); }
.card-body { padding: var(--s6); }
.card-foot {
  padding: var(--s4) var(--s6);
  border-block-start: 1px solid var(--line-soft);
  background: var(--surface-2);
  border-end-start-radius: var(--r-lg); border-end-end-radius: var(--r-lg);
  display: flex; align-items: center; gap: var(--s3);
}

.panel-title { font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-3); }
html[dir="rtl"] .panel-title { letter-spacing: 0; }

/* =========================================================================
   Forms
   ========================================================================= */

.field { display: block; margin-block-end: var(--s4); }
.field:last-child { margin-block-end: 0; }
.label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); margin-block-end: 6px; }
.hint  { font-size: 12.5px; color: var(--ink-3); margin-block-start: 6px; }
.err   { font-size: 12.5px; color: var(--rose); margin-block-start: 6px; font-weight: 550; }

.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface);
  border: 1px solid var(--field-line);
  border-radius: var(--r);
  font-size: 15px;
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:hover:not(:focus):not(:disabled),
.select:hover:not(:focus):not(:disabled),
.textarea:hover:not(:focus):not(:disabled) { border-color: var(--field-line-hover); }
/* A disabled field is not interactive, so it drops back to the soft edge. */
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-2); border-color: var(--line); color: var(--ink-3); cursor: not-allowed;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-400); box-shadow: var(--ring);
}
.input.is-error, .textarea.is-error { border-color: var(--rose); }
.input.is-error:focus { box-shadow: var(--ring-danger); }
.textarea { min-height: 96px; resize: vertical; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%238592ab' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 20px;
  background-position: right 12px center;
  padding-inline-end: 38px;
}
html[dir="rtl"] .select { background-position: left 12px center; padding-inline-end: 38px; padding-inline-start: 38px; }

.input-sm { padding: 8px 11px; font-size: 14px; border-radius: var(--r-sm); }
/* .input-sm resets padding, so the arrow gutter has to be restored after it. */
.select.input-sm { padding-inline-end: 34px; }
.input-search.input-sm { padding-inline-start: 36px; }

.input-search {
  padding-inline-start: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%238592ab' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='9' cy='9' r='6'/%3E%3Cpath d='M13.5 13.5L17 17'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 18px;
  background-position: left 13px center;
}
html[dir="rtl"] .input-search { background-position: right 13px center; }

/* toggle */
.switch { display: flex; align-items: center; gap: var(--s3); cursor: pointer; }
.switch > span:last-child { min-width: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 44px; height: 25px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--line);
  position: relative; flex: none; transition: background .18s ease, border-color .18s ease;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; inset-inline-start: 2px;
  width: 19px; height: 19px; border-radius: var(--r-pill);
  background: #fff; box-shadow: var(--sh-1);
  transition: transform .18s cubic-bezier(.4,0,.2,1);
}
.switch input:checked + .switch-track { background: var(--brand-600); border-color: var(--brand-600); }
.switch input:checked + .switch-track::after { transform: translateX(19px); }
html[dir="rtl"] .switch input:checked + .switch-track::after { transform: translateX(-19px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

/* radio cards */
.choice-list { display: grid; gap: var(--s3); }
.choice {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s4); border: 1.5px solid var(--line); border-radius: var(--r);
  background: var(--surface); cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.choice:hover { border-color: var(--brand-200); background: var(--surface-2); }
.choice input { margin: 0; accent-color: var(--brand-600); margin-block-start: 3px; flex: none; }
.choice-t { display: block; font-weight: 620; font-size: 14.5px; }
.choice-b { display: block; font-size: 13px; color: var(--ink-3); margin-block-start: 2px; line-height: 1.45; }
.choice.is-on { border-color: var(--brand-500); background: var(--brand-50); box-shadow: var(--ring); }

/* checkbox */
.check { display: inline-flex; align-items: center; gap: var(--s2); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand-600); cursor: pointer; }

/* =========================================================================
   Badges and chips
   ========================================================================= */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 650; line-height: 1.6;
  background: var(--surface-3); color: var(--ink-2);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.badge-ready      { background: var(--mint-soft);   color: var(--mint); }
.badge-processing { background: var(--violet-soft); color: var(--violet); }
.badge-uploading  { background: var(--amber-soft);  color: var(--amber); }
.badge-failed     { background: var(--rose-soft);   color: var(--rose); }
.badge-expired    { background: var(--surface-3);   color: var(--ink-3); }
.badge-brand      { background: var(--brand-50);    color: var(--brand-700); }

.badge-processing .dot, .badge-uploading .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 13.5px; font-weight: 550; color: var(--ink-2); cursor: pointer;
}
.chip:hover { border-color: var(--brand-200); color: var(--ink); text-decoration: none; }
.chip.is-on { background: var(--brand-600); border-color: var(--brand-600); color: #fff; box-shadow: var(--sh-brand); }
.chip.is-on:hover { color: #fff; }

/* =========================================================================
   Storage bar
   ========================================================================= */

.bar {
  height: 10px; border-radius: var(--r-pill);
  background: var(--surface-3); overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--brand-500), var(--violet));
  transition: width .5s cubic-bezier(.4,0,.2,1);
  min-width: 4px;
}
html[dir="rtl"] .bar-fill { background: linear-gradient(-90deg, var(--brand-500), var(--violet)); }
.bar.is-warn .bar-fill { background: linear-gradient(90deg, #f59e0b, #ea580c); }
.bar.is-full .bar-fill { background: linear-gradient(90deg, #f43f5e, #be123c); }

.notice {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s4) var(--s5); border-radius: var(--r);
  font-size: 14px; border: 1px solid transparent;
}
.notice svg { width: 19px; height: 19px; flex: none; margin-block-start: 1px; }
.notice-warn   { background: var(--amber-soft); color: #92400e; border-color: #fbdca0; }
.notice-danger { background: var(--rose-soft);  color: #9f1239; border-color: #fbc8d3; }
.notice-info   { background: var(--brand-50);   color: var(--brand-700); border-color: var(--brand-100); }
.notice-ok     { background: var(--mint-soft);  color: #0b6b4c; border-color: #b7ecd7; }

/* =========================================================================
   Library toolbar
   ========================================================================= */

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s5); flex-wrap: wrap; margin-block-end: var(--s6); }
.page-head .sub { color: var(--ink-3); margin-block-start: 6px; }

.toolbar {
  display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3); margin-block-end: var(--s5);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.toolbar .search-box { flex: 1 1 260px; min-width: 200px; }
.toolbar-sep { width: 1px; align-self: stretch; background: var(--line); margin-inline: var(--s1); }

/* =========================================================================
   Media grid
   ========================================================================= */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
  gap: var(--s5);
}

.mcard {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  overflow: hidden;
  transition: transform .18s cubic-bezier(.4,0,.2,1), box-shadow .18s ease, border-color .18s ease;
}
.mcard:hover { transform: translateY(-3px); box-shadow: var(--sh-3); border-color: var(--brand-200); }
.mcard.is-selected { border-color: var(--brand-500); box-shadow: var(--ring); }

.mcard-thumb {
  position: relative; display: block;
  aspect-ratio: 16 / 10; background: var(--surface-3);
  overflow: hidden;
}
.mcard-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mcard-thumb::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(15,23,42,.42) 0%, rgba(15,23,42,0) 42%);
  opacity: 0; transition: opacity .18s ease; pointer-events: none;
}
.mcard:hover .mcard-thumb::after { opacity: 1; }

.thumb-placeholder {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-50), var(--violet-soft));
  color: var(--brand-400);
}
.thumb-placeholder svg { width: 40px; height: 40px; opacity: .6; }
.thumb-placeholder.is-shot { background: linear-gradient(135deg, var(--sky-soft), var(--mint-soft)); color: var(--sky); }
.thumb-placeholder.is-busy { background: linear-gradient(115deg, var(--surface-3) 20%, var(--brand-50) 40%, var(--surface-3) 60%); background-size: 260% 100%; animation: shimmer 1.8s linear infinite; }
@keyframes shimmer { from { background-position: 160% 0; } to { background-position: -60% 0; } }

.pill-time {
  position: absolute; inset-block-end: 9px; inset-inline-end: 9px;
  background: rgba(15,23,42,.78); color: #fff;
  padding: 2px 8px; border-radius: var(--r-xs);
  font-size: 11.5px; font-weight: 650; letter-spacing: .02em;
  direction: ltr; unicode-bidi: isolate;
}

.mcard-status { position: absolute; inset-block-start: 9px; inset-inline-start: 9px; }

.mcard-pick {
  position: absolute; inset-block-start: 9px; inset-inline-end: 9px;
  width: 26px; height: 26px; border-radius: var(--r-xs);
  background: rgba(255,255,255,.92); border: 1px solid var(--line);
  display: grid; place-items: center; cursor: pointer; z-index: 2;
  opacity: 0; transition: opacity .15s ease;
  box-shadow: var(--sh-1);
}
.mcard:hover .mcard-pick,
.mcard.is-selected .mcard-pick,
.lib.has-selection .mcard-pick { opacity: 1; }
.mcard-pick input { width: 16px; height: 16px; margin: 0; accent-color: var(--brand-600); cursor: pointer; }

.mcard-body { padding: var(--s4) var(--s4) var(--s3); }
.mcard-title {
  display: block; font-weight: 640; font-size: 14.5px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mcard-title:hover { color: var(--brand-600); text-decoration: none; }
.mcard-meta {
  display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap;
  margin-block-start: 5px; font-size: 12.5px; color: var(--ink-3);
}
.mcard-meta .sep { width: 3px; height: 3px; border-radius: 50%; background: var(--ink-3); opacity: .55; }

.mcard-actions {
  display: flex; align-items: center; gap: 2px;
  padding: 0 var(--s3) var(--s3);
  opacity: 0; transition: opacity .15s ease;
}
.mcard:hover .mcard-actions, .mcard:focus-within .mcard-actions { opacity: 1; }
@media (hover: none) { .mcard-actions { opacity: 1; } .mcard-pick { opacity: 1; } }

.progress-strip {
  position: absolute; inset-inline: 0; inset-block-end: 0; height: 4px;
  background: rgba(255,255,255,.5);
}
.progress-strip i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand-500), var(--violet));
  transition: width .6s ease;
}

/* selection bar */
.selbar {
  position: sticky; inset-block-end: var(--s5); z-index: 50;
  margin-block-start: var(--s6);
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s3) var(--s3) var(--s3) var(--s5);
  background: var(--ink); color: #fff;
  border-radius: var(--r-pill); box-shadow: var(--sh-3);
}
html[dir="rtl"] .selbar { padding: var(--s3) var(--s5) var(--s3) var(--s3); }
.selbar .btn-ghost { color: rgba(255,255,255,.75); }
.selbar .btn-ghost:hover { background: rgba(255,255,255,.12); color: #fff; }

/* =========================================================================
   Empty state
   ========================================================================= */

.empty {
  text-align: center;
  padding: var(--s9) var(--s5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-1);
  position: relative; overflow: hidden;
}
.empty::before {
  content: ""; position: absolute; inset-block-start: -140px; inset-inline-start: 50%;
  transform: translateX(-50%); width: 620px; height: 320px;
  background: radial-gradient(closest-side, rgba(124,58,237,.14), rgba(124,58,237,0));
  pointer-events: none;
}
.empty > * { position: relative; }
.empty h2 { font-size: 26px; max-width: 22ch; margin-inline: auto; }
.empty p.lead { max-width: 54ch; margin-inline: auto; margin-block-start: var(--s3); font-size: 16px; }

.empty-art {
  width: 78px; height: 78px; margin-inline: auto; margin-block-end: var(--s5);
  border-radius: 24px;
  background: linear-gradient(135deg, var(--brand-500), var(--violet));
  box-shadow: 0 12px 34px rgba(124,58,237,.3);
  display: grid; place-items: center; color: #fff;
}
.empty-art svg { width: 36px; height: 36px; }

.steps {
  display: grid; gap: var(--s4);
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  margin-block: var(--s8) var(--s7);
  text-align: start;
}
.step {
  padding: var(--s5);
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
}
.step-n {
  width: 28px; height: 28px; border-radius: var(--r-pill);
  background: var(--brand-600); color: #fff;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; margin-block-end: var(--s3);
}
.step h4 { margin-block-end: 4px; }
.step p { font-size: 13.5px; margin: 0; }

/* =========================================================================
   Item page
   ========================================================================= */

.item-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(330px, 1fr);
  gap: var(--s6);
  align-items: start;
}

.player-shell {
  background: #0f172a;
  border-radius: var(--r-lg);
  overflow: hidden;
  position: relative;
  aspect-ratio: 16 / 9;
  box-shadow: var(--sh-2);
}
.player-shell video, .player-shell img { width: 100%; height: 100%; object-fit: contain; background: #0f172a; }
.player-shell.is-shot { aspect-ratio: auto; background: var(--surface-3); }
.player-shell.is-shot img { max-height: 70vh; }

.player-missing {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: var(--s3); color: #cbd5e1; text-align: center; padding: var(--s6);
}
.player-missing svg { width: 42px; height: 42px; opacity: .6; }

/* CTA overlay preview */
.cta-layer { position: absolute; inset: 0; pointer-events: none; }
.cta-slot { position: absolute; display: flex; flex-wrap: wrap; gap: 8px; max-width: 72%; }
.cta-slot.tl { inset-block-start: 14px; left: 14px; }
.cta-slot.tr { inset-block-start: 14px; right: 14px; justify-content: flex-end; }
.cta-slot.bl { inset-block-end: 14px; left: 14px; }
.cta-slot.br { inset-block-end: 14px; right: 14px; justify-content: flex-end; }

.cta-btn {
  padding: 8px 16px; border-radius: var(--r-pill);
  font-size: 13.5px; font-weight: 650; line-height: 1.3;
  border: 1.5px solid currentColor; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(15,23,42,.24);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.cta-btn.solid { color: #fff; }
.cta-btn.outline { background: rgba(255,255,255,.94); }

.cta-below-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-block-start: var(--s4); }

/* CTA editor */
.cta-row {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); margin-block-end: var(--s3);
  transition: border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.cta-row.is-dragging { opacity: .4; }
.cta-row.is-over { border-color: var(--brand-500); box-shadow: var(--ring); }
.cta-row-head {
  display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s3) var(--s3) var(--s2);
}
html[dir="rtl"] .cta-row-head { padding: var(--s3) var(--s2) var(--s3) var(--s3); }
.drag-handle {
  cursor: grab; color: var(--ink-3); padding: 4px; border-radius: var(--r-xs);
  background: none; border: 0; display: grid; place-items: center;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:hover { background: var(--surface-3); color: var(--ink-2); }
.drag-handle svg { width: 16px; height: 16px; }
.cta-swatch { width: 22px; height: 22px; border-radius: 7px; border: 1px solid rgba(15,23,42,.12); flex: none; }
.cta-row-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3);
  padding: 0 var(--s4) var(--s4);
}
.cta-row-grid .full { grid-column: 1 / -1; }

/* tabs */
.tabs { display: flex; gap: 4px; border-block-end: 1px solid var(--line); margin-block-end: var(--s5); overflow-x: auto; }
.tab {
  padding: 10px 16px; border: 0; background: none; cursor: pointer;
  font-size: 14.5px; font-weight: 600; color: var(--ink-3);
  border-block-end: 2px solid transparent; margin-block-end: -1px; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--brand-700); border-block-end-color: var(--brand-600); }

/* link box */
.linkbox {
  display: flex; align-items: center; gap: var(--s2);
  padding: 6px 6px 6px var(--s4);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-pill);
}
html[dir="rtl"] .linkbox { padding: 6px var(--s4) 6px 6px; }
.linkbox code {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: 13px; color: var(--ink-2);
  direction: ltr; unicode-bidi: isolate; text-align: start;
}

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: var(--s3); }
.stat {
  padding: var(--s4); border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line-soft);
}
.stat-n { font-size: 24px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; direction: ltr; unicode-bidi: isolate; }
/* A tile whose value is words, not a numeral: it must follow the page direction. */
.stat-n.is-text { direction: inherit; unicode-bidi: plaintext; font-size: 16px; padding-block: 4px; }
html[dir="rtl"] .stat-n { text-align: start; }
.stat-l { font-size: 12.5px; color: var(--ink-3); margin-block-start: 2px; }

/* chart */
.chart { width: 100%; height: 168px; display: block; }
.chart-bar { fill: var(--brand-500); transition: fill .15s ease; }
.chart-bar:hover { fill: var(--violet); }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--ink-3); font-size: 10px; font-family: var(--font); }

/* comments */
.comment { display: flex; gap: var(--s3); padding-block: var(--s4); border-block-end: 1px solid var(--line-soft); }
.comment:last-child { border-block-end: 0; }
.comment-av {
  width: 32px; height: 32px; border-radius: var(--r-pill); flex: none;
  background: var(--surface-3); color: var(--ink-2);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; text-transform: uppercase;
}
.comment-b { flex: 1 1 auto; min-width: 0; }
.comment-t { display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap; }
.comment-body { margin-block-start: 3px; color: var(--ink); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.time-link {
  font-family: var(--font-mono); font-size: 12px; font-weight: 650;
  background: var(--brand-50); color: var(--brand-700);
  padding: 1px 7px; border-radius: var(--r-xs); cursor: pointer; border: 0;
  direction: ltr; unicode-bidi: isolate;
}
.time-link:hover { background: var(--brand-100); }

/* =========================================================================
   Auth pages
   ========================================================================= */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.auth-form-side {
  display: flex; align-items: center; justify-content: center;
  padding: var(--s7) var(--s6);
}
.auth-box { width: 100%; max-width: 408px; }
.auth-box h1 { font-size: 27px; }
.auth-box .sub { color: var(--ink-2); margin-block-start: var(--s2); margin-block-end: var(--s7); }

.auth-art {
  background:
    radial-gradient(600px 420px at 78% 18%, rgba(255,255,255,.4), rgba(255,255,255,0)),
    linear-gradient(150deg, var(--brand-500) 0%, var(--violet) 62%, #a855f7 100%);
  color: #fff;
  padding: var(--s9) var(--s8);
  display: flex; flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.auth-art::after {
  content: ""; position: absolute; inset-block-end: -180px; inset-inline-end: -120px;
  width: 460px; height: 460px; border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.auth-art > * { position: relative; z-index: 1; }
.auth-art h2 { font-size: 32px; line-height: 1.25; max-width: 15ch; }
.auth-art .promise { display: flex; gap: var(--s3); align-items: flex-start; margin-block-start: var(--s5); font-size: 15px; }
.auth-art .promise svg { width: 21px; height: 21px; flex: none; margin-block-start: 2px; opacity: .92; }
.auth-art .brand-word { color: #fff; }
.auth-art .brand-mark { background: rgba(255,255,255,.2); box-shadow: none; }
/* The logo's tile is the panel's own gradient; a thin light ring keeps its edge. */
.auth-art .brand-logo {
  box-shadow: 0 0 0 2px rgba(255,255,255,.42);
  filter: drop-shadow(0 8px 18px rgba(30,27,75,.28));
}

/* The brand ribbons (hero-bg), multiplied into the gradient: the near-white
   middle of the art leaves the gradient as it was behind the copy, and only
   the ribbons at two corners deepen it. The url()s are relative to this file
   (app/assets/), so they hold wherever the site is installed. */
.auth-art::before {
  content: ""; position: absolute; inset: 0;
  background: url("../../public/assets/brand/hero-bg.jpg") center / cover no-repeat;
  background-image: image-set(
    url("../../public/assets/brand/hero-bg.webp") type("image/webp"),
    url("../../public/assets/brand/hero-bg.jpg") type("image/jpeg"));
  mix-blend-mode: multiply;
  opacity: .55;
  pointer-events: none;
}

/* login.php?next=staff says which door it is. */
.auth-staff { display: flex; width: fit-content; background: var(--violet-soft); color: var(--violet); margin-block-end: var(--s4); }
.auth-staff svg { width: 14px; height: 14px; }

.auth-foot { margin-block-start: var(--s6); font-size: 14px; color: var(--ink-2); text-align: center; }

.divider { display: flex; align-items: center; gap: var(--s3); margin-block: var(--s5); color: var(--ink-3); font-size: 12.5px; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--line); flex: 1 1 auto; }

/* =========================================================================
   Toasts and modal
   ========================================================================= */

.toasts {
  position: fixed; inset-block-end: var(--s5); inset-inline-end: var(--s5);
  z-index: 300; display: flex; flex-direction: column; gap: var(--s2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--s3);
  padding: 12px 18px; border-radius: var(--r-pill);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 550;
  box-shadow: var(--sh-3); pointer-events: auto;
  animation: toast-in .22s cubic-bezier(.4,0,.2,1);
  max-width: min(420px, calc(100vw - 40px));
}
.toast svg { width: 17px; height: 17px; flex: none; }
.toast.is-ok    { background: #065f46; }
.toast.is-error { background: #9f1239; }
.toast.is-out   { animation: toast-out .18s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(14px) scale(.96); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px) scale(.97); } }

.modal-back {
  position: fixed; inset: 0; z-index: 250;
  background: rgba(15,23,42,.44);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: var(--s5);
  animation: fade-in .15s ease;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 440px;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-3); overflow: hidden;
  animation: modal-in .2s cubic-bezier(.4,0,.2,1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.modal-body { padding: var(--s6); }
.modal-body h3 { margin-block-end: var(--s2); font-size: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--s2);
  padding: var(--s4) var(--s6); background: var(--surface-2);
  border-block-start: 1px solid var(--line-soft);
}

/* =========================================================================
   Pagination
   ========================================================================= */

.pager { display: flex; align-items: center; justify-content: center; gap: var(--s3); margin-block-start: var(--s8); }
.pager .count { font-size: 13.5px; color: var(--ink-3); }

/* arrows are direction-aware */
html[dir="rtl"] .flip-x { transform: scaleX(-1); }

/* =========================================================================
   Responsive
   ========================================================================= */

@media (max-width: 1040px) {
  .item-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
}

@media (max-width: 720px) {
  :root { --nav-h: 58px; }
  h1 { font-size: 25px; }
  .wrap { padding-inline: var(--s4); }
  .page { padding-block: var(--s5) var(--s8); }
  .nav-storage { display: none; }
  .nav-inner { gap: var(--s3); }
  .nav-link { padding: 8px 10px; }
  .nav-link span { display: none; }
  .brand-word { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: var(--s4); }
  .card-pad, .card-body, .card-head { padding: var(--s5) var(--s4); }
  .empty { padding: var(--s8) var(--s4); }
  .empty h2 { font-size: 22px; }
  .cta-row-grid { grid-template-columns: minmax(0, 1fr); }
  .toasts { inset-inline: var(--s4); align-items: stretch; }
  .selbar { inset-inline: 0; border-radius: var(--r-lg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  .nav, .toolbar, .mcard-actions, .selbar, .toasts { display: none !important; }
  body { background: #fff; }
}
