/* POS guest scan-order lookalike (tokens + menu / cart / welcome) */
:root {
  --ink: #1a1512;
  --ink-soft: #7a6f68;
  --paper: #f1efec;
  --paper-2: #e5e1db;
  --surface: #ffffff;
  --line: rgba(80, 40, 20, 0.08);
  --lacquer: #9b1b1b;
  --lacquer-deep: #7a1515;
  --lacquer-soft: rgba(155, 27, 27, 0.12);
  --danger: #9b1b1b;
  --glass: rgba(255, 255, 255, 0.64);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-blur: 28px;
  --radius: 10px;
  --radius-sm: 8px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue",
    "Segoe UI", sans-serif;
  --font-display: "Songti SC", "STSong", "Noto Serif SC", "PingFang SC", serif;
  --topbar-h: 72px;
  --bottom-h: 2.25rem;
  --footer-h: 2.25rem;
  --cart-bar-h: 56px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.25, 0.1, 0.25, 1);
  --dur: 220ms;
  --dur-slow: 360ms;

  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-sans);
  line-height: 1.47;
  font-weight: 400;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--paper);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  -webkit-tap-highlight-color: transparent;
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button.primary,
a.primary {
  background: var(--lacquer);
  color: #fff;
  font-weight: 600;
  border-radius: 980px;
  padding: 0.7rem 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button.primary:hover:not(:disabled) {
  background: var(--lacquer-deep);
}

button.primary.wide,
.wide {
  width: 100%;
}

button.ghost-btn {
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.35rem;
  line-height: 1;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

button.ghost-btn:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.04);
  color: var(--ink);
}

button.text-danger {
  background: transparent;
  color: var(--danger);
}

.muted,
.hint,
.empty,
.dish-sub,
.status {
  color: var(--ink-soft);
}

.demo-chip {
  position: fixed;
  left: max(0.75rem, env(safe-area-inset-left));
  bottom: max(1rem, calc(env(safe-area-inset-bottom) + 0.85rem));
  right: auto;
  top: auto;
  z-index: 260;
  display: inline-flex;
  align-items: center;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
  padding: 0.45rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  border-radius: 4px;
  white-space: nowrap;
  text-decoration: none;
  transition: box-shadow 180ms ease, transform 160ms ease;
}

.demo-chip:hover {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
  transform: translateY(-1px);
}

/* —— Welcome —— */
.welcome-page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1.25rem 4.5rem;
  background: var(--paper);
}

.welcome-page[hidden] {
  display: none;
}

.welcome-card {
  width: min(100%, 26rem);
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  text-align: center;
}

.welcome-tri {
  display: grid;
  gap: 0.12rem;
  margin-top: 0.35rem;
}

.welcome-line {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.welcome-line-zh {
  font-size: clamp(1.65rem, 5vw, 2.05rem);
}

.welcome-line-es,
.welcome-line-en {
  font-size: clamp(1.05rem, 3.4vw, 1.25rem);
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: -0.02em;
}

.welcome-logo {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: cover;
  border-radius: 1.15rem;
  margin-bottom: 0.55rem;
  background: var(--surface);
  border: 1px solid var(--line);
}

.welcome-logo-fallback {
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  background: var(--lacquer);
  border: 0;
}

.welcome-kicker {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
}

.welcome-table {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--lacquer-deep);
}

.welcome-tri-sub {
  margin: 0.55rem 0 0.35rem;
  max-width: 22rem;
  gap: 0.2rem;
}

.welcome-sub-line {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.35;
}

.welcome-lang-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  width: 100%;
  margin-top: 0.55rem;
}

.welcome-lang-btn {
  display: grid;
  gap: 0.15rem;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.85rem 1rem;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.welcome-lang-btn strong {
  font-size: 1.05rem;
}

.welcome-lang-btn:hover {
  border-color: color-mix(in srgb, var(--lacquer) 40%, var(--line));
  background: color-mix(in srgb, var(--lacquer-soft) 55%, var(--surface));
}

/* —— App shell —— */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app-shell[hidden] {
  display: none;
}

.app-shell-menu {
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

.app-footer {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: var(--footer-h);
  padding: 0.55rem 1rem;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--ink) 42%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  background: color-mix(in srgb, var(--paper) 94%, var(--ink) 4%);
}

.login-footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  border-top: 0;
  background: transparent;
  padding: 0.85rem 1rem 1.1rem;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0 1.15rem;
  background: var(--glass);
  backdrop-filter: saturate(200%) blur(var(--glass-blur));
  -webkit-backdrop-filter: saturate(200%) blur(var(--glass-blur));
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-mark {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--paper-2);
  flex-shrink: 0;
}

.brand-logo-placeholder {
  display: grid;
  place-items: center;
  background: var(--lacquer);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

.brand .status {
  font-size: 0.8rem;
}

.app-shell-menu .main-with-cart {
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-with-cart {
  padding-bottom: calc(var(--bottom-h) + var(--cart-bar-h) + env(safe-area-inset-bottom));
}

.app-shell-menu .main-with-cart > .menu-page {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.menu-page {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  background: var(--surface);
}

.category-rail {
  position: sticky;
  top: 0;
  align-self: stretch;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0.35rem 0;
  background: var(--paper);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  z-index: 3;
}

.rail-item {
  position: relative;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  padding: 1.15rem 0.55rem;
  color: var(--ink-soft);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  min-height: 3.4rem;
}

.rail-item:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.03);
  color: var(--ink);
}

.rail-item.active {
  background: var(--surface);
  color: var(--ink);
}

.rail-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 22%;
  bottom: 22%;
  width: 3px;
  border-radius: 2px;
  background: var(--lacquer);
}

.menu-main {
  padding: 0 0 1.25rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.menu-section {
  scroll-margin-top: 0.35rem;
}

.menu-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  padding: calc(1.2rem + 1px) 1.25rem 1rem;
  min-height: 4.2rem;
  position: sticky;
  top: -1px;
  z-index: 2;
  width: 100%;
  box-sizing: border-box;
  background: var(--glass-strong);
  backdrop-filter: saturate(180%) blur(var(--glass-blur));
  -webkit-backdrop-filter: saturate(180%) blur(var(--glass-blur));
  box-shadow: 0 1px 0 var(--line);
}

.menu-heading h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.menu-count {
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.dish-list {
  display: flex;
  flex-direction: column;
  margin-top: 0.35rem;
}

.dish-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 0.85rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--line);
  transition: background var(--dur) var(--ease-soft);
  cursor: pointer;
}

.dish-row:active {
  background: rgba(0, 0, 0, 0.015);
}

.dish-media {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
}

.dish-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dish-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--lacquer);
  background: var(--lacquer-soft);
}

.dish-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dish-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.dish-sub {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
}

.dish-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-top: 0.35rem;
}

.dish-price {
  color: var(--ink);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}

.add-btn {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 980px;
  border: 0;
  background: var(--lacquer);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.add-btn > span:not(.add-qty) {
  display: block;
  line-height: 1;
  transform: translateY(-0.05em);
}

.add-btn:hover:not(:disabled) {
  background: var(--lacquer-deep);
}

.add-qty {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 980px;
  background: var(--ink);
  color: #fff;
  font-size: 0.65rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: pop var(--dur) var(--ease-out);
}

/* —— Cart —— */
.cart-bar {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(var(--bottom-h) + 0.55rem + env(safe-area-inset-bottom));
  z-index: 35;
  display: flex;
  align-items: stretch;
  gap: 0;
  height: var(--cart-bar-h);
  background: rgba(29, 29, 31, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #fff;
  border-radius: 980px;
  overflow: hidden;
  animation: bar-in var(--dur-slow) var(--ease-out) both;
}

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

.cart-bar-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0 0.35rem 0 0.85rem;
}

.cart-bar-info strong {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.cart-bar-info small {
  color: rgba(255, 255, 255, 0.62);
}

.cart-bar-count {
  width: 28px;
  height: 28px;
  border-radius: 980px;
  display: grid;
  place-items: center;
  background: var(--lacquer);
  font-weight: 600;
  font-size: 0.82rem;
}

.cart-bar-cta {
  border-radius: 0;
  padding: 0 1.35rem;
  white-space: nowrap;
  height: 100%;
  background: transparent;
  color: #f0c9c9;
  font-weight: 600;
}

.cart-bar-cta:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
}

.cart-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 45;
  display: flex;
  flex-direction: column;
  max-height: 82dvh;
  transform: translate3d(0, 105%, 0);
  transition: transform var(--dur-slow) var(--ease-out);
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  overflow: hidden;
  pointer-events: none;
}

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

.cart-sheet.open {
  transform: translate3d(0, 0, 0);
  pointer-events: auto;
}

.cart-sheet .cart-panel {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 82dvh;
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom));
}

.cart-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease-soft);
  z-index: 40;
}

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

.cart-sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

html.sheet-open,
html.sheet-open body {
  overflow: hidden;
}

.cart-panel {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  height: 100%;
  min-height: 0;
  padding: 0.85rem;
  background: var(--surface);
  overflow: hidden;
}

.cart-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
  flex-shrink: 0;
}

.cart-panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.cart-panel-head .muted {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
}

.cart-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}

.cart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}

.cart-row-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.cart-row-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
}

.cart-row-main .muted {
  font-size: 0.82rem;
}

.qty {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.qty-value {
  min-width: 1.25rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.qty button {
  box-sizing: border-box;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  background: var(--paper-2);
  display: inline-grid;
  place-items: center;
  font-size: 1rem;
}

.qty button.text-danger {
  background: transparent;
  font-size: 1.15rem;
}

.note-field {
  display: grid;
  gap: 0.3rem;
  flex-shrink: 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.note-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  background: var(--paper);
}

.note-field input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--lacquer) 55%, var(--line));
  box-shadow: 0 0 0 4px var(--lacquer-soft);
  background: var(--surface);
}

.checkout {
  display: grid;
  gap: 0.55rem;
  flex-shrink: 0;
  padding-top: 0.35rem;
}

.total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1.05rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom-h) + var(--cart-bar-h) + 1.1rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  padding: 0.7rem 1.05rem;
  border-radius: 980px;
  background: rgba(29, 29, 31, 0.92);
  backdrop-filter: blur(12px);
  color: #fff;
  max-width: min(92vw, 400px);
  font-size: 0.9rem;
  font-weight: 500;
  animation: toast-in var(--dur) var(--ease-out) both;
}

.toast[hidden] {
  display: none;
}

.demo-end-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(0, 0, 0, 0.55);
}

.demo-end-backdrop[hidden] {
  display: none !important;
}

.demo-end-card {
  width: min(100%, 22rem);
  padding: 1.5rem 1.25rem;
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.demo-end-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #3d6b55;
}

.demo-end-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.55rem;
}

.demo-end-code {
  margin: 0 0 1.25rem;
  color: #666;
  font-size: 0.92rem;
}

@keyframes bar-in {
  from {
    opacity: 0;
    transform: translate3d(0, 100%, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate3d(-50%, 12px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
  }
}

@keyframes pop {
  from {
    transform: scale(0.6);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (min-width: 480px) {
  .app-shell,
  .welcome-page {
    max-width: 430px;
    margin: 0 auto;
    box-shadow: 0 0 0 1px var(--line);
  }

  .cart-bar {
    left: calc(50% - 215px + 0.75rem);
    right: calc(50% - 215px + 0.75rem);
    width: auto;
    max-width: none;
  }

  .cart-sheet,
  .cart-sheet-backdrop {
    left: calc(50% - 215px);
    right: calc(50% - 215px);
    width: auto;
    max-width: none;
  }
}
