:root {
  color-scheme: light;
  --paper: #f6f2e9;
  --ink: #183427;
  --muted: #506458;
  --accent: #973b27;
  --rule: #bc8a7a;
  font-family: "Noto Serif SC", "Songti SC", SimSun, serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0 auto; width: min(88%, 1240px); }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; }
button {
  background: transparent; color: inherit; border: 1px solid currentColor;
  border-radius: 9px; padding: .55rem .95rem; min-height: 42px; cursor: pointer;
  font-size: 1.02rem; font-weight: 600;
}
button:hover { background: #e8e3d7; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.primary { background: #233e2c; color: #fffaf0; border-color: #233e2c; }
.primary:hover { background: #355641; }
.accent, a { color: var(--accent); }
.masthead {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--ink); min-height: 66px; gap: 1rem;
}
.masthead strong { font-size: 1.55rem; }
main { padding: 30px 0 48px; }
h1 { font-size: clamp(2.7rem, 6vw, 4.3rem); line-height: 1.15; letter-spacing: -.045em; }
time { display: block; color: var(--muted); margin-top: 8px; font-size: 1.15rem; }
.meals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 26px; }
.meal { border: 1px solid var(--accent); border-radius: 14px; padding: 20px 25px 23px; display: flex; flex-direction: column; }
.meal-header {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  border-bottom: 1px solid var(--accent); color: var(--accent); padding-bottom: 12px;
}
.meal-header h2 { font-size: 1.9rem; }
.refresh { border: 0; }
.meal h3 { text-align: center; font-size: clamp(1.85rem, 4vw, 3.8rem); letter-spacing: -.035em; margin-top: 20px; }
.tags { display: flex; justify-content: center; gap: .55rem; margin: 12px 0 20px; flex-wrap: wrap; }
.tags span { color: var(--accent); border: 1px solid var(--rule); border-radius: 30px; padding: 3px 12px; }
.divider { display: flex; align-items: center; gap: .8rem; margin: 0 0 14px; }
.divider::before, .divider::after { content: ""; height: 1px; background: var(--rule); flex: 1; }
.options, .meal-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.meal-actions { grid-template-columns: 3fr 2fr; padding-top: 20px; margin-top: auto; }
#nearby { margin-top: 30px; }
#nearby h2 { font-size: clamp(2rem, 4vw, 2.8rem); }
#nearby-title:focus { outline: none; }
.nearby-header { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-bottom: 14px; }
.nearby-header p { margin-top: 4px; }
#keyword { color: var(--accent); }
.location-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.results { border-top: 1px solid var(--rule); }
#status { color: var(--muted); margin: 13px 0 10px; line-height: 1.55; }
#restaurants { margin: 12px 0 0; padding: 0; list-style: none; }
.restaurant { display: grid; grid-template-columns: 1.25fr 1.8fr auto auto; gap: 16px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.restaurant a { text-decoration: none; }
.restaurant a:hover { text-decoration: underline; }
.distance { color: var(--muted); }
#address-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 16px; }
#address-form[hidden] { display: none; }
.saved-locations { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.saved-locations:has(:not([hidden]) > select), .saved-locations:has(button:not([hidden])) { margin-block: 0 12px; }
#saved-location-field:not([hidden]), #save-location-form label { display: grid; gap: 4px; }
#saved-location { max-width: 100%; min-height: 42px; padding-inline: 8px; font: inherit; color: inherit; background: var(--paper); border: 1px solid var(--muted); border-radius: 8px; }
#save-location-form label, #save-location-status:not(:empty) { margin-block: 10px; }
#address-form label { display: grid; gap: 6px; flex: 1 1 145px; }
#address-form label:nth-child(2) { flex-grow: 2; }
input:not([type=checkbox]) { width: 100%; min-height: 42px; border: 1px solid var(--muted); border-radius: 8px; color: var(--ink); padding: 8px 10px; background: transparent; }
dialog { width: min(calc(100% - 32px), 470px); padding: 22px; border: 1px solid var(--accent); border-radius: 14px; color: var(--ink); background: var(--paper); }
dialog::backdrop { background: #172f2580; }
fieldset { margin: 15px 0; border: 1px solid var(--rule); border-radius: 8px; }
fieldset div { display: flex; flex-wrap: wrap; gap: 8px 18px; }
fieldset label { padding: 5px 0; display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--ink); }
.masthead { flex-wrap: wrap; padding-block: 8px; }
#login-form label, #password-form label, .history-filters label { display: grid; gap: 4px; margin-block: 10px; }
#register-form label, #admin-dialog label { display: grid; gap: 4px; margin-block: 10px; }
#register-status, #admin-status, #admin-create-status { margin-block: 10px; overflow-wrap: anywhere; }
#admin-dialog { width: min(calc(100% - 24px), 660px); }
.admin-heading, .admin-account, .admin-account-actions, .admin-pagination {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
.admin-heading, .admin-account-actions { justify-content: space-between; }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--rule); margin-block: 12px; }
#default-menu { padding-inline-start: 24px; }
#default-menu li { padding-block: 5px; overflow-wrap: anywhere; }
#default-tastes-input, #default-dish-form select { width: 100%; font: inherit; color: inherit; background: var(--paper); }
#default-dish-form { margin-top: 14px; border-top: 1px solid var(--rule); }
#custom-dish-tastes { max-height: 165px; overflow: auto; }
#sayings-input {
  width: 100%; resize: vertical; padding: 10px; font: inherit; color: inherit;
  background: transparent; border: 1px solid var(--muted); border-radius: 8px;
}
#sayings-status:not(:empty) { margin-top: 8px; }
.admin-tabs button { border: 0; border-radius: 8px 8px 0 0; }
.admin-tabs [aria-selected="true"] { background: #233e2c; color: #fffaf0; }
#admin-filter { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; }
#admin-filter select { font: inherit; color: inherit; background: var(--paper); border: 1px solid var(--muted); border-radius: 8px; padding-inline: 6px; }
#admin-list { max-height: min(48dvh, 430px); overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
#admin-list form { border: 1px solid #d5c8b9; border-radius: 9px; margin: 0 6px 8px 0; padding: 10px 12px; }
.admin-account strong { overflow-wrap: anywhere; }
.admin-role, .admin-state { border-radius: 5px; padding: 2px 6px; font-size: .84rem; background: #e9e2d5; }
.admin-role.elevated { background: #233e2c; color: #fffaf0; }
.admin-state { background: #dce8dc; }
.admin-state.inactive { color: var(--accent); background: #f0ded6; }
#admin-dialog .admin-disable { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.admin-pagination { justify-content: flex-end; padding-top: 8px; }
#admin-page-info { margin-right: auto; }
.admin-empty { padding: 14px 0; }
#admin-list .history-filters input { min-width: 0; }
#settings .menu-tools { flex-wrap: nowrap; gap: 8px; margin-top: 8px; }
.menu-tools input { min-width: 0; }
.menu-tools button { white-space: nowrap; }
#custom-menu { list-style: none; margin: 0; padding: 0; }
#custom-menu li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-block: 6px; border-bottom: 1px solid var(--rule); }
#custom-menu li span { flex: 1 1 100px; overflow-wrap: anywhere; }
#custom-menu:empty { display: none; }
#custom-taste { font: inherit; color: inherit; background: var(--paper); }
#menu-status:not(:empty) { margin-bottom: 10px; }
#login-status, #password-status, #history-status, #import-dialog p { margin-block: 10px; }
#sync-setting { display: block; margin-bottom: 14px; }
#sync-setting[hidden] { display: none; }
.history-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
#history-list { max-height: 40vh; overflow: auto; padding-inline-start: 24px; }
#history-list li { padding-block: 6px; }
#account-status { position: fixed; inset: auto 16px 16px; margin: auto; width: fit-content;
  padding: 10px 14px; background: var(--paper); border: 1px solid var(--accent); border-radius: 8px; }
@media (max-width: 660px) {
  #admin-dialog { padding: 14px; }
  body { width: calc(100% - 32px); }
  main { padding-top: 22px; }
  .meals { grid-template-columns: 1fr; gap: 14px; }
  .meal { padding: 14px 15px 16px; }
  .meal h3 { font-size: 2.2rem; }
  .restaurant { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
  .restaurant strong { grid-column: 1; grid-row: 1; }
  .restaurant span:not(.distance) { grid-column: 1; grid-row: 2; }
  .restaurant .distance { grid-column: 2; grid-row: 1; text-align: right; }
  .restaurant a { grid-column: 2; grid-row: 2; }
}
@media (max-width: 380px) {
  #admin-filter { grid-template-columns: 1fr auto; }
  #admin-filter input { grid-column: 1 / -1; }
}
.masthead:has(.profile) { flex-wrap: nowrap; }
.profile { position: relative; min-width: 0; z-index: 2; }
.profile summary {
  display: flex; align-items: center; gap: 8px; padding: 5px 9px 5px 5px;
  border: 1px solid var(--rule); border-radius: 24px; cursor: pointer; list-style: none;
}
.profile summary::-webkit-details-marker { display: none; }
.profile-avatar {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: 50%; color: #fffaf0; background: #233e2c; font-weight: bold;
}
#profile-name { max-width: min(24vw, 190px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-chevron { flex: none; width: 7px; height: 7px; border-right: 1px solid; border-bottom: 1px solid; transform: rotate(45deg); margin: 0 2px 4px; }
.profile[open] .profile-chevron { transform: rotate(225deg); margin-bottom: 0; }
.profile-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 176px; padding: 6px;
  border: 1px solid var(--rule); border-radius: 12px; background: var(--paper);
  box-shadow: 0 12px 28px #182a2326;
}
.profile-panel button { width: 100%; border: 0; text-align: left; }
.profile-panel #account-button { border-top: 1px solid var(--rule); border-radius: 0 0 8px 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.meal { position: relative; }
.draw-invitation {
  display: grid; place-items: center; align-content: center; gap: 14px;
  flex: 1; min-height: 218px; width: 100%; margin-top: 14px; padding: 24px 14px;
  border: 1px dashed var(--rule); border-radius: 12px;
  background: radial-gradient(ellipse at center, #ffedc9, var(--paper) 80%);
  text-align: center;
}
.draw-invitation:hover { border-color: var(--accent); }
.invitation-seal {
  display: grid; place-items: center; width: 34px; height: 40px;
  border: 1px solid currentColor; border-radius: 5px; color: var(--accent);
  transform: rotate(-8deg); font-size: 1.15rem;
}
.invitation-quote { font-size: clamp(1.06rem, 3vw, 1.4rem); line-height: 1.55; }
.invitation-hint { color: var(--accent); font-size: .86rem; }
.draw-stage {
  position: absolute; inset: 0; z-index: 1; display: grid; place-items: center;
  overflow: hidden; border-radius: inherit; background: radial-gradient(ellipse at center, #ffedc9, var(--paper) 75%);
}
.draw-bundle { position: relative; width: 74px; height: 70px; transform-origin: center bottom; animation: draw-shake 620ms ease-in-out both; }
.draw-cup {
  position: absolute; inset: 4px 0 0; display: grid; place-items: center; border-radius: 10px 10px 24px 24px;
  background: linear-gradient(90deg, #793523, #ad5636 45%, #77321f); border: 2px solid #d89651;
  color: #fff0cb; font-size: 26px;
}
.draw-stick, .draw-picked {
  position: absolute; width: 11px; height: 65px; border-radius: 4px;
  background: linear-gradient(#a84930 0 20%, #e4b36d 20%); border: 1px solid #b27e45;
}
.draw-stick { bottom: 43px; left: 31px; transform-origin: bottom; }
.draw-stick:first-child { transform: rotate(-24deg); }
.draw-stick:nth-child(3) { transform: rotate(24deg); }
.draw-picked { opacity: 0; animation: draw-pick 380ms 470ms ease-out both; }
.draw-result h3 { animation: draw-reveal 280ms ease-out both; }
@keyframes draw-shake { 0%, 100% { transform: rotate(0); } 18%, 54% { transform: rotate(-15deg); } 36%, 72% { transform: rotate(15deg); } }
@keyframes draw-pick { 0% { opacity: 0; transform: translateY(10px); } 30% { opacity: 1; } 100% { opacity: 1; transform: translateY(-84px) rotate(20deg); } }
@keyframes draw-reveal { from { opacity: .3; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .draw-bundle, .draw-picked, .draw-result h3 { animation: none; }
}
