:root {
  /* Brand Colors - HSL for better manipulation */
  --c-navy: 228 50% 24%;
  /* #1E2A5A */
  --c-sky: 198 80% 64%;
  /* #5BC0EB */
  --c-gold: 45 90% 57%;
  /* #F4C430 */
  --c-dark: 222 47% 11%;
  /* #0f172a */
  --c-gray: 215 16% 47%;
  /* #64748b */
  --c-light: 210 40% 96.1%;
  /* #f1f5f9 */

  /* Semantic Colors */
  --bg-app: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.7);
  --text-main: hsl(var(--c-dark));
  --text-muted: hsl(var(--c-gray));
  --primary: hsl(var(--c-navy));
  --accent: hsl(var(--c-gold));
  --link: #2563eb;

  /* Dimensions */
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --header-h: 64px;
  /* ... */
  --nav-h: 70px;

  --nav-h: 70px;
  /* Mobile nav height */

  /* Effects */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1),
    0 8px 10px -6px rgb(0 0 0 / 0.1);
  --glass-border: 1px solid rgba(255, 255, 255, 0.5);
}

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

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg-app);
  background-image:
    radial-gradient(at 0% 0%, hsla(var(--c-sky), 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, hsla(var(--c-gold), 0.1) 0px, transparent 50%);
  color: var(--text-main);
  -webkit-tap-highlight-color: transparent;
  line-height: 1.5;
}

h1,
h2,
h3,
h4,
h5 {
  font-family: 'Outfit', sans-serif;
  margin: 0;
  font-weight: 700;
  color: var(--primary);
}

p {
  margin: 0 0 1rem;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
  transition: 0.2s;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  transition: all 0.2s ease;
}

input,
textarea,
select {
  font-family: inherit;
}

/* Utilities */
.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* App Shell Layout */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
}

.topbarInner {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brandRow {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brandRow img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.brandTitle {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.brandSub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.shell {
  flex: 1;
  display: grid;
  gap: 20px;
  padding: 20px 16px 100px;
  /* Bottom padding for mobile nav */
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Desktop Grid Override */
@media (min-width: 900px) {
  .shell {
    grid-template-columns: 260px 1fr;
    padding-bottom: 40px;
  }
}

/* Sidebar (Desktop) */
.sidebar {
  display: none;
}

@media (min-width: 900px) {
  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: calc(var(--header-h) + 20px);
    height: fit-content;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: var(--glass-border);
    padding: 20px;
    gap: 8px;
    box-shadow: var(--shadow-lg);
  }
}

.navItem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 600;
}

.navItem:hover {
  background: hsla(var(--c-sky), 0.1);
  color: var(--primary);
}

.navItem.active {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-lg);
}

.navItem img {
  width: 22px;
  height: 22px;
  filter: grayscale(1);
  opacity: 0.7;
  transition: 0.2s;
}

.navItem.active img {
  filter: grayscale(0) brightness(200%);
  opacity: 1;
}

/* White icon */
.navLabel {
  font-size: 0.95rem;
}

.navDesc {
  display: none;
}

/* Hide desc to keep it clean */

/* Mobile Nav (Bottom) */
.mobileNav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.05);
}

@media (min-width: 900px) {
  .mobileNav {
    display: none;
  }
}

.mobileNavGrid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  width: 100%;
  max-width: 600px;
}

.mobileNav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 8px 0;
  border-radius: 8px;
}

.mobileNav a.active {
  color: var(--primary);
}

.mobileNav img {
  width: 24px;
  height: 24px;
  opacity: 0.6;
  transition: 0.2s;
}

.mobileNav a.active img {
  opacity: 1;
  transform: translateY(-2px);
}

/* Components */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  border: var(--glass-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.pad {
  padding: 20px;
}

.pad-lg {
  padding: 24px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px hsla(var(--c-navy), 0.3);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px hsla(var(--c-navy), 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.btn.secondary {
  background: white;
  color: var(--primary);
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow-sm);
}

.btn.secondary:hover {
  background: var(--bg-app);
  border-color: rgba(0, 0, 0, 0.2);
}

.btn.small {
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

/* Inputs */
.input,
.select,
.textarea {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.8);
  font-size: 1rem;
  transition: 0.2s;
  color: var(--text-main);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 3px hsla(var(--c-navy), 0.15);
}

.label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
}

/* Authentication */
.authWrap {
  display: grid;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px;
}

@media (min-width: 768px) {
  .authWrap {
    grid-template-columns: 1.2fr 0.8fr;
    align-items: start;
  }
}

.tabs {
  display: flex;
  padding: 4px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.04);
  margin-bottom: 20px;
}

.tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  border-radius: 99px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

.tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Chat Interface */
.split {
  display: grid;
  gap: 20px;
  height: 100%;
}

@media (min-width: 900px) {
  .split {
    grid-template-columns: 300px 1fr;
  }
}

.chatList {
  display: flex;
  flex-direction: column;
  background: white;
  max-height: 400px;
  /* fallback mobile */
}

@media (min-width: 900px) {
  .chatList {
    max-height: calc(100vh - 120px);
  }
}

.chatListItem {
  padding: 12px;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.chatListItem:hover {
  background: var(--bg-app);
}

.chatListItem.active {
  background: hsla(var(--c-sky), 0.1);
  border-color: hsla(var(--c-sky), 0.2);
}

.chatListItem .t {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.95rem;
}

.chatListItem .s {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chatPane {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  min-height: 0;
  background: white;
  border-radius: var(--radius-md);
  /* Ensure it mimics card if needed, but it is inside a card now */
}

/* Ensure the parent Page wrapper fills height */
.shell>div:last-child {
  height: 100%;
  min-height: 0;
}

.chatMsgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f1f5f9;
  border-radius: var(--radius-md);
  margin: 10px 0;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubbleRow {
  display: flex;
  width: 100%;
}

.bubbleRow.user {
  justify-content: flex-end;
}

.bubbleRow.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 0.95rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: relative;
  word-wrap: break-word;
}

.bubble.user {
  background: var(--primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.bubble.assistant {
  background: white;
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

/* Markdown Styles in Bubble */
.bubble .md p {
  margin-bottom: 8px;
}

.bubble .md p:last-child {
  margin-bottom: 0;
}

.bubble .md strong {
  font-weight: 700;
}

.bubble .md ul,
.bubble .md ol {
  margin: 8px 0 8px 20px;
  padding: 0;
}

.bubble.user a {
  color: #a5f3fc;
  text-decoration: underline;
}

.bubble.assistant a {
  color: var(--link);
  font-weight: 600;
}

.msgImg {
  margin-top: 8px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.composer {
  background: white;
  padding-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.composerRow {
  display: flex;
  gap: 8px;
  align-items: center;
}

.composerActions {
  margin-top: 8px;
  display: flex;
  align-items: center;
  /* justify-content: space-between; Removed to let margin-left:auto do the work */
}

/* Grid & Rows */
.row {
  display: grid;
  gap: 16px;
}

.row2 {
  display: grid;
  gap: 16px;
}

@media (min-width: 700px) {
  .row2 {
    grid-template-columns: 1fr 1fr;
  }
}

.hr {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 16px 0;
  width: 100%;
}

.badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.05);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Map & Points */
.mapWrap {
  height: 300px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: var(--shadow-sm);
}

@media (min-width: 768px) {
  .mapWrap {
    height: 400px;
  }
}

.pointCard {
  background: white;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  transition: 0.2s;
}

.pointCard:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.pointActions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: flex-start;
}

/* Push send button to the right */
.composerActions #sendBtn {
  margin-left: auto;
}

/* Toast */
.toast {
  position: fixed;
  top: 80px;
  right: 20px;
  background: var(--text-main);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(-20px);
  opacity: 0;
  pointer-events: none;
  transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Modal */
.modalBackdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
}

.modalBackdrop.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.smallHelp {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}