/* shared header */
.site-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* hdr btn */
.hdr-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  height: 38px;
  min-width: 38px;
  padding: 0 0.7rem;
  border-radius: 11px;
  border: 1px solid var(--hdr-border, rgba(255, 255, 255, 0.13));
  background: var(--hdr-bg, rgba(255, 255, 255, 0.05));
  color: inherit;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.18s ease, background 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.hdr-btn:hover {
  border-color: rgba(124, 92, 255, 0.65);
  background: rgba(124, 92, 255, 0.12);
}

.hdr-btn .icon { width: 1.15rem; height: 1.15rem; }

/* light theme */
body.light-theme .hdr-btn,
html[data-theme="light"] .hdr-btn {
  --hdr-border: rgba(16, 24, 48, 0.13);
  --hdr-bg: rgba(16, 24, 48, 0.04);
}

.hdr-account-btn { padding: 0 0.35rem 0 0.7rem; }
.hdr-account-btn:not(.is-user) { padding: 0; width: 38px; }
.hdr-user-icon { width: 1.35rem !important; height: 1.35rem !important; }

/* hdr avatar */
.hdr-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c5cff, #00d4ff);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* hdr username */
.hdr-username {
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

/* stacking: keep header controls above page content */
.site-actions { position: relative; z-index: 900; }

.hdr-settings { position: relative; }

/* hdr scrim */
.hdr-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2147482999;
  background: rgba(4, 6, 16, .5);
  backdrop-filter: blur(2px);
}

/* hdr panel: lives on body so no stacking context can bury it */
.hdr-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: min(290px, calc(100vw - 32px));
  background: var(--hdr-panel-bg, rgba(14, 14, 26, 0.98));
  border: 1px solid var(--hdr-panel-border, rgba(124, 92, 255, 0.3));
  border-radius: 16px;
  padding: 14px;
  z-index: 2147483000;
  color: inherit;
  direction: rtl;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4);
}

body.light-theme .hdr-scrim,
html[data-theme="light"] .hdr-scrim { background: rgba(30, 34, 66, .3); }

body.light-theme .hdr-panel,
html[data-theme="light"] .hdr-panel {
  --hdr-panel-bg: rgba(255, 255, 255, 0.99);
  --hdr-panel-border: rgba(16, 24, 48, 0.12);
  box-shadow: 0 18px 44px rgba(20, 30, 60, 0.16);
}

.hdr-panel.open { opacity: 1; visibility: visible; transform: translateY(0); }

.hdr-panel h3 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 3px;
  color: #00d4ff;
}

body.light-theme .hdr-panel h3,
html[data-theme="light"] .hdr-panel h3 { color: #0b5cad; }

.hdr-panel-sub {
  font-size: 0.7rem;
  opacity: 0.65;
  margin: 0 0 11px;
  line-height: 1.8;
}

.hdr-options { display: flex; flex-direction: column; gap: 5px; }

/* hdr option */
.hdr-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.035);
  color: inherit;
  font-family: inherit;
  font-size: 0.79rem;
  cursor: pointer;
  text-align: right;
  transition: border-color 0.16s ease, background 0.16s ease;
}

body.light-theme .hdr-option,
html[data-theme="light"] .hdr-option {
  border-color: rgba(16, 24, 48, 0.1);
  background: rgba(16, 24, 48, 0.03);
}

.hdr-option:hover { border-color: rgba(0, 212, 255, 0.5); }

.hdr-option[aria-checked="true"] {
  border-color: #7c5cff;
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.22), rgba(0, 212, 255, 0.13));
}

/* hdr badge */
.hdr-badge {
  font-size: 0.61rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 212, 255, 0.15);
  color: #00d4ff;
  white-space: nowrap;
}

body.light-theme .hdr-badge,
html[data-theme="light"] .hdr-badge {
  background: rgba(0, 102, 204, 0.11);
  color: #0b5cad;
}

/* hdr panel */
.hdr-panel-meta {
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.66rem;
  opacity: 0.62;
  line-height: 1.95;
  word-break: break-word;
}

body.light-theme .hdr-panel-meta,
html[data-theme="light"] .hdr-panel-meta { border-top-color: rgba(16, 24, 48, 0.1); }

/* hdr recheck */
.hdr-recheck {
  width: 100%;
  margin-top: 10px;
  padding: 7px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

body.light-theme .hdr-recheck,
html[data-theme="light"] .hdr-recheck { border-color: rgba(16, 24, 48, 0.13); }
.hdr-recheck:disabled { opacity: 0.5; cursor: default; }

/* toast stack */
.toast-stack {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(440px, calc(100vw - 28px));
  pointer-events: none;
}

/* toast */
.toast {
  pointer-events: auto;
  background: rgba(14, 14, 26, 0.98);
  border: 1px solid rgba(124, 92, 255, 0.4);
  border-radius: 13px;
  padding: 12px 15px;
  color: #f2f2ff;
  font-family: var(--font-family, "Vazirmatn", sans-serif);
  font-size: 0.78rem;
  line-height: 1.9;
  direction: rtl;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.24s ease, transform 0.24s ease;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42);
}

body.light-theme .toast,
html[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.99);
  color: #16182b;
  border-color: rgba(106, 75, 255, 0.28);
  box-shadow: 0 16px 40px rgba(20, 30, 60, 0.16);
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast-warn { border-color: rgba(255, 176, 32, 0.5); }
.toast-error { border-color: rgba(255, 82, 118, 0.5); }

.toast-actions { display: flex; gap: 8px; margin-top: 9px; }

/* toast btn */
.toast-btn {
  flex: 1;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: none;
  color: inherit;
  font-family: inherit;
  font-size: 0.73rem;
  cursor: pointer;
}

body.light-theme .toast-btn,
html[data-theme="light"] .toast-btn { border-color: rgba(16, 24, 48, 0.14); }

.toast-btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, #7c5cff, #00d4ff);
  color: #fff;
  font-weight: 700;
}

/* mobile 768px */
@media (max-width: 768px) {
  .site-actions { gap: 0.35rem; }
  .hdr-username { display: none; }
  .hdr-account-btn.is-user { padding: 0; width: 38px; }
  .toast-stack { bottom: 16px; }
}

a.logo,
a.auth-brand,
/* a */
a.topbar-left {
  text-decoration: none;
  color: inherit;
  transition: opacity 0.18s ease;
}

a.logo:hover,
a.auth-brand:hover,
a.topbar-left:hover { opacity: 0.82; }

a.topbar-left { display: flex; align-items: center; gap: 12px; }

/* hdr badge */
.hdr-badge {
  font-size: .62rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #7c5cff, #00d4ff);
  white-space: nowrap;
}

/* hdr account */
.hdr-account-btn.is-admin {
  border-color: rgba(124, 92, 255, .45);
  background: rgba(124, 92, 255, .12);
}

/* mobile 560px */
@media (max-width: 560px) {
  .hdr-badge { display: none; }
}

/* narrow: bottom sheet, never clipped by the header */
@media (max-width: 768px) {
  .hdr-scrim.open { display: block; }

  .hdr-panel {
    inset: auto 0 0 0 !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100%;
    max-width: none;
    max-height: min(78vh, 560px);
    border-radius: 20px 20px 0 0;
    border-inline: 0;
    border-bottom: 0;
    padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
    transform: translateY(14px);
    box-shadow: 0 -18px 44px rgba(0, 0, 0, .45);
  }

  .hdr-panel::before {
    content: "";
    display: block;
    width: 44px;
    height: 4px;
    margin: -4px auto 12px;
    border-radius: 999px;
    background: currentColor;
    opacity: .22;
  }

  .hdr-panel.open { transform: translateY(0); }
}

/* announcement bar */
.site-announcement {
  position: relative;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .65rem clamp(.8rem, 4vw, 1.4rem);
  font-size: clamp(.76rem, 3vw, .86rem);
  line-height: 1.9;
  color: #1c1204;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  box-shadow: 0 2px 14px rgba(0, 0, 0, .28);
}

.site-announcement > span { flex: 1; min-width: 0; }

.site-announcement .icon { flex-shrink: 0; font-size: 1.05em; }

.site-announcement-close {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, .12);
  color: inherit;
  cursor: pointer;
  font-size: .72rem;
}

.site-announcement-close:hover { background: rgba(0, 0, 0, .22); }
