/* --- SEARCH CONTAINER --- */
      .search-container {
        max-width: 600px;
        margin: 2rem auto;
        padding: 0 1rem; /* Horizontal padding for mobile safety */
        text-align: center;
      }

      .search-input {
        width: 100%;
        padding: 15px 20px;
        font-size: 1.1rem; /* Desktop size */
        border: 2px solid #e0e0e0;
        border-radius: 8px;
        outline: none;
        transition: border-color 0.2s;
        /* Remove iOS default styling */
        -webkit-appearance: none;
        box-sizing: border-box; /* Ensures padding doesn't widen the element */
      }

      .search-input:focus {
        border-color: #333;
      }

      /* --- GRID SYSTEM (DESKTOP DEFAULT) --- */
      .portfolio-grid {
        display: grid;
        /* Desktop: Auto-fit columns, min width 300px */
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 2rem;
        padding: 2rem;
        align-items: start;
      }

      .clear-btn {
        position: absolute;
        right: 15px;
        background: #ccc;
        color: white;
        border: none;
        border-radius: 50%;
        width: 22px;
        height: 22px;
        cursor: pointer;
        display: none; /* Hidden by default */
        font-size: 16px;
        line-height: 1;
        padding: 0;
        transition: background 0.2s;
      }

      .clear-btn:hover {
        background: #999;
      }

      /* --- MOBILE BREAKPOINT --- */
      @media (max-width: 768px) {
        .portfolio-grid {
          /* Force 1 column on mobile for large, clear images */
          grid-template-columns: 1fr;
          padding: 1rem; /* Less padding on edges */
          gap: 1.5rem; /* Smaller gaps between cards */
        }

        .search-input {
          /* Prevents iOS from zooming in on focus */
          font-size: 16px;
        }

        .search-container {
          margin: 1.5rem auto;
        }
      }

      /* --- CARD STYLES --- */
      .grid-item {
        background: #fff;
        border-radius: 8px;
        overflow: hidden;
        text-decoration: none;
        color: inherit;
        display: flex;
        flex-direction: column;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        transition: transform 0.2s;
      }

      /* Hover effect only on devices that support hover (not mobile) */
      @media (hover: hover) {
        .grid-item:hover {
          transform: translateY(-4px);
        }
      }

      /* --- IMAGE --- */
      .image-wrapper {
        width: 100%;
        aspect-ratio: 16 / 9;
        background: #f4f4f4;
        overflow: hidden;
      }

      .grid-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
      }

      /* --- CONTENT --- */
      .post-info {
        padding: 1rem;
      }

      .post-info h3 {
        margin: 0;
        font-size: 1.2rem;
        line-height: 1.4;
        color: #222;
      }

      /* --- SNIPPET LOGIC --- */
      .search-snippet {
        display: none; /* Hidden by default */
        margin-top: 0.8rem;
        padding-top: 0.8rem;
        border-top: 1px solid #eee;
        font-size: 0.95rem;
        color: #555;
        line-height: 1.5;
      }

      /* Visible only when parent has .is-searching class */
      .portfolio-grid.is-searching .search-snippet {
        display: block;
      }

      mark {
        background-color: #ffd700;
        color: #000;
      }

      @media (max-width: 768px) {
        .post-info h3 {
          font-size: 1.1rem;
        }
        .image-wrapper {
          height: 200px;
        }
      }