:root {
  --cream: #fff6e4;
  --paper: #fffdf7;
  --ink: #3b2a21;
  --ink-soft: #6b5445;
  --muted: #9b8878;
  --tomato: #ff6f5e;
  --tomato-deep: #e8503f;
  --butter: #ffc94d;
  --butter-deep: #f0b12a;
  --mint: #5fd3a0;
  --mint-deep: #35b783;
  --sky: #79c7f5;
  --pink: #ffafc5;
  --line: 3px solid var(--ink);
  --radius: 22px;
  --shadow: 0 5px 0 var(--ink);
  --shadow-sm: 0 4px 0 var(--ink);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: var(--ink);
  background-color: var(--cream);
  background-image: radial-gradient(circle, rgba(59, 42, 33, 0.07) 1.4px, transparent 1.5px);
  background-size: 18px 18px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button,
input,
textarea,
select {
  font-family: inherit;
  color: inherit;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

.page {
  padding: 16px 16px calc(112px + env(safe-area-inset-bottom));
  animation: fade-in 0.22s ease both;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes pop {
  0% { transform: scale(0.9); opacity: 0; }
  70% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes cart-pop {
  0% { transform: translateX(-50%) scale(0.92); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}

@keyframes wiggle {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}

/* ---------------- header ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px 14px;
}

.topbar h1 {
  font-size: 24px;
  font-weight: 900;
  margin: 0;
  letter-spacing: 1px;
}

.topbar .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 600;
}

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: var(--line);
  background: var(--butter);
  display: grid;
  place-items: center;
  font-size: 24px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  flex: none;
}

/* ---------------- card ---------------- */

.card {
  background: var(--paper);
  border: var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}

.card.tight { padding: 12px 14px; }
.card.flush { padding: 0; overflow: hidden; }

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

.row.between { justify-content: space-between; }

.grow { flex: 1; min-width: 0; }

.muted { color: var(--muted); font-size: 12px; font-weight: 600; }

.title {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.3px;
}

.subtitle {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.5;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- buttons ---------------- */

.btn {
  appearance: none;
  border: var(--line);
  background: var(--paper);
  border-radius: 16px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.1;
}

.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

.btn:disabled {
  opacity: 0.45;
  box-shadow: var(--shadow-sm);
  transform: none;
  cursor: not-allowed;
}

.btn-primary { background: var(--tomato); color: #fff; }
.btn-butter { background: var(--butter); }
.btn-mint { background: var(--mint); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 13px; font-size: 13px; border-radius: 13px; box-shadow: 0 3px 0 var(--ink); }
.btn-sm:active { box-shadow: 0 1px 0 var(--ink); }
.btn-lg { padding: 15px 20px; font-size: 17px; border-radius: 18px; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:active { transform: none; box-shadow: none; }

.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  font-size: 17px;
}

/* ---------------- chips / badges ---------------- */

.chip {
  border: 2.5px solid var(--ink);
  background: var(--paper);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.chip:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.chip.on { background: var(--butter); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 2.5px solid var(--ink);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 900;
  background: var(--paper);
  white-space: nowrap;
}

.badge.pending { background: var(--butter); }
.badge.cooking { background: var(--tomato); color: #fff; }
.badge.served { background: var(--mint); }
.badge.cancelled { background: #e6ddd2; color: var(--muted); }
.badge.open { background: var(--mint); }

/* ---------------- login ---------------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px 22px 40px;
}

.login-hero {
  text-align: center;
  margin-bottom: 26px;
}

.login-hero .pot {
  font-size: 76px;
  display: inline-block;
  animation: floaty 3.6s ease-in-out infinite;
  filter: drop-shadow(0 6px 0 rgba(59, 42, 33, 0.12));
}

.login-hero h1 {
  font-size: 32px;
  font-weight: 900;
  margin: 6px 0 4px;
  letter-spacing: 2px;
}

.login-hero p {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 14px;
}

/* ---------------- fields ---------------- */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 900;
  color: var(--ink-soft);
  margin: 0 0 6px 4px;
  letter-spacing: 0.6px;
}

.input,
textarea.input,
select.input {
  width: 100%;
  border: var(--line);
  border-radius: 16px;
  background: var(--paper);
  padding: 13px 14px;
  font-size: 16px;
  font-weight: 700;
  outline: none;
  box-shadow: inset 0 2px 0 rgba(59, 42, 33, 0.06);
}

.input:focus { border-color: var(--tomato); }
.input::placeholder { color: #c3b3a4; font-weight: 600; }

textarea.input { resize: none; line-height: 1.5; }

/* ---------------- role pick ---------------- */

.role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 8px 0 18px;
}

.role-card {
  border: var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  padding: 22px 12px 18px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
  overflow: hidden;
}

.role-card:nth-child(1) { background: var(--butter); transform: rotate(-1.5deg); }
.role-card:nth-child(2) { background: var(--sky); transform: rotate(1.5deg); }
.role-card:active { transform: translateY(4px) rotate(0); box-shadow: 0 1px 0 var(--ink); }

.role-card .big { font-size: 58px; line-height: 1; display: block; margin-bottom: 10px; }
.role-card .name { font-size: 22px; font-weight: 900; letter-spacing: 3px; }
.role-card .desc { font-size: 12px; font-weight: 700; color: rgba(59, 42, 33, 0.7); margin-top: 6px; line-height: 1.45; }

/* ---------------- kitchen cards ---------------- */

.kitchen-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--paper);
  border: var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
  padding: 14px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.kitchen-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

.kitchen-avatar {
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: 18px;
  border: var(--line);
  background: var(--butter);
  display: grid;
  place-items: center;
  font-size: 30px;
}

.kitchen-card.away .kitchen-avatar { background: var(--pink); }

/* ---------------- dish list ---------------- */

.dish-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 2px dashed rgba(59, 42, 33, 0.14);
}

.dish-row:last-child { border-bottom: none; }

.dish-emoji {
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 15px;
  border: 2.5px solid var(--ink);
  background: var(--cream);
  display: grid;
  place-items: center;
  font-size: 25px;
}

.dish-name { font-weight: 900; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.dish-desc { font-size: 12px; color: var(--muted); font-weight: 600; margin-top: 2px; line-height: 1.4; }

.stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.stepper button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2.5px solid var(--ink);
  background: var(--paper);
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}

.stepper .add { background: var(--tomato); color: #fff; }
.stepper .qty { min-width: 16px; text-align: center; font-weight: 900; font-size: 15px; }

/* ---------------- cart bar ---------------- */

.cartbar {
  position: fixed;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(448px, calc(100% - 28px));
  background: var(--ink);
  color: #fff;
  border-radius: 20px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 6px 18px rgba(59, 42, 33, 0.3);
  z-index: 40;
  animation: cart-pop 0.2s ease both;
}

.cartbar .info { font-weight: 800; font-size: 14px; }
.cartbar .btn { box-shadow: 0 3px 0 rgba(0, 0, 0, 0.3); border-color: var(--ink); }

/* ---------------- tabbar ---------------- */

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  display: flex;
  background: var(--paper);
  border-top: var(--line);
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
  box-shadow: 0 -4px 0 rgba(59, 42, 33, 0.06);
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 900;
  color: var(--muted);
  cursor: pointer;
  border-radius: 14px;
  position: relative;
}

.tab .ico { font-size: 22px; line-height: 1; filter: grayscale(0.55); transition: transform 0.15s ease; }
.tab.on { color: var(--ink); }
.tab.on .ico { filter: none; transform: translateY(-3px) scale(1.12); }

.tab .dot {
  position: absolute;
  top: 2px;
  right: 50%;
  margin-right: -22px;
  min-width: 17px;
  height: 17px;
  border-radius: 9px;
  background: var(--tomato);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  border: 2px solid var(--paper);
  display: grid;
  place-items: center;
  padding: 0 3px;
}

/* ---------------- order card ---------------- */

.order-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 2px dashed rgba(59, 42, 33, 0.14);
  margin-bottom: 10px;
}

.order-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }

.order-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

.order-item .q { color: var(--tomato); font-weight: 900; font-size: 12px; }

.order-note {
  background: var(--cream);
  border: 2.5px dashed rgba(59, 42, 33, 0.22);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  line-height: 1.5;
  margin-bottom: 10px;
}

.order-actions { display: flex; gap: 8px; }
.order-actions .btn { flex: 1; }

/* ---------------- empty ---------------- */

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--muted);
}

.empty .emoji { font-size: 54px; display: block; margin-bottom: 10px; opacity: 0.9; animation: floaty 4s ease-in-out infinite; }
.empty .t { font-weight: 900; color: var(--ink-soft); font-size: 15px; margin-bottom: 6px; }
.empty .d { font-size: 12px; font-weight: 600; line-height: 1.6; }

/* ---------------- sheet ---------------- */

.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(59, 42, 33, 0.42);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.16s ease both;
}

.sheet {
  width: min(480px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--paper);
  border: var(--line);
  border-bottom: none;
  border-radius: 26px 26px 0 0;
  padding: 18px 18px calc(22px + env(safe-area-inset-bottom));
  animation: sheet-up 0.24s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.sheet-handle {
  width: 46px;
  height: 5px;
  border-radius: 3px;
  background: rgba(59, 42, 33, 0.18);
  margin: 0 auto 14px;
}

.sheet h3 {
  margin: 0 0 14px;
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

/* ---------------- emoji picker ---------------- */

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  padding: 6px;
  border: 2.5px dashed rgba(59, 42, 33, 0.2);
  border-radius: 14px;
}

.emoji-grid button {
  border: none;
  background: transparent;
  font-size: 22px;
  padding: 4px 0;
  border-radius: 10px;
  cursor: pointer;
}

.emoji-grid button.on { background: var(--butter); }

/* ---------------- toast ---------------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 11px 18px;
  border-radius: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 99;
  max-width: 82vw;
  text-align: center;
  line-height: 1.4;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- misc ---------------- */

.divider { height: 2px; background: rgba(59, 42, 33, 0.1); margin: 12px 0; border-radius: 2px; }

.switch {
  width: 56px;
  height: 32px;
  border-radius: 999px;
  border: var(--line);
  background: #e6ddd2;
  position: relative;
  cursor: pointer;
  transition: background 0.18s ease;
  flex: none;
  padding: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--paper);
  border: 2.5px solid var(--ink);
  transition: transform 0.18s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.switch.on { background: var(--mint); }
.switch.on::after { transform: translateX(24px); }

.stat {
  flex: 1;
  text-align: center;
  padding: 10px 4px;
}

.stat .n { font-size: 24px; font-weight: 900; }
.stat .l { font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 2px; }

.list-plain { margin: 0; padding: 0; list-style: none; }
.list-plain li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 2px dashed rgba(59, 42, 33, 0.12);
  font-size: 14px;
  font-weight: 700;
}
.list-plain li:last-child { border-bottom: none; }

.link { color: var(--tomato-deep); font-weight: 900; text-decoration: none; }

@media (min-width: 520px) {
  body { padding: 18px 0; }
  #app {
    border: var(--line);
    border-radius: 30px;
    box-shadow: 0 10px 0 rgba(59, 42, 33, 0.15);
    overflow: hidden;
    min-height: calc(100vh - 36px);
    background: var(--cream);
  }
  .tabbar { bottom: 18px; border-radius: 0 0 27px 27px; }
  .cartbar { bottom: 104px; }
}
