:root {
  --font-base:   "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --size-xl:     2rem;
  --size-lg:     1.5rem;
  --size-md:     1.2rem;
  --size-sm:     1rem;
  --weight-bold: 700;

  --color-zhushi:      #FF9800;
  --color-zhushi-bg:   #FFF8ED;
  --color-huncai:      #E91E63;
  --color-huncai-bg:   #FFF0F5;
  --color-shucai:      #4CAF50;
  --color-shucai-bg:   #F1FAF1;
  --color-tang:        #2196F3;
  --color-tang-bg:     #EDF5FF;

  --color-primary:     #43A047;
  --color-random-btn:  #9C27B0;
  --color-copy-btn:    #0288D1;
  --color-page-bg:     #F5EFE0;
  --color-card-bg:     #FFFDF7;
  --color-text:        #1A1A1A;
  --color-muted:       #888888;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-base);
  font-size: var(--size-md);
  background: var(--color-page-bg);
  color: var(--color-text);
  line-height: 1.5;
}

.page-wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 0 3rem;
}

/* ── Header ─────────────────────────────────────────────────── */
.app-header {
  padding: 1.5rem 1rem 0.75rem;
  text-align: center;
}
.app-header h1 {
  font-size: var(--size-xl);
  font-weight: var(--weight-bold);
}
.subtitle {
  font-size: var(--size-sm);
  color: var(--color-muted);
  margin-top: 0.4rem;
}

/* ── Hero header (index page) ────────────────────────────────── */
.hero-header {
  padding: 1rem 0.5rem 1rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-align: left;
}
.hero-img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  flex-shrink: 0;
}
.hero-text {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.hero-header .hero-title {
  font-size: 3.2rem;
  font-weight: var(--weight-bold);
  line-height: 1.2;
  white-space: nowrap;
}

/* Narrow phones: stack image above text, center everything */
@media (max-width: 480px) {
  .hero-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.25rem;
  }
  .hero-img {
    width: 120px;
    height: 120px;
  }
  .hero-header .hero-title {
    font-size: 2.4rem;
  }
  .hero-header .subtitle {
    text-align: center;
  }
}
.hero-title span {
  text-shadow: 2px 2px 0 rgba(0,0,0,0.18);
}
.hw-purple { color: #9C27B0; }
.hw-orange { color: #FF9800; }
.hw-red    { color: #E91E63; font-size: 1.25em; display: inline-block; transform: rotate(-12deg); vertical-align: middle; }
.hw-green  { color: #4CAF50; }
.hw-blue   { color: #2196F3; font-size: 1.25em; display: inline-block; transform: rotate(12deg); vertical-align: middle; }
.hero-header .subtitle {
  text-align: left;
}

/* ── Back to home link (plan page) ──────────────────────────── */
.back-to-home {
  display: inline-block;
  margin-top: 0.6rem;
  font-size: var(--size-sm);
  color: var(--color-copy-btn);
  text-decoration: none;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  font-family: var(--font-base);
  font-size: var(--size-lg);
  font-weight: var(--weight-bold);
  border: none;
  border-radius: 14px;
  padding: 1rem;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  color: #fff;
  transition: opacity 0.15s;
}
.btn:active { opacity: 0.8; }

.btn-primary  { background: var(--color-primary); }
.btn-random   { background: var(--color-random-btn); }
.btn-copy     { background: var(--color-copy-btn); margin-top: 0.75rem; }

.btn-submit   { margin: 1rem 1rem 0; width: calc(100% - 2rem); }

/* ── Random section ──────────────────────────────────────────── */
.random-section {
  padding: 0.5rem 1rem;
  text-align: center;
}
.random-hint {
  font-size: var(--size-sm);
  color: var(--color-muted);
  margin-top: 0.4rem;
}

/* ── Category colors ─────────────────────────────────────────── */
/* cat-1=主食 cat-2=荤菜 cat-3=蔬菜 cat-4=汤 */
.cat-1-header  { background: var(--color-zhushi);  }
.cat-2-header  { background: var(--color-huncai);  }
.cat-3-header  { background: var(--color-shucai);  }
.cat-4-header  { background: var(--color-tang);    }

/* ── Category sections ───────────────────────────────────────── */
.category-section {
  margin: 0.75rem 1rem 0;
  border-radius: 14px;
  overflow: hidden;
  background: var(--color-card-bg);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.category-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  color: #fff;
  font-size: var(--size-xl);
  font-weight: var(--weight-bold);
  gap: 0.5rem;
}
.cat-hint {
  font-size: var(--size-sm);
  font-weight: 400;
  opacity: 0.9;
}

/* ── Dish cards ──────────────────────────────────────────────── */
.dish-list { display: flex; flex-direction: column; }

.dish-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  cursor: pointer;
  border-left: 5px solid transparent;
  border-top: 1px solid #f0f0f0;
  transition: background 0.1s, border-color 0.1s;
  min-height: 60px;
}
.dish-card:hover { background: #f9f9f9; }

.dish-card input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}
.dish-emoji { font-size: 1.8rem; flex-shrink: 0; }
.dish-name  { font-size: var(--size-lg); font-weight: var(--weight-bold); flex: 1; }
.dish-notes {
  font-size: var(--size-sm);
  background: #eee;
  border-radius: 99px;
  padding: 2px 10px;
  color: #555;
  flex-shrink: 0;
}

/* Selected state per category */
.dish-card.selected-1 { border-left-color: var(--color-zhushi); background: var(--color-zhushi-bg); }
.dish-card.selected-2 { border-left-color: var(--color-huncai); background: var(--color-huncai-bg); }
.dish-card.selected-3 { border-left-color: var(--color-shucai); background: var(--color-shucai-bg); }
.dish-card.selected-4 { border-left-color: var(--color-tang);   background: var(--color-tang-bg);   }

/* ── Summary table ───────────────────────────────────────────── */
.summary-section {
  margin: 1rem 1rem 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.summary-table {
  width: 100%;
  border-collapse: collapse;
}
.summary-row td {
  padding: 0.75rem 1rem;
  font-size: var(--size-md);
  vertical-align: top;
}
.summary-cat {
  font-weight: var(--weight-bold);
  white-space: nowrap;
  width: 6rem;
}
.cat-row-1 { background: var(--color-zhushi-bg); }
.cat-row-2 { background: var(--color-huncai-bg); }
.cat-row-3 { background: var(--color-shucai-bg); }
.cat-row-4 { background: var(--color-tang-bg);   }
.cat-row-1 .summary-cat { color: var(--color-zhushi); }
.cat-row-2 .summary-cat { color: var(--color-huncai); }
.cat-row-3 .summary-cat { color: var(--color-shucai); }
.cat-row-4 .summary-cat { color: var(--color-tang);   }
.summary-empty { color: var(--color-muted); }

/* ── Waiter comment ──────────────────────────────────────────── */
.waiter-comment {
  text-align: center;
  font-size: var(--size-md);
  color: #555;
  padding: 0.75rem 1rem;
  background: var(--color-card-bg);
}

/* ── Copy link button (plan page) ────────────────────────────── */
.btn-copy { margin: 0.75rem 1rem 0; width: calc(100% - 2rem); }

/* ── Ingredients section ─────────────────────────────────────── */
.ingredients-section {
  margin: 1.25rem 1rem 0;
}
.ingredients-section h2,
.copy-section h2 {
  font-size: var(--size-xl);
  font-weight: var(--weight-bold);
  margin-bottom: 0.4rem;
}
.section-hint {
  font-size: var(--size-sm);
  color: var(--color-muted);
  margin-bottom: 0.75rem;
}

.ingredient-list {
  background: var(--color-card-bg);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.ingredient-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid #f0f0f0;
  cursor: pointer;
  min-height: 56px;
  transition: background 0.1s;
}
.ingredient-card:first-child { border-top: none; }
.ingredient-card:hover { background: #f9f9f9; }
.ingredient-card.checked {
  background: #f0f0f0;
  opacity: 0.5;
  text-decoration: line-through;
}
.ingredient-card input[type="checkbox"] {
  width: 22px; height: 22px;
  accent-color: var(--color-primary);
  flex-shrink: 0;
}
.ing-emoji { font-size: 1.8rem; flex-shrink: 0; }
.ing-name  { font-size: var(--size-lg); font-weight: var(--weight-bold); flex: 1; }
.ing-qty   { font-size: var(--size-md); color: #555; flex-shrink: 0; }

/* ── Copy text block ─────────────────────────────────────────── */
.copy-section {
  margin: 1.25rem 1rem 0;
}

.copy-block {
  background: #F4F4F4;
  border-radius: 12px;
  padding: 1rem;
  font-size: var(--size-md);
  white-space: pre-wrap;
  font-family: "Courier New", "Menlo", monospace;
  min-height: 80px;
  line-height: 1.8;
}

.all-done-msg {
  background: #E8F5E9;
  border-radius: 12px;
  padding: 1rem;
  font-size: var(--size-md);
  color: #2E7D32;
  text-align: center;
}

/* ── Error / expired page ────────────────────────────────────── */
.error-page {
  text-align: center;
  padding: 4rem 2rem;
}
.error-icon { font-size: 4rem; margin-bottom: 1rem; }
.error-page h1 { font-size: var(--size-xl); margin-bottom: 0.75rem; }
.error-page p { color: var(--color-muted); margin-bottom: 1.5rem; }
.error-page .btn { display: inline-block; width: auto; padding: 0.75rem 2rem; }

/* ── Login page ──────────────────────────────────────────────── */
.login-page {
  max-width: 400px;
  margin: 4rem auto;
  padding: 0 1rem;
}
.login-page h1 { margin-bottom: 1.5rem; font-size: var(--size-xl); }
.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-form label { display: flex; flex-direction: column; gap: 0.4rem; font-size: var(--size-md); }
.login-form input {
  padding: 0.75rem;
  border: 1.5px solid #ccc;
  border-radius: 8px;
  font-size: var(--size-md);
  font-family: var(--font-base);
}
.login-error { color: var(--color-huncai); font-size: var(--size-sm); }
.login-form .btn { margin-top: 0.5rem; }

/* ── Admin page ──────────────────────────────────────────────── */
.back-link {
  display: inline-block;
  font-size: var(--size-sm);
  color: var(--color-copy-btn);
  text-decoration: none;
  margin-top: 0.4rem;
}

.admin-section {
  margin: 1.5rem 1rem 0;
}
.admin-section h2 { font-size: var(--size-xl); margin-bottom: 0.75rem; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--size-sm);
  background: var(--color-card-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.admin-table th {
  background: #f0f0f0;
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: var(--weight-bold);
}
.admin-table td {
  padding: 0.6rem 0.75rem;
  border-top: 1px solid #f0f0f0;
  vertical-align: middle;
}
.dish-hidden td { opacity: 0.5; }
.mono { font-family: monospace; font-size: 0.9rem; }
.emoji-cell { font-size: 1.4rem; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: var(--weight-bold);
}
.badge-active { background: #E8F5E9; color: #2E7D32; }
.badge-hidden { background: #f0f0f0; color: #888; }

.action-cell { white-space: nowrap; }
.btn-sm {
  padding: 4px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font-base);
  margin-right: 4px;
}
.btn-hide  { background: #FFF3E0; color: #E65100; }
.btn-show  { background: #E8F5E9; color: #2E7D32; }
.btn-delete { background: #FFEBEE; color: #C62828; }

.reseed-section { margin-top: 2rem; }
.reseed-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--color-card-bg);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.reseed-form input[type="file"] {
  font-size: var(--size-md);
  font-family: var(--font-base);
}
.reseed-warning {
  font-size: var(--size-sm);
  color: #E65100;
}
.reseed-form .btn { margin: 0; }

.flash-msg {
  margin: 0.75rem 1rem 0;
  padding: 0.75rem 1rem;
  background: #E8F5E9;
  border-radius: 10px;
  color: #2E7D32;
  font-size: var(--size-md);
}
.error-msg {
  margin: 0.75rem 1rem 0;
  padding: 0.75rem 1rem;
  background: #FFEBEE;
  border-radius: 10px;
  color: #C62828;
  font-size: var(--size-md);
}

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