:root {
  --bg: #fff9f2;
  --surface: #ffffff;
  --surface-soft: #fff2e2;
  --border: #ecd9c4;
  --text: #231914;
  --muted: #6b5b50;
  --primary: #d95d18;
  --primary-hover: #b94b0e;
  --line-green: #06c755;
  --line-green-hover: #05a847;
  --success-bg: #e7f8ee;
  --success-text: #126b37;
  --warn-bg: #fff3cd;
  --warn-text: #855800;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(72, 39, 14, 0.08);
}

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

body {
  margin: 0;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 88px;
}

.hidden {
  display: none !important;
}

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Demo 頂部與會員提示隱藏（真實點餐介面無多餘干擾） */
.demo-top-bar, .member-bar {
  display: none !important;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, #d95d18 0%, #f28a2e 100%);
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 3px 12px rgba(185, 75, 14, 0.25);
}

.header-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.brand-logo {
  font-size: 1.5rem;
  background: rgba(255, 255, 255, 0.2);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-block h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shop-subtitle {
  margin: 2px 0 0;
  font-size: 0.78rem;
  opacity: 0.92;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.status-pill, .hours-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-open {
  background: #dffae8;
  color: #0e602e;
}

.status-closed {
  background: #fde2e2;
  color: #9e1c1c;
}

.hours-pill {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.btn-link-subtle {
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 5px 10px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 8px;
}

.btn-link-subtle:hover {
  background: rgba(255, 255, 255, 0.16);
}

/* Main - Mobile-first app container */
.page-main {
  max-width: 600px;
  margin: 12px auto;
  padding: 0 12px;
}

/* Optional Shop Banner */
.shop-banner-wrap {
  margin-bottom: 12px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--surface);
}

.shop-banner-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 7;
  object-fit: cover;
}

/* Member Bar */
.member-bar {
  margin-bottom: 16px;
}

.member-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.line-badge {
  background: var(--line-green);
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 10px 8px;
  border-radius: 10px;
}

.demo-tag-icon {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.avatar-img, .avatar-fallback {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  font-size: 1.3rem;
}

.muted-text {
  margin: 2px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.member-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Tabs */
.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  padding: 11px 12px;
  border-radius: 12px;
  cursor: pointer;
  min-height: 46px;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Toolbar & Sticky Categories */
.menu-toolbar {
  position: sticky;
  top: 0;
  z-index: 25;
  background: var(--bg);
  padding: 8px 0 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.search-box input {
  width: 100%;
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  font-size: max(1rem, 1em);
  background: var(--surface);
}

.category-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

.cat-pill {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 40px;
}

.cat-pill.active {
  background: #231914;
  color: #fff;
  border-color: #231914;
}

/* Mobile-first Menu List Cards with Food Photos */
.menu-section {
  margin-bottom: 20px;
}

.menu-section-title {
  margin: 0 0 10px;
  font-size: 1.1rem;
  padding-left: 10px;
  border-left: 4px solid var(--primary);
}

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

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 12px;
  box-shadow: 0 2px 10px rgba(72, 39, 14, 0.05);
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.item-card:hover {
  border-color: var(--primary);
}

.item-card:active {
  transform: scale(0.99);
}

.item-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.item-name {
  margin: 0;
  font-size: 1.05rem;
}

.item-desc {
  margin: 3px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.item-tag {
  font-size: 0.72rem;
  background: var(--surface-soft);
  color: #8f420e;
  padding: 2px 6px;
  border-radius: 6px;
}

.item-media {
  flex: 0 0 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.item-photo {
  width: 92px;
  height: 92px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  display: block;
}

.item-icon {
  font-size: 2.2rem;
  width: 92px;
  height: 92px;
  border-radius: 12px;
  background: linear-gradient(145deg, #fff5e8 0%, #fde6cb 100%);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.item-price {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--primary);
}

.dialog-food-img {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

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

.btn-sm {
  min-height: 38px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface-soft);
  color: var(--primary);
  border-color: var(--border);
}

.btn-line {
  background: var(--line-green);
  color: #fff;
}

.btn-line:hover:not(:disabled) {
  background: var(--line-green-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

/* Floating Cart Bar */
.cart-bar {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(94vw, 576px);
  background: #231914;
  color: #fff;
  padding: 10px 14px;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  z-index: 40;
}

.cart-bar-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-count-badge {
  background: var(--primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.cart-total-text {
  font-size: 1.08rem;
}

/* Native <dialog> + scroll containment + Mobile Bottom Sheet */
dialog.modal-dialog {
  width: min(94vw, 540px);
  max-height: 90dvh;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

@media (max-width: 640px) {
  dialog.modal-dialog {
    width: 100%;
    max-width: 100%;
    max-height: 88dvh;
    margin: auto 0 0 0;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

dialog.modal-sm {
  width: min(94vw, 420px);
}

dialog.modal-dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(24, 16, 11, 0.55);
  backdrop-filter: blur(2px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dialog-icon {
  font-size: 1.8rem;
}

.dialog-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.btn-icon-close {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
}

.dialog-body {
  padding: 16px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dialog-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

/* Forms & Branded Select */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.field label {
  font-weight: 700;
  font-size: 0.94rem;
}

.field input,
.field textarea,
.field select {
  font: inherit;
  font-size: max(1rem, 1em);
  padding: 10px 12px;
  min-height: 48px;
  border: 1.5px solid #c9b5a0;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  width: 100%;
}

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

/* Branded customizable select with progressive enhancement */
.brand-select,
.brand-select::picker(select) {
  appearance: base-select;
}

.brand-select {
  background-color: #fffcf8;
  border: 1.5px solid #c9b5a0;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.brand-select::picker(select) {
  background-color: #fff;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(45, 24, 10, 0.16);
}

.brand-select option {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.brand-select option:hover {
  background-color: var(--surface-soft);
}

.brand-select::picker-icon {
  color: var(--primary);
}

.brand-select option::checkmark {
  color: var(--primary);
}

/* Non-intrusive validation after interaction */
:is(:user-invalid, .user-invalid-fallback) {
  border-color: var(--danger) !important;
  background-color: var(--danger-bg) !important;
}

.error-msg {
  display: none;
  color: var(--danger);
  font-size: 0.84rem;
  font-weight: 600;
}

:is(:user-invalid, .user-invalid-fallback) + .error-msg {
  display: block;
}

.field :focus-visible,
.btn:focus-visible,
.tab-btn:focus-visible,
.cat-pill:focus-visible {
  outline: 3px solid #0b57d0;
  outline-offset: 2px;
}

/* Qty & Price */
.qty-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface-soft);
  padding: 10px 14px;
  border-radius: 12px;
}

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

.btn-qty {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
}

.qty-value {
  min-width: 24px;
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
}

.item-calc-price strong {
  font-size: 1.25rem;
  color: var(--primary);
}

/* Cart Items */
.cart-items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-item-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.cart-item-title {
  font-weight: 800;
}

.cart-item-opts {
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 2px;
}

.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.checkout-fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin: 0;
}

.checkout-fieldset legend {
  font-weight: 800;
  padding: 0 6px;
}

.checkout-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--surface-soft);
  border-radius: 12px;
  font-weight: 700;
}

.checkout-summary strong {
  font-size: 1.3rem;
  color: var(--primary);
}

.form-error {
  color: var(--danger);
  background: var(--danger-bg);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin: 0;
}

/* Orders View */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.orders-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.order-card-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.order-code {
  font-size: 1.1rem;
  font-weight: 800;
}

.order-badge {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.badge-pending { background: #fff3cd; color: #855800; }
.badge-preparing { background: #dceeff; color: #084d91; }
.badge-ready { background: #dffae8; color: #0e602e; }
.badge-completed { background: #eeeeee; color: #444; }
.badge-cancelled { background: #fde2e2; color: #9e1c1c; }

.order-items-ul {
  margin: 8px 0;
  padding-left: 18px;
}

.order-items-ul li {
  margin-bottom: 4px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
}

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.demo-hint {
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 0;
}

.toast-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: #231914;
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 700;
  z-index: 99;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

/* 內用桌號提示橫幅 */
.table-notice-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff8eb;
  border: 1px solid #f6cf7e;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
}

.table-notice-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-notice-icon {
  font-size: 1.5rem;
}

.table-notice-banner p {
  margin: 2px 0 0;
  font-size: 0.84rem;
}

/* 用餐方式切換按鈕組 */
.dining-type-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 4px;
}

.dining-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  transition: all 0.18s ease;
}

.dining-pill input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.dining-pill:has(input:checked) {
  border-color: var(--primary);
  background: #fdf5f0;
  color: var(--primary);
}

/* 客製化多選 Checkbox 清單 */
.choice-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin: 0 0 12px 0;
}

.choice-legend {
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0 6px;
  color: var(--text);
}

.choice-checkbox-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

@media (max-width: 420px) {
  .choice-checkbox-list {
    grid-template-columns: 1fr;
  }
}

.choice-checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.92rem;
  cursor: pointer;
}

.choice-checkbox-row:has(input:checked) {
  border-color: var(--primary);
  background: #fdf5f0;
  font-weight: 600;
}

.status-subtle {
  background: #f1f3f5;
  color: #495057;
}

