:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-soft: #f0eee8;
  --text: #24231f;
  --muted: #77746d;
  --line: #e7e3da;
  --accent: #778b7a;
  --accent-dark: #5f7162;
  --star: #b99655;
  --danger: #a95f59;
  --radius: 22px;
  --shadow: 0 16px 50px rgba(56, 52, 43, .08);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: "DM Sans", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; padding-bottom: 90px; }
.topbar { height: 74px; padding: 0 5vw; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20; background: rgba(247,245,240,.88); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(231,227,218,.7); }
.brand { display: flex; align-items: center; gap: 12px; border: 0; background: transparent; color: inherit; text-align: left; }
.brand-mark { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: white; font-family: "Playfair Display", serif; font-size: 20px; }
.brand strong { display: block; font-size: 15px; }
.brand small { color: var(--muted); }
.top-actions { display: flex; gap: 10px; align-items: center; }
.icon-btn { border: 0; background: var(--surface); width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 23px; box-shadow: 0 4px 18px rgba(0,0,0,.05); color: var(--text); }
.profile-pill { border: 0; background: var(--surface); padding: 6px 12px 6px 6px; border-radius: 999px; display: flex; align-items: center; gap: 8px; }
.profile-pill span:first-child { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: white; font-weight: 700; }
main { width: min(1400px, 92vw); margin: 0 auto; }
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } }
.hero { padding: 72px 0 42px; max-width: 760px; }
.eyebrow { margin: 0 0 8px; color: var(--accent-dark); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-family: "Playfair Display", serif; font-size: clamp(42px, 6vw, 78px); line-height: .98; margin-bottom: 18px; font-weight: 600; }
.hero > p:last-child { font-size: 18px; color: var(--muted); max-width: 650px; }
.search-wrap { margin-bottom: 22px; }
.search-wrap input, .filter-panel input, .filter-panel select, .ranking-controls select, label input, label select, label textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 14px 15px; color: var(--text); outline: none; }
.search-wrap input:focus, input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(119,139,122,.12); }
.chips { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--muted); border-radius: 999px; padding: 10px 16px; white-space: nowrap; }
.chip.active { background: var(--text); color: white; border-color: var(--text); }
.section-block { padding: 38px 0 64px; }
.section-heading, .split-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 24px; }
.section-heading h2 { font-size: 28px; margin: 0; }
.text-btn { border: 0; background: transparent; color: var(--accent-dark); font-weight: 700; padding: 8px 0; }
.places-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 28px 20px; }
.place-card { border: 0; background: transparent; padding: 0; text-align: left; color: inherit; min-width: 0; }
.card-image { aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface-soft); position: relative; }
.card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.place-card:hover img { transform: scale(1.03); }
.card-placeholder { height: 100%; display: grid; place-items: center; font-size: 40px; color: var(--muted); }
.card-badge { position: absolute; top: 12px; left: 12px; padding: 7px 10px; border-radius: 999px; background: rgba(255,255,255,.9); backdrop-filter: blur(12px); font-size: 12px; font-weight: 700; }
.card-info { padding: 12px 2px 0; }
.card-title-row { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.card-title-row h3 { margin: 0; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-score { white-space: nowrap; font-weight: 700; }
.card-meta { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.empty-state { text-align: center; padding: 70px 20px; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-icon { font-size: 44px; color: var(--accent); }
.primary-btn, .secondary-btn { border-radius: 999px; padding: 12px 20px; font-weight: 700; border: 0; }
.primary-btn { background: var(--text); color: white; }
.secondary-btn { background: var(--surface-soft); color: var(--text); }
.page-heading { padding: 64px 0 30px; }
.page-heading h1 { font-size: clamp(40px, 5vw, 64px); }
.filter-panel { display: grid; grid-template-columns: 2fr repeat(4, 1fr) auto; gap: 10px; margin-bottom: 28px; }
.ranking-controls { display: flex; gap: 10px; min-width: min(100%, 400px); }
.ranking-list { display: grid; gap: 10px; padding-bottom: 60px; }
.ranking-item { display: grid; grid-template-columns: 44px 76px 1fr auto; align-items: center; gap: 16px; background: var(--surface); border-radius: 18px; padding: 10px 18px 10px 10px; border: 1px solid var(--line); }
.rank-number { text-align: center; font-size: 20px; font-weight: 700; }
.rank-image { width: 76px; height: 66px; object-fit: cover; border-radius: 13px; background: var(--surface-soft); }
.rank-title { font-weight: 700; margin-bottom: 3px; }
.rank-meta { color: var(--muted); font-size: 13px; }
.rank-score { font-weight: 700; font-size: 18px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.stat-card strong { display: block; font-size: 31px; margin-bottom: 4px; }
.stat-card span { color: var(--muted); }
.recent-list { display: grid; gap: 10px; }
.recent-item { display: flex; gap: 14px; align-items: center; padding: 10px; background: var(--surface); border-radius: 16px; border: 1px solid var(--line); }
.recent-item img { width: 64px; height: 56px; border-radius: 12px; object-fit: cover; background: var(--surface-soft); }
.recent-item strong { display: block; }
.recent-item small { color: var(--muted); }
.floating-add { position: fixed; right: 5vw; bottom: 94px; z-index: 30; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--text); color: white; font-size: 31px; box-shadow: var(--shadow); }
.bottom-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 15px; z-index: 30; width: min(520px, calc(100vw - 24px)); background: rgba(255,255,255,.93); backdrop-filter: blur(20px); display: grid; grid-template-columns: repeat(4,1fr); border: 1px solid rgba(231,227,218,.9); border-radius: 22px; padding: 8px; box-shadow: var(--shadow); }
.bottom-nav button { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; border-radius: 16px; padding: 7px; }
.bottom-nav button.active { color: var(--text); background: var(--surface-soft); }
.bottom-nav span { font-size: 20px; }
.bottom-nav small { font-size: 11px; }
.modal { border: 0; padding: 0; background: transparent; width: min(760px, calc(100vw - 24px)); max-height: 92vh; }
.modal::backdrop { background: rgba(33,31,27,.42); backdrop-filter: blur(5px); }
.modal-card, .detail-card { background: var(--bg); border-radius: 28px; max-height: 92vh; overflow: auto; box-shadow: var(--shadow); }
.modal-card { padding: 28px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h2 { margin: 0; font-size: 30px; }
.stepper { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; margin: 16px 0 28px; }
.stepper span { height: 4px; border-radius: 999px; background: var(--line); }
.stepper span.active { background: var(--accent); }
.form-step { display: none; gap: 16px; }
.form-step.active { display: grid; }
label { display: grid; gap: 8px; font-size: 13px; font-weight: 700; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-zone { border: 1px dashed #cbc5b9; border-radius: var(--radius); text-align: center; padding: 42px 20px; background: rgba(255,255,255,.45); }
.upload-zone.dragover { border-color: var(--accent); background: rgba(119,139,122,.08); }
.upload-icon { font-size: 38px; color: var(--accent); }
.upload-zone p { color: var(--muted); }
.photo-preview { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.preview-item { position: relative; aspect-ratio: 1; border-radius: 16px; overflow: hidden; }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item button { position: absolute; top: 7px; right: 7px; border: 0; width: 28px; height: 28px; border-radius: 50%; background: rgba(255,255,255,.9); }
.rating-person-toggle, .segmented { display: grid; grid-template-columns: repeat(2,1fr); padding: 4px; border-radius: 999px; background: var(--surface-soft); }
.rating-person-toggle button, .segmented button { border: 0; background: transparent; padding: 10px; border-radius: 999px; }
.rating-person-toggle button.active, .segmented button.active { background: var(--surface); box-shadow: 0 2px 10px rgba(0,0,0,.05); }
.segmented { grid-template-columns: repeat(3,1fr); }
.criteria-list { display: grid; gap: 12px; }
.criterion-card { background: var(--surface); border: 1px solid var(--line); border-radius: 17px; padding: 15px; }
.criterion-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.criterion-head strong { font-size: 15px; }
.stars { display: flex; gap: 3px; }
.star { border: 0; background: transparent; padding: 2px; color: #d7d2c8; font-size: 25px; line-height: 1; }
.star.selected { color: var(--star); }
.criterion-note-toggle { border: 0; background: transparent; color: var(--accent-dark); padding: 8px 0 0; font-size: 12px; }
.criterion-note { margin-top: 9px; width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 10px; display: none; }
.criterion-note.visible { display: block; }
.price-picker { display: flex; gap: 8px; }
.price-picker button { flex: 1; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 13px 5px; }
.price-picker button.active { background: var(--text); color: white; border-color: var(--text); }
.form-footer { display: flex; align-items: center; gap: 12px; margin-top: 28px; }
.spacer { flex: 1; }
.detail-card { position: relative; }
.detail-close { position: absolute; right: 16px; top: 16px; z-index: 2; }
.detail-gallery { display: grid; grid-template-columns: 2fr 1fr; gap: 6px; background: var(--surface-soft); }
.detail-gallery img { width: 100%; height: 100%; object-fit: cover; min-height: 260px; max-height: 430px; }
.detail-gallery img:first-child { grid-row: span 2; }
.detail-gallery.single { grid-template-columns: 1fr; }
.detail-gallery.single img { min-height: 420px; }
.detail-body { padding: 28px; }
.detail-kicker { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 13px; }
.detail-title-row { display: flex; justify-content: space-between; align-items: start; gap: 18px; margin: 10px 0 20px; }
.detail-title-row h2 { font-family: "Playfair Display", serif; font-size: 38px; margin: 0; }
.big-score { font-size: 28px; font-weight: 700; white-space: nowrap; }
.detail-summary { display: flex; gap: 12px; flex-wrap: wrap; padding: 13px 0 22px; border-bottom: 1px solid var(--line); }
.summary-pill { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; font-size: 13px; }
.person-scores { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 22px 0; }
.person-score { background: var(--surface); border-radius: 16px; padding: 16px; border: 1px solid var(--line); }
.person-score strong { display: block; font-size: 21px; }
.detail-criteria { display: grid; gap: 8px; }
.detail-criterion { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.detail-criterion summary { list-style: none; display: flex; justify-content: space-between; padding: 15px; cursor: pointer; }
.detail-criterion summary::-webkit-details-marker { display: none; }
.detail-criterion-content { border-top: 1px solid var(--line); padding: 14px 15px; display: grid; gap: 10px; color: var(--muted); }
.detail-comment { margin-top: 24px; line-height: 1.65; color: #504e48; }
.detail-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.danger-btn { border: 0; border-radius: 999px; padding: 12px 18px; color: var(--danger); background: #f5e9e7; font-weight: 700; }
.toast { position: fixed; left: 50%; bottom: 105px; transform: translate(-50%, 20px); background: var(--text); color: white; border-radius: 999px; padding: 12px 18px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%,0); }
.hidden { display: none !important; }
@media (max-width: 980px) {
  .places-grid { grid-template-columns: repeat(2,1fr); }
  .filter-panel { grid-template-columns: repeat(2,1fr); }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  .topbar { padding: 0 16px; height: 66px; }
  .profile-pill span:last-child { display: none; }
  main { width: calc(100% - 28px); }
  .hero { padding: 42px 0 26px; }
  h1 { font-size: 44px; }
  .places-grid { grid-template-columns: 1fr 1fr; gap: 22px 10px; }
  .card-image { border-radius: 16px; aspect-ratio: 1 / 1.05; }
  .card-badge { display: none; }
  .card-title-row { display: block; }
  .card-score { display: inline-block; margin-top: 5px; font-size: 13px; }
  .card-meta { font-size: 12px; }
  .section-heading { align-items: center; }
  .section-heading h2 { font-size: 23px; }
  .page-heading { padding-top: 40px; }
  .split-heading { display: block; }
  .ranking-controls { margin-top: 18px; width: 100%; }
  .filter-panel { grid-template-columns: 1fr 1fr; }
  .filter-panel input { grid-column: 1 / -1; }
  .ranking-item { grid-template-columns: 34px 58px 1fr auto; gap: 10px; padding-right: 12px; }
  .rank-image { width: 58px; height: 54px; }
  .rank-title { font-size: 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: 16px; }
  .modal { width: 100vw; max-height: 96vh; margin: auto 0 0; }
  .modal-card, .detail-card { border-radius: 26px 26px 0 0; max-height: 94vh; }
  .modal-card { padding: 22px 16px; }
  .two-col { grid-template-columns: 1fr; }
  .criterion-head { display: block; }
  .stars { margin-top: 8px; }
  .photo-preview { grid-template-columns: repeat(3,1fr); }
  .detail-gallery, .detail-gallery.single { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; }
  .detail-gallery img, .detail-gallery.single img { width: 100%; min-width: 100%; height: 330px; min-height: 330px; scroll-snap-align: start; }
  .detail-body { padding: 22px 16px 30px; }
  .detail-title-row h2 { font-size: 30px; }
  .person-scores { grid-template-columns: 1fr 1fr; }
  .person-scores .person-score:first-child { grid-column: 1 / -1; }
}


/* Authentication and account */
.auth-view{min-height:100vh;display:grid;place-items:center;padding:24px;background:#f7f5f0}
.auth-card{width:min(100%,420px);background:#fff;border:1px solid #ebe8e1;border-radius:28px;padding:36px;box-shadow:0 18px 60px rgba(41,38,32,.08);text-align:center}
.auth-mark{margin:0 auto 18px}.auth-card h1{margin:.25rem 0 .5rem;font-family:"Playfair Display",serif;font-size:2.2rem}.auth-copy{color:#777268;margin:0 auto 28px;max-width:320px;line-height:1.55}
.auth-form{display:grid;gap:14px;text-align:left}.auth-form .primary-btn{width:100%;margin-top:8px}.auth-error{min-height:20px;color:#b34b45;text-align:center;margin:0;font-size:.9rem}
.loading-overlay{position:fixed;inset:0;z-index:9999;background:rgba(247,245,240,.86);backdrop-filter:blur(6px);display:grid;place-content:center;gap:12px;text-align:center;color:#4a473f}.loader{width:34px;height:34px;border:3px solid #ddd8cf;border-top-color:#7f9278;border-radius:50%;animation:spin .8s linear infinite;margin:auto}@keyframes spin{to{transform:rotate(360deg)}}
.account-wrap{position:relative}.account-menu{position:absolute;right:0;top:calc(100% + 10px);min-width:150px;background:#fff;border:1px solid #e8e4dc;border-radius:14px;box-shadow:0 12px 32px rgba(41,38,32,.12);padding:6px;z-index:50}.account-menu button{width:100%;border:0;background:transparent;padding:11px 12px;text-align:left;border-radius:10px;cursor:pointer}.account-menu button:hover{background:#f4f1eb}
.rating-person-toggle button:disabled{opacity:.55;cursor:not-allowed}.hidden{display:none!important}

/* iPhone-first UX fixes */
html {
  width: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  width: 100%;
  overflow-x: hidden;
  min-height: 100dvh;
}
input, select, textarea { font-size: 16px; }
.form-field { display: grid; gap: 8px; }
.field-label { font-size: 13px; font-weight: 700; }
.price-picker button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
.ranking-item > span:nth-child(3) {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.rank-title, .rank-meta { display: block; max-width: 100%; }
.rank-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button:disabled { cursor: not-allowed; }
#savePlace:disabled { opacity: .65; pointer-events: none; }

@media (max-width: 640px) {
  .auth-view {
    min-height: 100dvh;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  }
  .auth-card { width: 100%; max-width: 380px; padding: 26px 20px; border-radius: 22px; }
  .auth-mark { margin-bottom: 12px; }
  .auth-card h1 { font-size: 1.9rem; }
  .auth-copy { margin-bottom: 20px; font-size: 14px; }
  .auth-form { gap: 12px; }
  .auth-form label input { min-height: 50px; }

  .hero { padding: 30px 0 22px; }
  .hero h1 { max-width: 330px; font-size: clamp(36px, 10vw, 42px); line-height: 1.02; }
  .hero > p:last-child { font-size: 15px; line-height: 1.5; }

  .modal {
    width: calc(100vw - 8px);
    max-width: none;
    max-height: calc(100dvh - 8px);
    margin: auto 4px 0;
    overflow: hidden;
  }
  .place-modal .modal-card {
    height: min(760px, calc(100dvh - 8px));
    max-height: calc(100dvh - 8px);
    padding: 16px 14px max(12px, env(safe-area-inset-bottom));
    border-radius: 22px 22px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .modal-header { flex: 0 0 auto; margin-bottom: 8px; }
  .modal-header h2 { font-size: 24px; }
  .modal-header .eyebrow { margin-bottom: 4px; }
  .stepper { flex: 0 0 auto; margin: 8px 0 14px; }
  .form-step.active {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: start;
    gap: 12px;
    padding: 2px 1px 12px;
    -webkit-overflow-scrolling: touch;
  }
  .form-footer {
    flex: 0 0 auto;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    background: var(--bg);
  }
  .form-footer .primary-btn, .form-footer .text-btn { min-height: 46px; }
  .two-col { gap: 12px; }
  .upload-zone { padding: 24px 14px; }
  .upload-zone h3 { margin-bottom: 6px; }
  .upload-zone p { margin-bottom: 16px; font-size: 13px; }
  .criterion-card { padding: 12px; }
  .criterion-head { display: flex; align-items: center; }
  .stars { flex: 0 0 auto; margin-top: 0; gap: 0; }
  .star { min-width: 34px; min-height: 38px; padding: 3px; font-size: 24px; }
  .rating-person-toggle {
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.5fr);
    border-radius: 16px;
  }
  .rating-person-toggle button {
    min-width: 0;
    padding: 9px 7px;
    font-size: 12px;
    line-height: 1.2;
  }
  .price-picker {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }
  .price-picker button {
    min-width: 0;
    overflow: hidden;
    padding: 12px 1px;
    font-size: 12px;
  }
  .ranking-item {
    grid-template-columns: 28px 52px minmax(0, 1fr) auto;
    gap: 9px;
    padding: 9px 10px 9px 7px;
  }
  .rank-number { font-size: 16px; }
  .rank-image { width: 52px; height: 50px; }
  .rank-title { margin-bottom: 2px; font-size: 14px; }
  .rank-meta { font-size: 12px; line-height: 1.25; }
  .rank-score { font-size: 15px; }
}


/* Native price selector: reliable on iPhone Safari */
.price-field {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.price-field .field-label {
  display: block;
  margin-bottom: 8px;
}

.price-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.price-option {
  display: block;
  min-width: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.price-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.price-option span {
  min-height: 48px;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 10px 2px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  user-select: none;
  -webkit-user-select: none;
}

.price-option input:checked + span {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.price-option input:focus-visible + span {
  outline: 3px solid rgba(119,139,122,.22);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .price-picker {
    gap: 5px;
  }

  .price-option span {
    min-height: 50px;
    padding: 10px 1px;
    font-size: 12px;
  }
}
