:root {
  --bg: #FFFFFF;
  --surface: #FAFAFA;
  --border: #EEEDE8;
  --border-strong: #D3D1C7;
  --text: #2C2C2A;
  --text-muted: #5F5E5A;
  --text-hint: #888780;
  --primary: #378ADD;
  --primary-soft: #E6F1FB;
  --primary-dark: #185FA5;
  --like: #F09595;
  --like-stroke: #E24B4A;
  --star: #EF9F27;
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.auth-page {
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 20px;
}

h1 {
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 20px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}

input:focus {
  outline: 2px solid var(--primary-soft);
  border-color: var(--primary);
}

button {
  font: inherit;
  font-weight: 500;
  padding: 12px 16px;
  background: var(--primary);
  color: #fff;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 6px;
}

button:hover { background: var(--primary-dark); }

p { font-size: 14px; color: var(--text-muted); }
a { color: var(--primary-dark); }

.errors {
  list-style: none;
  padding: 12px 14px;
  margin: 0 0 16px;
  background: #FDECEC;
  border: 1px solid var(--like);
  border-radius: var(--radius);
  color: var(--like-stroke);
  font-size: 13px;
}

.errors li + li { margin-top: 4px; }

.ob { max-width: 560px; margin: 0 auto; padding: 20px 16px 64px; }

.ob-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
.ob-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 500; }
.ob-sub { margin: 0; font-size: 13px; color: var(--text-muted); }

.ob-skip { margin: 0; }
.ob-skip-btn {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  margin: 0;
  font-size: 13px;
}
.ob-skip-btn:hover { background: var(--surface); color: var(--text); }

.ob-form { display: flex; flex-direction: column; gap: 22px; }

.ob-section h2 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}

.ob-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.ob-card {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.ob-card input { position: absolute; opacity: 0; pointer-events: none; }
.ob-card:has(input:checked) {
  background: #E6F1FB;
  border-color: #378ADD;
  color: #0C447C;
  font-weight: 500;
}

.ob-custom {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.ob-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ob-chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.ob-chip input { position: absolute; opacity: 0; pointer-events: none; }
.ob-chip:has(input:checked) {
  background: #E6F1FB;
  border-color: #378ADD;
  color: #0C447C;
  font-weight: 500;
}

.ob-radius select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  width: 100%;
}

.ob-save { margin-top: 8px; }

/* ========== App shell ========== */
body.app { background: var(--bg); }

.app-main {
  padding-bottom: 80px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 0.5px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.hdr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 0;
  cursor: pointer;
}
.hdr-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.hdr-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--primary);
}
.hdr-name { font-size: 17px; font-weight: 500; }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}
.drawer-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 78vw;
  max-width: 300px;
  background: #fff;
  padding: 20px 16px;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
}
.drawer-close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  font-size: 26px;
  padding: 4px 10px;
  cursor: pointer;
}
.drawer-list { list-style: none; margin: 28px 0 0; padding: 0; }
.drawer-list li + li { margin-top: 2px; }
.drawer-list a,
.drawer-logout {
  display: block;
  padding: 12px 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 15px;
}
.drawer-list a:hover { background: var(--surface); }
.drawer-logout {
  background: transparent;
  border: 0;
  text-align: left;
  width: 100%;
  color: var(--like-stroke);
  font: inherit;
  cursor: pointer;
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #fff;
  border-top: 0.5px solid var(--border);
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 40;
}
.bn-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 2px 0;
}
.bn-item svg { color: var(--text-muted); }
.bn-item.is-active,
.bn-item.is-active svg { color: var(--primary-dark); }
.bn-item.is-active { font-weight: 500; }

/* ========== Discover ========== */
.location-pill-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 0.5px solid var(--border);
}
.location-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 500;
}
.location-radius {
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.stories-wrap {
  padding: 12px 0 10px;
  overflow-x: auto;
  border-bottom: 0.5px solid var(--border);
  -webkit-overflow-scrolling: touch;
}
.stories {
  display: inline-flex;
  gap: 14px;
  padding: 0 12px;
  min-width: min-content;
}
.story {
  flex-shrink: 0;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  max-width: 76px;
  text-decoration: none;
  color: var(--text);
}
.story-ring {
  display: inline-block;
  width: 66px;
  height: 66px;
  border-radius: 50%;
  padding: 2px;
  background: var(--primary);
}
.story-ring img,
.story-fallback {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: #EAE6DC;
  border: 2px solid #fff;
  box-sizing: border-box;
}
.story-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 500;
  color: var(--text-muted);
}
.story-name {
  font-size: 10px;
  font-weight: 500;
  line-height: 1.1;
  text-align: center;
  max-width: 70px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.story-dist { font-size: 9px; color: var(--text-hint); }

.feed {
  padding: 14px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.feed-state {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.card {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.card-photo {
  display: block;
  position: relative;
  aspect-ratio: 4 / 5;
  background: #EAE6DC;
  color: var(--text);
  text-decoration: none;
}
.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-photo-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  font-weight: 500;
  color: var(--text-muted);
}
.card-dist {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 500;
}
.card-menu {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  border: 0;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.card-menu span { font-size: 14px; line-height: 1; }
.card-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 44px 14px 14px;
  color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
}
.card-name { font-size: 18px; font-weight: 500; margin-bottom: 2px; }
.card-meta { font-size: 12px; opacity: 0.9; }
.card-tap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  background: #fff;
  color: var(--primary-dark);
  font-size: 11px;
  padding: 6px 11px;
  border-radius: 999px;
  font-weight: 500;
}

.tooltip {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 40%;
  z-index: 45;
}
.tooltip-body {
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.4;
}
.tooltip-body button {
  background: #fff;
  color: var(--text);
  margin-top: 10px;
  padding: 8px 14px;
  font-size: 12px;
}

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
}
.sheet-panel {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sheet-title {
  font-size: 14px;
  color: var(--text-muted);
  padding: 8px 10px 12px;
  border-bottom: 0.5px solid var(--border);
  margin-bottom: 6px;
}
.sheet-action {
  display: block;
  padding: 14px 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 15px;
}
.sheet-action:hover { background: var(--surface); }
.sheet-cancel {
  background: transparent;
  color: var(--text-muted);
  margin-top: 6px;
  padding: 14px 10px;
  border-radius: var(--radius);
  font-weight: 500;
}

/* ========== Restaurant detail ========== */
.detail { padding-bottom: 20px; }
.detail-back { padding: 10px 14px 0; }
.back-link {
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
}

.hero-carousel {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  background: #EAE6DC;
  margin-top: 10px;
}
.hero-slide {
  flex: 0 0 100%;
  aspect-ratio: 4 / 3;
  scroll-snap-align: start;
  background: #EAE6DC;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-hint);
}
.hero-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hero-empty .hero-slide span { font-size: 14px; }

.detail-head {
  padding: 16px 16px 8px;
}
.detail-head h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; }
.detail-meta { margin: 0; font-size: 13px; color: var(--text-muted); }
.detail-meta .muted { color: var(--text-hint); font-weight: 400; }
.detail-hours {
  margin: 10px 0 2px;
  font-size: 13px;
  color: var(--text-muted);
}
.detail-hours .open { color: #1F7A3A; font-weight: 500; }
.detail-hours .closed { color: var(--like-stroke); font-weight: 500; }
.hours-toggle {
  background: transparent;
  color: var(--primary-dark);
  border: 0;
  padding: 0 0 0 6px;
  font-size: 13px;
  cursor: pointer;
  margin: 0;
}
.hours-list {
  list-style: none;
  padding: 8px 10px;
  margin: 6px 0 0;
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-muted);
}
.hours-list li { padding: 2px 0; }
.detail-address { margin: 8px 0 0; font-size: 13px; color: var(--text-muted); }

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 16px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 10px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
}
.action-btn.primary {
  background: var(--primary);
  color: #fff;
}
.action-btn.outline {
  border-color: var(--border-strong);
  color: var(--text);
  background: #fff;
}

.add-dish, .prior-dishes { padding: 0 16px; margin-top: 22px; }
.add-dish h2, .prior-dishes h2 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}
.dish-form { display: flex; flex-direction: column; gap: 12px; }
.dish-form textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  resize: vertical;
  min-height: 70px;
}
.inline-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.inline-check input { width: auto; }

/* ========== Dishes list ========== */
.dishes { padding: 16px 16px 30px; }
.dishes-head h1 { font-size: 22px; font-weight: 500; margin: 0 0 12px; }
.dish-filter {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  margin-bottom: 16px;
}
.dish-filter input[type="search"],
.dish-filter select {
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}
.dish-filter button { margin: 0; padding: 9px 14px; }

.empty-state {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
}
.empty-state .muted { color: var(--text-hint); font-size: 13px; }

.dish-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.dish-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  padding: 10px;
  background: var(--surface);
  border-radius: var(--radius);
  align-items: flex-start;
}
.dish-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  object-fit: cover;
}
.dish-body { min-width: 0; }
.dish-name { font-size: 15px; font-weight: 500; display: flex; gap: 6px; align-items: center; }
.dish-rest { font-size: 12px; color: var(--primary-dark); }
.dish-rest a { color: inherit; text-decoration: none; }
.dish-notes { font-size: 13px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.dish-date { font-size: 11px; color: var(--text-hint); margin-top: 4px; }
.heart { color: var(--like-stroke); }
.dish-del {
  background: transparent;
  color: var(--text-hint);
  border: 0;
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}
.dish-del:hover { color: var(--like-stroke); background: transparent; }

/* ========== Profile ========== */
.profile { padding: 20px 16px 30px; max-width: 560px; margin: 0 auto; }
.profile-head h1 { margin: 0 0 2px; font-size: 22px; font-weight: 500; }
.profile .muted { color: var(--text-muted); font-size: 13px; margin: 0; }

.profile-section { margin-top: 22px; }
.profile-section h2 {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 10px;
}
.sub-section { margin-bottom: 18px; }
.sub-section h3 {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.inline-form select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: #fff;
}
.inline-form button { margin: 0; padding: 10px 16px; }

.save-btn { margin-top: 6px; }

.profile-links {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}
.profile-links li { padding: 0; }
.profile-links a {
  display: block;
  padding: 12px 10px;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 15px;
  background: var(--surface);
  margin-bottom: 6px;
}

.logout-form { margin-top: 12px; }
.logout-btn {
  background: transparent;
  color: var(--like-stroke);
  border: 1px solid var(--border-strong);
  width: 100%;
  margin: 0;
}
.logout-btn:hover { background: #FDECEC; }

.toast {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border: 1px solid var(--primary);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 10px;
}
