:root {
  --bg: #f7faf8;
  --surface: #ffffff;
  --ink: #1f2a27;
  --muted: #71807b;
  --line: #e2ebe7;
  --mint: #dff2e9;
  --green: #34745f;
  --green-dark: #275a4b;
  --blue: #e8f1f6;
  --danger: #b95e59;
  --shadow: 0 14px 40px rgba(44, 83, 69, .09);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(100%, 520px); min-height: 100svh; margin: 0 auto; padding: 28px 20px calc(104px + env(safe-area-inset-bottom)); }
.view { display: none; animation: fade .24s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } }

.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.eyebrow { margin: 0 0 5px; color: #8aa298; font-size: 11px; font-weight: 750; letter-spacing: .16em; }
h1 { margin: 0; font-size: 29px; letter-spacing: -.04em; }
.title-note { display: block; margin-top: 5px; color: var(--green); font-size: 14px; font-weight: 650; letter-spacing: .08em; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 50%; color: var(--green); background: rgba(255,255,255,.76); font-size: 22px; }

.library-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 14px; background: #edf4f1; }
.library-option { min-height: 42px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-weight: 650; }
.library-option.active { color: var(--green-dark); background: var(--surface); box-shadow: 0 3px 12px rgba(39,90,75,.08); }

.filter-card { padding: 17px; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,255,255,.76); }
.section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.section-heading h2 { margin: 0; font-size: 17px; }
.section-heading span { color: var(--muted); font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; color: #52625d; background: var(--surface); font-size: 14px; }
.chip.active { border-color: #9ecbb9; color: var(--green-dark); background: var(--mint); font-weight: 650; }

.cow-stage { position: relative; display: grid; place-items: center; height: 260px; margin: 8px 0 -2px; overflow: hidden; }
.soft-blob { position: absolute; width: 225px; height: 190px; border-radius: 44% 56% 56% 44% / 54% 42% 58% 46%; background: linear-gradient(145deg, var(--blue), var(--mint)); transform: rotate(-5deg); }
.cow-stage img { position: relative; z-index: 1; width: 205px; max-height: 228px; object-fit: contain; filter: drop-shadow(0 14px 17px rgba(39,90,75,.12)); }
.count-pill { position: absolute; z-index: 2; bottom: 5px; margin: 0; padding: 7px 12px; border: 1px solid rgba(255,255,255,.9); border-radius: 999px; color: var(--green-dark); background: rgba(255,255,255,.82); backdrop-filter: blur(8px); font-size: 13px; }

.pick-button { width: 100%; min-height: 56px; border: 0; border-radius: 16px; color: white; background: var(--green); box-shadow: 0 11px 24px rgba(52,116,95,.2); font-size: 17px; font-weight: 750; }
.pick-button:active { transform: translateY(1px); background: var(--green-dark); }

.result-card { position: fixed; z-index: 20; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); width: min(calc(100% - 32px), 488px); padding: 20px; transform: translateX(-50%); border: 1px solid #d7e6df; border-radius: 23px; background: rgba(255,255,255,.96); box-shadow: 0 24px 70px rgba(27,60,49,.2); backdrop-filter: blur(14px); animation: rise .32s cubic-bezier(.2,.8,.2,1); }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 18px) scale(.98); } }
.result-top { display: flex; justify-content: space-between; align-items: center; }
.result-kicker { color: var(--green); font-size: 13px; font-weight: 700; }
.plain-btn { width: 32px; height: 32px; border: 0; color: var(--muted); background: transparent; font-size: 24px; }
.result-card h2 { margin: 11px 0 6px; font-size: 25px; }
.result-meta { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 17px; }
.mini-tag { padding: 5px 9px; border-radius: 8px; color: #4d6960; background: #edf6f2; font-size: 12px; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.primary-small,.secondary-small { min-height: 44px; border-radius: 12px; font-weight: 700; }
.primary-small { border: 0; color: white; background: var(--green); }
.secondary-small { border: 1px solid var(--line); color: var(--green-dark); background: white; }
.status-actions { display: flex; justify-content: center; gap: 14px; margin-top: 13px; }
.status-actions button { border: 0; color: var(--muted); background: transparent; font-size: 13px; }

.header-count { padding-top: 9px; color: var(--muted); font-size: 13px; }
.library-header-actions { display: flex; align-items: center; gap: 9px; }
.add-restaurant-btn { min-height: 40px; padding: 0 13px; border: 1px solid #b9d8cc; border-radius: 12px; color: var(--green-dark); background: var(--mint); font-size: 14px; font-weight: 700; }
.search-box { display: flex; align-items: center; gap: 9px; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.search-box span { color: #8a9a95; font-size: 22px; }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 16px; }
.library-filters { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 11px; }
.library-filters label { position: relative; display: grid; gap: 4px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.library-filters label span { color: #8a9a95; font-size: 11px; }
.library-filters select { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 14px; font-weight: 650; }
.clear-filter { align-self: stretch; padding: 0 12px; border: 1px solid var(--line); border-radius: 13px; color: var(--green); background: #f1f7f4; font-size: 13px; font-weight: 650; }
.status-filter { margin: 14px 0 18px; }
.restaurant-list { display: grid; gap: 10px; }
.restaurant-card { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.restaurant-card h3 { margin: 0 0 7px; font-size: 16px; line-height: 1.35; }
.restaurant-card p { margin: 0; color: var(--muted); font-size: 13px; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.status-badge { align-self: start; padding: 5px 8px; border-radius: 8px; color: var(--green-dark); background: var(--mint); font-size: 12px; }
.status-badge.avoid { color: #95524e; background: #f9e8e6; }
.more-btn { align-self: start; width: 35px; height: 35px; border: 0; border-radius: 50%; color: var(--muted); background: #f2f6f4; }
.card-menu { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px; padding-top: 11px; border-top: 1px solid var(--line); }
.card-menu button { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: #52625d; background: white; font-size: 12px; }
.card-menu .delete { color: var(--danger); }
.empty { padding: 70px 20px; color: var(--muted); text-align: center; }

.bottom-nav { position: fixed; z-index: 30; left: 50%; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; width: min(100%, 520px); padding: 10px 28px calc(10px + env(safe-area-inset-bottom)); transform: translateX(-50%); border-top: 1px solid rgba(213,226,220,.85); background: rgba(249,252,250,.92); backdrop-filter: blur(18px); }
.nav-item { display: grid; justify-items: center; gap: 3px; border: 0; color: #86938f; background: transparent; font-size: 12px; }
.nav-item span { font-size: 22px; line-height: 1; }
.nav-item.active { color: var(--green); font-weight: 700; }
.toast { position: fixed; z-index: 50; left: 50%; top: 18px; padding: 10px 14px; transform: translate(-50%,-70px); border-radius: 999px; color: white; background: #2c3e38; opacity: 0; transition: .25s ease; font-size: 13px; }
.toast.show { transform: translate(-50%,0); opacity: 1; }

.add-dialog { width: min(100% - 24px, 496px); max-height: calc(100svh - 24px); margin: auto auto 12px; padding: 0; border: 0; border-radius: 24px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(28,55,46,.22); }
.add-dialog::backdrop { background: rgba(31,42,39,.3); backdrop-filter: blur(3px); }
.add-dialog[open] { animation: sheet-up .25s ease-out; }
@keyframes sheet-up { from { opacity: 0; transform: translateY(24px); } }
.add-form { display: grid; gap: 14px; padding: 8px 18px calc(20px + env(safe-area-inset-bottom)); }
.dialog-handle { width: 42px; height: 4px; margin: 0 auto 2px; border-radius: 99px; background: #dce7e2; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.dialog-heading h2 { margin: 0; font-size: 22px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-field { display: grid; gap: 7px; color: #52625d; font-size: 14px; font-weight: 650; }
.form-field b { color: var(--danger); }
.form-field input { width: 100%; height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; outline: 0; color: var(--ink); background: #fbfdfc; font-size: 16px; font-weight: 400; }
.form-field input:focus { border-color: #8fc2ae; box-shadow: 0 0 0 3px rgba(143,194,174,.16); }
.heavy-check { display: flex; align-items: center; gap: 11px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #f7fbf9; }
.heavy-check input { width: 20px; height: 20px; accent-color: var(--green); }
.heavy-check span { display: grid; gap: 2px; }
.heavy-check strong { font-size: 14px; }
.heavy-check small { color: var(--muted); font-size: 12px; }
.save-restaurant-btn { min-height: 50px; border: 0; border-radius: 14px; color: white; background: var(--green); font-size: 16px; font-weight: 750; }

@media (max-width: 370px) {
  .form-row { grid-template-columns: 1fr; }
  .header-count { display: none; }
}

@media (min-width: 700px) {
  body { background: linear-gradient(135deg, #edf5f2, #f8fbfa 45%, #eef5f8); }
  .app-shell { margin-top: 26px; margin-bottom: 26px; min-height: calc(100svh - 52px); border: 1px solid rgba(214,228,222,.8); border-radius: 28px; background: var(--bg); box-shadow: var(--shadow); }
  .bottom-nav { bottom: 26px; border: 1px solid rgba(213,226,220,.85); border-radius: 0 0 28px 28px; }
}
