* { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }

  body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #f1f5f9;
    margin: 0;
    color: #111827;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    -webkit-tap-highlight-color: transparent;
  }

  h1 {
    text-align: center;
    font-size: clamp(20px, 5vw, 28px);
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 0 0 clamp(12px, 3vw, 28px) 0;
  }

  .search-bar {
    position: sticky;
    top: calc(56px + env(safe-area-inset-top, 0px));
    z-index: 20;
    display: flex;
    gap: 10px;
    max-width: 1000px;
    margin: 0 auto 12px;
    padding: 8px 0;
    background: #f1f5f9;
  }

  .search-wrap { position: relative; flex: 1; min-width: 0; }

  .search-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    background: #fff;
    color: inherit;
    -webkit-appearance: none;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .search-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  }

  .kbd-hint {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #9ca3af;
    font-size: 12px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 4px;
    padding: 2px 6px;
    line-height: 1;
    display: none;
  }
  .search-input:not(:focus):placeholder-shown ~ .kbd-hint { display: block; }
  .search-input:not(:placeholder-shown) ~ .kbd-hint { display: none; }
  @media (hover: none) { .kbd-hint { display: none !important; } }

  .suggestions {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    z-index: 30;
    overflow: hidden auto;
    max-height: min(65vh, 460px);
    display: none;
  }
  .suggestions.open { display: block; }

  .suggestion-header {
    padding: 8px 14px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
    border-bottom: 1px solid #f3f4f6;
    position: sticky;
    top: 0;
    z-index: 1;
  }
  .suggestion-header button {
    background: none;
    border: none;
    color: #2563eb;
    font: inherit;
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
  }
  .suggestion-header button:hover { background: #eff6ff; }

  .suggestion {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.3;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    color: #111827;
  }
  .suggestion:last-child { border-bottom: none; }
  .suggestion.active,
  .suggestion:hover { background: #f3f4f6; }
  .suggestion .s-icon {
    flex: none;
    width: 16px; height: 16px;
    color: #9ca3af;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .suggestion .s-text {
    flex: 1; min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .suggestion .s-meta { flex: none; color: #9ca3af; font-size: 12px; margin-left: 8px; }
  .suggestion mark { background: transparent; color: #2563eb; font-weight: 700; }

  .results-bar {
    max-width: 1000px;
    margin: 0 auto 14px;
    padding: 0 4px;
    min-height: 20px;
    color: #6b7280;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
  }
  .results-bar .scopes { display: flex; gap: 6px; flex-wrap: wrap; }
  .scope-chip {
    background: #eef2ff;
    color: #3730a3;
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 11.5px;
    font-weight: 600;
  }
  .scope-chip button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    margin-left: 4px;
    font: inherit;
    padding: 0;
    opacity: 0.7;
  }
  .scope-chip button:hover { opacity: 1; }

  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
  }

  .status {
    grid-column: 1 / -1;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    padding: 40px 0;
    margin: 0;
    line-height: 1.5;
  }

  .card {
    position: relative;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
  }

  .badge-3d {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #10b981;
    color: white;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 3px 7px;
    border-radius: 999px;
    z-index: 1;
    box-shadow: 0 2px 6px rgba(16,185,129,0.35);
  }

  .card-image {
    width: 100%;
    height: 190px;
    padding: 14px;
    background: #ffffff;
    border-bottom: 1px solid #f1f5f9;
    flex: none;
  }
  .card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
  }

  .card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .card-body h2 {
    margin: 0 0 6px 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }
  .card-body .meta {
    margin: 0 0 12px 0;
    color: #6b7280;
    font-size: 12.5px;
    overflow-wrap: anywhere;
  }
  .card-body .meta .id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11.5px;
    color: #4b5563;
  }
  .card mark {
    background: #fef9c3;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
  }

  .spacer { flex: 1; }
  .btn-row { display: flex; flex-direction: column; gap: 8px; }

  .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 44px;
    padding: 10px 8px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.2;
    cursor: pointer;
    text-align: center;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    text-decoration: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  }
  .buy-btn { background: #2563eb; color: white; border: none; }
  .download-btn { background: white; color: #374151; border: 1px solid #d1d5db; }

  .btn[aria-disabled="true"] {
    background: #f3f4f6;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
    pointer-events: none;
  }
  .btn:active:not([aria-disabled="true"]) { transform: scale(0.97); }

  .skeleton {
    background: linear-gradient(90deg, #f3f4f6 0%, #e5e7eb 50%, #f3f4f6 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: 8px;
  }
  @keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }
  .card.skeleton-card { pointer-events: none; }
  .skeleton-line { height: 12px; border-radius: 4px; }

  .sentinel { grid-column: 1 / -1; height: 20px; }
  .loading-more {
    grid-column: 1 / -1;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
    padding: 12px 0;
  }

  @media (hover: hover) and (pointer: fine) {
    .card:hover {
      transform: translateY(-3px);
      box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    }
    .buy-btn:hover:not([aria-disabled="true"]) { background: #1d4ed8; }
    .download-btn:hover:not([aria-disabled="true"]) { background: #f3f4f6; }
  }

  @media (max-width: 640px) {
    body {
      padding-left: max(12px, env(safe-area-inset-left));
      padding-right: max(12px, env(safe-area-inset-right));
    }
    .grid {
      grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr));
      gap: 12px;
    }
    .card-image { height: 130px; padding: 10px; }
    .card-body { padding: 11px; }
    .card-body h2 { font-size: 13.5px; }
    .card-body .meta { font-size: 11.5px; margin-bottom: 10px; }
    .btn { font-size: 12px; padding: 10px 6px; }
    .btn-row { gap: 6px; }
    .suggestion { padding: 12px 14px; font-size: 14px; }
    .badge-3d { top: 6px; right: 6px; font-size: 9px; padding: 2px 5px; }
  }
  .brand-select {
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    background: #fff;
    color: #111827;
    cursor: pointer;
    min-width: 120px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
  }
  .brand-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  }

  /* Make sure it looks good on mobile */
  @media (max-width: 640px) {
    .brand-select {
      padding: 10px;
      font-size: 14px;
      min-width: 105px;
    }
  }
