:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #67717d;
  --line: #d9e2ec;
  --paper: #fbfcfd;
  --surface: #ffffff;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #c2410c;
  --success: #15803d;
  --shadow: 0 18px 45px rgba(25, 39, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 0%, rgba(15, 118, 110, 0.1), transparent 30%),
    linear-gradient(180deg, #f7fbf9 0%, var(--paper) 46%);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
  min-height: 100vh;
  padding: 24px;
}

.is-share-view .app-shell {
  display: none;
}

.share-page {
  min-height: 100vh;
  padding: 28px 16px;
}

.share-page-inner {
  width: min(520px, 100%);
  margin: 0 auto;
}

.menu-poster {
  display: block;
  width: 100%;
  margin: 18px 0 14px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: #ffffff;
}

.share-page-actions {
  display: grid;
  gap: 10px;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 4px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

.subtitle {
  max-width: 520px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.icon-button,
.quantity-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  min-width: 72px;
  height: 40px;
  border-radius: 8px;
  font-weight: 700;
}

.icon-button:hover,
.quantity-button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.category-tabs {
  grid-column: 1 / 2;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab-button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.tab-button.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #ffffff;
  font-weight: 700;
}

.menu-area {
  grid-column: 1 / 2;
  min-width: 0;
}

.dish-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.dish-card {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 12px;
  min-height: 132px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.dish-thumb {
  width: 76px;
  height: 76px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: 30px;
  font-weight: 800;
}

.dish-card:nth-child(4n + 1) .dish-thumb {
  background: linear-gradient(135deg, #0f766e, #22c55e);
}

.dish-card:nth-child(4n + 2) .dish-thumb {
  background: linear-gradient(135deg, #c2410c, #f59e0b);
}

.dish-card:nth-child(4n + 3) .dish-thumb {
  background: linear-gradient(135deg, #1d4ed8, #06b6d4);
}

.dish-card:nth-child(4n + 4) .dish-thumb {
  background: linear-gradient(135deg, #7c2d12, #dc2626);
}

.dish-body {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.dish-name {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.dish-desc {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.dish-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.price {
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
}

.quantity-control {
  display: inline-grid;
  grid-template-columns: 32px 32px 32px;
  align-items: center;
  height: 32px;
}

.quantity-button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
}

.quantity-value {
  text-align: center;
  font-weight: 800;
}

.cart-panel {
  grid-column: 2 / 3;
  grid-row: 2 / -1;
  align-self: start;
  position: sticky;
  top: 24px;
  display: grid;
  gap: 14px;
  max-height: calc(100vh - 48px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

#cartTotal {
  color: var(--accent);
  font-size: 24px;
}

.cart-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  min-height: 140px;
  max-height: 48vh;
}

.empty-cart {
  display: grid;
  place-items: center;
  min-height: 140px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.cart-item p {
  margin: 0;
  font-weight: 800;
}

.cart-item span {
  color: var(--muted);
  font-size: 13px;
}

.submit-button {
  width: 100%;
  height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #ffffff;
  cursor: pointer;
  font-weight: 800;
}

.secondary-button {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.secondary-button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.submit-button:hover {
  background: var(--brand-dark);
}

.submit-button:disabled {
  background: #b8c2cc;
  cursor: not-allowed;
}

.order-dialog {
  width: min(560px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.order-dialog::backdrop {
  background: rgba(15, 23, 42, 0.42);
}

.order-dialog form {
  display: grid;
  gap: 14px;
}

.share-box {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

#qrCanvas {
  width: 240px;
  height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
}

.share-actions {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.share-hint {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  font-weight: 700;
}

#shareLink {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  color: var(--muted);
  background: #f8fafc;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

pre {
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink);
  background: #f3f6f8;
  border-radius: 8px;
  padding: 12px;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 16px;
    padding-bottom: 300px;
  }

  .category-tabs,
  .menu-area,
  .cart-panel {
    grid-column: 1 / -1;
  }

  .cart-panel {
    position: fixed;
    inset: auto 10px 10px;
    gap: 10px;
    max-height: 42vh;
    padding: 14px;
    z-index: 5;
  }

  .cart-list {
    min-height: 70px;
    max-height: 20vh;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

  h1 {
    font-size: 25px;
  }

  .subtitle {
    font-size: 13px;
  }

  .dish-grid {
    grid-template-columns: 1fr;
  }

  .dish-card {
    grid-template-columns: 68px 1fr;
  }

  .dish-thumb {
    width: 68px;
    height: 68px;
    font-size: 26px;
  }

  .cart-header {
    align-items: center;
  }

  #cartTotal {
    font-size: 21px;
  }

  .submit-button {
    height: 44px;
  }

  .share-box {
    grid-template-columns: 1fr;
  }

  #qrCanvas {
    justify-self: center;
    width: 220px;
    height: 220px;
  }
}
