/* =================================================
   رِفد — Enhanced UI v2
   ================================================= */

/* ===== 1. CSS Variables ===== */
:root {
  --bg: #edf1f7;
  --ink: #142746;
  --muted: #4e607f;
  --card: #ffffff;
  --card-alt: #f6f9ff;
  --line: #d4ddeb;
  --brand: #1a2e62;
  --brand-strong: #35548a;
  --brand-soft: #e8eefb;
  --accent: #486ca5;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;

  --shadow-xs: 0 2px 8px rgba(17, 35, 78, 0.07);
  --shadow-sm: 0 4px 14px rgba(17, 35, 78, 0.09);
  --shadow: 0 8px 26px rgba(17, 35, 78, 0.13);
  --shadow-lg: 0 18px 48px rgba(17, 35, 78, 0.17);
  --shadow-xl: 0 28px 64px rgba(17, 35, 78, 0.22);

  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-md: 18px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-full: 999px;

  --t-fast: 0.14s ease;
  --t: 0.22s ease;
  --t-slow: 0.4s ease;
  --t-bounce: 0.38s cubic-bezier(0.34, 1.56, 0.64, 1);

  --focus-ring: rgba(61, 115, 184, 0.26);

  --preview-brand: #1a2e62;
  --preview-brand-strong: #35548a;
  --preview-brand-soft: #e8eefb;
}

/* ===== 2. Dark Mode Variables ===== */
[data-theme="dark"] {
  --bg: #0e1423;
  --ink: #dce6f5;
  --muted: #7893b8;
  --card: #162033;
  --card-alt: #1b2840;
  --line: #243352;
  --brand-soft: #172240;
  --danger: #ef4444;
  --danger-soft: #2a0e0e;

  --shadow-xs: 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.38);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.48);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.58);
  --shadow-xl: 0 28px 64px rgba(0, 0, 0, 0.68);

  --focus-ring: rgba(100, 155, 230, 0.3);
}

/* ===== 3. Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Tajawal", "Cairo", "Noto Kufi Arabic", sans-serif;
  line-height: 1.6;
  transition: background-color 0.35s ease, color 0.35s ease;
  -webkit-font-smoothing: antialiased;
}

/* ===== 4. Background Layer ===== */
.background-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  transition: opacity 0.5s ease;
}

:root:not([data-theme="dark"]) .background-layer {
  background:
    radial-gradient(circle at 90% 8%, rgba(26, 46, 98, 0.2), transparent 34%),
    radial-gradient(circle at 7% 84%, rgba(72, 108, 165, 0.17), transparent 30%),
    linear-gradient(165deg, #f8fafd, #eff4fb 45%, #e8eef9);
}

[data-theme="dark"] .background-layer {
  background:
    radial-gradient(circle at 90% 8%, rgba(26, 46, 140, 0.28), transparent 38%),
    radial-gradient(circle at 7% 84%, rgba(36, 66, 140, 0.22), transparent 32%),
    linear-gradient(165deg, #090f1e, #0d1528 45%, #101c35);
}

/* ===== 5. Layout ===== */
main {
  width: min(1200px, 95vw);
  margin: 26px auto 48px;
}

.shell {
  display: grid;
  gap: 18px;
}

/* ===== 6. Page Transition ===== */
.page-enter {
  animation: page-enter 0.32s ease both;
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(14px);
    filter: blur(2.5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

/* ===== 7. Top Banner ===== */
.top-banner {
  background:
    radial-gradient(circle at 14% 10%, rgba(255, 255, 255, 0.15), transparent 40%),
    linear-gradient(118deg, var(--brand-strong), var(--brand));
  border-radius: var(--r-lg);
  padding: 18px 22px;
  color: #f0f6ff;
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  position: relative;
  overflow: hidden;
}

.top-banner::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.05) 0%, transparent 60%);
  pointer-events: none;
}

/* ===== 8. Brand ===== */
.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  position: relative;
  z-index: 1;
}

.brand-logo {
  width: 70px;
  height: 70px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.26);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform var(--t-bounce), box-shadow var(--t);
}

.brand-logo:hover {
  transform: scale(1.05) rotate(-2deg);
  box-shadow: 0 8px 20px rgba(0,0,0,0.2);
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-logo .fallback-logo {
  font-weight: 700;
  letter-spacing: 0.5px;
  opacity: 0.88;
  font-size: 0.9rem;
  color: #fff;
}

.brand h1,
.brand h2,
.brand p {
  margin: 0;
}

.brand h1,
.brand h2 {
  font-size: 1.3rem;
  font-weight: 800;
}

.brand p {
  opacity: 0.9;
  font-size: 0.92rem;
}

.brand-description-fancy {
  margin-top: 8px !important;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--r-full);
  padding: 4px 13px;
  max-width: min(560px, 92vw);
  white-space: normal;
  overflow-wrap: anywhere;
  color: #eef5ff;
  font-size: 0.84rem !important;
  font-weight: 600;
  line-height: 1.5;
}

/* ===== 9. User Badge ===== */
.user-badge {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 10px 14px;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

/* ===== 10. Dark Mode Toggle ===== */
.dark-mode-toggle {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  border-radius: var(--r-full) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.3) !important;
  background: rgba(255, 255, 255, 0.13) !important;
  color: #fff !important;
  font-size: 1.1rem;
  cursor: pointer;
  display: grid !important;
  place-items: center;
  padding: 0 !important;
  transition: background var(--t), transform var(--t-bounce), border-color var(--t), box-shadow var(--t) !important;
  position: relative;
  z-index: 2;
  line-height: 1;
}

.dark-mode-toggle:hover {
  background: rgba(255, 255, 255, 0.24) !important;
  transform: rotate(22deg) scale(1.1) !important;
  filter: none !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25) !important;
}

.dark-mode-toggle:active {
  transform: rotate(22deg) scale(0.94) !important;
}

/* Floating public dark mode toggle */
.dm-toggle-public {
  position: fixed;
  top: 18px;
  inset-inline-start: 18px;
  z-index: 800;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: var(--shadow-sm);
  transition: background var(--t), transform var(--t-bounce), box-shadow var(--t), border-color var(--t);
  line-height: 1;
}

.dm-toggle-public:hover {
  box-shadow: var(--shadow);
  transform: rotate(22deg) scale(1.1);
  filter: none;
  border-color: var(--accent);
}

.dm-toggle-public:active {
  transform: rotate(22deg) scale(0.94);
}

/* ===== 11. Public Builder Hero ===== */
.public-builder-hero {
  align-items: flex-start;
}

.public-hero-actions {
  align-self: flex-start;
}

.public-hero-actions button {
  white-space: nowrap;
}

/* ===== 12. Landing Shell ===== */
.landing-shell {
  gap: 20px;
}

/* ===== 13. Landing Hero ===== */
.landing-hero {
  position: relative;
  overflow: hidden;
  padding: 36px 32px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    radial-gradient(circle at 10% 16%, rgba(255, 255, 255, 0.14), transparent 36%),
    radial-gradient(circle at 88% 10%, rgba(160, 196, 255, 0.24), transparent 42%),
    linear-gradient(128deg, #0d224a, #1a3a72 43%, #2f5b97 100%);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
}

.landing-hero::before,
.landing-hero::after {
  content: "";
  position: absolute;
  border-radius: var(--r-full);
  pointer-events: none;
}

.landing-hero::before {
  width: 360px;
  height: 360px;
  left: -160px;
  bottom: -180px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0));
  animation: hero-blob 7.5s ease-in-out infinite;
}

.landing-hero::after {
  width: 240px;
  height: 240px;
  right: -100px;
  top: -100px;
  background: radial-gradient(circle, rgba(173, 211, 255, 0.32), rgba(173, 211, 255, 0));
  animation: hero-blob 9.5s ease-in-out infinite reverse;
}

@keyframes hero-blob {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(12px, -16px) scale(1.05); }
  66%       { transform: translate(-10px, 12px) scale(0.96); }
}

.landing-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  width: 100%;
  align-items: stretch;
  position: relative;
  z-index: 1;
}

/* ===== 14. Landing Chip Row ===== */
.landing-chip-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.landing-hero-copy h1 {
  font-size: clamp(1.9rem, 4vw, 2.48rem);
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.2px;
  background: linear-gradient(120deg, #ffffff 0%, #ccdeff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-hero-copy p {
  margin-top: 0;
  color: rgba(245, 248, 255, 0.92);
  font-size: 1.04rem;
  line-height: 1.88;
  margin-bottom: 16px;
  max-width: 720px;
}

.landing-hero-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.landing-hero-logo {
  width: 90px;
  height: 90px;
  border-radius: 22px;
  border: 1px solid rgba(208, 226, 255, 0.4);
  background: rgba(255, 255, 255, 0.13);
  display: grid;
  place-items: center;
  padding: 9px;
  box-shadow: 0 14px 32px rgba(8, 26, 56, 0.28);
  flex-shrink: 0;
  transition: transform var(--t-bounce);
}

.landing-hero-logo:hover {
  transform: scale(1.06) rotate(-3deg);
}

.landing-hero-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.landing-hero-logo .fallback-logo {
  color: #fff;
  font-weight: 700;
}

.landing-hero-title-wrap {
  display: grid;
  gap: 5px;
}

.landing-hero-copy p:last-of-type {
  margin-bottom: 16px;
}

/* ===== 15. Landing Chips ===== */
.landing-chip {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-full);
  padding: 5px 13px;
  font-size: 0.79rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.34);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  letter-spacing: 0.1px;
  transition: background var(--t), transform var(--t-fast);
}

.landing-chip:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.landing-chip.soft {
  background: rgba(234, 243, 255, 0.16);
  color: rgba(240, 247, 255, 0.96);
  border-color: rgba(207, 225, 255, 0.44);
}

/* ===== 16. Landing Hero Actions ===== */
.landing-hero-actions {
  flex-wrap: wrap;
}

.landing-hero-actions button {
  flex: 1 1 220px;
  min-width: 190px;
  min-height: 48px;
  white-space: normal;
  line-height: 1.45;
}

/* ===== 17. Landing Stats ===== */
.landing-stat-row {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.landing-stat-item {
  border: 1px solid rgba(191, 213, 247, 0.44);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  padding: 14px;
  transition: background var(--t), transform var(--t);
}

.landing-stat-item:hover {
  background: rgba(255, 255, 255, 0.17);
  transform: translateY(-2px);
}

.landing-stat-item strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: #ffffff;
  line-height: 1.2;
}

.landing-stat-item span {
  font-size: 0.82rem;
  color: rgba(237, 245, 255, 0.9);
  line-height: 1.6;
}

/* ===== 18. Landing Hero Panel ===== */
.landing-hero-panel {
  border-radius: var(--r-lg);
  border: 1px solid rgba(198, 219, 253, 0.52);
  background:
    radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.15), transparent 44%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.15), rgba(196, 219, 252, 0.08));
  backdrop-filter: blur(4px);
  padding: 20px;
  display: grid;
  align-content: start;
}

.landing-hero-panel h3 {
  margin: 0 0 12px;
  font-size: 1.12rem;
  color: #f0f8ff;
}

.landing-feature-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  gap: 10px;
}

.landing-feature-list li {
  position: relative;
  padding-inline-start: 24px;
  font-size: 0.91rem;
  color: rgba(245, 249, 255, 0.94);
  line-height: 1.75;
}

.landing-feature-list li::before {
  content: "✓";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  color: #9dd3ff;
  font-weight: 800;
}

/* ===== 19. Landing Card Grid ===== */
.landing-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.landing-info-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(165deg, #fafcff, #eef5ff);
  border-color: #cee0f4;
  padding: 20px;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}

[data-theme="dark"] .landing-info-card {
  background: linear-gradient(165deg, var(--card), var(--card-alt));
  border-color: var(--line);
}

.landing-info-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.landing-card-icon {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r);
  margin-bottom: 12px;
  font-size: 1.15rem;
  border: 1px solid #c4d7f2;
  background: linear-gradient(135deg, #eef6ff, #e3efff);
  transition: transform var(--t-bounce), box-shadow var(--t);
}

.landing-info-card:hover .landing-card-icon {
  transform: scale(1.14) rotate(-5deg);
  box-shadow: 0 6px 14px rgba(26, 46, 98, 0.2);
}

[data-theme="dark"] .landing-card-icon {
  border-color: var(--line);
  background: linear-gradient(135deg, var(--card), var(--card-alt));
}

.landing-info-card h3 {
  margin-bottom: 8px;
  color: #173565;
}

[data-theme="dark"] .landing-info-card h3 {
  color: var(--ink);
}

.landing-info-card p {
  margin: 0;
  color: #4a6485;
  line-height: 1.75;
}

[data-theme="dark"] .landing-info-card p {
  color: var(--muted);
}

/* ===== 20. Landing Section Card ===== */
.landing-section-card {
  background:
    radial-gradient(circle at 92% 9%, rgba(74, 112, 175, 0.07), transparent 36%),
    linear-gradient(165deg, #ffffff, #f5f9ff 66%, #eef5ff);
  border-color: #c4d9f0;
  padding: 24px;
}

[data-theme="dark"] .landing-section-card {
  background: linear-gradient(165deg, var(--card), var(--card-alt));
  border-color: var(--line);
}

.landing-section-head p {
  margin: 0 0 5px;
  color: #5a7299;
  font-size: 0.81rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

[data-theme="dark"] .landing-section-head p {
  color: var(--accent);
}

.landing-section-head h3 {
  margin: 0 0 14px;
  color: #153463;
}

[data-theme="dark"] .landing-section-head h3 {
  color: var(--ink);
}

/* ===== 21. Landing Steps ===== */
.landing-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.landing-step {
  position: relative;
  border: 1px solid #ceddf3;
  border-radius: var(--r-md);
  background: #f8fbff;
  padding: 16px;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}

[data-theme="dark"] .landing-step {
  background: var(--card-alt);
  border-color: var(--line);
}

.landing-step:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.landing-step:not(:last-child)::after {
  content: "";
  position: absolute;
  inset-inline-end: -7px;
  top: 28px;
  width: 14px;
  height: 2px;
  background: linear-gradient(90deg, #c5d9f2, #b5cdee);
}

[data-theme="dark"] .landing-step:not(:last-child)::after {
  background: var(--line);
}

.landing-step-index {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-full);
  margin-bottom: 10px;
  font-weight: 800;
  font-size: 0.96rem;
  color: #fff;
  background: linear-gradient(120deg, #1f3b76, #3f6aac);
  box-shadow: 0 5px 12px rgba(31, 59, 118, 0.38);
  transition: transform var(--t-bounce);
}

.landing-step:hover .landing-step-index {
  transform: scale(1.15);
}

.landing-step h4 {
  margin: 0 0 6px;
  color: #163560;
  font-size: 0.96rem;
}

[data-theme="dark"] .landing-step h4 {
  color: var(--ink);
}

.landing-step p {
  margin: 0;
  color: #4f6b8e;
  line-height: 1.72;
  font-size: 0.91rem;
}

[data-theme="dark"] .landing-step p {
  color: var(--muted);
}

/* ===== 22. Landing Module Grid ===== */
.landing-module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px;
}

.landing-module-item {
  position: relative;
  border: 1px solid #d0e0f4;
  border-radius: var(--r);
  background: linear-gradient(165deg, #f7fbff, #eef5ff);
  padding: 13px;
  padding-inline-start: 44px;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}

[data-theme="dark"] .landing-module-item {
  background: linear-gradient(165deg, var(--card), var(--card-alt));
  border-color: var(--line);
}

.landing-module-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent);
}

.landing-module-item::before {
  content: "✓";
  position: absolute;
  inset-inline-start: 13px;
  top: 14px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: var(--r-full);
  color: #22457e;
  font-weight: 800;
  font-size: 0.76rem;
  background: #d9eafb;
  border: 1px solid #b8d1ee;
}

[data-theme="dark"] .landing-module-item::before {
  background: #1a3060;
  border-color: #2a4580;
  color: #7ab8ff;
}

.landing-module-item strong {
  display: block;
  margin-bottom: 5px;
  color: #1d3c70;
  font-size: 0.94rem;
}

[data-theme="dark"] .landing-module-item strong {
  color: var(--ink);
}

.landing-module-item span {
  color: #50698f;
  font-size: 0.91rem;
  line-height: 1.62;
}

[data-theme="dark"] .landing-module-item span {
  color: var(--muted);
}

/* ===== 23. Landing CTA & Telegram ===== */
.landing-cta-card {
  border: 1px solid #c0d4f0;
  background:
    radial-gradient(circle at 12% 22%, rgba(63, 108, 177, 0.14), transparent 36%),
    linear-gradient(132deg, #f6fbff, #eaf3ff 60%, #e1ecff);
  text-align: center;
  padding: 32px 24px;
}

[data-theme="dark"] .landing-cta-card {
  background: linear-gradient(132deg, var(--card), var(--card-alt));
  border-color: var(--line);
}

.landing-cta-card h3 {
  margin-bottom: 10px;
  color: #153463;
  font-size: 1.32rem;
}

[data-theme="dark"] .landing-cta-card h3 {
  color: var(--ink);
}

.landing-cta-card p {
  max-width: 760px;
  margin: 0 auto 18px;
  color: #4f6a8c;
  line-height: 1.82;
}

[data-theme="dark"] .landing-cta-card p {
  color: var(--muted);
}

.landing-cta-card button {
  min-width: 260px;
}

.landing-telegram-card {
  border: 1px solid #c3d7f2;
  background:
    radial-gradient(circle at 88% 16%, rgba(53, 84, 138, 0.14), transparent 36%),
    linear-gradient(138deg, #f8fbff, #ecf4ff 58%, #e4eeff);
  text-align: center;
  padding: 32px 24px;
}

[data-theme="dark"] .landing-telegram-card {
  background: linear-gradient(138deg, var(--card), var(--card-alt));
  border-color: var(--line);
}

.landing-telegram-card h3 {
  margin-bottom: 10px;
  color: #153463;
  font-size: 1.2rem;
}

[data-theme="dark"] .landing-telegram-card h3 {
  color: var(--ink);
}

.landing-telegram-card p {
  max-width: 760px;
  margin: 0 auto 18px;
  color: #4f6b8c;
  line-height: 1.82;
}

[data-theme="dark"] .landing-telegram-card p {
  color: var(--muted);
}

.landing-telegram-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 260px;
  padding: 12px 24px;
  border-radius: var(--r);
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  background: linear-gradient(120deg, #2e6ab0, #1d4e88);
  box-shadow: 0 6px 20px rgba(30, 78, 140, 0.38);
  transition: filter 0.22s ease, transform 0.16s ease, box-shadow 0.22s ease;
}

.landing-telegram-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(30, 78, 140, 0.48);
}

.landing-telegram-btn:active {
  transform: translateY(-1px);
}

.landing-telegram-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== 24. Semester Chip ===== */
.semester-chip {
  margin-top: 7px !important;
  display: inline-block;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: var(--r-full);
  padding: 4px 11px;
  font-size: 0.79rem !important;
}

/* ===== 25. Role Navigation ===== */
.role-nav {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  padding: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  position: relative;
}

.role-nav .nav-btn {
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  border: 1px solid transparent;
  padding: 9px 15px;
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t), transform var(--t-fast), box-shadow var(--t);
  font-size: 0.93rem;
}

.role-nav .nav-btn:hover:not(.active) {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--line);
}

[data-theme="dark"] .role-nav .nav-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

.role-nav .nav-btn.active {
  background: linear-gradient(120deg, var(--brand), var(--brand-strong));
  color: #fff;
  box-shadow: 0 4px 14px rgba(26, 46, 98, 0.32);
  border-color: transparent;
}

.role-nav .nav-btn:active {
  transform: scale(0.96);
}

.role-nav .nav-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ===== 26. Cards ===== */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow);
  padding: 20px;
  animation: rise-in 0.4s ease both;
  transition: box-shadow var(--t), border-color var(--t);
}

.card:hover {
  box-shadow: var(--shadow-lg);
}

.card > :last-child {
  margin-bottom: 0;
}

.card h3,
.card h4,
.card p,
.card h2 {
  margin-top: 0;
}

.card hr {
  border: 0;
  border-top: 1px dashed var(--line);
  margin: 16px 0;
}

/* ===== 27. Grid System ===== */
.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* ===== 28. Stats Card ===== */
.stats-card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card-alt);
  padding: 16px;
  animation: rise-in 0.4s ease both;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}

.stats-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.stats-card strong {
  display: block;
  font-size: 1.42rem;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--brand);
}

[data-theme="dark"] .stats-card strong {
  color: var(--accent);
}

/* ===== 29. Labels ===== */
label {
  display: block;
  margin-bottom: 7px;
  font-weight: 600;
  font-size: 0.94rem;
}

/* ===== 30. Form Elements ===== */
input,
select,
button,
textarea {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: var(--r);
  padding: 10px 13px;
  margin-bottom: 13px;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--card-alt);
  border-color: var(--line);
  color: var(--ink);
  color-scheme: dark;
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
  border-color: var(--accent);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3.5px var(--focus-ring);
}

/* ===== 31. Password Toggle ===== */
.password-input-wrap {
  position: relative;
  margin-bottom: 13px;
}

.password-input-wrap input {
  margin-bottom: 0;
  padding-inline-end: 48px;
}

button.password-toggle-btn {
  position: absolute;
  inset-inline-end: 8px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--brand-strong);
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background var(--t), border-color var(--t);
}

[data-theme="dark"] button.password-toggle-btn {
  background: var(--card-alt);
  border-color: var(--line);
  color: var(--accent);
}

button.password-toggle-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button.password-toggle-btn:hover {
  filter: none;
  background: var(--brand-soft);
  border-color: var(--accent);
  transform: translateY(-50%);
  box-shadow: none;
}

button.password-toggle-btn:active {
  transform: translateY(-50%);
}

button.password-toggle-btn.is-revealed {
  background: var(--brand-soft);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 88px;
}

/* ===== 32. Buttons ===== */
button {
  border: none;
  border-radius: var(--r);
  padding: 10px 18px;
  background: linear-gradient(120deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: filter var(--t-fast), transform 0.14s ease, box-shadow var(--t);
  position: relative;
  overflow: hidden;
}

button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255,255,255,0.18), transparent 68%);
  opacity: 0;
  transition: opacity var(--t);
  pointer-events: none;
  border-radius: inherit;
}

button:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(26, 46, 98, 0.32);
  transform: translateY(-1px);
}

button:hover::before {
  opacity: 1;
}

button:active {
  transform: scale(0.96) translateY(0);
  box-shadow: 0 2px 8px rgba(26, 46, 98, 0.22);
  filter: brightness(0.98);
}

button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  filter: none !important;
  box-shadow: none !important;
  transform: none !important;
}

button.secondary {
  background: linear-gradient(120deg, #4a618d, #5c749e);
}

button.danger {
  background: linear-gradient(120deg, var(--danger), #991b1b);
}

/* ===== 33. Small Button ===== */
.small-btn {
  padding: 6px 11px;
  border-radius: var(--r-sm);
  font-size: 0.84rem;
}

/* ===== 34. Inline Actions ===== */
.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ===== 35. Helper Text ===== */
.helper {
  color: var(--muted);
  font-size: 0.91rem;
  margin-top: -3px;
  line-height: 1.62;
}

/* ===== 36. Check Grid ===== */
.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin-bottom: 13px;
}

.check-item {
  border: 1.5px solid var(--line);
  background: var(--card-alt);
  border-radius: var(--r);
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}

.check-item:hover {
  border-color: var(--accent);
  background: var(--brand-soft);
}

[data-theme="dark"] .check-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.check-item input {
  width: auto;
  margin: 0;
  accent-color: var(--brand);
}

/* ===== 37. Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: var(--r);
  background: var(--card);
}

th,
td {
  text-align: right;
  border-bottom: 1px solid var(--line);
  padding: 11px 13px;
  font-size: 0.93rem;
  vertical-align: middle;
}

th {
  background: var(--card-alt);
  color: var(--brand);
  font-weight: 700;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 0.88rem;
  letter-spacing: 0.1px;
}

[data-theme="dark"] th {
  background: var(--card-alt);
  color: var(--accent);
}

tbody tr {
  transition: background var(--t-fast);
}

tbody tr:nth-child(even) {
  background: rgba(72, 108, 165, 0.03);
}

[data-theme="dark"] tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.025);
}

tbody tr:hover {
  background: var(--brand-soft) !important;
}

[data-theme="dark"] tbody tr:hover {
  background: rgba(255, 255, 255, 0.055) !important;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* ===== 38. Badges ===== */
.badge {
  display: inline-block;
  border-radius: var(--r-full);
  padding: 3px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1px;
}

.badge.positive {
  color: #1c3d78;
  background: #d9e8fa;
}

[data-theme="dark"] .badge.positive {
  color: #9cc8ff;
  background: #1a3060;
}

.badge.negative {
  color: #991b1b;
  background: #fee2e2;
}

[data-theme="dark"] .badge.negative {
  color: #fca5a5;
  background: #3d1111;
}

.badge.neutral {
  color: #1f3870;
  background: #e2ecfa;
}

[data-theme="dark"] .badge.neutral {
  color: #93b4f0;
  background: #1a2e5a;
}

/* ===== 39. Progress Bar ===== */
.progress {
  width: 100%;
  background: var(--line);
  border-radius: var(--r-full);
  overflow: hidden;
  height: 12px;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-strong), var(--brand));
  border-radius: var(--r-full);
  position: relative;
  overflow: hidden;
  transition: width 0.95s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.progress > span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.22) 50%, transparent 100%);
  animation: shimmer 2.4s ease-in-out infinite;
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(220%); }
}

/* Animated: starts from 0 on load */
.progress.animate-on-load > span {
  animation: progress-grow 1.1s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes progress-grow {
  from { width: 0 !important; }
}

/* ===== 40. Switch Row ===== */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  background: var(--card-alt);
  border-radius: var(--r);
  margin-bottom: 13px;
  transition: border-color var(--t);
}

.switch-row:hover {
  border-color: var(--accent);
}

.switch-row input {
  width: auto;
  margin: 0;
  transform: scale(1.28);
  accent-color: var(--brand);
}

/* ===== 41. Notices ===== */
.notice {
  border-radius: var(--r);
  padding: 10px 14px;
  font-weight: 600;
  margin-bottom: 13px;
  line-height: 1.6;
}

.notice.warning {
  background: #fff8ed;
  border: 1px solid #fcd5a6;
  color: #9a3412;
}

[data-theme="dark"] .notice.warning {
  background: rgba(45, 36, 0, 0.5);
  border-color: #4a3400;
  color: #fde68a;
}

.notice.info {
  background: #ecf2fe;
  border: 1px solid #c4d7f3;
  color: #1c3d74;
}

[data-theme="dark"] .notice.info {
  background: rgba(26, 46, 98, 0.35);
  border-color: var(--line);
  color: var(--accent);
}

.notice.success {
  background: #f0fdf4;
  border: 1px solid #b8f0cc;
  color: #14603b;
}

[data-theme="dark"] .notice.success {
  background: rgba(13, 45, 26, 0.5);
  border-color: #134a2a;
  color: #86efb0;
}

/* ===== 42. Request Success Card ===== */
.request-success-card {
  border: 1px solid #c8e8d4;
  background: #f4fff7;
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 13px;
}

[data-theme="dark"] .request-success-card {
  background: rgba(13, 45, 26, 0.4);
  border-color: #134a2a;
}

.request-success-text {
  white-space: pre-line;
  margin-top: 0;
  margin-bottom: 13px;
}

/* ===== 43. Fieldset ===== */
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-inline-size: 0;
}

fieldset:disabled {
  opacity: 0.58;
}

/* ===== 44. Alert Host ===== */
.alert-host {
  position: fixed;
  inset-inline-start: 18px;
  bottom: 18px;
  z-index: 1200;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
}

.alert-box {
  border-radius: var(--r);
  padding: 13px 15px;
  box-shadow: 0 16px 36px rgba(15, 35, 76, 0.24);
  border: 1px solid #c5d7f2;
  background: var(--card);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  animation: slide-alert 0.3s var(--t-bounce) both;
}

[data-theme="dark"] .alert-box {
  background: var(--card);
  border-color: var(--line);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.55);
}

@keyframes slide-alert {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.alert-box .alert-text {
  white-space: pre-line;
  line-height: 1.48;
  font-weight: 600;
  color: #183667;
  flex: 1;
}

[data-theme="dark"] .alert-box .alert-text {
  color: var(--ink);
}

.alert-box .alert-close {
  padding: 2px 8px;
  min-width: 30px;
  line-height: 1;
  border-radius: 8px;
  background: transparent;
  color: #32538d;
  border: 1px solid #c8d8f3;
  font-size: 1rem;
}

[data-theme="dark"] .alert-box .alert-close {
  color: var(--accent);
  border-color: var(--line);
}

.alert-box.success {
  border-color: #9ee4bb;
  background: #f2fcf6;
}

[data-theme="dark"] .alert-box.success {
  background: rgba(13, 45, 26, 0.5);
  border-color: #134a2a;
}

.alert-box.success .alert-text { color: #145230; }
[data-theme="dark"] .alert-box.success .alert-text { color: #86efb0; }

.alert-box.warning {
  border-color: #f7cea4;
  background: #fffaf1;
}

[data-theme="dark"] .alert-box.warning {
  background: rgba(45, 36, 0, 0.5);
  border-color: #4a3400;
}

.alert-box.warning .alert-text { color: #7c3a0a; }
[data-theme="dark"] .alert-box.warning .alert-text { color: #fde68a; }

.alert-box.danger {
  border-color: #f4bcbc;
  background: #fff5f5;
}

[data-theme="dark"] .alert-box.danger {
  background: rgba(42, 14, 14, 0.5);
  border-color: #4a1010;
}

.alert-box.danger .alert-text { color: #8b1515; }
[data-theme="dark"] .alert-box.danger .alert-text { color: #fca5a5; }

.alert-box.closing {
  opacity: 0;
  transform: translateY(8px) scale(0.94);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

/* ===== 45. Site Dialog ===== */
.site-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(7, 14, 34, 0.58);
  backdrop-filter: blur(5px);
  animation: overlay-fade 0.22s ease both;
}

@keyframes overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.site-dialog-card {
  width: min(580px, 100%);
  border-radius: var(--r-xl);
  border: 1px solid #ccd8ed;
  background:
    radial-gradient(circle at 88% 9%, rgba(72, 108, 165, 0.12), transparent 46%),
    linear-gradient(165deg, #ffffff, #f3f7ff 70%, #eaf2ff);
  box-shadow: 0 28px 64px rgba(8, 20, 52, 0.38);
  padding: 24px;
  animation: dialog-in 0.28s var(--t-bounce) both;
}

[data-theme="dark"] .site-dialog-card {
  background: linear-gradient(165deg, var(--card), var(--card-alt));
  border-color: var(--line);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.65);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.site-dialog-card.danger {
  border-color: #f2c8c8;
  background:
    radial-gradient(circle at 90% 10%, rgba(248, 113, 113, 0.12), transparent 46%),
    linear-gradient(165deg, #ffffff, #fff5f5 68%, #ffe8e8);
}

[data-theme="dark"] .site-dialog-card.danger {
  background: linear-gradient(165deg, var(--card), #2a0e0e);
  border-color: #4a1212;
}

.site-dialog-card h3 {
  margin: 0 0 10px;
  color: #102f5d;
  font-size: 1.18rem;
}

[data-theme="dark"] .site-dialog-card h3 {
  color: var(--ink);
}

.site-dialog-message {
  margin: 0 0 14px;
  color: #34517e;
  font-size: 0.97rem;
  line-height: 1.82;
}

[data-theme="dark"] .site-dialog-message {
  color: var(--muted);
}

.site-dialog-label {
  margin-bottom: 7px;
  color: #1b3c72;
}

[data-theme="dark"] .site-dialog-label {
  color: var(--ink);
}

.site-dialog-input {
  margin-bottom: 11px;
}

.site-dialog-error {
  margin: 0 0 13px;
  border: 1px solid #f2c7c7;
  background: #fff5f5;
  color: #991b1b;
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font-size: 0.9rem;
  font-weight: 600;
}

[data-theme="dark"] .site-dialog-error {
  background: var(--danger-soft);
  border-color: #4a1212;
  color: #fca5a5;
}

.site-dialog-actions {
  justify-content: flex-start;
}

.site-dialog-actions button {
  min-width: 116px;
}

/* ===== 46. Ranking List ===== */
.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.ranking-list li {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card-alt);
  padding: 11px 14px;
  display: grid;
  grid-template-columns: 50px 1fr auto;
  align-items: center;
  gap: 10px;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}

.ranking-list li:hover {
  transform: translateX(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--accent);
}

.ranking-list li.current-student {
  border-color: var(--accent);
  background: var(--brand-soft);
}

[data-theme="dark"] .ranking-list li.current-student {
  background: rgba(72, 108, 165, 0.18);
}

.ranking-list li em {
  font-style: normal;
  color: var(--brand-strong);
  font-weight: 700;
}

[data-theme="dark"] .ranking-list li em {
  color: var(--accent);
}

/* ===== 47. Week Program Hero ===== */
.week-program-hero {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card-alt);
  padding: 18px;
  margin-bottom: 14px;
}

/* ===== 48. Weekly Schedule ===== */
.weekly-schedule {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.schedule-step {
  position: relative;
  border: 1px solid var(--line);
  background: var(--card-alt);
  border-radius: var(--r-md);
  padding: 16px 11px;
  text-align: center;
  transition: transform var(--t), box-shadow var(--t), border-color var(--t);
}

.schedule-step:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
}

.schedule-node {
  width: 84px;
  height: 84px;
  border-radius: var(--r-full);
  margin: 0 auto 12px;
  border: 5px solid var(--brand);
  box-shadow: 0 0 0 4px var(--brand-soft) inset;
  background: var(--card);
  display: grid;
  place-items: center;
  transition: transform var(--t-bounce);
}

.schedule-step:hover .schedule-node {
  transform: scale(1.1) rotate(-4deg);
}

[data-theme="dark"] .schedule-node {
  border-color: var(--accent);
  background: var(--card);
}

.schedule-icon {
  font-size: 1.85rem;
}

.schedule-step h4 {
  margin: 0 0 5px;
  color: var(--brand-strong);
  font-size: 0.94rem;
}

[data-theme="dark"] .schedule-step h4 {
  color: var(--accent);
}

.schedule-step p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
}

.schedule-arrow {
  position: absolute;
  left: -14px;
  top: 34%;
  color: var(--muted);
  font-size: 1.2rem;
}

/* ===== 49. Week Fruit ===== */
.week-fruit {
  border: 1.5px dashed var(--line);
  border-radius: var(--r);
  padding: 13px 16px;
  background: var(--card-alt);
}

.week-fruit.elegant {
  background: var(--card-alt);
  border-style: solid;
  border-color: var(--line);
}

.week-fruit blockquote {
  margin: 0 0 9px;
  padding-inline-start: 14px;
  border-inline-start: 4px solid var(--brand);
  color: var(--ink);
  font-weight: 600;
  line-height: 1.72;
}

/* ===== 50. Week Items ===== */
.week-items-wrap {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.week-items-wrap > .helper,
.weekly-schedule > .helper {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: var(--r);
  padding: 11px 13px;
  background: var(--card-alt);
}

.weekly-schedule > .helper {
  grid-column: 1 / -1;
}

.week-item-row {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card-alt);
  padding: 14px;
  transition: border-color var(--t);
}

.week-item-row:hover {
  border-color: var(--accent);
}

.week-item-row-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.week-item-row-fields input,
.week-item-row-fields select {
  margin-bottom: 0;
}

.week-item-row-actions {
  margin-top: 10px;
  justify-content: flex-end;
}

.week-program-actions {
  margin-bottom: 18px;
}

.week-program-fruit {
  margin-top: 12px;
}

/* ===== 51. Term Report Card ===== */
.term-report-card {
  background: var(--card) !important;
  border-color: var(--line);
  box-shadow: none;
}

.term-report-header {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 16px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 16px;
}

.term-report-header img {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

.term-report-header h2 {
  margin: 0 0 5px;
  font-size: 1.2rem;
}

.term-report-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.term-report-footer {
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.92rem;
}

.term-report-card table th {
  background: var(--card-alt);
}

/* ===== 52. PDF Export ===== */
.pdf-export-root {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  overflow: auto;
  background: #ffffff;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  direction: rtl;
}

.pdf-export-sheet {
  width: 210mm;
  max-width: 210mm;
  min-height: auto;
  margin: 0 auto;
  padding: 12mm;
  background: #fff;
  color: #0f1a2f;
  font-family: "Tajawal", "Cairo", sans-serif;
  direction: rtl;
  text-align: right;
}

.pdf-export-sheet h2,
.pdf-export-sheet h3 {
  color: #1b355f;
  margin-top: 0;
}

.pdf-export-sheet section {
  margin-bottom: 14px;
}

.pdf-table-wrap {
  overflow: hidden;
  border: 1px solid #cfd9ec;
  border-radius: 10px;
}

.pdf-export-sheet table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.pdf-export-sheet table th,
.pdf-export-sheet table td {
  border: 1px solid #d6e0f0;
  padding: 6px 8px;
  text-align: right;
  vertical-align: top;
}

.pdf-export-sheet table th {
  background: #eef4ff;
}

/* ===== 53. Archive Report ===== */
.archive-report-header,
.term-report-export .term-report-header {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 16px;
}

.archive-report-header {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 16px;
  align-items: center;
}

.archive-report-header img {
  width: 88px;
  height: 88px;
  object-fit: contain;
}

.report-logo-placeholder {
  width: 88px;
  height: 88px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--card-alt);
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.78rem;
  text-align: center;
  padding: 8px;
}

.archive-report-sheet,
.term-report-export {
  direction: rtl;
  text-align: right;
}

.archive-report-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.archive-report-stats > div {
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--card-alt);
  padding: 10px;
  text-align: center;
}

.archive-report-stats strong {
  display: block;
  font-size: 1.18rem;
  color: var(--brand);
}

[data-theme="dark"] .archive-report-stats strong {
  color: var(--accent);
}

.archive-report-stats span {
  color: var(--muted);
  font-size: 0.86rem;
}

/* ===== 54. Site Links ===== */
.site-links-actions {
  align-items: center;
}

.site-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--brand-strong);
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--card-alt);
  padding: 7px 14px;
  font-size: 0.92rem;
  transition: background var(--t), border-color var(--t), transform var(--t-fast), box-shadow var(--t);
}

.site-link:hover {
  background: var(--brand-soft);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-xs);
}

[data-theme="dark"] .site-link {
  color: var(--accent);
}

/* ===== 55. Podium Chart ===== */
.podium-chart {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 14px;
  margin-top: 10px;
}

.podium-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card-alt);
  padding: 16px 13px;
  text-align: center;
  display: grid;
  align-content: start;
  gap: 10px;
  transition: transform var(--t), box-shadow var(--t);
}

.podium-chart .podium-card:nth-child(1) {
  animation: rise-in 0.5s ease 0.08s both;
}

.podium-chart .podium-card:nth-child(2) {
  animation: rise-in 0.5s ease 0.14s both;
}

.podium-chart .podium-card:nth-child(3) {
  animation: rise-in 0.5s ease 0.22s both;
}

/* Medal emoji */
.podium-medal {
  font-size: 2.4rem;
  line-height: 1;
  animation: medal-pop 0.55s var(--t-bounce) 0.5s both;
}

@keyframes medal-pop {
  from { transform: scale(0) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

.podium-rank {
  display: inline-block;
  margin: 0 auto;
  padding: 5px 14px;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 800;
  font-size: 0.88rem;
}

[data-theme="dark"] .podium-rank {
  background: rgba(72, 108, 165, 0.22);
  color: var(--accent);
}

.podium-content {
  display: grid;
  gap: 5px;
}

.podium-name {
  font-size: 1.06rem;
  color: var(--ink);
  font-weight: 700;
}

.podium-points {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
}

/* Place 1 - Gold */
.podium-card.place-1 {
  min-height: 215px;
  transform: translateY(-14px);
  border-color: #d4a800;
  background: linear-gradient(165deg, #fefce8, #fef3c7);
  box-shadow: 0 14px 32px rgba(212, 168, 0, 0.24);
}

[data-theme="dark"] .podium-card.place-1 {
  background: linear-gradient(165deg, #2d2600, #1e1a00);
  border-color: #5a4d00;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.5);
}

.podium-card.place-1:hover {
  transform: translateY(-20px);
  box-shadow: 0 22px 48px rgba(212, 168, 0, 0.36);
}

.podium-card.place-1 .podium-rank {
  background: linear-gradient(120deg, #d4a800, #b38c00);
  color: #fff;
  box-shadow: 0 4px 14px rgba(212, 168, 0, 0.45);
}

/* Place 2 - Silver */
.podium-card.place-2 {
  min-height: 175px;
  border-color: #9aa6b8;
}

[data-theme="dark"] .podium-card.place-2 {
  border-color: #4b5563;
}

.podium-card.place-2 .podium-rank {
  background: linear-gradient(120deg, #9ca3af, #6b7280);
  color: #fff;
}

/* Place 3 - Bronze */
.podium-card.place-3 {
  min-height: 160px;
  border-color: #c07828;
}

[data-theme="dark"] .podium-card.place-3 {
  border-color: #6b3a0a;
}

.podium-card.place-3 .podium-rank {
  background: linear-gradient(120deg, #c07828, #9a5c14);
  color: #fff;
}

.podium-card.place-empty {
  border-style: dashed;
  background: var(--card);
  opacity: 0.65;
}

/* ===== 56. Announcement List ===== */
.announcement-list {
  display: grid;
  gap: 16px;
}

.announcement-card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: var(--r-md);
  padding: 18px;
  animation: rise-in 0.4s ease both;
  position: relative;
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}

.announcement-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.announcement-card h4 {
  margin: 0;
  font-size: 1.08rem;
}

.announcement-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.announcement-meta {
  color: var(--muted);
  margin-top: 9px;
  font-size: 0.86rem;
}

.announcement-card .inline-actions {
  position: relative;
  z-index: 2;
}

.announcement-card .inline-actions button {
  pointer-events: auto;
}

button[data-action="edit-announcement"],
button[data-action="delete-announcement"] {
  position: relative;
  z-index: 6;
}

/* ===== 57. Announcement Attachments ===== */
.announcement-attachments {
  margin-top: 14px;
  border-top: 1px dashed var(--line);
  padding-top: 14px;
  display: grid;
  gap: 14px;
}

.announcement-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 13px;
}

.announcement-image {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 9px;
  background: var(--card-alt);
  transition: border-color var(--t), transform var(--t);
}

.announcement-image:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.announcement-image-link {
  display: block;
  text-decoration: none;
}

.announcement-image img {
  width: 100%;
  height: 192px;
  object-fit: cover;
  border-radius: calc(var(--r) - 3px);
  display: block;
  transition: opacity var(--t);
}

.announcement-image img:hover {
  opacity: 0.88;
}

.announcement-image figcaption {
  margin-top: 8px;
  font-size: 0.84rem;
  color: var(--muted);
  word-break: break-word;
}

.announcement-files {
  display: grid;
  gap: 10px;
}

.announcement-file {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--card-alt);
  padding: 11px 13px;
  transition: border-color var(--t);
}

.announcement-file:hover {
  border-color: var(--accent);
}

.announcement-file span {
  flex: 1;
  overflow-wrap: anywhere;
}

.announcement-file-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.announcement-file a {
  text-decoration: none;
  color: var(--brand-strong);
  font-weight: 700;
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  background: var(--card);
  padding: 5px 11px;
  font-size: 0.88rem;
  transition: background var(--t), border-color var(--t);
}

.announcement-file a:hover {
  background: var(--brand-soft);
  border-color: var(--accent);
}

[data-theme="dark"] .announcement-file a {
  color: var(--accent);
}

.announcement-pdf-preview {
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  background: var(--card);
}

.announcement-pdf-preview iframe {
  width: 100%;
  height: 340px;
  border: 0;
  pointer-events: none;
}

/* ===== 58. Attachment Manager ===== */
.attachment-manager {
  margin-top: 9px;
  margin-bottom: 13px;
  border: 1.5px dashed var(--line);
  border-radius: var(--r);
  padding: 12px;
  background: var(--card-alt);
  transition: border-color var(--t);
}

.attachment-manager:hover {
  border-color: var(--accent);
}

.attachment-manager h4 {
  margin-top: 0;
  margin-bottom: 9px;
}

.attachment-check {
  margin-bottom: 8px;
}

.attachment-check:last-child {
  margin-bottom: 0;
}

/* ===== 59. Site Settings Grid ===== */
.site-settings-grid .card {
  height: 100%;
  position: relative;
  overflow: hidden;
}

.site-settings-grid .card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 92% 8%, rgba(72, 108, 165, 0.12), transparent 40%),
    radial-gradient(circle at 6% 100%, rgba(26, 46, 98, 0.07), transparent 36%);
}

.site-settings-grid .card > * {
  position: relative;
  z-index: 1;
}

/* ===== 60. Site Theme Palette ===== */
.site-theme-palette {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 14px;
}

.theme-swatch-btn {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  background: var(--card-alt);
  color: var(--ink);
  padding: 11px 12px;
  text-align: right;
  font-weight: 700;
  transition: transform var(--t-fast), box-shadow var(--t), border-color var(--t);
}

.theme-swatch-btn::after {
  content: "";
  position: absolute;
  left: -48px;
  top: -54px;
  width: 120px;
  height: 120px;
  border-radius: var(--r-full);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
  opacity: 0;
  transition: opacity var(--t);
}

.theme-swatch-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.theme-swatch-btn:hover::after {
  opacity: 1;
}

.theme-swatch-btn.active {
  border-color: var(--brand);
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(72, 108, 165, 0.2);
  background: var(--brand-soft);
}

.theme-swatch-btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-swatch-dot {
  width: 22px;
  height: 22px;
  border-radius: var(--r-full);
  border: 1px solid rgba(15, 23, 42, 0.2);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.32);
  flex: 0 0 auto;
}

.site-theme-custom-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.site-theme-custom-row input[type="color"] {
  width: 66px;
  min-width: 66px;
  height: 46px;
  border-radius: var(--r-sm);
  padding: 4px;
  margin-bottom: 0;
  cursor: pointer;
}

.site-theme-custom-row input[type="text"] {
  margin-bottom: 0;
}

.site-settings-actions {
  margin-top: 9px;
}

.site-settings-actions button {
  min-width: 175px;
}

.site-settings-actions .secondary {
  background: linear-gradient(120deg, #4b618a, #5c749e);
}

/* ===== 61. Site Login Preview ===== */
.site-login-preview {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--card);
  position: relative;
  isolation: isolate;
  box-shadow: var(--shadow-lg);
  animation: rise-in 0.4s ease both;
}

.site-login-preview::after {
  content: "";
  position: absolute;
  inset: -35% auto auto -40%;
  width: 180px;
  height: 180px;
  border-radius: var(--r-full);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0));
  pointer-events: none;
  z-index: 2;
  animation: preview-glow 4.8s ease-in-out infinite;
}

.site-login-preview-banner {
  padding: 16px;
  position: relative;
  z-index: 1;
  background:
    radial-gradient(circle at 88% 15%, rgba(255, 255, 255, 0.18), transparent 42%),
    linear-gradient(126deg, var(--preview-brand-strong), var(--preview-brand));
  color: #f6fbff;
}

.site-login-preview-banner h4,
.site-login-preview-banner p {
  margin: 0;
}

.site-login-preview-banner h4 {
  font-size: 1.06rem;
  font-weight: 700;
}

.site-login-preview-banner p {
  margin-top: 6px;
  opacity: 0.9;
  font-size: 0.9rem;
}

.site-login-preview-description {
  margin-top: 8px !important;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.14);
  border-radius: var(--r-full);
  padding: 4px 12px;
  font-size: 0.81rem !important;
  line-height: 1.48;
}

.site-login-preview-body {
  padding: 16px;
  display: grid;
  gap: 9px;
  background: linear-gradient(180deg, #fcfdff, var(--preview-brand-soft));
  position: relative;
  z-index: 1;
}

.site-login-preview-field {
  border: 1px solid #c7d8ef;
  border-radius: var(--r-sm);
  padding: 9px 11px;
  background: #fff;
  color: #516886;
  font-size: 0.9rem;
}

.site-login-preview-body button {
  margin-top: 3px;
  background: linear-gradient(122deg, var(--preview-brand), var(--preview-brand-strong));
  opacity: 0.94;
  box-shadow: 0 8px 18px rgba(22, 41, 79, 0.22);
}

/* ===== 62. Loading State ===== */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 55vh;
  gap: 20px;
  text-align: center;
  animation: rise-in 0.4s ease both;
}

.loading-logo-wrap {
  position: relative;
  width: 84px;
  height: 84px;
}

.loading-logo-img {
  width: 84px;
  height: 84px;
  border-radius: 20px;
  object-fit: contain;
  animation: pulse-logo 1.9s ease-in-out infinite;
}

@keyframes pulse-logo {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(0.9); opacity: 0.72; }
}

.loading-spinner-ring {
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-right-color: var(--accent);
  animation: spin 1.2s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}

.loading-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand);
  animation: dots-bounce 1.3s ease-in-out infinite both;
}

.loading-dots span:nth-child(2) { animation-delay: 0.18s; }
.loading-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes dots-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1); opacity: 1; }
}

.loading-text {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.96rem;
}

/* ===== 63. Scroll Reveal ===== */
.sr {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}

.sr.sr-visible {
  opacity: 1;
  transform: translateY(0);
}

.sr-delay-1 { transition-delay: 0.1s; }
.sr-delay-2 { transition-delay: 0.2s; }
.sr-delay-3 { transition-delay: 0.3s; }
.sr-delay-4 { transition-delay: 0.42s; }

/* ===== 64. Hidden ===== */
.hidden {
  display: none !important;
}

/* ===== 65. Keyframes ===== */
@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes preview-glow {
  0%, 100% {
    transform: translate3d(0, 0, 0);
    opacity: 0.22;
  }
  50% {
    transform: translate3d(18px, -12px, 0);
    opacity: 0.44;
  }
}

/* ===== 66. Responsive ===== */
@media (max-width: 900px) {
  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .top-banner {
    padding: 14px 16px;
  }

  .brand h1,
  .brand h2 {
    font-size: 1.1rem;
  }

  .user-badge {
    width: 100%;
    justify-content: space-between;
  }

  .landing-hero {
    padding: 22px 18px;
  }

  .landing-hero-grid {
    grid-template-columns: 1fr;
  }

  .landing-hero-head {
    gap: 12px;
    margin-bottom: 14px;
  }

  .landing-hero-logo {
    width: 72px;
    height: 72px;
    border-radius: 17px;
    padding: 7px;
  }

  .landing-chip-row {
    margin-bottom: 8px;
  }

  .landing-hero-copy h1 {
    font-size: 1.65rem;
    -webkit-text-fill-color: #ffffff;
    background: none;
  }

  .landing-stat-row,
  .landing-card-grid,
  .landing-steps,
  .landing-module-grid {
    grid-template-columns: 1fr;
  }

  .landing-section-card {
    padding: 18px;
  }

  .landing-step:not(:last-child)::after {
    display: none;
  }

  .landing-hero-actions button,
  .landing-cta-card button,
  .landing-telegram-btn {
    width: 100%;
    min-width: 0;
  }

  .landing-hero-actions button {
    line-height: 1.55;
  }

  .public-hero-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .public-hero-actions button {
    flex: 1 1 calc(50% - 8px);
  }

  .role-nav .nav-btn {
    flex: 1 1 calc(50% - 6px);
  }

  .site-theme-palette {
    grid-template-columns: 1fr;
  }

  .site-theme-custom-row {
    flex-direction: column;
    align-items: stretch;
  }

  .site-theme-custom-row input[type="color"] {
    width: 100%;
    min-width: 0;
  }

  .inline-actions > button,
  .inline-actions > .site-link {
    flex: 1 1 100%;
    text-align: center;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .podium-chart {
    gap: 8px;
  }

  .podium-card {
    padding: 12px 9px;
  }

  .podium-card.place-1 {
    min-height: 184px;
    transform: translateY(-10px);
  }

  .podium-card.place-2 {
    min-height: 154px;
  }

  .podium-card.place-3 {
    min-height: 142px;
  }

  .weekly-schedule {
    grid-template-columns: 1fr;
  }

  .week-item-row-fields {
    grid-template-columns: 1fr;
  }

  .schedule-arrow {
    display: none;
  }

  .announcement-images {
    grid-template-columns: 1fr;
  }

  .announcement-image img {
    height: 220px;
  }

  .announcement-file {
    flex-direction: column;
  }

  .announcement-pdf-preview iframe {
    height: 260px;
  }

  .alert-host {
    inset-inline-start: 10px;
    inset-inline-end: 10px;
    width: auto;
    bottom: 10px;
  }

  .ranking-list li {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .term-report-header {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .term-report-header img {
    margin: 0 auto;
  }

  .dm-toggle-public {
    top: 12px;
    inset-inline-start: 12px;
    width: 38px;
    height: 38px;
  }
}
