:root {
  --bg: #0d0d0d;
  --bg-card: #1a1a1a;
  --text: #f2f2f2;
  --text-muted: #a0a0a0;
  --accent: #e8c547;
  --accent-hover: #f5d76e;
  --border: #2a2a2a;
  --danger: #e74c3c;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  font-size: 16px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 16px 16px 12px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.header-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-titles {
  flex: 1;
  min-width: 0;
}

.logo {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.tagline {
  margin: 4px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.header-user {
  margin: 8px 0 0;
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 500;
}

.header-user:empty {
  display: none;
}

.cart-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.cart-btn:hover {
  background: var(--bg-card);
  border-color: var(--accent);
}

.cart-icon {
  width: 22px;
  height: 22px;
}

.cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  background: var(--accent);
  color: var(--bg);
  border-radius: 9px;
}

.cart-count:empty,
.cart-count[data-count="0"] {
  display: none;
}

/* Main */
.main {
  padding: 16px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Menu grid */
.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start; /* ← важно для стабильной высоты */
}

/* --- Flip только изображения --- */
.image-flip-container {
  width: 100%;
  aspect-ratio: 1;
  perspective: 1000px;
  margin-bottom: 8px;
  cursor: pointer;
}

.image-flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease-in-out;
  transform-style: preserve-3d;
}

.image-flipper.flipped {
  transform: rotateY(180deg);
}

.image-side {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
}

.image-side.front .img {
  width: 100%;
  height: 100%;
  display: flex;
  object-fit: cover;
  padding: 12px;
  text-align: center;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.image-side.front img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.image-side.back {
  transform: rotateY(180deg);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.image-back-content {
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-muted);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}

/* Фолбэк-иконка */
.menu-card-img.fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--text-muted);
  background: var(--bg);
}

/* Карточка товара */
.menu-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.menu-card:active {
  border-color: var(--accent);
}

.menu-card-title {
  margin: 8px 0 4px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.menu-card-price {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}

.menu-card-add {
  width: 100%;
  margin-top: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--bg);
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.menu-card-add:hover {
  background: var(--accent-hover);
}

.menu-card-add:active {
  transform: scale(0.98);
}

/* Cart panel */
.cart-panel {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: slideUp 0.25s ease-out;
}

.cart-panel[hidden] {
  display: none;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

.cart-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.close-btn {
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 8px;
  transition:
    color 0.2s,
    background 0.2s;
}

.close-btn:hover {
  color: var(--text);
  background: var(--bg-card);
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-item-name {
  flex: 1;
  font-weight: 500;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cart-item-qty button {
  width: 28px;
  height: 28px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.cart-item-qty button:hover {
  background: var(--border);
}

.cart-item-qty span {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
}

.cart-item-price {
  font-weight: 600;
  color: var(--accent);
  min-width: 60px;
  text-align: right;
}

.cart-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.cart-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.cart-total strong {
  color: var(--accent);
  font-size: 1.25rem;
}

/* Buttons */
.btn {
  display: block;
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    background 0.2s,
    transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-order {
  color: var(--bg);
  background: var(--accent);
}

.btn-order:hover {
  background: var(--accent-hover);
}

.btn-order:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-submit {
  color: var(--bg);
  background: var(--accent);
  margin-top: 8px;
}

.btn-submit:hover {
  background: var(--accent-hover);
}

/* Order form */
.order-form {
  position: fixed;
  inset: 0;
  z-index: 101;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

.order-form[hidden] {
  display: none;
}

.form-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.form-header h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.form-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.form {
  padding: 16px;
  flex: 1;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field span {
  display: block;
  margin-bottom: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.field input,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.2s;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field textarea {
  resize: vertical;
  min-height: 60px;
}

.form-actions {
  margin-top: 24px;
}

.form-actions .btn {
  margin-bottom: 0;
}

.form-actions .btn-secondary {
  margin-bottom: 8px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  padding: 8px 16px;
  background: #f0f0f0;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #d32f2f;
  color: white;
}

.tab-btn:hover:not(.active) {
  background: #e0e0e0;
}

/* Спиннер */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top: 2px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  margin-right: 8px;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-submit.loading {
  opacity: 0.8;
  cursor: not-allowed;
  pointer-events: none;
}
