:root {
  --bg: #0e0f14; --bg2: #161821; --card: #1c1f2a; --line: #2a2e3d;
  --text: #eef0f6; --muted: #8d93a8; --accent: #7c6cff; --accent2: #b06cff;
  --ok: #2ecc8f; --no: #ff5c7a; --warn: #f5b84a;
  --radius: 14px;
  font-family: Vazirmatn, Tahoma, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: radial-gradient(1200px 700px at 50% -10%, #23204a 0%, var(--bg) 60%) fixed; color: var(--text); -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
input, textarea, select {
  width: 100%; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.err { color: var(--no); min-height: 1em; margin: 6px 0 0; font-size: 13px; }
.ok { color: var(--ok); margin: 6px 0 0; font-size: 13px; }

.btn { border: 0; border-radius: 10px; padding: 9px 16px; cursor: pointer; background: var(--card); transition: .2s; white-space: nowrap; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-weight: 500; }
.btn.primary:disabled { opacity: .6; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--card); }
.btn.danger { background: #3a1b25; color: var(--no); }
.btn.wide { width: 100%; }
.mini { border: 1px solid var(--line); background: var(--bg2); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.mini.ok { border-color: #1f5b45; color: var(--ok); } .mini.no { border-color: #5b2232; color: var(--no); }
.badge { background: var(--no); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 7px; margin-inline-start: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card.sub { padding: 14px; margin-bottom: 12px; background: var(--bg2); }
.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth { width: min(380px, 100%); text-align: center; }
.auth form { display: grid; gap: 10px; }
.auth h1 { margin: 6px 0; font-size: 22px; }
.logo { font-size: 44px; background: linear-gradient(135deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.tabs { display: flex; gap: 4px; background: var(--bg2); border-radius: 12px; padding: 4px; margin: 12px 0; overflow-x: auto; }
.tab { flex: 1; border: 0; background: none; padding: 8px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tab.active { background: var(--card); color: var(--text); box-shadow: 0 1px 4px #0006; }

/* ---------- Gallery ---------- */
#view-app { min-height: 100%; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: #0e0f14cc; backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 18px; color: var(--accent); }
.brand span { color: var(--text); }
.modes { flex: 1; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; justify-content: center; }
.modes::-webkit-scrollbar { display: none; }
.modes button { border: 1px solid var(--line); background: var(--bg2); color: var(--muted); border-radius: 99px; padding: 6px 14px; cursor: pointer; white-space: nowrap; font-size: 13px; }
.modes button.active { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; }
.actions { display: flex; gap: 6px; }

.stage { position: relative; height: min(64vh, 640px); min-height: 340px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
#stage-host { width: 100%; height: 100%; position: relative; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); }

.swiper { width: 100%; height: 100%; padding: 28px 0 40px; }
.swiper-slide { display: flex; align-items: center; justify-content: center; }
.swiper-slide img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius); display: block; user-select: none; box-shadow: 0 20px 60px #0009; }
.swiper-pagination-bullet { background: #fff; }
.swiper-pagination-bullet-active { background: var(--accent); }
.swiper-button-next, .swiper-button-prev { color: #fff; --swiper-navigation-size: 28px; }

.mode-coverflow .swiper-slide { width: min(56vw, 440px); height: 92%; }
.mode-cube .swiper, .mode-flip .swiper, .mode-cards .swiper { width: min(80vw, 460px); height: 88%; }
.mode-cube .swiper-slide img { border-radius: 0; }
.mode-cards .swiper { width: min(70vw, 380px); overflow: visible; }
.mode-cards .swiper-slide { border-radius: var(--radius); }
.mode-depth .swiper, .mode-tilt .swiper { width: min(72vw, 520px); overflow: visible; }

/* Ring */
.ring-scene { position: absolute; inset: 0; perspective: 1400px; perspective-origin: 50% 40%; display: flex; align-items: center; justify-content: center; touch-action: pan-y; cursor: grab; user-select: none; }
.ring-scene:active { cursor: grabbing; }
.ring { position: relative; width: min(42vw, 260px); aspect-ratio: 3/4; transform-style: preserve-3d; }
.ring figure { position: absolute; inset: 0; margin: 0; border-radius: var(--radius); overflow: hidden; backface-visibility: visible;
  box-shadow: 0 10px 40px #000a; transition: filter .3s, opacity .3s; filter: brightness(.55); -webkit-box-reflect: below 8px linear-gradient(transparent 70%, #fff3); }
.ring figure.active { filter: none; outline: 2px solid var(--accent); }
.ring img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.ring-nav { position: absolute; top: 50%; transform: translateY(-50%); z-index: 5; width: 44px; height: 44px; border-radius: 50%; border: 0; background: #0008; color: #fff; font-size: 26px; cursor: pointer; }
.ring-nav.prev { right: 12px; } .ring-nav.next { left: 12px; }

/* Grid */
.mode-grid { overflow-y: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 16px; }
.tile { position: relative; border: 2px solid transparent; padding: 0; border-radius: 12px; overflow: hidden; aspect-ratio: 1; cursor: pointer; background: var(--card); transition: transform .25s; }
.tile:hover { transform: perspective(600px) rotateX(6deg) rotateY(-6deg) scale(1.03); }
.tile.active { border-color: var(--accent); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .cc { position: absolute; bottom: 6px; inset-inline-start: 6px; background: #000a; border-radius: 99px; padding: 1px 8px; font-size: 12px; }

/* Info + comments */
.info { width: min(760px, 100%); margin: 0 auto; padding: 8px 16px 40px; }
.info-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.info h2 { margin: 6px 0 2px; font-size: 20px; }
.info-head p { margin: 0; white-space: pre-line; }
.counter { color: var(--muted); font-size: 13px; margin-top: 10px; }
.comments h3 { font-size: 15px; margin: 22px 0 10px; }
#comment-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.comment { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.comment.pending { border-style: dashed; opacity: .85; }
.comment.rejected { opacity: .5; }
.comment p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.c-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment-form { display: flex; gap: 8px; align-items: flex-end; }
.comment-form textarea { resize: none; max-height: 160px; }
.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); }
.pill.pending { color: var(--warn); border-color: #5b4a1f; } .pill.rejected, .pill.disabled { color: var(--no); border-color: #5b2232; }
.pill.active { color: var(--ok); border-color: #1f5b45; } .pill.senior { color: var(--accent2); } .pill.admin { color: var(--accent); }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 60; background: #000e; display: grid; place-items: center; animation: fade .2s; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 8px; }
.lightbox .close { position: absolute; top: 14px; left: 14px; background: none; border: 0; color: #fff; font-size: 26px; cursor: pointer; }

/* Drawers */
.drawer { position: fixed; inset: 0; z-index: 50; background: #0009; display: flex; justify-content: flex-start; animation: fade .2s; }
.drawer-panel { width: min(720px, 100%); height: 100%; overflow-y: auto; background: var(--bg); border-inline-end: 1px solid var(--line); padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); animation: slide .25s; }
.drawer-panel.narrow { width: min(400px, 100%); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; font-size: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin: 14px 0 4px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stats b { display: block; font-size: 22px; } .stats span { color: var(--muted); font-size: 12px; }
.stats .hot { border-color: var(--warn); } .stats .hot b { color: var(--warn); }

.upload { display: grid; gap: 8px; margin-bottom: 16px; }
.drop { display: grid; place-items: center; gap: 4px; border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px; cursor: pointer; text-align: center; transition: .2s; }
.drop.over, .drop:hover { border-color: var(--accent); background: #7c6cff11; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.ph { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; gap: 6px; padding-bottom: 8px; }
.ph img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.ph input { margin: 0 8px; width: calc(100% - 16px); padding: 6px 8px; font-size: 13px; }
.ph .row { display: flex; gap: 6px; padding: 0 8px; } .ph .row .mini { flex: 1; }

.seg { display: flex; gap: 6px; margin-bottom: 10px; }
.seg button { border: 1px solid var(--line); background: var(--bg2); border-radius: 99px; padding: 5px 14px; cursor: pointer; color: var(--muted); }
.seg button.active { color: var(--text); border-color: var(--accent); }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.item { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; flex-wrap: wrap; }
.item p { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.item .grow { flex: 1; min-width: 160px; }
.item .col { display: flex; flex-direction: column; gap: 4px; }
.thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent2)); font-weight: 700; flex: none; }
.item.pending { border-color: #5b4a1f; }
.item.rejected, .item.disabled { opacity: .7; }
.ctrl { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border-top: 1px solid var(--line); padding-top: 8px; }
.duration { display: flex; gap: 6px; }
.duration select { width: auto; padding: 4px 8px; font-size: 12px; }
.duration input { width: 80px; padding: 4px 8px; font-size: 12px; }
.grid-form { display: grid; gap: 8px; margin-top: 10px; }
.grid-form .duration select { width: 100%; padding: 10px 12px; font-size: inherit; }
summary { cursor: pointer; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 99; background: var(--card); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; box-shadow: 0 10px 30px #0008; max-width: calc(100% - 32px); text-align: center; animation: fade .2s; }

@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; padding: 8px 12px; }
  .modes { order: 3; flex-basis: 100%; justify-content: flex-start; }
  .brand { flex: 1; }
  .stage { height: 58vh; }
  .mode-coverflow .swiper-slide { width: 68vw; }
  .swiper-button-next, .swiper-button-prev { display: none; }
}

/* ---------- Multi-gallery ---------- */
.back { font-size: 18px; padding: 6px 12px; }
.home { width: min(1100px, 100%); margin: 0 auto; padding: 20px 16px 40px; }
.gal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.gal-card { text-align: start; padding: 0; border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); overflow: hidden; cursor: pointer;
  transition: transform .3s, box-shadow .3s; transform-style: preserve-3d; }
.gal-card:active { transform: scale(.98); }
@media (hover: hover) { .gal-card:hover { transform: perspective(800px) rotateX(4deg) rotateY(-4deg) translateY(-4px); box-shadow: 0 18px 40px #0008; } }
.gal-cover { position: relative; overflow: hidden; aspect-ratio: 16/10; background: linear-gradient(135deg, #2a2550, #1a1c28); display: grid; place-items: center; font-size: 40px; }
.gal-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-body { padding: 12px 14px; display: grid; gap: 4px; }
.gal-body p { margin: 0; }
.empty-msg { text-align: center; color: var(--muted); padding: 60px 0; }
.modal { position: fixed; inset: 0; z-index: 55; background: #000b; display: grid; place-items: center; padding: 16px; animation: fade .2s; }
.modal form { display: grid; gap: 10px; }
.pill.view { color: var(--muted); } .pill.comment { color: var(--ok); border-color: #1f5b45; } .pill.manage { color: var(--accent2); border-color: #4a2f6b; }
.field-label { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; white-space: nowrap; }
.gal-admin h4 { margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
.gal-admin-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; }
.gal-admin .edit { margin-top: 8px; }
.gal-admin .row { display: flex; gap: 8px; }
.members { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.members li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--card); border-radius: 10px; padding: 6px 10px; }
.members li > span:first-child { flex: 1; min-width: 140px; }
.members li.expired { opacity: .55; }
.grant { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.grant select { width: auto; flex: 1; min-width: 130px; padding: 6px 8px; font-size: 13px; }
.grant .btn { padding: 6px 12px; font-size: 13px; }
