/* ==========================================================================
   آزمایشگاه راه آهن دانشگاه اصفهان — استایل مشترک
   فهرست:
   1. فونت  2. متغیرها (توکن‌ها)  3. ریست و پایه  4. تایپوگرافی  5. چیدمان
   6. هدر و ناوبری  7. دکمه‌ها  8. هرو  9. نوار دسته‌ها  10. کارت‌ها و بخش‌ها
   11. خبرها  12. دسترسی سریع  13. مشتریان  14. فوتر  15. حالت تاریک
   16. واکنش‌گرایی  17. دسترس‌پذیری
   ========================================================================== */

/* 1. فونت (فایل‌ها را در static/fonts قرار دهید) */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500; font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700; font-display: swap;
}

/* 2. متغیرها */
:root {
  /* رنگ */
  --navy: #142B50;
  --blue: #2459A6;
  --sky: #4DA3F5;
  --bg: #F5F7FB;
  --surface: #FFFFFF;
  --text: #142B50;
  --text-muted: #5B6B82;
  --line: #E3E8F1;
  --header-bg: var(--navy);
  --on-navy: #FFFFFF;
  --on-navy-muted: #B9C6DD;

  /* فونت */
  --font: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
  --fs-xs: .8125rem;
  --fs-sm: .875rem;
  --fs-base: 1rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-hero: clamp(1.75rem, 4vw, 2.75rem);
  --lh: 1.9;

  /* فاصله */
  --sp-1: .25rem; --sp-2: .5rem; --sp-3: .75rem; --sp-4: 1rem;
  --sp-5: 1.5rem; --sp-6: 2rem; --sp-7: 3rem; --sp-8: 4.5rem;

  /* شکل */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 3px rgb(20 43 80 / .08);
  --shadow: 0 6px 24px rgb(20 43 80 / .10);

  /* چیدمان */
  --container: 1200px;
  --header-h: 82px;
  --ease: .2s ease;
  --fade-dir: to left;
  --fade-mid: rgb(245 247 251 / .92);
}
[dir="ltr"] { --fade-dir: to right; }

/* 3. ریست و پایه */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: var(--lh);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
main { flex: 1; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; border-radius: 4px; }

/* متن لاتین و عددها داخل متن فارسی */
body [lang="en"], .ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

.icon { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor;
        stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.flip-rtl { transform: none; }
[dir="ltr"] .flip-rtl { transform: scaleX(-1); }

/* 4. تایپوگرافی */
h1, h2, h3, h4 { line-height: 1.4; font-weight: 700; }
h1 { font-size: var(--fs-hero); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
h4 { font-size: var(--fs-base); }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }

/* 5. چیدمان */
.container { width: min(100% - 2 * var(--sp-5), var(--container)); margin-inline: auto; }
.section { padding-block: var(--sp-7); }
.grid-3 { display: grid; gap: var(--sp-5);
          grid-template-columns: 1fr 1.6fr 1fr; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line);
         border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.panel__body { padding: var(--sp-5); }
.panel__title { display: flex; align-items: center; gap: var(--sp-3);
                font-size: var(--fs-lg); margin-bottom: var(--sp-4); }
.panel__title .icon { color: var(--blue); width: 1.6em; height: 1.6em; }

/* 6. هدر و ناوبری */
.site-header { position: sticky; top: 0; z-index: 50; background: var(--header-bg);
               color: var(--on-navy); min-height: var(--header-h); }
.site-header__inner { display: flex; align-items: center; gap: var(--sp-5);
                      min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: var(--sp-4); }
.brand__logo { width: 62px; height: 62px; object-fit: contain; }
.brand__text { line-height: 1.5; padding-inline-start: var(--sp-4);
               border-inline-start: 1px solid rgb(255 255 255 / .25); }
.brand__text strong { display: block; font-size: var(--fs-md); }
.brand__text span { font-size: var(--fs-xs); color: var(--on-navy-muted); }

.main-nav { margin-inline: auto; }
.main-nav__list { display: flex; align-items: center; gap: var(--sp-5); }
.main-nav__link { display: inline-flex; align-items: center; gap: var(--sp-2);
                  padding-block: var(--sp-2); font-size: var(--fs-sm); font-weight: 500;
                  border-bottom: 2px solid transparent; color: var(--on-navy);
                  transition: color var(--ease), border-color var(--ease); }
.main-nav__link:hover { color: var(--sky); }
.main-nav__link[aria-current="page"] { color: var(--sky); border-color: var(--sky); }
.main-nav__link .icon { width: 1em; height: 1em; }

.header-tools { display: flex; align-items: center; gap: var(--sp-3); }
.tool-btn { width: 40px; height: 40px; display: grid; place-items: center;
            border-radius: var(--radius-pill); background: rgb(255 255 255 / .1);
            transition: background var(--ease); }
.tool-btn:hover { background: rgb(255 255 255 / .2); }
.lang-switch { display: flex; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--on-navy-muted); }
.lang-switch a[aria-current="true"] { color: var(--on-navy); font-weight: 700; }
.nav-toggle { display: none; }

/* 7. دکمه‌ها */
.btn { display: inline-flex; align-items: center; gap: var(--sp-3);
       padding: .65rem 1.5rem; border-radius: var(--radius-pill);
       font-weight: 500; font-size: var(--fs-sm);
       background: var(--navy); color: #fff; box-shadow: var(--shadow-sm);
       transition: background var(--ease), transform var(--ease); }
.btn:hover { background: var(--blue); transform: translateY(-1px); }
.btn--light { background: #fff; color: var(--navy); }
.btn--light:hover { background: var(--bg); }
.link-more { display: inline-flex; align-items: center; gap: var(--sp-2);
             color: var(--blue); font-size: var(--fs-sm); font-weight: 500; }
.link-more:hover { text-decoration: underline; }

/* 8. هرو */
.hero { position: relative; min-height: 460px; display: flex; align-items: center;
        background: var(--navy) var(--hero-image, none) center / cover no-repeat;
        padding-bottom: 90px; isolation: isolate; }
.hero::before { /* محو شدن تصویر به سمت متن */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(var(--fade-dir), var(--bg) 0%, var(--fade-mid) 38%, transparent 68%); }
.hero__content { max-width: 560px; margin-inline-start: 0; margin-inline-end: auto;
                 padding-block: var(--sp-7);position: relative; z-index: 2; }
.hero__tagline { display: flex; align-items: center; gap: var(--sp-3);
                 color: var(--blue); font-size: var(--fs-sm); margin-bottom: var(--sp-4); }
.hero__tagline::before { content: ""; width: 120px; height: 1px; background: var(--blue); }
.hero h1 { color: var(--text); margin-bottom: var(--sp-4); }
.hero h1 em { font-style: normal; color: var(--blue); }
.hero p { color: var(--text-muted); font-size: var(--fs-md); margin-bottom: var(--sp-5); }
.hero__dots { position: absolute; bottom: 120px; inset-inline-end: var(--sp-6);
              display: flex; gap: var(--sp-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: rgb(255 255 255 / .8);
       transition: transform var(--ease), background var(--ease); }
.dot.active { background: var(--sky); transform: scale(1.3); }

/* 9. نوار دسته‌ها (روی لبه‌ی هرو) */
.category-strip { position: relative; z-index: 2; margin-top: -64px; }
.category-strip__list { display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; }
.category { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-3); font-size: var(--fs-sm); font-weight: 500;
  color: var(--navy); text-align: center; transition: color var(--ease), background var(--ease); }
.category + .category { border-inline-start: 1px solid var(--line); }
.category .icon { width: 2.4rem; height: 2.4rem; color: var(--blue); }
.category:hover { color: var(--blue); background: var(--bg); }


/* 10. کارت‌ها و بخش‌های محتوا */
.about { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); align-items: center; }
.about__img { border-radius: var(--radius-sm); aspect-ratio: 4 / 3; object-fit: cover; width: 100%; }
.about__text p { color: var(--text-muted); margin-bottom: var(--sp-4); text-align: justify; }

.banner { background: var(--navy); color: var(--on-navy); border-radius: var(--radius);
          padding: var(--sp-6); display: flex; align-items: center;
          justify-content: space-between; gap: var(--sp-5); flex-wrap: wrap; }
.banner p { color: var(--on-navy-muted); }

/* 11. خبرها */
.news-list { display: flex; flex-direction: column; }
.news-item { display: flex; gap: var(--sp-4); align-items: center; padding-block: var(--sp-4);
             border-bottom: 1px solid var(--line); }
.news-item:first-child { padding-top: 0; }
.news-item__thumb { width: 96px; height: 72px; flex: none; border-radius: var(--radius-sm);
                    object-fit: cover; background: var(--bg); }
.news-item h4 { font-size: var(--fs-sm); line-height: 1.7; transition: color var(--ease); }
.news-item:hover h4 { color: var(--blue); }
.news-item time { font-size: var(--fs-xs); color: var(--text-muted); }
.panel__footer { padding-top: var(--sp-3); }

/* 12. دسترسی سریع */
.quick { background: var(--surface); }
.quick .panel__head { background: var(--navy); color: #fff; padding: var(--sp-4) var(--sp-5);
                      display: flex; align-items: center; justify-content: space-between; }
.quick .panel__head .icon { color: var(--sky); width: 1.6em; height: 1.6em; }
.quick__list { padding: var(--sp-3) var(--sp-5) var(--sp-5); }
.quick__link { display: flex; align-items: center; justify-content: space-between;
               padding-block: var(--sp-3); border-bottom: 1px solid var(--line);
               font-size: var(--fs-sm); transition: color var(--ease), padding var(--ease); }
.quick__link:hover { color: var(--blue); padding-inline-start: var(--sp-2); }
.quick__link .icon { width: 1em; height: 1em; color: var(--text-muted); }
.quick__art { height: 90px; background: var(--quick-art, none) bottom / cover no-repeat; opacity: .6; }

/* 13. مشتریان */
.clients { overflow: hidden; }
.clients__track { display: flex; gap: var(--sp-6); align-items: center; width: max-content;
                  animation: marquee 40s linear infinite; }
.clients:hover .clients__track { animation-play-state: paused; }
.client-logo { width: 150px; height: 70px; flex: none; display: grid; place-items: center; }
.client-logo img { max-height: 60px; width: auto; filter: grayscale(1); opacity: .75;
                   transition: filter var(--ease), opacity var(--ease); }
.client-logo:hover img { filter: none; opacity: 1; }
@keyframes marquee { to { transform: translateX(-50%); } }
[dir="rtl"] .clients__track { animation-name: marquee-rtl; }
@keyframes marquee-rtl { to { transform: translateX(50%); } }

/* 14. فوتر */
.site-footer { position: relative; overflow: hidden; isolation: isolate;
               background: var(--navy); color: var(--on-navy); margin-top: var(--sp-7);
               --skyline-opacity: .35;
               --skyline-h: clamp(130px, 18vw, 250px);
               min-height: calc(var(--skyline-h) + 80px); }

/* افق اصفهان: وسط فوتر، چسبیده به پایین، با محو شدن دو طرف */
.site-footer::before {
  content: ""; position: absolute; inset-inline: 0; bottom: 0; z-index: -1;
  height: var(--skyline-h);
  background: var(--skyline, none) center bottom / 100% auto no-repeat;
  opacity: var(--skyline-opacity);
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 22%, #000 78%, transparent);
          mask-image: linear-gradient(to right, transparent, #000 22%, #000 78%, transparent);
}
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--sp-6);
               padding-block: var(--sp-7) var(--sp-5); }
.footer-title { font-size: var(--fs-md); margin-bottom: var(--sp-3); }
.footer-list li + li { margin-top: var(--sp-2); }
.footer-list a { color: var(--on-navy-muted); font-size: var(--fs-sm); transition: color var(--ease); }
.footer-list a:hover { color: #fff; }
.footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
                 flex-wrap: wrap; padding-block: var(--sp-4);
                 border-top: 1px solid rgb(255 255 255 / .15);
                 font-size: var(--fs-xs); color: var(--on-navy-muted); }
.social { display: flex; gap: var(--sp-3); }
.social a { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%;
            background: #fff; color: var(--navy); transition: background var(--ease); }
.social a:hover { background: var(--sky); }

/* 15. حالت تاریک */
[data-theme="dark"] {
  --bg: #0D1B33; --surface: #14264A; --text: #E8EEF8; --text-muted: #9FB0CB;
  --line: #243A63; --fade-mid: rgb(13 27 51 / .9); --header-bg: #0A1529; --shadow: 0 6px 24px rgb(0 0 0 / .4);
}
[data-theme="dark"] .category, [data-theme="dark"] .hero h1 { color: var(--text); }
[data-theme="dark"] .hero__tagline, [data-theme="dark"] .hero h1 em { color: var(--sky); }
[data-theme="dark"] .btn { background: var(--blue); }

/* 16. واکنش‌گرایی */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > .quick { grid-column: 1 / -1; order: 3; }
}
@media (max-width: 960px) {
  .nav-toggle { display: grid; }
  .main-nav { position: absolute; inset-inline: 0; top: 100%; margin: 0;
              background: var(--header-bg); border-top: 1px solid rgb(255 255 255 / .15);
              max-height: 0; overflow: hidden; visibility: hidden; transition: max-height .3s ease, visibility .3s;}
  .main-nav.is-open { max-height: 80vh; overflow-y: auto; visibility: visible;}
  .main-nav__list { flex-direction: column; align-items: stretch; gap: 0; padding: var(--sp-3) var(--sp-5); }
  .main-nav__link { width: 100%; padding-block: var(--sp-3); border-bottom: 1px solid rgb(255 255 255 / .1); }
  .header-tools { margin-inline-start: auto; }
  .brand__text { display: none; }
  .category-strip__list { grid-template-columns: repeat(3, 1fr); }
  .category:nth-child(n+4) { border-top: 1px solid var(--line); }
  .category:nth-child(4) { border-inline-start: 0; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .hero { min-height: 0; padding-bottom: 80px; background-position: 25% center; }
  :root, [dir="ltr"] { --fade-dir: to top; }
  .hero__content { padding-top: 14rem; margin-inline: 0; }
  .hero__dots { display: none; }
  .grid-3, .about, .footer-grid { grid-template-columns: 1fr; }
  .category-strip__list { grid-template-columns: repeat(2, 1fr); }
  .category + .category { border-inline-start: 0; }
  .category { border-top: 1px solid var(--line); }
  .banner { flex-direction: column; align-items: flex-start; }
}

/* 17. دسترس‌پذیری */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- اسلایدر هرو ---------- */
.hero__slides { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.hero__slide { position: absolute; inset: 0; width: 100%; height: 100%;
               object-fit: cover; opacity: 0; transition: opacity .9s ease; }
.hero__slide.is-active { opacity: 1; }

.hero__dots { align-items: center; z-index: 1; }
.dot { position: relative; padding: 0; }
.dot::after { content: ""; position: absolute; inset: -10px; } /* سطح لمس بزرگ‌تر */
.hero__pause { width: 28px; height: 28px; display: grid; place-items: center;
               margin-inline-start: var(--sp-2); border-radius: 50%;
               background: rgb(20 43 80 / .55); color: #fff; }
.hero__pause:hover { background: var(--blue); }
.hero__pause .icon { width: 14px; height: 14px; }
.hero__pause .icon-play { display: none; }
.hero__pause[aria-pressed="true"] .icon-pause { display: none; }
.hero__pause[aria-pressed="true"] .icon-play { display: block; fill: currentColor; }

/* ---------- جستجوی زنده ---------- */
.search-panel { position: absolute; inset-inline: 0; top: 100%;
                background: var(--surface); color: var(--text);
                border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
                padding-block: var(--sp-4); }
.search-panel[hidden] { display: none; }
.search-box { display: flex; align-items: center; gap: var(--sp-3);
              padding-inline: var(--sp-4); background: var(--bg);
              border: 1px solid var(--line); border-radius: var(--radius-pill); }
.search-box:focus-within { border-color: var(--sky); box-shadow: 0 0 0 3px rgb(77 163 245 / .25); }
.search-box .icon { color: var(--text-muted); }
.search-box input { flex: 1; min-width: 0; border: 0; background: transparent;
                    font: inherit; color: inherit; padding-block: .7rem; }
.search-box input:focus-visible { outline: 0; }

.search-results { margin-top: var(--sp-3); max-height: min(50vh, 420px); overflow-y: auto; }
.search-hit { display: block; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius-sm); }
.search-hit:hover, .search-hit[aria-selected="true"] { background: var(--bg); }
.search-hit__meta { font-size: var(--fs-xs); color: var(--blue); }
.search-hit__title { font-weight: 500; }
.search-hit__snippet { font-size: var(--fs-sm); color: var(--text-muted); }
.search-hit mark { background: rgb(77 163 245 / .28); color: inherit; border-radius: 3px; padding-inline: 2px; }
.search-status { margin: var(--sp-2) 0 0; padding-inline: var(--sp-4);
                 font-size: var(--fs-sm); color: var(--text-muted); }
.search-status:empty { display: none; }

@media (max-width: 700px) {
  .hero__slide { object-position: 25% center; }
  .hero__dots { display: flex; bottom: 88px; }
}

/* ---------- انیمیشن ورود بخش‌ها ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity .7s ease, transform .7s ease;
  transition-delay: var(--reveal-delay, 0s);
}
.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

/* ورود متن هرو هنگام بارگذاری صفحه */
@keyframes hero-rise { from { opacity: 0; transform: translateY(20px); } }
.hero__content { animation: hero-rise .8s ease both; }

/* ---------- حالت انگلیسی ---------- */
[dir="ltr"] .btn .icon { transform: scaleX(-1); }
html[lang="en"] .brand__text span { display: none; } /* خط لاتین تکراری */

@media (max-width: 700px) {
  .site-footer { --skyline-h: 100px; --skyline-opacity: .25; }
}

/* ---------- صفحه‌های داخلی ---------- */
/* سربرگ صفحات داخلی */
.page-head {
    position: relative;
    isolation: isolate;
    overflow: hidden;

    background: var(--navy);
    color: var(--on-navy);
    padding-block: var(--sp-7);
}

/* تصویر نگارگری */
.page-head::after {
    content: "";

    position: absolute;
    inset: 0;
    z-index: 0;

    background-image: url("../images/isfahan_sign.png");
    background-repeat: no-repeat;
    background-position: left center;
    background-size: 100% auto;
    opacity: 0.15;
    pointer-events: none;
}

/* قرار گرفتن نوشته‌ها روی تصویر */
.page-head > .container {
    position: relative;
    z-index: 1;
}
.page-head h1 { font-size: var(--fs-xl); margin-bottom: var(--sp-3); }
.page-head p { color: var(--on-navy-muted); max-width: 60ch; }
.breadcrumb { display: flex; gap: var(--sp-2); font-size: var(--fs-sm);
              color: var(--on-navy-muted); margin-bottom: var(--sp-4); }
.breadcrumb a:hover { color: #fff; }
.breadcrumb a::after { content: "/"; margin-inline-start: var(--sp-2); }

.card-grid { display: grid; gap: var(--sp-5);
             grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { display: flex; flex-direction: column; background: var(--surface);
        border: 1px solid var(--line); border-radius: var(--radius);
        box-shadow: var(--shadow-sm); overflow: hidden;
        transition: border-color var(--ease), box-shadow var(--ease); }
.card:hover { border-color: var(--sky); box-shadow: var(--shadow); }
.card__img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card__body { padding: var(--sp-5); }
.card__title { font-size: var(--fs-md); margin-bottom: var(--sp-3); }
.card__text { color: var(--text-muted); font-size: var(--fs-sm); white-space: pre-line; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--text-muted); padding-block: var(--sp-6); }
.page-back { display: flex; justify-content: center; margin-top: var(--sp-7); }
[dir="ltr"] .breadcrumb a::after { margin-inline-start: var(--sp-2); }

.card__date { display: block; font-size: var(--fs-xs); color: var(--text-muted);
              margin-bottom: var(--sp-2); }

/* ---------- درباره و تماس ---------- */
.about-contact { display: grid; grid-template-columns: 1.3fr 1fr; gap: var(--sp-5); align-items: start; }
.about-contact__img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
                      border-radius: var(--radius-sm); margin-bottom: var(--sp-4); }
.info-list li { display: flex; flex-direction: column; gap: 2px;
                padding-block: var(--sp-3); border-bottom: 1px solid var(--line); }
.info-list li:first-child { padding-top: 0; }
.info-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.info-list__label { font-size: var(--fs-xs); color: var(--text-muted); }
.info-list a { color: var(--blue); }
.info-list a:hover { text-decoration: underline; }
@media (max-width: 900px) { .about-contact { grid-template-columns: 1fr; } }

[hidden] { display: none !important; }

.auth-page {
  --danger: #B3261E;
  --danger-bg: rgb(217 48 37 / .08);
  --success: #188038;
  --success-bg: rgb(24 128 56 / .09);
}
[data-theme="dark"] .auth-page {
  --danger: #FF8A80;
  --danger-bg: rgb(255 138 128 / .12);
  --success: #81C995;
  --success-bg: rgb(129 201 149 / .14);
}

/* ---------- نوار بالا: فقط نشان آزمایشگاه ---------- */
.auth-hero {
  background: var(--header-bg);
  color: var(--on-navy);
  padding: var(--sp-4) 0 calc(var(--sp-8) + var(--sp-4));
}
.auth-hero .container {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-4);
}
.auth-back {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-sm); color: var(--on-navy-muted);
  transition: color var(--ease);
}
.auth-back:hover { color: #fff; }
.auth-back .icon { width: 1em; height: 1em; transform: scaleX(-1); }
[dir="ltr"] .auth-back .icon { transform: none; }

.auth-brand { display: flex; align-items: center; gap: var(--sp-4); }
.auth-brand img { width: 56px; height: 56px; object-fit: contain; }
.auth-brand__text { line-height: 1.5; }
.auth-brand__text strong { display: block; font-size: var(--fs-md); }
.auth-brand__text span { font-size: var(--fs-xs); color: var(--on-navy-muted); }

/* ---------- کارت اصلی (روی لبه‌ی نوار، مثل نوار دسته‌ها در صفحه‌ی اصلی) ---------- */
.auth {
  flex: 1;
  position: relative; z-index: 1;
  width: min(100% - 2 * var(--sp-4), 440px);
  margin: calc(-1 * var(--sp-7)) auto 0;
  padding-bottom: var(--sp-7);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-6) var(--sp-5);
}
.auth-note {
  margin-top: var(--sp-4); text-align: center;
  font-size: var(--fs-xs); color: var(--text-muted);
}

/* ---------- نوار مراحل (فقط برای مسیر ثبت‌نام) ---------- */
.stepper {
  display: flex; margin: 0 0 var(--sp-6); padding: 0; list-style: none;
}
.stepper li {
  position: relative; flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  font-size: var(--fs-xs); color: var(--text-muted); text-align: center;
}
.stepper li:not(:last-child)::after {
  content: ""; position: absolute; top: 15px;
  inset-inline-start: calc(50% + 24px);
  width: calc(100% - 48px); height: 2px;
  background: var(--line); transition: background var(--ease);
}
.stepper__dot {
  width: 32px; height: 32px; display: grid; place-items: center;
  border-radius: 50%; border: 2px solid var(--line);
  background: var(--surface); font-weight: 500; font-size: var(--fs-sm);
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.stepper__check { display: none; width: 1rem; height: 1rem; stroke-width: 2.4; }
.stepper li.is-current { color: var(--text); font-weight: 500; }
.stepper li.is-current .stepper__dot { border-color: var(--blue); color: var(--blue); }
.stepper li.is-done .stepper__dot { background: var(--blue); border-color: var(--blue); color: #fff; }
.stepper li.is-done .stepper__num { display: none; }
.stepper li.is-done .stepper__check { display: block; }
.stepper li.is-done::after { background: var(--blue); }
[data-theme="dark"] .stepper li.is-current .stepper__dot { border-color: var(--sky); color: var(--sky); }

/* ---------- پیام‌ها ---------- */
.auth-message {
  margin: 0 0 var(--sp-4); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm); font-size: var(--fs-sm);
  border-inline-start: 3px solid currentColor;
}
.auth-message[data-type="error"]   { color: var(--danger);  background: var(--danger-bg); }
.auth-message[data-type="success"] { color: var(--success); background: var(--success-bg); }

/* ---------- مرحله‌ها ---------- */
.step { animation: step-in .25s ease both; }
@keyframes step-in { from { opacity: 0; transform: translateY(6px); } }

.step h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-2); }
.step__lead { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-5); }

/* ---------- فیلدها ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.field label { font-size: var(--fs-sm); font-weight: 500; }
.field input {
  width: 100%; height: 48px; padding-inline: var(--sp-4);
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field input::placeholder { color: var(--text-muted); opacity: .8; }
.field input:focus { outline: 0; border-color: var(--sky); box-shadow: 0 0 0 3px rgb(77 163 245 / .25); }
.field input[dir="ltr"] { text-align: left; }
.field__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }

/* کد ۶ رقمی: حروف جدا، ولی متن راهنما (فارسی) نباید حروفش از هم باز شود */
#verification-code {
  text-align: center; letter-spacing: .4em; font-size: var(--fs-lg);
}
#verification-code::placeholder { letter-spacing: normal; font-size: var(--fs-base); }

/* ---------- کد امنیتی ---------- */
.captcha { display: flex; align-items: stretch; gap: var(--sp-3); }
.captcha__img {
  flex: 1; min-width: 0; min-height: 56px; padding: 4px;
  display: grid; place-items: center;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.captcha__img img { max-height: 48px; width: auto; }
.icon-btn {
  width: 56px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--blue); background: var(--bg);
  transition: border-color var(--ease), background var(--ease);
}
.icon-btn:hover { border-color: var(--sky); }
[data-theme="dark"] .icon-btn { color: var(--sky); }

/* ---------- دکمه‌ها ---------- */
.btn-primary {
  width: 100%; height: 48px; margin-top: var(--sp-2);
  border-radius: var(--radius-pill);
  background: var(--navy); color: #fff; font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: background var(--ease), transform var(--ease);
}
.btn-primary:hover { background: var(--blue); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .6; cursor: wait; transform: none; }
[data-theme="dark"] .btn-primary { background: var(--blue); }
[data-theme="dark"] .btn-primary:hover { background: var(--sky); }

.step__links {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: var(--sp-1) var(--sp-4); margin-top: var(--sp-4);
}
.link-button {
  padding: var(--sp-1) 0; font-size: var(--fs-sm); font-weight: 500; color: var(--blue);
}
.link-button:hover { text-decoration: underline; }
.link-button:disabled { color: var(--text-muted); cursor: not-allowed; text-decoration: none; }
[data-theme="dark"] .link-button:not(:disabled) { color: var(--sky); }

/* ---------- پایان ثبت‌نام ---------- */
.step--done { text-align: center; }
.done-mark {
  width: 64px; height: 64px; margin: 0 auto var(--sp-4);
  display: grid; place-items: center; border-radius: 50%;
  background: var(--success-bg); color: var(--success);
}
.done-mark .icon { width: 32px; height: 32px; stroke-width: 2; }

/* ---------- موبایل ---------- */
@media (max-width: 480px) {
  .auth-card { padding: var(--sp-5) var(--sp-4); }
  .field-row { grid-template-columns: 1fr; gap: 0; }
}

.auth--wide { width: min(100% - 2 * var(--sp-4), 640px); }

/* ---------- نوار بالا: نام و سطح کاربر ---------- */
.profile-bar {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.profile-bar .auth-back { align-self: auto; }
.profile-bar__end { display: flex; align-items: center; gap: var(--sp-4); }
.bar-link {
  font-size: var(--fs-sm); color: var(--on-navy-muted);
  transition: color var(--ease);
}
.bar-link:hover { color: #fff; }

.profile-id {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-2); text-align: center;
}
.avatar {
  width: 72px; height: 72px; display: grid; place-items: center;
  border-radius: 50%; background: var(--blue); color: #fff;
  border: 3px solid rgb(255 255 255 / .2);
  font-size: var(--fs-xl); font-weight: 700; line-height: 1;
}
.profile-id h1 { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.role-badge {
  padding: 2px var(--sp-4); border-radius: var(--radius-pill);
  background: rgb(255 255 255 / .12); color: var(--on-navy);
  font-size: var(--fs-xs);
}

/* ---------- زبانه‌ها ---------- */
.tabs {
  display: flex; gap: var(--sp-2);
  margin-bottom: var(--sp-5); border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-2); margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-weight: 500; color: var(--text-muted);
  transition: color var(--ease), border-color var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-color: var(--blue); }
[data-theme="dark"] .tab[aria-selected="true"] { border-color: var(--sky); }

.count {
  min-width: 1.4rem; padding-inline: 6px; border-radius: var(--radius-pill);
  background: var(--blue); color: #fff; text-align: center;
  font-size: var(--fs-xs); line-height: 1.4rem;
}

.section-title { font-size: var(--fs-md); margin: var(--sp-6) 0 var(--sp-2); }

/* ---------- فرم اطلاعات ---------- */
.field select {
  width: 100%; height: 48px; padding-inline: var(--sp-3);
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field select:focus { outline: 0; border-color: var(--sky); box-shadow: 0 0 0 3px rgb(77 163 245 / .25); }

.birth { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: var(--sp-3); }
.optional { color: var(--text-muted); font-weight: 400; }

/* ---------- اطلاعات حساب (فقط خواندنی) ---------- */
.account { margin: 0; }
.account__row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding-block: var(--sp-3); border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.account__row:last-child { border-bottom: 0; }
.account dt { color: var(--text-muted); flex: none; }
.account dd {
  margin: 0; font-weight: 500; overflow-wrap: anywhere;
  display: flex; align-items: center; gap: var(--sp-3);
}
.not-set { color: var(--text-muted); font-weight: 400; }
.copy-btn {
  flex: none; padding: 2px var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: var(--fs-xs); color: var(--blue);
  transition: border-color var(--ease);
}
.copy-btn:hover { border-color: var(--sky); }
[data-theme="dark"] .copy-btn { color: var(--sky); }

/* ---------- صندوق پیام ---------- */
.inbox-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.inbox-head h2 { font-size: var(--fs-md); }

.inbox {
  margin: 0; padding: 0; list-style: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
}
.msg + .msg { border-top: 1px solid var(--line); }
.msg summary {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); cursor: pointer; list-style: none;
}
.msg summary::-webkit-details-marker { display: none; }
.msg summary:hover { background: var(--bg); }
.msg[open] summary { background: var(--bg); }

.msg__dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: transparent; }
.msg.is-unread .msg__dot { background: var(--blue); }
[data-theme="dark"] .msg.is-unread .msg__dot { background: var(--sky); }
.msg__title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg.is-unread .msg__title { font-weight: 700; }
.msg__date { flex: none; font-size: var(--fs-xs); color: var(--text-muted); }

.msg__body, .msg__foot {
  padding-inline: var(--sp-4);
  padding-inline-start: calc(var(--sp-4) + 8px + var(--sp-3));
}
.msg__body { padding-top: var(--sp-3); white-space: pre-line; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.msg__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding-block: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs); color: var(--text-muted);
}
.link-button--danger:not(:disabled), [data-theme="dark"] .link-button--danger:not(:disabled) { color: var(--danger); }

.inbox-empty { padding-block: var(--sp-6); text-align: center; color: var(--text-muted); }

@media (max-width: 480px) {
  .birth { grid-template-columns: 1fr 1.4fr 1.2fr; gap: var(--sp-2); }
  .account__row { flex-direction: column; align-items: flex-start; gap: 0; }
}



.auth--wide { width: min(100% - 2 * var(--sp-4), 640px); }

/* ---------- نوار بالا: نام و سطح کاربر ---------- */
.profile-bar {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
}
.profile-bar .auth-back { align-self: auto; }
.profile-bar__end { display: flex; align-items: center; gap: var(--sp-4); }
.bar-link {
  font-size: var(--fs-sm); color: var(--on-navy-muted);
  transition: color var(--ease);
}
.bar-link:hover { color: #fff; }

.profile-id {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--sp-2); text-align: center;
}
.avatar {
  width: 72px; height: 72px; display: grid; place-items: center;
  border-radius: 50%; background: var(--blue); color: #fff;
  border: 3px solid rgb(255 255 255 / .2);
  font-size: var(--fs-xl); font-weight: 700; line-height: 1;
}
.profile-id h1 { font-size: var(--fs-lg); overflow-wrap: anywhere; }
.role-badge {
  padding: 2px var(--sp-4); border-radius: var(--radius-pill);
  background: rgb(255 255 255 / .12); color: var(--on-navy);
  font-size: var(--fs-xs);
}

/* ---------- زبانه‌ها ---------- */
.tabs {
  display: flex; gap: var(--sp-2);
  margin-bottom: var(--sp-5); border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-2); margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-weight: 500; color: var(--text-muted);
  transition: color var(--ease), border-color var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-color: var(--blue); }
[data-theme="dark"] .tab[aria-selected="true"] { border-color: var(--sky); }

.count {
  min-width: 1.4rem; padding-inline: 6px; border-radius: var(--radius-pill);
  background: var(--blue); color: #fff; text-align: center;
  font-size: var(--fs-xs); line-height: 1.4rem;
}

.section-title { font-size: var(--fs-md); margin: var(--sp-6) 0 var(--sp-2); }

/* ---------- فرم اطلاعات ---------- */
.field select {
  width: 100%; height: 48px; padding-inline: var(--sp-3);
  font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field select:focus { outline: 0; border-color: var(--sky); box-shadow: 0 0 0 3px rgb(77 163 245 / .25); }

.birth { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: var(--sp-3); }
.optional { color: var(--text-muted); font-weight: 400; }

/* ---------- اطلاعات حساب (فقط خواندنی) ---------- */
.account { margin: 0; }
.account__row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding-block: var(--sp-3); border-bottom: 1px solid var(--line);
  font-size: var(--fs-sm);
}
.account__row:last-child { border-bottom: 0; }
.account dt { color: var(--text-muted); flex: none; }
.account dd {
  margin: 0; font-weight: 500; overflow-wrap: anywhere;
  display: flex; align-items: center; gap: var(--sp-3);
}
.not-set { color: var(--text-muted); font-weight: 400; }
.copy-btn {
  flex: none; padding: 2px var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: var(--fs-xs); color: var(--blue);
  transition: border-color var(--ease);
}
.copy-btn:hover { border-color: var(--sky); }
[data-theme="dark"] .copy-btn { color: var(--sky); }

/* ---------- صندوق پیام ---------- */
.inbox-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.inbox-head h2 { font-size: var(--fs-md); }

.inbox {
  margin: 0; padding: 0; list-style: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
}
.msg + .msg { border-top: 1px solid var(--line); }
.msg summary {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); cursor: pointer; list-style: none;
}
.msg summary::-webkit-details-marker { display: none; }
.msg summary:hover { background: var(--bg); }
.msg[open] summary { background: var(--bg); }

.msg__dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: transparent; }
.msg.is-unread .msg__dot { background: var(--blue); }
[data-theme="dark"] .msg.is-unread .msg__dot { background: var(--sky); }
.msg__title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg.is-unread .msg__title { font-weight: 700; }
.msg__date { flex: none; font-size: var(--fs-xs); color: var(--text-muted); }

.msg__body, .msg__foot {
  padding-inline: var(--sp-4);
  padding-inline-start: calc(var(--sp-4) + 8px + var(--sp-3));
}
.msg__body { padding-top: var(--sp-3); white-space: pre-line; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.msg__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding-block: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs); color: var(--text-muted);
}
.link-button--danger:not(:disabled), [data-theme="dark"] .link-button--danger:not(:disabled) { color: var(--danger); }

.inbox-empty { padding-block: var(--sp-6); text-align: center; color: var(--text-muted); }

@media (max-width: 480px) {
  .birth { grid-template-columns: 1fr 1.4fr 1.2fr; gap: var(--sp-2); }
  .account__row { flex-direction: column; align-items: flex-start; gap: 0; }
}

/* ---------- پنجره‌ی افزودن / تغییر شماره و ایمیل ---------- */
.modal {
  margin: auto;
  width: min(100% - 2 * var(--sp-4), 420px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgb(20 43 80 / .55); }
.modal__box { padding: var(--sp-5); }
.modal h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-2); }
.modal__box > .step__links { justify-content: center; margin-top: var(--sp-2); }
/* نگارگری تزئینی فقط در بخش آبی Hero */

.stepper__dot,
.stepper li {
    transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}

/* دکمه‌ی لینک آیتم‌ها (اخبار، دوره‌ها، منابع علمی، ...) */
.card__btn { margin-top: var(--sp-4); }
a.client-logo { cursor: pointer; }

/* ==========================================================================
   صندوق پیام (گفت‌وگوها) و ویجت پیام صفحه‌ی اصلی
   ========================================================================== */
.chat [hidden], .chat-widget [hidden] { display: none !important; }
.chat-ico { display: inline-flex; flex: none; }
.chat-ico .icon { width: 1.1em; height: 1.1em; }

/* ---------- دکمه‌ها ---------- */
.chat-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: 38px; padding: 0 var(--sp-4); border: 1px solid var(--line);
  border-radius: var(--radius-pill); background: var(--surface); color: var(--blue);
  font-size: var(--fs-sm); font-weight: 500;
  transition: border-color var(--ease), background var(--ease), color var(--ease);
}
.chat-btn:hover { border-color: var(--sky); }
.chat-btn:disabled { opacity: .6; cursor: wait; }
.chat-btn--solid { background: var(--navy); border-color: var(--navy); color: #fff; }
.chat-btn--solid:hover { background: var(--blue); border-color: var(--blue); }
.chat-btn--danger { color: var(--danger); }
.chat-btn.is-on { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.chat-more { display: flex; margin: var(--sp-3) auto 0; }
[data-theme="dark"] .chat-btn { color: var(--sky); }
[data-theme="dark"] .chat-btn--solid { background: var(--blue); border-color: var(--blue); color: #fff; }
[data-theme="dark"] .chat-btn--danger { color: var(--danger); }
.chat-icon-btn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border-radius: 50%; color: var(--text-muted); transition: background var(--ease), color var(--ease);
}
.chat-icon-btn:hover { background: var(--bg); color: var(--text); }
.chat-send { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); }

/* ---------- نوار بالا و فیلترها ---------- */
.chat-head, .chat-thread-head {
  display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3);
}
.chat-head { justify-content: space-between; flex-wrap: wrap; }
.chat-head h2 { font-size: var(--fs-md); }
.chat-head__actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.chat-thread-head { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.chat-thread-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.5; }
.chat-thread-title strong { display: flex; align-items: center; gap: var(--sp-2); }
.chat-thread-title small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-thread-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.chat-filters { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); flex-wrap: wrap; }
.chat-filter {
  padding: 2px var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius-pill);
  font-size: var(--fs-sm); color: var(--text-muted);
}
.chat-filter[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
[data-theme="dark"] .chat-filter[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); }
.chat-chip {
  flex: none; padding: 0 var(--sp-2); border-radius: var(--radius-pill);
  background: var(--bg); border: 1px solid var(--line);
  font-size: var(--fs-xs); font-weight: 500; color: var(--blue); line-height: 1.6;
}
.chat-chip--owner { color: var(--navy); background: rgb(77 163 245 / .18); border-color: transparent; }
[data-theme="dark"] .chat-chip { color: var(--sky); }
[data-theme="dark"] .chat-chip--owner { color: var(--text); }

/* ---------- فهرست گفت‌وگوها ---------- */
.chat-list {
  margin: 0; padding: 0; list-style: none;
  border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
}
.chat-list:empty { display: none; }
.chat-list li + li { border-top: 1px solid var(--line); }
.chat-item {
  width: 100%; display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); text-align: start; color: inherit;
  transition: background var(--ease);
}
.chat-item:hover { background: var(--bg); }
.chat-avatar {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--bg); border: 1px solid var(--line);
  color: var(--blue); font-weight: 700;
}
[data-theme="dark"] .chat-avatar { color: var(--sky); }
.chat-item__main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.6; }
.chat-item__top { display: flex; align-items: center; gap: var(--sp-2); }
.chat-item__who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.chat-item__time { margin-inline-start: auto; flex: none; font-size: var(--fs-xs); color: var(--text-muted); }
.chat-item__subject { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item__snippet { font-size: var(--fs-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item.is-unread .chat-item__who, .chat-item.is-unread .chat-item__subject { font-weight: 700; }
.chat-item__dot { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--blue); }
[data-theme="dark"] .chat-item__dot { background: var(--sky); }
.chat-item__ttl {
  display: inline-flex; align-items: center; gap: var(--sp-1); margin-top: 2px;
  font-size: var(--fs-xs); color: var(--danger);
}

/* هشدار کوچک حذف خودکار */
.ttl-note {
  display: flex; align-items: center; gap: var(--sp-2); margin: var(--sp-3) 0 0;
  font-size: var(--fs-xs); color: var(--text-muted);
}
.ttl-note--soon {
  padding: var(--sp-2) var(--sp-3); margin: 0 0 var(--sp-3);
  border-radius: var(--radius-sm); border-inline-start: 3px solid var(--danger);
  background: var(--danger-bg); color: var(--danger);
}

/* ---------- گفت‌وگو ---------- */
.chat-scroll {
  max-height: min(52vh, 460px); min-height: 160px; overflow-y: auto;
  padding: var(--sp-3) var(--sp-1); scroll-behavior: smooth;
}
.chat-msgs { display: flex; flex-direction: column; gap: var(--sp-2); }
.chat-day {
  align-self: center; margin: var(--sp-2) 0; padding: 0 var(--sp-3);
  border-radius: var(--radius-pill); background: var(--bg);
  font-size: var(--fs-xs); color: var(--text-muted);
}
.bubble {
  max-width: min(82%, 460px); padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius); border-end-start-radius: 4px;
  background: var(--bg); border: 1px solid var(--line);
  align-self: flex-end;
}
.bubble--mine {
  align-self: flex-start; background: var(--navy); border-color: var(--navy); color: #fff;
  border-end-start-radius: var(--radius); border-end-end-radius: 4px;
}
[data-theme="dark"] .bubble--mine { background: var(--blue); border-color: var(--blue); }
.bubble__who { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); font-weight: 700; color: var(--blue); }
[data-theme="dark"] .bubble__who { color: var(--sky); }
.bubble__body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.bubble--deleted .bubble__body { font-style: italic; opacity: .7; }
.bubble__foot {
  display: flex; align-items: center; gap: var(--sp-3); margin-top: 2px;
  font-size: var(--fs-xs); opacity: .8;
}
.bubble__tag { padding: 0 var(--sp-2); border-radius: var(--radius-pill); border: 1px solid currentColor; }
.bubble__del { font-size: var(--fs-xs); color: inherit; text-decoration: underline; opacity: .85; }
.chat-reply {
  display: flex; align-items: flex-end; gap: var(--sp-2);
  margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--line);
}
.chat-reply textarea { flex: 1; min-height: 46px; }
.chat-reply .btn-primary { width: auto; height: 46px; margin: 0; padding-inline: var(--sp-4); }
.chat-closed { padding-top: var(--sp-3); text-align: center; }

/* ---------- فرم پیام جدید ---------- */
.field textarea {
  width: 100%; padding: var(--sp-3) var(--sp-4); resize: vertical;
  font: inherit; color: var(--text); line-height: 1.8;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.field textarea:focus { outline: 0; border-color: var(--sky); box-shadow: 0 0 0 3px rgb(77 163 245 / .25); }
.chat-label { font-size: var(--fs-sm); font-weight: 500; }
.chat-to {
  display: flex; align-items: center; gap: var(--sp-2); min-height: 48px; padding-inline: var(--sp-4);
  border: 1px dashed var(--line); border-radius: var(--radius-sm); background: var(--bg);
}
.chat-to .chat-icon-btn { margin-inline-start: auto; }
.chat-results {
  margin: 0; padding: 0; list-style: none; max-height: 220px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
}
.chat-results li + li { border-top: 1px solid var(--line); }
.chat-result { width: 100%; display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); text-align: start; }
.chat-result:hover { background: var(--bg); }
.chat-result small { margin-inline-start: auto; color: var(--text-muted); }
.chat-results__empty { padding: var(--sp-3) var(--sp-4); font-size: var(--fs-sm); color: var(--text-muted); }
.chat-topics { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chat-topic {
  padding: 0 var(--sp-3); border: 1px solid var(--line); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); color: var(--text-muted); transition: border-color var(--ease), color var(--ease);
}
.chat-topic:hover { border-color: var(--sky); color: var(--text); }
.chat-compose__meta { display: flex; justify-content: flex-end; }
.chat-counter { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- اتصال به بله ---------- */
.bale-box { margin-top: var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.bale-box summary {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-3) var(--sp-4);
  cursor: pointer; list-style: none; font-size: var(--fs-sm); font-weight: 500;
}
.bale-box summary::-webkit-details-marker { display: none; }
.bale-box[open] summary { border-bottom: 1px solid var(--line); }
.bale-box__body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-4); }
.bale-box__body .auth-message { width: 100%; margin: 0; }
.bale-code { width: 100%; }
.bale-steps { margin: 0 0 var(--sp-3); padding-inline-start: var(--sp-5); font-size: var(--fs-sm); }
.bale-steps a { color: var(--blue); text-decoration: underline; }
[data-theme="dark"] .bale-steps a { color: var(--sky); }
.bale-code__value {
  display: block; text-align: center; padding: var(--sp-3); margin-bottom: var(--sp-2);
  border: 1px dashed var(--sky); border-radius: var(--radius-sm); background: var(--bg);
  font-size: var(--fs-lg); font-weight: 700; letter-spacing: .3em; user-select: all;
}
.bale-check { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }

/* ---------- ویجت شناور صفحه‌ی اصلی ---------- */
.chat-widget {
  position: fixed; z-index: 60;
  inset-inline-end: var(--sp-5); bottom: max(var(--sp-5), env(safe-area-inset-bottom));
}
.chat-fab {
  position: relative; width: 58px; height: 58px; display: grid; place-items: center;
  border-radius: 50%; background: var(--navy); color: #fff; box-shadow: var(--shadow);
  transition: transform var(--ease), background var(--ease);
}
.chat-fab:hover { background: var(--blue); transform: translateY(-2px); }
.chat-fab .icon { width: 26px; height: 26px; }
.chat-fab__badge {
  position: absolute; top: -4px; inset-inline-start: -4px; min-width: 22px; height: 22px; padding-inline: 5px;
  border-radius: var(--radius-pill); background: var(--danger); color: #fff;
  font-size: var(--fs-xs); line-height: 22px; text-align: center; border: 2px solid var(--bg);
}
[data-theme="dark"] .chat-fab { background: var(--blue); }
[data-theme="dark"] .chat-fab__badge { color: #14264A; }
.chat-pop {
  position: absolute; bottom: calc(100% + var(--sp-3)); inset-inline-end: 0;
  width: min(380px, calc(100vw - 2 * var(--sp-4))); max-height: min(600px, 78vh);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  animation: chat-pop-in .18s ease both; transform-origin: bottom;
}
@keyframes chat-pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.chat-pop__head {
  display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-4);
  background: var(--navy); color: #fff;
}
.chat-pop__head strong { flex: 1; font-size: var(--fs-base); }
.chat-pop__head .chat-icon-btn { color: var(--on-navy-muted); }
.chat-pop__head .chat-icon-btn:hover { background: rgb(255 255 255 / .12); color: #fff; }
[data-theme="dark"] .chat-pop__head { background: var(--header-bg); }
.chat-pop__body { padding: var(--sp-4); overflow-y: auto; }
.chat-pop__body .field { margin-bottom: var(--sp-3); }
.chat-pop__body .chat-list { border: 0; border-radius: 0; margin: calc(-1 * var(--sp-2)) calc(-1 * var(--sp-4)); }
.chat-pop__body .chat-item { padding-inline: var(--sp-4); }
.chat-pop__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4); border-top: 1px solid var(--line);
}
.chat-pop__note { padding: 0 var(--sp-4) var(--sp-3); }
.chat-pop__note .ttl-note { margin: 0; }
.chat-pop__cta { display: grid; place-items: center; margin-top: var(--sp-3); }

@media (max-width: 480px) {
  .chat-widget { inset-inline-end: var(--sp-3); }
  .chat-bubble, .bubble { max-width: 90%; }
  .chat-thread-actions { width: 100%; }
}



/* هدر در گوشی: جلوگیری از بیرون‌زدن دکمه‌ی منو */
@media (max-width: 600px) {
  .site-header__inner { gap: var(--sp-3); }
  .header-tools { gap: var(--sp-2); min-width: 0; }
  .header-tools .btn { padding: .5rem 1rem; }
  .lang-switch { display: none; }
}