:root {
  --paper: #fbf6ec;
  --paper-2: #fffdf7;
  --ink: #2a211c;
  --ink-soft: #857465;
  --ink-faint: #b3a494;
  --line: #e8ddc9;
  --red: #b5342a;
  --red-deep: #8e2620;
  --gold: #c99a4e;
  --shadow: 0 1px 2px rgba(74, 52, 34, .05), 0 8px 24px -12px rgba(74, 52, 34, .18);
  --serif: "Songti SC", "Noto Serif CJK SC", "Noto Serif SC", "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  background:
    radial-gradient(circle at 12% -8%, rgba(201, 154, 78, .10), transparent 42%),
    radial-gradient(circle at 92% 4%, rgba(181, 52, 42, .07), transparent 38%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: 96px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- hero ---------- */
.hero {
  padding: 40px 0 26px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.brand h1 {
  font-family: var(--serif);
  font-size: 40px;
  letter-spacing: .14em;
  margin: 0 0 10px;
  font-weight: 700;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 14px;
}

.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--red);
  border-radius: 6px;
  color: var(--red);
  font-size: 15px;
  font-family: var(--serif);
  letter-spacing: 0;
  line-height: 1;
  transform: rotate(-6deg);
  opacity: .9;
}

.brand p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  letter-spacing: .08em;
}

.stats {
  display: flex;
  gap: 26px;
}

.stat {
  text-align: right;
}

.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.1;
  color: var(--red);
  font-weight: 700;
}

.stat span {
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: .12em;
}

/* ---------- filters ---------- */
.filters {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: 12px 0;
  background: rgba(251, 246, 236, .88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}

.filters.stuck {
  border-bottom-color: var(--line);
}

.filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

select, input[type="text"], input[type="date"], input[type="number"], textarea {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .16s, box-shadow .16s;
  -webkit-appearance: none;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23857465' stroke-width='1.4' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  cursor: pointer;
}

select:focus, input:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201, 154, 78, .14);
}

select:disabled {
  color: var(--ink-faint);
  background-color: rgba(232, 221, 201, .3);
  cursor: default;
  opacity: .8;
}

#province { min-width: 130px; }
#city { min-width: 118px; }
#taste { min-width: 112px; }

.search {
  flex: 1;
  min-width: 150px;
  position: relative;
}

.search input {
  width: 100%;
  padding-left: 34px;
}

.search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  opacity: .45;
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 0 2px;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .16s;
  font-family: var(--sans);
  white-space: nowrap;
}

.chip:hover { border-color: var(--gold); color: var(--ink); }

.chip.on {
  background: var(--ink);
  border-color: var(--ink);
  color: #fdf9f0;
}

/* ---------- list ---------- */
main { padding-top: 8px; }

.group {
  margin-top: 30px;
}

.group-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.group-head h2 {
  font-family: var(--serif);
  font-size: 19px;
  margin: 0;
  letter-spacing: .06em;
  font-weight: 700;
}

.group-head .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--gold);
  transform: translateY(-4px);
}

.group-head .count {
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: .1em;
}

.group-head .rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--line), transparent);
}

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

.card {
  position: relative;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 17px 14px 20px;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent, var(--gold));
  opacity: .85;
}

.card:hover {
  transform: translateY(-2px);
  border-color: #ddd0b8;
  box-shadow: 0 2px 4px rgba(74, 52, 34, .06), 0 14px 30px -14px rgba(74, 52, 34, .28);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card h3 {
  font-family: var(--serif);
  font-size: 18px;
  margin: 0 0 3px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.35;
}

.shop {
  font-size: 12.5px;
  color: var(--ink-soft);
  letter-spacing: .02em;
  margin-bottom: 8px;
}

.score-badge {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--serif);
  line-height: 1;
  border: 1.5px solid var(--line);
  color: var(--ink-soft);
  background: transparent;
}

.score-badge b {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.score-badge i {
  font-size: 8px;
  font-style: normal;
  opacity: .6;
  margin-top: 2px;
  letter-spacing: .08em;
}

.score-badge[data-band="high"] {
  background: linear-gradient(145deg, #c04034, var(--red-deep));
  border-color: transparent;
  color: #fff8ec;
  box-shadow: 0 3px 10px -3px rgba(142, 38, 32, .45);
}

.score-badge[data-band="high"] i { opacity: .72; }

.score-badge[data-band="good"] {
  border-color: var(--gold);
  color: var(--gold);
  background: #fdf6e9;
}

.score-badge[data-band="mid"] {
  border-color: #cdbda4;
  color: #8a7a66;
}

.score-badge[data-band="low"] {
  border-color: #e0d6c6;
  color: #b3a494;
}

.score-badge.is-tasted {
  box-shadow: 0 0 0 2px var(--paper-2), 0 0 0 3.5px var(--gold);
}

.score-badge.is-tasted[data-band="high"] {
  box-shadow: 0 0 0 2px var(--paper-2), 0 0 0 3.5px var(--red-deep);
}

.score-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.score-hint {
  font-size: 9px;
  color: var(--ink-faint);
  letter-spacing: .06em;
  line-height: 1;
}

.taste-btn {
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1;
  color: var(--red-deep);
  background: #fff5f0;
  border: 1px solid #f0d4c5;
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .1s;
}

.taste-btn:hover { background: #ffeadf; }
.taste-btn:active { transform: scale(.96); }
.taste-btn.done {
  color: var(--ink-soft);
  background: transparent;
  border-color: var(--line);
}

.taste-sheet { max-width: 440px; }

.taste-name {
  font-family: var(--serif);
  font-size: 20px;
  color: var(--ink);
  margin: 0 0 6px;
}

.taste-hint {
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-soft);
  background: #f7f0e3;
  border-left: 2px solid var(--gold);
  padding: 8px 11px;
  margin: 0 0 18px;
}

.note {
  font-size: 13px;
  line-height: 1.6;
  color: #5d4f43;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #f5ecdc;
  color: #8a6f4d;
  letter-spacing: .04em;
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-faint);
  letter-spacing: .04em;
  border-top: 1px dashed var(--line);
  padding-top: 9px;
  margin-top: 2px;
}

.price {
  color: var(--red);
  font-weight: 600;
}

.cat-label {
  display: inline-block;
  font-size: 11px;
  color: var(--accent, var(--gold));
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 1px 6px;
  opacity: .85;
  margin-left: 6px;
  vertical-align: 2px;
  font-weight: 500;
}

/* ---------- empty ---------- */
.empty {
  margin: 60px auto;
  max-width: 460px;
  text-align: center;
  padding: 48px 28px;
  border: 1.5px dashed var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 247, .5);
}

.empty .ico { font-size: 34px; margin-bottom: 14px; opacity: .55; }

.empty h3 {
  font-family: var(--serif);
  font-size: 18px;
  margin: 0 0 8px;
  letter-spacing: .06em;
}

.empty p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.7;
}

/* ---------- footer ---------- */
.foot {
  margin-top: 56px;
  padding: 20px 0 26px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-faint);
  letter-spacing: .04em;
}

.foot b {
  color: var(--ink-soft);
  font-weight: 600;
}

.foot-links { display: flex; gap: 14px; }

.linkbtn {
  border: none;
  background: none;
  padding: 0;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  letter-spacing: .04em;
  border-bottom: 1px solid transparent;
  transition: border-color .16s, color .16s;
}

.linkbtn:hover {
  color: var(--red);
  border-bottom-color: var(--red);
}

/* ---------- fab ---------- */
.fab {
  position: fixed;
  right: 24px;
  bottom: 26px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #c04034, var(--red-deep));
  color: #fff8ec;
  font-size: 27px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px -4px rgba(142, 38, 32, .5), 0 2px 6px rgba(0, 0, 0, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .16s, box-shadow .16s;
  z-index: 50;
}

.fab:hover {
  transform: translateY(-2px) rotate(90deg);
  box-shadow: 0 10px 24px -4px rgba(142, 38, 32, .55);
}

.fab:active { transform: scale(.95); }

/* ---------- dialog ---------- */
dialog {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  margin: 0;
}

dialog::backdrop {
  background: rgba(42, 33, 28, .38);
  backdrop-filter: blur(3px);
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  background: var(--paper-2);
  border-radius: 20px 20px 0 0;
  padding: 22px 24px 0;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(42, 33, 28, .2);
  animation: rise .26s cubic-bezier(.22, 1, .36, 1);
}

@keyframes rise {
  from { transform: translate(-50%, 24px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.sheet-head h2 {
  font-family: var(--serif);
  font-size: 20px;
  margin: 0;
  letter-spacing: .08em;
}

.close {
  border: none;
  background: transparent;
  font-size: 22px;
  color: var(--ink-faint);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 11.5px;
  color: var(--ink-soft);
  letter-spacing: .12em;
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  font-size: 15px;
}

.field textarea {
  resize: vertical;
  min-height: 74px;
  line-height: 1.6;
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.row3 {
  display: grid;
  grid-template-columns: 1.1fr .9fr .9fr;
  gap: 12px;
}

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

.score-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--gold) 0%, var(--gold) var(--pct, 80%), #e8ddc9 var(--pct, 80%), #e8ddc9 100%);
  outline: none;
  padding: 0;
  border: none;
}

.score-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fffdf7;
  border: 2px solid var(--red);
  box-shadow: 0 1px 4px rgba(142, 38, 32, .25);
  cursor: pointer;
}

.score-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fffdf7;
  border: 2px solid var(--red);
  cursor: pointer;
}

.score-out {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--red);
  min-width: 52px;
  text-align: right;
  letter-spacing: .02em;
}

.sheet-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  margin: 22px -24px 0;
  padding: 14px 24px calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--paper-2);
  border-top: 1px solid var(--line);
  z-index: 2;
}

.btn {
  flex: 1;
  font-family: var(--sans);
  font-size: 15px;
  padding: 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  letter-spacing: .06em;
  transition: all .16s;
}

.btn:hover { background: #f6eddd; }

.btn.primary {
  background: linear-gradient(145deg, #c04034, var(--red-deep));
  border-color: transparent;
  color: #fff8ec;
  font-weight: 500;
}

.btn.primary:hover { filter: brightness(1.06); }

.btn.danger {
  flex: 0 0 auto;
  padding: 12px 16px;
  color: var(--red);
  border-color: #ecd3ce;
}

.btn.danger:hover { background: #fbeae7; }

.hint {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: .04em;
  margin-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translate(-50%, 12px);
  background: var(--ink);
  color: #fdf9f0;
  font-size: 13.5px;
  padding: 10px 20px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: all .26s;
  z-index: 100;
  letter-spacing: .04em;
}

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

@media (max-width: 620px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 28px 0 18px; }
  .brand h1 { font-size: 32px; }
  .stats { gap: 20px; }
  .stat b { font-size: 22px; }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .row3 { grid-template-columns: 1fr 1fr; }
  .row3 .field:last-child { grid-column: 1 / -1; }
  .fab { right: 18px; bottom: 20px; }
}

@media (min-width: 621px) {
  .sheet {
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    border-radius: 20px;
    animation: pop .22s cubic-bezier(.22, 1, .36, 1);
  }
  .sheet::before { display: none; }
  @keyframes pop {
    from { transform: translate(-50%, -46%); opacity: 0; }
    to { transform: translate(-50%, -50%); opacity: 1; }
  }
}
