:root {
  --rd-bg-1: #110b24;
  --rd-bg-2: #1b1233;
  --rd-panel: rgba(19, 12, 39, 0.88);
  --rd-panel-2: rgba(30, 17, 57, 0.92);
  --rd-border: rgba(196, 167, 255, 0.22);
  --rd-text: #f5edff;
  --rd-muted: #cabbe8;
  --rd-accent: #8f56ff;
  --rd-accent-2: #5f39cf;
  --rd-ok: #2dd07d;
}

.page-main {
  padding-bottom: 110px;
}

.rd-wrap {
  max-width: 1320px;
  margin: 0 auto;
  color: var(--rd-text);
  font-family: Inter, system-ui, sans-serif;
}

.rd-hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.rd-hero p {
  margin: 8px 0 0;
  color: var(--rd-muted);
}

.rd-stat-pills {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.rd-stat-pill {
  background: linear-gradient(135deg, rgba(143, 86, 255, 0.2), rgba(95, 57, 207, 0.11));
  border: 1px solid var(--rd-border);
  border-radius: 16px;
  padding: 10px 12px;
}

.rd-stat-pill b {
  display: block;
  font-size: 1.1rem;
}

.rd-stat-pill span {
  font-size: 0.85rem;
  color: var(--rd-muted);
}

.rd-sage-banner {
  margin-top: 18px;
  border: 1px solid rgba(45, 208, 125, 0.3);
  background: radial-gradient(130% 120% at 0% 0%, rgba(53, 32, 104, 0.95), rgba(15, 9, 28, 0.96));
  border-radius: 18px;
  padding: 16px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  cursor: pointer;
}

.rd-sage-avatar-wrap {
  position: relative;
  width: 64px;
  height: 64px;
}

.rd-sage-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.7rem;
  background: linear-gradient(135deg, #5f39cf, #8f56ff);
  box-shadow: 0 0 0 0 rgba(143, 86, 255, 0.6);
  animation: rdPulse 2s infinite;
}

.rd-online-dot {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--rd-ok);
  border: 2px solid #120b23;
}

@keyframes rdPulse {
  0% { box-shadow: 0 0 0 0 rgba(143, 86, 255, 0.56); }
  70% { box-shadow: 0 0 0 16px rgba(143, 86, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(143, 86, 255, 0); }
}

.rd-sage-badge {
  color: #8cffc8;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
}

.rd-sage-copy h2 {
  margin: 4px 0 6px;
  font-size: 1.2rem;
}

.rd-sage-copy p {
  margin: 0;
  color: var(--rd-muted);
}

.rd-sage-chips {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rd-chip {
  border: 1px solid var(--rd-border);
  background: rgba(26, 16, 50, 0.8);
  color: var(--rd-text);
  border-radius: 999px;
  font-size: 0.8rem;
  padding: 7px 10px;
  cursor: pointer;
}

.rd-sage-cta {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--rd-accent), var(--rd-accent-2));
  cursor: pointer;
}

.rd-controls {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

#rdSearch {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--rd-border);
  background: rgba(15, 10, 30, 0.84);
  color: var(--rd-text);
  border-radius: 12px;
  padding: 0 12px;
}

.rd-view-toggle button,
.rd-admin-add {
  height: 42px;
  border: 1px solid var(--rd-border);
  color: var(--rd-text);
  background: rgba(15, 10, 30, 0.84);
  border-radius: 12px;
  padding: 0 12px;
  cursor: pointer;
}

.rd-view-toggle .is-active {
  background: rgba(143, 86, 255, 0.25);
}

.rd-admin-add {
  background: linear-gradient(135deg, rgba(143, 86, 255, 0.26), rgba(95, 57, 207, 0.18));
}

.rd-filter-bar {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

#rdFilterBar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#rdResultCount {
  margin-left: auto;
  color: var(--rd-muted);
  font-size: 0.92rem;
}

.rd-chip.is-active {
  border-color: rgba(143, 86, 255, 0.9);
  background: rgba(143, 86, 255, 0.28);
}

.rd-featured {
  margin-top: 20px;
}

.rd-featured h3 {
  margin: 0 0 10px;
}

.rd-featured-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.rd-feature-card {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(158, 111, 255, 0.35);
  background: linear-gradient(160deg, rgba(143, 86, 255, 0.2), rgba(20, 12, 39, 0.96));
}

.rd-feature-card h4 {
  margin: 8px 0;
}

.rd-feature-card p {
  margin: 0;
  color: var(--rd-muted);
}

.rd-feature-open {
  margin-top: 10px;
  border: 0;
  border-radius: 10px;
  background: rgba(143, 86, 255, 0.24);
  color: #fff;
  padding: 8px 10px;
  cursor: pointer;
}

.rd-resource-grid {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.rd-resource-grid.is-list {
  display: flex;
  flex-direction: column;
}

.rd-card {
  border-radius: 14px;
  border: 1px solid var(--rd-border);
  background: var(--rd-panel);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 210px;
}

.rd-resource-grid.is-list .rd-card {
  min-height: 0;
}

.rd-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.rd-card-icon {
  font-size: 1.35rem;
}

.rd-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rd-tag {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  border: 1px solid rgba(214, 192, 255, 0.3);
  color: #dccbfc;
}

.rd-card h4 {
  margin: 2px 0;
  font-size: 1.02rem;
}

.rd-card p {
  margin: 0;
  color: var(--rd-muted);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.rd-card-actions {
  margin-top: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rd-card-actions button {
  border: 1px solid rgba(202, 175, 251, 0.25);
  background: rgba(35, 22, 66, 0.9);
  color: #fff;
  border-radius: 10px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: 0.82rem;
}

.rd-card-actions .rd-open-btn {
  background: rgba(143, 86, 255, 0.25);
}

.rd-card-actions .is-bookmarked {
  background: rgba(45, 208, 125, 0.2);
  border-color: rgba(45, 208, 125, 0.5);
}

.rd-empty {
  margin-top: 14px;
  border: 1px dashed var(--rd-border);
  border-radius: 12px;
  padding: 18px;
  color: var(--rd-muted);
}

.rd-modal {
  position: fixed;
  inset: 0;
  z-index: 7800;
}

.rd-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 5, 12, 0.6);
  backdrop-filter: blur(8px);
}

.rd-modal-dialog {
  position: relative;
  z-index: 2;
  max-width: 980px;
  margin: 5vh auto;
  border: 1px solid var(--rd-border);
  border-radius: 16px;
  background: #100a22;
  color: var(--rd-text);
}

.rd-viewer-dialog {
  width: min(96vw, 1100px);
}

.rd-viewer-head,
.rd-viewer-foot {
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(210, 184, 255, 0.18);
}

.rd-viewer-foot {
  border-bottom: 0;
  border-top: 1px solid rgba(210, 184, 255, 0.18);
}

.rd-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
}

.rd-viewer-body {
  height: min(70vh, 720px);
  padding: 10px;
}

.rd-viewer-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 10px;
  background: #fff;
}

.rd-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--rd-muted);
}

.rd-viewer-foot button {
  border: 1px solid var(--rd-border);
  background: rgba(39, 24, 76, 0.8);
  color: #fff;
  border-radius: 10px;
  padding: 8px 11px;
  cursor: pointer;
}

.rd-sage-dialog {
  width: min(96vw, 720px);
  background: radial-gradient(120% 120% at 0% 0%, #2d1b56, #0f0a1f);
  border-color: rgba(143, 86, 255, 0.4);
}

.rd-sage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid rgba(205, 177, 255, 0.22);
}

.rd-sage-head-main {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rd-sage-head-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5f39cf, #8f56ff);
}

.rd-sage-head-avatar.is-active {
  animation: rdPulse 1.3s infinite;
}

.rd-sage-head-title {
  font-weight: 700;
}

.rd-sage-head-status {
  color: #9ef3c9;
  font-size: 0.82rem;
}

.rd-sage-head-status span {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--rd-ok);
  margin-right: 5px;
}

.rd-sage-messages {
  max-height: 440px;
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rd-msg {
  max-width: 84%;
  padding: 10px;
  border-radius: 12px;
  line-height: 1.45;
  white-space: pre-line;
}

.rd-msg.user {
  margin-left: auto;
  background: linear-gradient(135deg, #8f56ff, #5f39cf);
}

.rd-msg.agent {
  border: 1px solid rgba(143, 86, 255, 0.46);
  background: rgba(20, 13, 37, 0.85);
}

.rd-typing {
  display: inline-flex;
  gap: 4px;
}

.rd-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d8c6fc;
  animation: rdBounce 1s infinite;
}

.rd-typing i:nth-child(2) { animation-delay: .1s; }
.rd-typing i:nth-child(3) { animation-delay: .2s; }

@keyframes rdBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.6; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.rd-sage-quick-replies {
  padding: 0 12px 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rd-sage-input-row {
  border-top: 1px solid rgba(205, 177, 255, 0.22);
  padding: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
}

#rdSageInput {
  resize: none;
  max-height: 120px;
  min-height: 42px;
  border: 1px solid rgba(200, 171, 252, 0.35);
  border-radius: 10px;
  background: rgba(17, 11, 34, 0.85);
  color: #fff;
  padding: 10px;
  font-family: inherit;
}

#rdMicBtn,
#rdSageSendBtn {
  border: 1px solid rgba(200, 171, 252, 0.35);
  border-radius: 10px;
  background: rgba(30, 18, 57, 0.85);
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
}

.rd-link-block {
  margin-top: 8px;
  border: 1px solid rgba(192, 161, 250, 0.32);
  border-radius: 10px;
  background: rgba(20, 13, 37, 0.74);
  padding: 8px;
  cursor: pointer;
}

.rd-link-block strong {
  display: block;
}

.rd-floating-sage {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 8000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  color: #fff;
  font-size: 1.3rem;
  background: linear-gradient(135deg, #8f56ff, #5f39cf);
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.36);
}

.rd-floating-sage span {
  position: absolute;
  right: 7px;
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rd-ok);
  border: 2px solid #fff;
}

.rd-toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 8200;
  background: rgba(24, 16, 45, 0.96);
  border: 1px solid rgba(196, 167, 255, 0.28);
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
}

@media (max-width: 900px) {
  .rd-stat-pills {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rd-sage-banner {
    grid-template-columns: 1fr;
  }

  .rd-controls {
    grid-template-columns: 1fr;
  }

  .rd-view-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .rd-viewer-foot {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}
