/* Responsive finish. Shared controls retain one DOM and one behavior at every width. */
.filter-disclosure {
  border: 0;
  margin: 0;
}
.filter-disclosure > summary {
  list-style: none;
  cursor: pointer;
}
.filter-disclosure > summary::-webkit-details-marker {
  display: none;
}
.filter-fields .selection-filters {
  padding: 10px 0 0;
  margin: 0;
}
.filter-disclosure > summary {
  display: none;
}
.map-loading {
  padding: 28px;
  font-size: 16px;
  color: var(--muted);
}
#collections-page {
  height: calc(100dvh - var(--shell-height, 120px));
  overflow-y: auto;
  overscroll-behavior: contain;
}
#atlas.private-landing {
  grid-template-columns: minmax(0, 1fr);
}
.private-landing .map-panel {
  display: none;
}
.private-landing .journal-panel {
  width: 100%;
  max-width: 600px;
  margin-inline: auto;
}
button,
input,
select,
textarea,
summary {
  scroll-margin-block: 90px;
}
input,
select,
textarea {
  max-width: 100%;
}
img {
  max-width: 100%;
}
button,
label,
.detail-address,
.private-note {
  overflow-wrap: anywhere;
}
.filter-fields select {
  width: 100%;
  min-width: 0;
}
.filter-fields .filters {
  margin-bottom: 0;
}
.album-filters {
  grid-template-columns: minmax(0, 1fr);
}
.album-filters > label:first-child {
  max-width: 540px;
}
.album-filter-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}
.album-filter-fields label {
  min-width: 0;
}
.journal-panel,
#album-page,
#collections-page,
dialog {
  scrollbar-width: thin;
}
@media (min-width: 761px) {
  .masthead .nav-link,
  .masthead #account-nav button,
  .membership-link {
    font-size: 14px;
  }
  .language-picker select {
    font-size: 14px;
  }
  .masthead .nav-link,
  .header-tools button {
    min-height: 44px;
  }
  .masthead #account-nav .account-identity {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    max-width: 220px;
  }
  .masthead #account-nav .account-identity small {
    position: static;
    margin: 0;
    font-size: 11px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .filter-disclosure > .filter-fields {
    display: block;
  }
}

@media (max-width: 760px), (max-width: 960px) and (max-height: 500px) {
  :root {
    --space: 20px;
  }
  body {
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
  }
  [hidden] {
    display: none !important;
  }
  .masthead,
  .masthead:has(nav button[hidden]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    min-height: 76px;
    padding: calc(10px + env(safe-area-inset-top))
      max(20px, env(safe-area-inset-right)) 10px
      max(20px, env(safe-area-inset-left));
    gap: 16px;
    border-bottom: 1px solid var(--line);
  }
  .masthead .wordmark {
    font-size: 36px;
    line-height: 1;
    padding: 2px 0;
  }
  .wordmark .brand-underline {
    width: 82px;
    height: 13px;
    margin: 3px auto 0;
  }
  .wordmark > span {
    display: none;
  }
  #journal-list-view {
    padding-bottom: calc(100px + env(safe-area-inset-bottom));
  }
  #account-banner {
    font-size: 14px;
    padding: 10px 20px;
  }
  .journal-intro {
    padding: 24px var(--space) 0;
  }
  .journal-intro h1 {
    font-size: clamp(36px, 10vw, 44px);
    line-height: 1.06;
    letter-spacing: -0.025em;
    margin: 10px 0 12px;
  }
  .journal-intro > p {
    font-size: 15px;
    line-height: 1.6;
    margin: 10px 0 18px;
  }
  .eyebrow,
  #collection-label {
    font-size: 11px;
    line-height: 1.6;
    letter-spacing: 0.12em;
  }
  .stats {
    margin: 12px 0;
    padding: 14px 0;
    gap: 12px;
  }
  .stats strong {
    font-size: 30px;
    line-height: 1.1;
  }
  .stats span {
    font-size: 11px;
    line-height: 1.5;
    letter-spacing: 0;
    margin-top: 6px;
  }
  .stats > div + div {
    padding-left: 12px;
  }
  .collection-actions {
    gap: 8px;
    margin: 14px 0 18px;
  }
  .collection-actions:empty,
  .stats:empty {
    display: none;
  }
  .collection-actions button {
    font-size: 14px;
    min-height: 46px;
    padding: 10px 14px;
  }
  .collection-picker {
    margin: 0;
    padding: 0 var(--space) 18px;
  }
  .collection-picker > label {
    font-size: 13px;
    margin-bottom: 7px;
  }
  .collection-picker > div {
    gap: 8px;
  }
  .collection-picker select {
    font-size: 16px;
    min-height: 46px;
  }
  .collection-picker button {
    min-width: 46px;
    min-height: 46px;
    font-size: 14px;
  }
  .search-tools {
    padding: 0 var(--space);
  }
  .search-wrap {
    margin: 0;
  }
  .search-wrap input {
    font-size: 16px;
    min-height: 48px;
    padding-block: 12px;
  }
  .filter-disclosure {
    margin-top: 10px;
    border-bottom: 1px solid var(--line);
  }
  .filter-disclosure > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    padding: 10px 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--wine);
  }
  .filter-disclosure > summary::after {
    content: "+";
    margin-left: auto;
    font-size: 22px;
    font-weight: 400;
  }
  .filter-disclosure[open] > summary::after {
    content: "−";
  }
  #filter-count:not(:empty) {
    background: var(--wine);
    color: var(--paper);
    border-radius: 50%;
    min-width: 22px;
    padding: 0 6px;
    text-align: center;
    font-size: 12px;
  }
  #album-filter-count:not(:empty) {
    font-size: 13px;
    min-width: 22px;
    border-radius: 50%;
    padding: 0 6px;
    text-align: center;
    color: var(--paper);
    background: var(--wine);
  }
  .filter-disclosure:not([open]) > .filter-fields {
    display: none;
  }
  .filter-fields {
    padding-bottom: 16px;
  }
  .filter-fields .filters,
  .filter-fields .selection-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 0;
  }
  .filter-fields .selection-filters {
    padding-top: 10px;
  }
  .filter-fields select {
    font-size: 16px;
    min-height: 46px;
  }
  .list-heading {
    font-size: 11px;
    letter-spacing: 0.08em;
    padding: 22px var(--space) 10px;
    gap: 16px;
  }
  #restaurant-list {
    padding: 0 var(--space);
  }
  .restaurant-card {
    padding: 22px 0;
  }
  .restaurant-card .card-top {
    gap: 14px;
    align-items: start;
  }
  .restaurant-card h3 {
    font-size: 29px;
    line-height: 1.12;
    letter-spacing: -0.015em;
    margin-bottom: 9px;
    overflow-wrap: anywhere;
  }
  .restaurant-card .address,
  .restaurant-card .card-address,
  .restaurant-card .card-place {
    font-size: 14px;
    line-height: 1.55;
  }
  .restaurant-card .tags,
  .restaurant-card .tags span,
  .restaurant-card .card-tags,
  .card-bottom,
  .card-meta {
    font-size: 13px;
    line-height: 1.55;
  }
  .restaurant-card .card-bottom {
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
  }
  .restaurant-card .restaurant-cover {
    height: auto;
    aspect-ratio: 16/10;
    margin-bottom: 16px;
  }
  .score-seal {
    width: 64px;
    min-width: 64px;
    height: 77px;
  }
  .score-seal strong {
    font-size: 30px;
  }
  .score-seal small {
    font-size: 8px;
    letter-spacing: 0.04em;
  }
  .empty {
    padding: 30px 0;
  }
  .empty h3 {
    font-size: 30px;
  }
  .empty p {
    font-size: 16px;
    line-height: 1.6;
  }
  #load-more {
    margin: 20px;
    width: calc(100% - 40px);
  }

  /* Long restaurant names and dense visits remain readable without sideways scrolling. */
  .restaurant-toolbar {
    padding: 6px var(--space);
    gap: 12px;
  }
  .restaurant-toolbar button {
    font-size: 14px;
    min-height: 48px;
    padding: 8px 0;
  }
  .restaurant-sheet .detail-header {
    padding: 24px var(--space);
  }
  .restaurant-name {
    font-size: clamp(33px, 9vw, 40px);
    line-height: 1.08;
    letter-spacing: -0.025em;
  }
  .restaurant-sheet .detail-title-row {
    gap: 14px;
  }
  .restaurant-sheet .detail-header .score-seal {
    width: 68px;
    min-width: 68px;
    height: 82px;
  }
  .detail-address {
    font-size: 16px;
    line-height: 1.6;
    margin: 16px 0;
  }
  .detail-tags {
    gap: 7px;
  }
  .detail-tags > span {
    font-size: 13px;
    padding: 5px 9px;
    line-height: 1.4;
  }
  .detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 22px;
  }
  .detail-actions button {
    font-size: 14px;
    min-height: 46px;
    padding: 10px 13px;
    flex: 1 1 auto;
  }
  .restaurant-sheet .detail-content {
    padding: 0 var(--space) calc(100px + env(safe-area-inset-bottom));
  }
  .restaurant-sheet .section-heading {
    gap: 14px;
    align-items: end;
  }
  .restaurant-sheet .section-heading span {
    font-size: 11px;
    line-height: 1.6;
  }
  .restaurant-sheet .section-heading h2 {
    font-size: 30px;
    line-height: 1.1;
  }
  .restaurant-sheet .section-heading small {
    font-size: 13px;
  }
  .restaurant-sheet .aspect-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .restaurant-sheet .aspect-grid strong {
    font-size: 31px;
  }
  .restaurant-sheet .aspect-grid span {
    font-size: 13px;
    line-height: 1.4;
  }
  .restaurant-sheet .aspect-grid small {
    font-size: 12px;
  }
  .restaurant-sheet .laurel-grid {
    gap: 10px;
    grid-template-columns: 1fr;
  }
  .restaurant-sheet .laurel-item summary {
    font-size: 13px;
    max-width: none;
    min-height: 44px;
    line-height: 1.4;
  }
  .laurel-item p {
    font-size: 14px;
    line-height: 1.6;
  }
  .restaurant-sheet .visit-summary {
    gap: 12px;
    padding: 16px;
  }
  .restaurant-sheet .visit-summary h3 {
    font-size: 25px;
    line-height: 1.2;
  }
  .visit-summary p,
  .restaurant-sheet .visit-score small {
    font-size: 13px;
    line-height: 1.5;
  }
  .restaurant-sheet .visit-body {
    padding: 16px 16px 22px;
  }
  .visit-metrics {
    gap: 10px;
    flex-wrap: wrap;
  }
  .visit-metrics > span,
  .value-summary {
    font-size: 14px;
  }
  .restaurant-sheet .diner-detail h4 {
    font-size: 24px;
  }
  .meal-name {
    font-size: 18px;
    line-height: 1.45;
  }
  .meal-detail > div:first-child {
    min-width: 0;
  }
  .meal-detail small,
  .restaurant-sheet .meal-rating small {
    font-size: 13px;
  }
  .private-note,
  .journal-prose {
    font-size: 16px;
    line-height: 1.75;
    overflow-wrap: anywhere;
  }
  .journal-prose h1 {
    font-size: 32px;
  }
  .journal-prose h2 {
    font-size: 28px;
  }
  .journal-prose h3 {
    font-size: 24px;
  }
  .journal-prose pre {
    max-width: 100%;
    overflow-x: auto;
  }
  .visit-journal-preview {
    padding: 12px 16px 22px;
  }
  .visit-edit-actions {
    gap: 12px;
    flex-wrap: wrap;
  }
  .visit-edit-actions button {
    font-size: 14px;
    min-height: 44px;
  }
  .restaurant-management {
    flex-direction: column;
    gap: 12px;
  }
  .restaurant-management p,
  .restaurant-management span {
    font-size: 14px;
  }
  .photo-gallery button {
    min-width: 72px;
  }
  .restaurant-photos:has(> button:only-child) > button,
  .restaurant-photos:has(> button:only-child) img {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 10;
  }
  .course-grid span,
  .course-grid small {
    font-size: 13px;
    line-height: 1.5;
  }
  .visibility-option span {
    font-size: 15px;
  }
  .visibility-option small,
  .privacy-options small,
  .member-list small,
  .laurel-choice small,
  .photo-editor-label small {
    font-size: 14px;
    line-height: 1.6;
  }

  /* All dialogs share generous targets, a reachable close button and safe-area padding. */
  dialog {
    width: 100%;
    max-width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    inset: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    padding: max(16px, env(safe-area-inset-top)) var(--space)
      max(24px, env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  dialog .dialog-top {
    position: sticky;
    top: calc(-1 * max(16px, env(safe-area-inset-top)));
    z-index: 1001;
    background: var(--paper);
    padding: 16px 0;
    margin: -16px 0 22px;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 -24px 0 var(--paper);
  }
  dialog .dialog-top > div {
    min-width: 0;
  }
  dialog .dialog-top h2 {
    font-size: 32px;
    line-height: 1.1;
    margin: 4px 0;
    overflow-wrap: anywhere;
  }
  dialog .close-button {
    width: 46px;
    min-width: 46px;
    height: 46px;
    min-height: 46px;
    margin-right: -10px;
  }
  dialog p {
    line-height: 1.6;
    overflow-wrap: anywhere;
  }
  .small,
  .muted.small,
  .field-help,
  .source-note,
  .entry-fold > summary small,
  .visit-rating-grid .field-help,
  .visit-rating-grid .source-note,
  .markdown-help,
  .legacy-private-note {
    font-size: 14px;
    line-height: 1.6;
  }
  label,
  .rating-label,
  .rating-field label,
  .weight-grid label {
    font-size: 14px;
    line-height: 1.5;
  }
  label small {
    font-size: 13px;
    line-height: 1.5;
  }
  button,
  .primary,
  .secondary,
  .text-button,
  button.small {
    min-height: 46px;
    font-size: 15px;
    line-height: 1.4;
  }
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select,
  textarea,
  .compact-rating select,
  .visit-price-grid select,
  .meal-editor select {
    font-size: 16px;
    min-height: 48px;
    line-height: 1.4;
    border-radius: 3px;
  }
  textarea {
    min-height: 120px;
    padding: 12px;
  }
  input[type="date"],
  input[type="time"] {
    min-width: 0;
    -webkit-appearance: none;
  }
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    min-height: 20px;
    flex-shrink: 0;
  }
  .form-grid,
  .form-grid.three {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
  .visit-date-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 12px;
  }
  .visit-rating-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
  .form-footer {
    z-index: 1001;
    bottom: calc(-1 * max(24px, env(safe-area-inset-bottom)));
    border-top: 1px solid var(--line);
    margin-top: 26px;
    padding: 16px 0 max(16px, env(safe-area-inset-bottom));
    gap: 12px;
  }
  .form-footer button {
    flex: 1;
    min-height: 48px;
  }
  .entry-fold > summary {
    min-height: 56px;
    padding: 14px;
    gap: 10px;
    flex-wrap: wrap;
  }
  .entry-fold > summary > span {
    font-size: 18px;
  }
  .entry-fold > summary > small {
    white-space: normal;
    flex: 1 1 100%;
    order: 2;
  }
  .entry-fold > summary > b {
    margin-left: auto;
  }
  .fold-content,
  .diner-editor-body {
    padding: 16px 12px;
  }
  .tag-options {
    gap: 8px;
  }
  .custom-tag input {
    flex: 1 1 160px;
    min-width: 0;
  }
  .custom-tag button {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .custom-tag {
    flex-wrap: wrap;
  }
  .photo-thumbnails > div > button {
    width: 44px;
    height: 44px;
    min-height: 44px;
    right: -5px;
    top: -10px;
  }
  .photo-thumbnails {
    gap: 16px;
    padding-top: 8px;
  }
  .photo-thumbnails img,
  .photo-upload {
    width: 96px;
    height: 90px;
  }
  .photo-upload small {
    font-size: 13px;
  }
  #edit-dialog button:not(.close-button),
  .collection-multiselect summary {
    font-size: 15px;
  }
  .location-status,
  .collection-multiselect summary strong {
    font-size: 14px;
  }
  .location-status {
    gap: 8px;
    align-items: center;
  }
  .location-status > span {
    width: auto;
  }
  .tag-choice span {
    font-size: 14px;
    min-height: 44px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
  }
  .tag-picker summary {
    min-height: 48px;
    font-size: 15px;
  }
  .tag-picker summary span {
    font-size: 14px;
  }
  .rating-control label {
    gap: 12px;
    font-size: 14px;
  }
  .weight-grid {
    gap: 12px;
  }
  .weight-grid input {
    padding-inline: 9px;
  }
  .meal-editor {
    padding-left: 10px;
  }
  .meal-editor-top {
    align-items: center;
    gap: 12px;
  }
  .meal-editor-top button {
    font-size: 14px;
  }
  .journal-editor-tabs button {
    min-height: 46px;
    font-size: 15px;
  }
  #journal-preview {
    padding: 16px;
  }
  .city-search {
    gap: 10px;
    flex-wrap: wrap;
  }
  .city-search input {
    flex: 1 1 180px;
    min-width: 0;
  }
  .city-search button {
    flex: 0 1 auto;
  }
  .account-actions,
  .auth-links {
    gap: 12px;
    flex-wrap: wrap;
  }
  .account-actions a,
  .auth-links a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 14px;
  }
  .membership-summary p,
  .membership-summary small {
    font-size: 14px;
  }
  .membership-summary strong {
    font-size: 24px;
    line-height: 1.25;
  }
  .privacy-options > label,
  .collection-multiselect label,
  .check-label {
    min-height: 44px;
    gap: 12px;
  }
  .collection-manager-row {
    align-items: start;
    gap: 12px;
    flex-wrap: wrap;
  }
  .collection-manager-row strong {
    font-size: 22px;
  }
  .collection-manager-row small,
  .admin-user small,
  .admin-users small {
    font-size: 13px;
    overflow-wrap: anywhere;
  }
  .admin-user,
  .admin-user-head,
  .admin-grid > * {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .admin-user-head {
    gap: 12px;
  }
  .admin-users article {
    flex-wrap: wrap;
    align-items: start;
  }
  .admin-users article > div {
    flex: 1 1 180px;
    min-width: 0;
  }
  .admin-users article > button {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .share-url {
    flex-wrap: wrap;
    gap: 10px;
  }
  .share-url input {
    flex: 1 1 200px;
    min-width: 0;
  }
  .tier-grid {
    grid-template-columns: 1fr;
  }
  #info-dialog,
  #confirm-dialog,
  #account-dialog:has(#auth-form) {
    inset: 0;
    width: calc(100% - 24px);
    max-width: 480px;
    height: fit-content;
    max-height: calc(100dvh - 32px);
    margin: auto;
    border: 1px solid var(--line);
    border-radius: 6px;
  }
  .tier-card p,
  .tier-card li {
    font-size: 15px;
    line-height: 1.6;
  }

  #collections-page,
  #album-page {
    padding: 26px var(--space) calc(80px + env(safe-area-inset-bottom));
  }
  .page-heading h1,
  .album-heading h1 {
    font-size: 40px;
    line-height: 1.08;
    letter-spacing: -0.02em;
    margin: 12px 0;
  }
  .page-heading p,
  .album-heading p {
    font-size: 16px;
    line-height: 1.6;
  }
  #collections-grid,
  .library-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
  }
  .collection-card {
    padding: 22px;
  }
  .collection-card h2 {
    font-size: 30px;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  .collection-card p {
    font-size: 15px;
    line-height: 1.6;
  }
  .collection-card .eyebrow {
    font-size: 11px;
  }
  .collection-card-actions {
    gap: 10px;
    flex-wrap: wrap;
  }
  .collection-card-actions button {
    font-size: 14px;
    min-height: 46px;
  }
  .library-section-heading h2 {
    font-size: 29px;
  }
  .album-filters {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px 12px;
    margin: 24px 0;
  }
  .album-filter-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    padding-bottom: 16px;
  }
  .album-filter-disclosure:not([open]) > .album-filter-fields {
    display: none;
  }
  .album-grid:has(> button:only-child) {
    grid-template-columns: minmax(0, 1fr);
  }
  .album-filters label {
    font-size: 14px;
  }
  .album-tile > span {
    font-size: 22px;
    line-height: 1.2;
  }
  .album-tile small {
    font-size: 13px;
    line-height: 1.5;
  }
  .album-back {
    top: -26px;
    font-size: 15px;
    min-height: 48px;
  }
  .album-selected .album-layout {
    display: block;
  }
  .album-selected .album-gallery-section,
  .album-selected .album-heading,
  .album-selected .album-filters {
    display: none;
  }
  #album-detail {
    position: static;
    max-height: none;
    border: 0;
    padding: 0;
  }
  .album-dish-notes {
    font-size: 16px;
    line-height: 1.7;
  }
  .album-meal-ratings {
    font-size: 14px;
  }
  #quick-add {
    bottom: max(20px, env(safe-area-inset-bottom));
    right: max(20px, env(safe-area-inset-right));
  }
  #quick-add-toggle {
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 16px #3d132024;
  }
  #toast {
    max-width: calc(100vw - 32px);
    font-size: 15px;
    line-height: 1.5;
    padding: 14px 18px;
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
  .leaflet-touch .leaflet-bar a {
    min-width: 44px;
    min-height: 44px;
    line-height: 44px;
  }
  .map-fit {
    min-height: 46px;
    font-size: 14px;
  }
}
@media (max-width: 359px) {
  :root {
    --space: 16px;
  }
  .masthead {
    padding-inline: 16px;
  }
  .masthead .wordmark {
    font-size: 32px;
  }
  .visit-date-grid,
  .visit-price-grid,
  .weight-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .detail-title-row {
    flex-wrap: wrap;
  }
  .stats {
    gap: 12px;
  }
  .stats > div + div {
    padding-left: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
