/* Mobile-first: Primary #202938 | Secondary (buttons) #ef3f3e */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #202938;
  --secondary: #ef3f3e;
  --secondary-hover: #e03837;
  --surface: #ffffff;
  --bg: #f4f5f7;
  --text: #202938;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 2px 12px rgba(32, 41, 56, 0.08);
  --shadow-lg: 0 8px 32px rgba(32, 41, 56, 0.12);
  --radius: 12px;
  --radius-lg: 16px;
  --touch: 44px; /* min touch target */
  --safe-top: env(safe-area-inset-top, 0);
  --safe-bottom: env(safe-area-inset-bottom, 0);
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html, body {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html::-webkit-scrollbar, body::-webkit-scrollbar {
  display: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 768px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* Header - native app bar feel */
header {
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  padding-top: calc(12px + var(--safe-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: calc(var(--touch) + var(--safe-top));
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
}
header h1 {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

#cart-btn {
  background: var(--secondary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  min-height: var(--touch);
  min-width: 100px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: transform 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

#cart-btn:active {
  transform: scale(0.97);
  background: var(--secondary-hover);
}

#cart-btn.has-items {
  animation: cart-attention 1.8s ease-in-out infinite;
}

@keyframes cart-attention {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 63, 62, 0.5);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(239, 63, 62, 0);
  }
}

/* Main content */
main {
  padding: 16px;
  padding-bottom: calc(24px + var(--safe-bottom));
}

/* Category sections */
.menu-category {
  margin-bottom: 24px;
}

.category-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 12px;
  background: var(--border);
}
.menu-category h2 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary);
}

.menu-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Menu cards - app-like */
.menu-item {
  background: var(--surface);
  padding: 16px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.menu-item:active {
  transform: scale(0.995);
}

.menu-item .menu-info {
  flex: 1;
  min-width: 0;
}

.menu-item .name {
  display: block;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
}

.menu-item .desc {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.menu-item .price {
  color: var(--primary);
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
}

.menu-item button {
  background: var(--secondary);
  color: #fff;
  border: none;
  padding: 10px 20px;
  min-width: 64px;
  min-height: var(--touch);
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.menu-item button:active {
  transform: scale(0.95);
  background: var(--secondary-hover);
}

/* Cart panel - bottom sheet on mobile */
#cart-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 85vh;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -4px 24px rgba(32, 41, 56, 0.15);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  overflow: hidden;
}

#cart-panel.open {
  transform: translateY(0);
}

/* Drag handle - mobile pattern */
.cart-header {
  padding: 16px 48px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
  position: relative;
}

.cart-header::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

.cart-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
}

#close-cart {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.5rem;
  width: var(--touch);
  height: var(--touch);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}

#close-cart:active {
  background: var(--bg);
  color: var(--primary);
}

#cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
  list-style: none;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#cart-items::-webkit-scrollbar {
  display: none;
}

#cart-items li {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

#cart-items li .cart-name {
  grid-column: 1;
  font-weight: 500;
  font-size: 0.9375rem;
}

#cart-items li .cart-price {
  grid-column: 2;
  color: var(--secondary);
  font-weight: 700;
  font-size: 0.9375rem;
}

#cart-items li .cart-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}

.cart-actions button {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border: none;
  background: var(--secondary);
  color: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, background 0.1s;
}

.cart-actions button:active {
  transform: scale(0.92);
  background: var(--secondary-hover);
}

.cart-actions span {
  font-weight: 600;
  font-size: 0.9375rem;
  min-width: 24px;
  text-align: center;
}

#cart-items li.empty {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
  padding: 24px 0;
}

/* Order message */
.order-message {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.order-message label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
}

.order-message textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  font-size: 0.9375rem;
  resize: none;
  min-height: 72px;
  transition: border-color 0.15s;
}

.order-message textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.takeaway-option {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.takeaway-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.takeaway-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  width: 50px;
  height: 30px;
  background: var(--border);
  border-radius: 15px;
  position: relative;
  transition: background 0.2s ease;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
}

.takeaway-switch input:checked + .switch-track {
  background: var(--secondary);
}

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

.switch-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--primary);
}

.cart-footer {
  padding: 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}

.cart-footer p {
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--primary);
}

#place-order {
  width: 100%;
  padding: 14px 20px;
  min-height: var(--touch);
  background: var(--secondary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}

#place-order:not(:disabled):active {
  transform: scale(0.98);
  background: var(--secondary-hover);
}

#place-order:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Overlay */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 41, 56, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  z-index: 99;
}

#overlay.show {
  opacity: 1;
  visibility: visible;
}

/* Order success modal */
.success-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(32, 41, 56, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.success-modal.show {
  opacity: 1;
  visibility: visible;
}

.success-modal-content {
  background: var(--surface);
  padding: 28px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 320px;
  width: 100%;
  text-align: center;
}

.success-modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 12px;
  line-height: 1.4;
}

.success-modal-sub {
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.success-modal-sub #redirect-countdown {
  font-weight: 700;
  color: var(--secondary);
}

/* Loading, error, empty states */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 48px 24px;
  min-height: calc(100vh - 64px);
}

.loading-logo-wrap {
  animation: loading-zoom 1.2s ease-in-out infinite;
  will-change: transform;
  line-height: 0;
}

.loading-logo {
  display: block;
  width: 80px;
  height: auto;
  object-fit: contain;
}

@keyframes loading-zoom {
  0%, 100% { transform: scale(0.8); }
  50% { transform: scale(1.2); }
}

.loading span {
  font-size: 1rem;
  color: var(--text-muted);
}

.error, .empty-state {
  text-align: center;
  padding: 48px 24px;
  font-size: 1rem;
  line-height: 1.5;
}

.loading {
  color: var(--text-muted);
}

.error {
  color: var(--secondary);
}

.empty-state {
  color: var(--text-muted);
}

/* Tablet: side panel, wider layout */
@media (min-width: 640px) {
  #app { max-width: 768px; }

  #cart-panel {
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: 380px;
    max-height: none;
    border-radius: 0;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }

  #cart-panel.open {
    transform: translateX(0);
  }

  .cart-header::before {
    display: none;
  }

  .cart-header {
    padding: 16px;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
  }

  #close-cart {
    position: static;
    width: auto;
    height: auto;
    transform: none;
  }

  .menu-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}
