:root {
  --bg-deep: #0a0b0d;
  --bg-charcoal: #111316;
  --bg-panel: #16191e;
  --bg-elevated: #1c2026;
  --bg-hover: #242a32;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.1);
  --text-primary: #f2f3f5;
  --text-secondary: #9aa3af;
  --text-muted: #6b7380;
  --accent-warm: #d4b896;
  --radius-pill: 999px;
  --radius-tile: 18px;
  --sidebar-width: 220px;
  --font-sans: "Outfit", "Segoe UI", sans-serif;
  --font-display: "Source Serif 4", "Georgia", serif;
  --shadow-soft: 0 20px 60px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-deep);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 55% 18%, rgba(180, 150, 110, 0.07), transparent 55%),
    radial-gradient(ellipse 50% 40% at 15% 80%, rgba(70, 90, 120, 0.08), transparent 50%),
    radial-gradient(ellipse 40% 30% at 85% 70%, rgba(90, 70, 50, 0.06), transparent 45%),
    linear-gradient(180deg, #0d0f12 0%, #0a0b0d 45%, #090a0c 100%);
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.shell {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.35rem 0.9rem 1rem;
  border-right: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(18, 20, 24, 0.92), rgba(12, 13, 16, 0.88));
  backdrop-filter: blur(10px);
}

.sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.5rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 1.2rem;
  height: 2.85rem;
  flex-shrink: 0;
  color: var(--text-primary);
}

.brand-mark .palmyrah-logo {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-name {
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  color: var(--text-secondary);
  transition: background 180ms var(--ease), color 180ms var(--ease), transform 180ms var(--ease);
}

.nav-item i {
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 1.75;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.is-active {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
}

.sidebar-bottom {
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.sign-in {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  color: var(--text-secondary);
  transition: background 180ms var(--ease), color 180ms var(--ease);
}

.sign-in:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.sign-in i {
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 1.75;
}

.sign-in-chevron {
  margin-left: auto;
  width: 1rem;
  height: 1rem;
  opacity: 0.55;
}

.menu-toggle {
  display: none;
  position: fixed;
  top: 0.9rem;
  left: 0.9rem;
  z-index: 40;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(22, 25, 30, 0.9);
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.menu-toggle i {
  width: 1.2rem;
  height: 1.2rem;
}

.sidebar-backdrop {
  display: none;
}

/* Main */
.main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.75rem 1.75rem 2rem;
  min-height: 100vh;
}

.hero {
  width: min(960px, 100%);
  text-align: center;
  animation: rise-in 700ms var(--ease) both;
}

.hero-logo {
  width: 3.85rem;
  height: 9.25rem;
  margin: 0 auto 0.5rem;
  color: var(--text-primary);
  filter: drop-shadow(0 8px 24px rgba(212, 184, 150, 0.12));
  animation: float-soft 5.5s ease-in-out infinite;
}

.hero-logo .palmyrah-logo {
  width: 100%;
  height: 100%;
  display: block;
}

.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.6vw, 2.55rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.hero-tagline {
  margin: 0.7rem auto 0;
  max-width: 34rem;
  color: var(--text-secondary);
  font-size: 0.98rem;
  font-weight: 400;
  line-height: 1.5;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: min(640px, 100%);
  margin: 1.55rem auto 0;
  padding: 0.5rem 0.5rem 0.5rem 1.1rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(28, 32, 38, 0.95), rgba(20, 23, 28, 0.95));
  box-shadow: var(--shadow-soft);
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease), transform 200ms var(--ease);
}

.search:focus-within {
  border-color: rgba(212, 184, 150, 0.35);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(212, 184, 150, 0.08);
  transform: translateY(-1px);
}

.search-icon {
  flex: 0 0 auto;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--text-muted);
  stroke-width: 1.75;
}

.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 1.02rem;
  padding: 0.55rem 0;
}

.search input::placeholder {
  color: var(--text-muted);
}

.search-submit {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  border: 0;
  border-radius: 50%;
  background: #f4f5f7;
  color: #121418;
  cursor: pointer;
  transition: transform 180ms var(--ease), background 180ms var(--ease);
}

.search-submit:hover {
  background: #ffffff;
  transform: scale(1.04);
}

.search-submit i {
  width: 1.1rem;
  height: 1.1rem;
  stroke-width: 2.2;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1.35rem;
}

.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.05rem 0.7rem 1rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-tile);
  background: linear-gradient(180deg, rgba(28, 32, 38, 0.72), rgba(18, 20, 24, 0.72));
  color: var(--text-primary);
  transition: transform 220ms var(--ease), background 220ms var(--ease), border-color 220ms var(--ease);
  animation: rise-in 700ms var(--ease) both;
}

.tile:nth-child(1) { animation-delay: 80ms; }
.tile:nth-child(2) { animation-delay: 140ms; }
.tile:nth-child(3) { animation-delay: 200ms; }
.tile:nth-child(4) { animation-delay: 260ms; }
.tile:nth-child(5) { animation-delay: 320ms; }

.tile:hover {
  transform: translateY(-3px);
  border-color: rgba(212, 184, 150, 0.22);
  background: linear-gradient(180deg, rgba(36, 41, 48, 0.9), rgba(22, 25, 30, 0.9));
}

.tile i {
  width: 1.35rem;
  height: 1.35rem;
  margin-bottom: 0.25rem;
  color: var(--accent-warm);
  stroke-width: 1.7;
}

.tile h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tile p {
  margin: 0;
  max-width: 11rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

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

@keyframes float-soft {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@media (max-width: 980px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: grid;
    place-items: center;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(280px, 84vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 260ms var(--ease);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.45);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 45;
    background: rgba(0, 0, 0, 0.45);
  }

  .sidebar-backdrop[hidden] {
    display: none;
  }

  .main {
    padding: 4.5rem 1.15rem 2.5rem;
  }

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

@media (max-width: 520px) {
  .hero-logo {
    width: 2.85rem;
    height: 6.85rem;
  }

  .tiles {
    grid-template-columns: 1fr;
  }

  .tile {
    align-items: flex-start;
    text-align: left;
    padding: 1.1rem 1.15rem;
  }

  .tile p {
    max-width: none;
  }
}

.rag-panel {
  width: min(720px, 100%);
  margin: 1.75rem auto 0;
  text-align: left;
  animation: rag-in 420ms var(--ease) both;
}

.rag-panel[hidden] {
  display: none;
}

.rag-status {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.rag-answer {
  margin: 0;
  padding: 1.1rem 0 0.25rem;
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--text-primary);
  border-top: 1px solid var(--border-subtle);
  font-size: 1.02rem;
}

.rag-refs {
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.85rem;
}

.rag-refs li {
  display: grid;
  gap: 0.35rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}

.rag-refs li strong,
.rag-ref-link {
  color: var(--accent-warm);
  font-weight: 500;
}

.rag-ref-link {
  text-decoration: underline;
  text-decoration-color: rgba(212, 184, 150, 0.35);
  text-underline-offset: 0.18em;
}

.rag-ref-link:hover {
  color: #e6d0b2;
  text-decoration-color: rgba(230, 208, 178, 0.7);
}

.rag-ref-meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.rag-ref-open {
  color: var(--accent-warm);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.rag-refs li span {
  color: var(--text-muted);
}

@keyframes rag-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
