* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text-main);
  font-family: var(--font-sans);
  background: var(--page-bg);
  background-size: 120% 120%;
  transition: background 0.32s ease, color 0.24s ease;
  animation: calmGradient 16s ease-in-out infinite alternate;
}

button,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.mobile-topbar,
.mobile-menu-backdrop {
  display: none;
}

.side-rail {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px;
  border-right: 1px solid var(--border);
  background: var(--rail-bg);
  backdrop-filter: blur(18px);
  transition: background-color 0.24s ease, border-color 0.24s ease;
}

.content-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 125, 168, 0.45) transparent;
}

.content-shell::-webkit-scrollbar {
  width: 8px;
}

.content-shell::-webkit-scrollbar-track {
  background: transparent;
}

.content-shell::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(255, 125, 168, 0.36);
  background-clip: padding-box;
}

.content-shell::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 125, 168, 0.58);
  background-clip: padding-box;
}

.top-bar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 34px 8px;
}

.top-bar h1 {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  position: relative;
  min-height: 32px;
  padding: 0;
  color: var(--ink);
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1rem, 1.45vw, 1.28rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.top-bar h1::before {
  content: "✦";
  color: var(--primary);
  font-family: var(--font-sans);
  font-size: 0.72em;
  line-height: 1;
  transform: translateY(-1px);
}

.top-bar h1::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: -7px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent), transparent);
  opacity: 0.72;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.welcome-copy .eyebrow::before {
  content: "✦";
  color: var(--primary);
  font-family: var(--font-sans);
  font-size: 0.85em;
  margin-right: 5px;
}

.page-view {
  min-height: 0;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.hidden {
  display: none !important;
}

#chat-container {
  flex: 0 0 auto;
  width: 100%;
  margin: 0 auto;
  padding: 0 max(24px, calc((100vw - 248px - 1080px) / 2 + 24px)) 220px;
  overflow: visible;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.footer-container {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 248px;
  z-index: 25;
  border-top: 0;
  padding: 12px 24px 16px;
  background: transparent;
  backdrop-filter: none;
  pointer-events: none;
  transition: background-color 0.24s ease, border-color 0.24s ease;
}

.mode-tabs,
#input-form,
.disclaimer {
  pointer-events: auto;
}

.disclaimer {
  margin-top: 8px;
  color: var(--text-soft);
  font-size: 0.76rem;
  text-align: center;
}

@keyframes calmGradient {
  0% {
    background-position: 0% 20%;
  }

  100% {
    background-position: 70% 50%;
  }
}

@media (max-width: 900px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
  }

  .mobile-topbar {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
  }

  .mobile-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    background: transparent;
    opacity: 0;
    pointer-events: none;
  }

  body.mobile-menu-open .mobile-menu-backdrop {
    pointer-events: auto;
  }

  .side-rail {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 45;
    width: min(290px, 82vw);
    height: 100vh;
    height: 100dvh;
    gap: 14px;
    padding: 18px 14px;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    background: var(--rail-bg);
    backdrop-filter: blur(18px);
    transform: translateX(-105%);
    transition: transform 0.28s ease, margin-bottom 0.28s ease, background-color 0.24s ease, border-color 0.24s ease;
  }

  body.mobile-menu-open .side-rail {
    transform: translateX(0);
  }

  .content-shell {
    min-height: 0;
    height: calc(100vh - 62px);
    height: calc(100dvh - 62px);
  }

  .top-bar {
    min-height: auto;
    padding: 12px 18px 6px;
  }

  .top-bar .eyebrow,
  .rail-note {
    display: none;
  }

  .status-pill {
    display: none;
  }

  #chat-container {
    padding: 18px 14px 190px;
  }

  .footer-container {
    left: 0;
    padding: 10px 12px 12px;
  }
}

@media (max-width: 640px) {
  .side-rail {
    display: flex;
    grid-template-columns: none;
    align-items: stretch;
    gap: 18px;
    padding: 18px 14px 20px;
  }

  .nav-links {
    grid-column: auto;
  }

  .top-bar {
    display: none;
  }

  .content-shell {
    flex: 1;
    height: calc(100vh - 62px);
    height: calc(100dvh - 62px);
    min-height: 0;
  }

  #chat-container {
    padding: 14px 14px 176px;
  }

  .footer-container {
    position: fixed;
    left: 0;
    z-index: 20;
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
    background: transparent;
  }
}
