:root {
  color-scheme: light;
  --paper: #fbf1ea;
  --surface: #fffaf5;
  --ink: #302925;
  --muted: #796b62;
  --line: #ead8cd;
  --line-strong: #d8bfae;
  --red: #b45843;
  --red-deep: #8a3c2d;
  --red-soft: #f6e2db;
  --green: #667660;
  --green-soft: #e6ede2;
  --amber: #bf8245;
  --shadow: 0 10px 30px rgba(85, 54, 35, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

:focus-visible {
  outline: 3px solid rgba(168, 71, 53, 0.35);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-shell {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
}

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 84px;
  padding: 14px 0 12px;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

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

.brand-mark {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-family: "Songti SC", "STSong", serif;
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 6px 16px rgba(138, 60, 45, 0.2);
}

.brand h1,
.menu-heading h2,
.wish-intro h2,
.dialog-copy h2 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-weight: 700;
}

.brand h1 {
  font-size: clamp(22px, 5.6vw, 30px);
  line-height: 1.15;
}

.eyebrow,
.section-kicker {
  margin: 0 0 3px;
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
}

.icon-button {
  display: inline-grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--red-deep);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: white;
  transform: translateY(-1px);
}

.icon-button:active {
  transform: translateY(0) scale(0.96);
}

.icon-button svg,
.primary-button svg,
.search-box svg,
.wish-card svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.top-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.top-tab {
  position: relative;
  min-height: 45px;
  padding: 10px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.top-tab::after {
  position: absolute;
  right: 26%;
  bottom: -1px;
  left: 26%;
  height: 3px;
  background: transparent;
  content: "";
}

.top-tab.active {
  color: var(--ink);
}

.top-tab.active::after {
  background: var(--red);
}

main {
  padding-top: 18px;
}

.menu-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.search-box {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 9px;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.search-box:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(168, 71, 53, 0.08);
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
}

.search-box input::placeholder {
  color: #9a9287;
}

.icon-button.subtle {
  width: 40px;
  height: 40px;
  border-color: transparent;
  background: transparent;
}

.group-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 1px 0 8px;
  scrollbar-width: none;
}

.group-tabs::-webkit-scrollbar {
  display: none;
}

.group-tab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.group-tab.active {
  border-color: var(--red);
  background: var(--red);
  color: white;
}

.menu-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 17px 0 12px;
}

.menu-heading h2,
.wish-intro h2 {
  font-size: 26px;
  line-height: 1.2;
}

.dish-count {
  flex: 0 0 auto;
  padding-bottom: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.dish-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(201, 189, 173, 0.72);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(62, 48, 33, 0.05);
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.dish-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.dish-card:active {
  transform: translateY(0) scale(0.99);
}

.dish-image-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: #eee0d5;
}

.dish-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 260ms ease;
}

.dish-card:hover .dish-image-wrap img {
  transform: scale(1.025);
}

.dish-copy {
  padding: 11px 12px 13px;
}

.dish-name {
  overflow: hidden;
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dish-group {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-note {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  min-height: 190px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: rgba(255, 250, 245, 0.68);
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 28px;
  height: 28px;
  margin: 0 auto 8px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

.wish-view {
  max-width: 680px;
  margin: 4px auto 0;
}

.wish-intro {
  margin: 4px 0 18px;
}

.wish-form {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.field {
  display: block;
  margin-bottom: 17px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
}

.field textarea {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 94px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #fff8f2;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.65;
}

.field input {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #fff8f2;
  color: var(--ink);
  font-size: 16px;
}

.field input:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(168, 71, 53, 0.08);
}

.field textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(168, 71, 53, 0.08);
}

.field textarea::placeholder {
  color: #9a9287;
}

.field input::placeholder {
  color: #9a9287;
}

.primary-button {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 17px;
  border: 0;
  border-radius: 7px;
  background: var(--red);
  color: white;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease;
}

.primary-button:hover {
  background: var(--red-deep);
}

.primary-button:active {
  transform: scale(0.98);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.wish-form .primary-button {
  width: 100%;
}

.form-status {
  min-height: 20px;
  margin: 11px 0 0;
  color: var(--green);
  font-size: 13px;
  text-align: center;
}

.form-status.error {
  color: var(--red-deep);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 30px 0 8px;
  color: #8f877b;
  font-size: 11px;
}

.dish-dialog {
  width: min(92vw, 640px);
  max-height: min(88vh, 760px);
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(33, 25, 17, 0.28);
}

.dish-dialog::backdrop {
  background: rgba(32, 26, 20, 0.58);
  backdrop-filter: blur(3px);
}

.dialog-inner {
  position: relative;
  overflow-y: auto;
  max-height: inherit;
}

.dialog-inner > img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eee0d5;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 253, 249, 0.92);
  box-shadow: 0 4px 12px rgba(24, 18, 13, 0.16);
}

.dialog-copy {
  padding: 20px;
}

.dialog-copy h2 {
  margin-bottom: 18px;
  font-size: 28px;
  line-height: 1.2;
}

.dialog-copy .primary-button {
  width: 100%;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  max-width: calc(100vw - 40px);
  padding: 11px 16px;
  border-radius: 7px;
  background: #2d2923;
  color: white;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(50%, 0);
}

.admin-shell {
  width: min(100%, 880px);
}

.admin-mark {
  background: var(--green);
  box-shadow: 0 5px 14px rgba(82, 106, 87, 0.18);
}

.admin-header {
  border-bottom: 1px solid var(--line);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-page main {
  padding-top: 20px;
}

.login-panel {
  max-width: 460px;
  margin: 42px auto 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h2 {
  margin: 0 0 22px;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  font-size: 28px;
  line-height: 1.2;
}

.login-panel .primary-button {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.stat-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  font-family: "Songti SC", "STSong", serif;
  font-size: 30px;
  line-height: 1;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.filter-tabs {
  display: flex;
  gap: 5px;
}

.filter-tabs button {
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.filter-tabs button.active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.sync-state {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
}

.sync-state.syncing {
  color: var(--amber);
}

.sync-state.error {
  color: var(--red);
}

.wish-list {
  display: grid;
  gap: 10px;
}

.wish-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.wish-card.is-planned {
  background: #f8f1eb;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
}

.status-pill::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.is-planned .status-pill {
  color: var(--green);
}

.wish-time {
  color: var(--muted);
  font-size: 11px;
}

.wish-block + .wish-block {
  margin-top: 11px;
}

.wish-block-label {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
}

.wish-block-text {
  margin: 0;
  font-size: 15px;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.wish-block-text.dishes {
  font-family: "Songti SC", "STSong", serif;
  font-size: 17px;
  font-weight: 700;
}

.wish-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.wish-actions .icon-button {
  width: 36px;
  height: 36px;
}

.wish-actions .delete-button {
  color: var(--muted);
}

.wish-actions .delete-button:hover {
  color: var(--red-deep);
}

.admin-empty {
  min-height: 210px;
}

@media (min-width: 620px) {
  .site-shell {
    padding-right: 24px;
    padding-left: 24px;
  }

  .site-header {
    min-height: 96px;
  }

  .dish-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 15px;
  }

  .dish-name {
    font-size: 18px;
  }

  .wish-form {
    padding: 24px;
  }
}

@media (min-width: 900px) {
  .dish-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 360px) {
  .site-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
    font-size: 20px;
  }

  .brand h1 {
    font-size: 21px;
  }

  .eyebrow {
    font-size: 10px;
  }

  .top-tab {
    font-size: 13px;
  }

  .dish-grid {
    gap: 9px;
  }

  .dish-copy {
    padding: 9px 10px 11px;
  }

  .dish-name {
    font-size: 15px;
  }

  .dish-group {
    font-size: 10px;
  }

  .stat {
    padding: 11px;
  }

  .stat strong {
    font-size: 26px;
  }

  .admin-toolbar {
    align-items: flex-start;
  }

  .filter-tabs button {
    padding-right: 9px;
    padding-left: 9px;
  }

  .login-panel {
    margin-top: 24px;
    padding: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
