:root {
  --hl-red: #d10a10;
  --hl-yellow: #ffb800;
  --background: #f5f5f5;
  --foreground: #1a1a1a;
  /* Demo phone column — typical handset width (Next body uses 480px; shell feels better narrower) */
  --phone-shell-max: 390px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: "Roboto", Arial, sans-serif;
  background: #f5f5f5;
  color: var(--foreground);
}

.desktop-note {
  text-align: center;
  color: #64748b;
  font-size: 12px;
  padding: 8px 0 2px;
}

.phone-stage {
  min-height: calc(100vh - 24px);
  display: grid;
  place-items: center;
  padding: 10px;
}

.phone-shell {
  width: min(var(--phone-shell-max), 100%);
  height: min(844px, calc(100vh - 38px));
  border: 9px solid #0f172a;
  border-radius: 34px;
  background: var(--background);
  overflow: hidden;
  box-shadow: 0 26px 42px rgba(15, 23, 42, 0.32);
  display: flex;
  flex-direction: column;
  /* Establishes containing block so position:fixed UI docks to the phone, not the viewport */
  transform: translateZ(0);
  isolation: isolate;
}

.phone-top {
  flex-shrink: 0;
  height: 44px;
  background: #fff;
  color: #0f172a;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  font-size: 12px;
  font-weight: 700;
}

.phone-top__logo {
  height: 22px;
  width: auto;
  max-width: min(120px, 38vw);
  display: block;
  object-fit: contain;
  object-position: left center;
}

.phone-top__route {
  font-size: 10px;
  font-weight: 500;
  color: #94a3b8;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phone-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  z-index: 0;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* Chat: column layout — messages scroll inside; composer stays above tab bar */
.phone-content--chat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.phone-content--chat > .shell-route {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Menu: sidebar + scrollable list (matches Next.js menu layout) */
.phone-content--menu {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.phone-content--menu > .shell-route {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Menu category rail — consistent vertical rhythm inside fixed 72px width */
.menu-sidebar-rail {
  width: 72px;
  flex-shrink: 0;
  align-self: stretch;
  min-height: 0;
  max-height: 100%;
  background: #fff;
  border-right: 1px solid #f3f4f6;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px 0 10px;
  /* Bottom edge lines up with the main panel above the tab bar (tab bar is outside #app-view) */
  box-sizing: border-box;
}

.menu-sidebar-rail a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 5px 12px;
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.menu-sidebar-rail a > span:last-child {
  display: block;
  width: 100%;
  padding: 0 1px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.menu-sidebar-rail a span svg {
  display: block;
}

.phone-content::-webkit-scrollbar {
  display: none;
}

/* Bottom nav — matches app BottomNav (FAB + icons) */
.bottom-nav {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 8px 4px 0;
  padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
  border-top: 1px solid #f3f4f6;
  background: #fff;
  box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.02);
  position: relative;
  z-index: 20;
}

.bottom-nav--hidden {
  display: none !important;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 2px 0;
  min-width: 0;
  text-decoration: none;
  color: #9ca3af;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.25px;
}

.bottom-nav__item.active {
  color: var(--hl-red);
  font-weight: 700;
}

.bottom-nav__icon {
  display: block;
}

.bottom-nav__item.active .bottom-nav__icon {
  stroke-width: 2.5px;
}

.bottom-nav__icon-wrap {
  position: relative;
  display: inline-flex;
}

.bottom-nav__cart-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--hl-red);
  color: #fff;
  border: 2px solid #fff;
  font-size: 9px;
  font-weight: 700;
  line-height: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav__fab-wrap {
  flex: 0 0 auto;
  width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #9ca3af;
  margin-top: -32px;
  position: relative;
  z-index: 21;
}

.bottom-nav__fab {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--hl-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 10px 15px -3px rgba(209, 10, 17, 0.4),
    0 4px 6px -4px rgba(209, 10, 17, 0.4);
  border: 4px solid #fff;
}

.bottom-nav__fab-wrap.active .bottom-nav__fab {
  box-shadow:
    0 10px 15px -3px rgba(209, 10, 17, 0.45),
    0 4px 6px -4px rgba(209, 10, 17, 0.45),
    0 0 0 2px rgba(252, 165, 165, 0.9);
}

.bottom-nav__fab-label {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.25px;
}

.bottom-nav__fab-wrap.active .bottom-nav__fab-label {
  color: var(--hl-red);
  font-weight: 700;
}

/* Horizontal carousels — hide scrollbars like the main app */
.horizontal-scroll {
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.horizontal-scroll::-webkit-scrollbar {
  display: none;
}

/* View cart strip (fixed above bottom nav) */
/* Sticky checkout bar on cart (sits flush to bottom when tab nav is hidden) */
.cart-sticky-footer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--phone-shell-max);
  z-index: 30;
  padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid #f3f4f6;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.04);
}

/* Scroll padding when tab bar is hidden (cart / checkout) */
.shell-wrap--cart {
  padding-bottom: 11rem;
}

/* Chat: composer is in-flow at bottom of flex column (not fixed — avoids viewport overlap) */
.chat-composer {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid #f3f4f6;
  padding: 10px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom, 12px));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.chat-scroll-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.chat-composer__row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.chat-composer__input {
  flex: 1;
  min-width: 0;
  min-height: 48px;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 15px;
  line-height: 1.35;
  border: 1px solid transparent;
  background: #f3f4f6;
  color: #111827;
}

.chat-composer__input:focus {
  outline: none;
  background: #fff;
  border-color: rgba(209, 10, 17, 0.35);
  box-shadow: 0 0 0 3px rgba(209, 10, 17, 0.08);
}

.chat-composer__send {
  flex-shrink: 0;
  width: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  border-radius: 14px;
  background: var(--hl-red);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(209, 10, 17, 0.25);
}

.checkout-place-footer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--phone-shell-max);
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.view-cart-strip {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 32px);
  max-width: min(calc(var(--phone-shell-max) - 32px), calc(100vw - 32px));
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--hl-red);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 10px 25px rgba(209, 10, 17, 0.35);
}

.view-cart-strip__count {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
}

.view-cart-strip__price {
  margin-left: auto;
  font-weight: 900;
  font-size: 14px;
}

/* Item / product page — fixed bar above bottom tab nav */
.item-page-dock {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: var(--phone-shell-max);
  z-index: 25;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid #f3f4f6;
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.04);
}

@media (max-width: 560px) {
  /* Full-bleed shell: fixed bars match viewport width, not demo column */
  .cart-sticky-footer,
  .checkout-place-footer,
  .item-page-dock {
    max-width: 100%;
  }

  .view-cart-strip {
    max-width: calc(100vw - 32px);
  }
}

/* iOS-style toggles (notifications) */
.hl-toggle-row {
  user-select: none;
}

.hl-toggle-switch-wrap {
  position: relative;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.hl-toggle-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.hl-toggle-track {
  display: block;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #e5e7eb;
  position: relative;
  transition: background 0.2s ease;
  pointer-events: none;
}

.hl-toggle-track::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  top: 3px;
  left: 3px;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.hl-toggle-input:checked + .hl-toggle-track {
  background: var(--hl-red);
}

.hl-toggle-input:checked + .hl-toggle-track::after {
  transform: translateX(20px);
}

.btn-hl {
  background: var(--hl-red);
  color: white;
  border-radius: 12px;
  padding: 14px 24px;
  font-weight: 600;
  font-size: 16px;
  width: 100%;
  border: none;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 560px) {
  .desktop-note {
    display: none;
  }

  .phone-stage {
    padding: 0;
    min-height: 100vh;
  }

  .phone-shell {
    width: 100%;
    height: 100vh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
}
