:root {
  color-scheme: light;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #f4f4f5;
  --text: #111827;
  --text-muted: #71717a;
  --border: #e4e4e7;
  --pink: #eb4a8c;
  --pink-soft: #fde7f1;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 25;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-badge {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.8rem;
  color: #ffffff;
  font-weight: 700;
  background: linear-gradient(135deg, #f471b5 0%, #eb4a8c 45%, #a91f55 100%);
}

.icon-button {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.22rem;
  width: 2.2rem;
  height: 2.2rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: var(--surface);
  cursor: pointer;
}

.icon-button span {
  width: 1rem;
  height: 2px;
  margin: 0 auto;
  border-radius: 999px;
  background: #52525b;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.25);
}

.tooltip-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 24, 39, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.tooltip-backdrop.visible {
  opacity: 1;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 15.5rem;
  min-height: 100vh;
  padding: 1rem 0.8rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.sidebar-top {
  padding: 0.35rem 0.55rem 0.9rem;
}

.nav-group {
  display: grid;
  gap: 0.2rem;
}

.nav-item {
  border-radius: 0.85rem;
  padding: 0.72rem 0.78rem;
  color: #52525b;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-item:hover {
  background: var(--surface-soft);
  color: #18181b;
}

.nav-item.active {
  background: var(--pink-soft);
  color: var(--pink);
}

.nav-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.nav-divider {
  margin: 0.65rem 0.8rem;
  border-top: 1px solid var(--border);
}

.nav-footer {
  margin-top: auto;
  display: grid;
  gap: 0.2rem;
}

.logged-in-card {
  margin-top: 0.75rem;
  border: 1px solid #f8c8df;
  border-radius: 0.85rem;
  padding: 0.65rem 0.78rem;
  background: #fff1f7;
}

.logged-in-label {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9f1239;
  font-weight: 600;
}

.logged-in-role {
  margin: 0.18rem 0 0;
  color: #881337;
  font-size: 0.9rem;
  font-weight: 600;
}

.main-content {
  flex: 1;
  min-width: 0;
  padding: 2.2rem;
}

.chat-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  max-width: 56rem;
  height: calc(100vh - 4.4rem);
  border: 1px solid var(--border);
  border-radius: 1.15rem;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-header {
  border-bottom: 1px solid var(--border);
  padding: 1.3rem 1.3rem 1.1rem;
  background: linear-gradient(180deg, #ffffff 0%, #fcfcfd 100%);
}

.chat-header h1 {
  margin: 0;
  font-size: clamp(1.55rem, 1.1rem + 1.5vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.chat-header p {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.45;
}

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  background: #fafafa;
}

.message {
  max-width: min(80%, 40rem);
}

.message.assistant,
.message.typing {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.message-label {
  margin-bottom: 0.3rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message p {
  margin: 0;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message-content {
  border-radius: 1rem;
  padding: 0.75rem 0.95rem;
}

.message.assistant,
.message.typing {
  align-self: flex-start;
}

.message.assistant .message-content,
.message.typing .message-content {
  background: #ffffff;
  border: 1px solid var(--border);
}

.message.user {
  align-self: flex-end;
}

.message.user .message-content {
  background: var(--pink-soft);
  border: 1px solid #f8c8df;
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.65rem;
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #ffffff;
  background: linear-gradient(135deg, #f471b5 0%, #eb4a8c 55%, #a91f55 100%);
  box-shadow: 0 6px 14px rgba(235, 74, 140, 0.25);
}

.composer-wrap {
  position: relative;
}

.chat-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translateX(-50%) translateY(8px);
  width: min(34rem, calc(100% - 1.4rem));
  border: 1px solid #fbcfe8;
  border-radius: 0.9rem;
  background: #fff1f7;
  padding: 0.9rem 1rem;
  box-shadow: 0 10px 25px rgba(167, 29, 90, 0.16);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 60;
}

.chat-tooltip.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.chat-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  width: 14px;
  height: 14px;
  background: #fff1f7;
  border-right: 1px solid #fbcfe8;
  border-bottom: 1px solid #fbcfe8;
  transform: translateX(-50%) rotate(45deg);
}

.chat-tooltip h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.chat-tooltip p {
  margin: 0.4rem 0 0.7rem;
  font-size: 0.9rem;
  color: #6b7280;
  line-height: 1.4;
}

.chat-tooltip button {
  border: 0;
  border-radius: 0.7rem;
  padding: 0.48rem 0.72rem;
  font-size: 0.86rem;
  font-weight: 600;
  color: #ffffff;
  background: var(--pink);
  cursor: pointer;
}

.chat-tooltip button:hover {
  filter: brightness(0.96);
}

.chat-composer {
  display: flex;
  gap: 0.7rem;
  align-items: flex-end;
  border-top: 1px solid var(--border);
  padding: 0.9rem;
  background: #ffffff;
}

.chat-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 0.75rem 0.85rem;
  font: inherit;
  color: var(--text);
  max-height: 10rem;
}

.chat-composer textarea:focus {
  outline: none;
  border-color: #f3a6ca;
  box-shadow: 0 0 0 3px rgba(235, 74, 140, 0.12);
}

.chat-composer button {
  border: 0;
  border-radius: 0.85rem;
  padding: 0.75rem 1rem;
  background: var(--pink);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
}

.chat-composer button:hover {
  filter: brightness(0.96);
}

.chat-composer button.flash-send {
  animation: flash-send 0.34s ease 2;
}

.message.typing p {
  min-height: 1.2rem;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.typing-dots span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: #9ca3af;
  animation: typing-pulse 1s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes typing-pulse {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-2px);
    opacity: 1;
  }
}

@keyframes flash-send {
  0% {
    box-shadow: 0 0 0 0 rgba(235, 74, 140, 0);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(235, 74, 140, 0.25);
    transform: scale(0.98);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(235, 74, 140, 0);
    transform: scale(1);
  }
}

.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;
}

@media (max-width: 920px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    position: fixed;
    z-index: 40;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

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

  .main-content {
    width: 100%;
    padding: 5.3rem 1rem 1.2rem;
  }

  .chat-shell {
    height: calc(100vh - 6.6rem);
  }

  .message {
    max-width: 92%;
  }

  .chat-tooltip {
    width: calc(100% - 1rem);
    left: 0.5rem;
    transform: translateY(8px);
  }

  .chat-tooltip.visible {
    transform: translateY(0);
  }

  .chat-tooltip::after {
    left: 35%;
  }
}
