  :root {
    --navy: #1F4E79;
    --blue: #2E6DA4;
    --light-blue: #D6E4F0;
    --green: #2D6A4F;
    --light-green: #D5E8D4;
    --orange: #843C0C;
    --light-orange: #FCE4D6;
    --chase-blue: #117ACA;
    --gold: #C9A84C;
    --red: #8B0000;
    --gray: #f5f5f5;
    --border: #d0d8e0;
  }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: 'Segoe UI', Arial, sans-serif; background: #f0f4f8; color: #222; }

  .sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
  }

  .header {
    background: var(--navy);
    color: white;
    padding: 20px 32px 14px;
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .header h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.3px; }
  .home-link { color: inherit; text-decoration: none; }
  .home-link:hover, .home-link:focus-visible { text-decoration: underline; }
  .header p { font-size: 13px; opacity: 0.8; margin-top: 3px; }

  .legend {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 10px 32px;
    display: flex;
    gap: 24px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 12.5px;
  }
  .legend-item { display: flex; align-items: center; gap: 6px; }
  .badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 4px; padding: 2px 7px; font-size: 11px; font-weight: 600; }
  .badge-vegan { background: #E8F5E9; color: #2D6A4F; border: 1px solid #A5D6A7; }
  .badge-meat  { background: #FFEBEE; color: #8B0000; border: 1px solid #EF9A9A; }
  .badge-chase { background: #E3F2FD; color: var(--chase-blue); border: 1px solid #90CAF9; font-size: 10px; }
  .badge-res   { background: #FFF8E1; color: #7B5800; border: 1px solid #FFD54F; }
  .badge-walkin{ background: #F3E5F5; color: #6A1B9A; border: 1px solid #CE93D8; }

  .search-bar {
    background: white;
    padding: 14px 32px;
    border-bottom: 1px solid var(--border);
  }
  .search-bar input {
    width: 100%;
    max-width: 480px;
    padding: 9px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    font-size: 13px;
    outline: none;
  }
  .search-bar input:focus { border-color: var(--blue); }

  .filters {
    background: white;
    padding: 12px 32px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border);
    align-items: center;
  }
  .filters span { font-size: 12px; font-weight: 600; color: #555; margin-right: 4px; }
  .filter-btn {
    padding: 5px 14px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: white;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.15s;
    color: #444;
  }
  .filter-btn:hover { border-color: var(--blue); color: var(--blue); }
  .filter-btn.active { background: var(--navy); color: white; border-color: var(--navy); }

  .content { padding: 24px 32px; max-width: 1300px; }

  .city-section { margin-bottom: 32px; }
  .city-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2.5px solid;
    border-color: var(--blue);
  }
  .city-header.sf  { border-color: var(--blue); }
  .city-header.taos{ border-color: var(--green); }
  .city-header.abq { border-color: var(--orange); }
  .city-header h2  { font-size: 17px; font-weight: 700; color: var(--navy); }
  .city-header.sf  h2 { color: var(--navy); }
  .city-header.taos h2{ color: var(--green); }
  .city-header.abq h2 { color: var(--orange); }

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

  .card {
    background: white;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    overflow: hidden;
    transition: box-shadow 0.2s;
  }
  .card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.10); }
  .card.hidden { display: none; }

  .card-header {
    padding: 13px 16px 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
  }
  .card-header      { background: var(--light-blue); }
  .card-header.sf   { background: var(--light-blue); }
  .card-header.taos { background: var(--light-green); }
  .card-header.abq  { background: var(--light-orange); }

  .card-name { font-size: 14px; font-weight: 700; color: #1a1a1a; line-height: 1.3; }
  .card-type { font-size: 11px; color: #666; margin-top: 2px; }

  .badges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }

  .chase-logo {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--chase-blue);
    color: white;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .chase-logo svg { width: 12px; height: 12px; }

  .card-body { padding: 12px 16px; }
  .card-desc { font-size: 12.5px; color: #444; line-height: 1.5; margin-bottom: 10px; }

  .links { display: flex; gap: 8px; flex-wrap: wrap; }
  .link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 11.5px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.15s;
  }
  .link-btn:hover { opacity: 0.82; }
  .link-menu     { background: #EEF2FF; color: #3730a3; border: 1px solid #C7D2FE; }
  .link-opentable{ background: #DA3743; color: white; }
  .link-resy     { background: #1A1A1A; color: white; }
  .link-website  { background: #F3F4F6; color: #374151; border: 1px solid #D1D5DB; }
  .link-phone    { background: #F0FDF4; color: #166534; border: 1px solid #BBF7D0; }
  .link-call     { background: #FEF9C3; color: #713F12; border: 1px solid #FDE047; }

  .res-note {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #92400e;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 5px;
    padding: 4px 9px;
    margin-bottom: 8px;
  }

  .state-section {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
  }
  .state-summary {
    cursor: pointer;
    padding: 14px 20px;
    font-size: 15px;
    font-weight: 700;
    color: var(--navy);
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
  }
  .state-summary::-webkit-details-marker { display: none; }
  .state-summary::after {
    content: '▸';
    font-size: 12px;
    color: #888;
    transition: transform 0.15s;
  }
  .state-section[open] > .state-summary::after { transform: rotate(90deg); }
  .state-summary:hover { background: #f8fafc; }
  .state-count { font-size: 12px; font-weight: 500; color: #888; margin-left: 8px; }
  .state-body { padding: 4px 20px 20px; }
  .state-empty { font-size: 13px; color: #888; padding: 4px 0 16px; }

  .back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--navy);
    color: white;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.2s, transform 0.2s, background 0.15s;
    z-index: 999;
  }
  .back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
  .back-to-top:hover { background: var(--blue); }

  @media (max-width: 700px) {
    .content { padding: 16px; }
    .header, .legend, .filters { padding-left: 16px; padding-right: 16px; }
    .grid { grid-template-columns: 1fr; }
    .back-to-top { bottom: 16px; right: 16px; }
  }

  /* ── Header add-restaurant button ─────────────────────────────────────────── */
  .header { justify-content: space-between; }
  .btn-add-restaurant {
    background: white; color: var(--navy);
    border: none; border-radius: 20px;
    padding: 8px 16px; font-size: 12.5px; font-weight: 700;
    cursor: pointer; white-space: nowrap;
  }
  .btn-add-restaurant:hover { background: var(--light-blue); }

  /* ── Visited badge ─────────────────────────────────────────────────────────── */
  .badge-visited { background: #E8F5E9; color: #1b5e20; border: 1px solid #A5D6A7; }
  .link-details { background: #F3F4F6; color: #374151; border: 1px solid #D1D5DB; }
  .card-name a { color: inherit; text-decoration: none; }
  .card-name a:hover { text-decoration: underline; }

  /* ── Modal (Add Restaurant) ───────────────────────────────────────────────── */
  .modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
  }
  .modal {
    background: white; border-radius: 12px; width: 480px; max-width: 100%;
    max-height: 90vh; overflow: auto; padding: 0;
  }
  .modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
  }
  .modal-header h3 { font-size: 16px; color: var(--navy); }
  .modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: #666; }
  #addForm { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
  #addForm label { font-size: 12px; font-weight: 600; color: #444; display: flex; flex-direction: column; gap: 4px; }
  #addForm input, #addForm textarea {
    font-size: 13px; font-weight: 400; padding: 8px 10px;
    border: 1.5px solid var(--border); border-radius: 6px; font-family: inherit;
  }
  #addForm textarea { min-height: 60px; resize: vertical; }
  .tag-checks { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; color: #444; }
  .tag-checks label { flex-direction: row; align-items: center; gap: 6px; }
  .btn-save {
    background: var(--navy); color: white; border: none; border-radius: 8px;
    padding: 9px 16px; font-size: 13px; font-weight: 700; cursor: pointer; align-self: flex-start;
  }
  .btn-save:hover { background: var(--blue); }
  #addStatus, #noteSaveStatus, #photoUploadStatus { font-size: 12px; color: #666; margin-left: 8px; }

  /* ── Detail view ───────────────────────────────────────────────────────────── */
  .back-link { display: inline-block; margin-bottom: 14px; font-size: 13px; color: var(--blue); text-decoration: none; }
  .back-link:hover { text-decoration: underline; }
  .detail-loading { padding: 40px; text-align: center; color: #888; }
  .detail-card {
    background: white; border: 1.5px solid var(--border); border-radius: 12px;
    padding: 20px; max-width: 640px;
  }
  .detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
  .detail-header h2 { font-size: 20px; color: var(--navy); }
  .detail-card .badges { margin: 8px 0; }
  .detail-card .card-desc { margin: 10px 0; }
  .detail-card .links { margin-bottom: 6px; }

  .our-notes { margin-top: 20px; padding-top: 16px; border-top: 2px solid var(--border); }
  .our-notes h3 { font-size: 14px; color: var(--navy); margin-bottom: 10px; }
  .visited-check { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-bottom: 12px; cursor: pointer; }
  .reservation-block { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
  .reservation-block .visited-check { margin-bottom: 0; }
  .reservation-date-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #444; }
  .reservation-date-label input[type="date"] {
    font-size: 13px; padding: 5px 8px; border: 1.5px solid var(--border);
    border-radius: 6px; font-family: inherit;
  }
  .badge-reservation { background: #E3F2FD; color: #0d47a1; border: 1px solid #90CAF9; }
  .rating-block { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 12px; }
  #notesText { width: 100%; min-height: 90px; padding: 10px; border: 1.5px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 13px; resize: vertical; margin-bottom: 10px; }
  .photo-grid { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
  .photo-thumb { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

  /* ── <star-rating> ────────────────────────────────────────────────────────── */
  .star-rating { display: inline-flex; gap: 2px; }
  .star-rating .star {
    font-size: 22px; line-height: 1; color: #d0d8e0;
    cursor: pointer; padding: 3px; border-radius: 4px;
    /* 44px min touch target per WCAG 2.5.5, even though the glyph is small */
    min-width: 28px; min-height: 28px; display: inline-flex; align-items: center; justify-content: center;
  }
  .star-rating-readonly .star { cursor: default; padding: 0; min-width: auto; min-height: auto; font-size: 15px; }
  .star-rating .star:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
  .star-rating .star.filled { color: #f5b301; }
  .star-rating-sm .star { font-size: 14px; }
  .star-rating-lg .star { font-size: 28px; }

  /* ── <status-message> ─────────────────────────────────────────────────────── */
  .status-message { font-size: 12px; margin-left: 8px; }
  .status-message-info    { color: #666; }
  .status-message-success { color: #1b5e20; font-weight: 600; }
  .status-message-error   { color: #b91c1c; font-weight: 600; }

  /* ── <empty-state> ────────────────────────────────────────────────────────── */
  .empty-state { display: block; text-align: center; padding: 48px 20px; color: #667; }
  .empty-state-icon { font-size: 40px; margin-bottom: 10px; }
  .empty-state-heading { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
  .empty-state-message { font-size: 13px; color: #777; margin-bottom: 14px; }
  .empty-state-action:empty { display: none; }

  /* ── <app-modal> ──────────────────────────────────────────────────────────── */
  /* Higher specificity than the plain .modal-overlay class rule above, so
     visibility is driven purely by the `open` attribute — not a JS/CSS
     specificity race (a class-selector "display:flex" would otherwise beat
     a type-selector "display:none" and show the modal on every page load). */
  app-modal.modal-overlay { display: none; }
  app-modal.modal-overlay[open] { display: flex; }
  app-modal [role="dialog"]:focus { outline: none; }

  /* ── Skeleton loading ─────────────────────────────────────────────────────── */
  .skeleton-card { padding: 16px; }
  .skeleton-line {
    height: 12px; border-radius: 4px; margin-bottom: 10px;
    background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 37%, #eef1f5 63%);
    background-size: 400% 100%; animation: skeleton-shimmer 1.4s ease infinite;
  }
  .skeleton-title { width: 55%; height: 15px; }
  .skeleton-sub   { width: 40%; }
  .skeleton-body  { width: 95%; }
  @keyframes skeleton-shimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
  }
  @media (prefers-reduced-motion: reduce) {
    .skeleton-line { animation: none; }
  }
