body, body * {
    box-sizing: border-box;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-smooth: always;
    -webkit-font-kerning: normal;
    font-kerning: normal;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    background-color: #f5f5f5;
    transition: all 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.3s ease;
}

.container.searched .logo {
    margin-bottom: 16px;
    font-size: 20px;
}

.container.searched {
    margin-top: 20px;
}

.search-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 800px;
    margin: calc(40 * var(--vh, 1vh)) auto 0;
    padding: 0 20px;
    transition: margin 0.3s ease;
}

.search-container.searched {
    margin: 20px auto 0;
}

#search-input {
    flex-grow: 1;
    padding: 15px 20px;
    border: 2px solid #eaeaea;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
    transition: all 0.2s ease;
}

#search-input:focus {
    border-color: #007AFF;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    -webkit-appearance: none;
    appearance: none;
}

#search-button {
    padding: 15px 30px;
    background-color: #df0fff;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

#search-button:hover {
    background-color: #cd27e7;
}

#results {
    width: 100%;
    max-width: 800px;
    margin-top: 32px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

#results.visible {
    opacity: 1;
    transform: translateY(0);
}

#results ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.result-card {
    display: block;  /* Changed to block as it's now an anchor */
    text-decoration: none;
    background: #fff;
    border-radius: 12px;
    margin-bottom: 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    overflow: hidden;
    width: 100%;
}

.result-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-inner {
    display: flex;
    flex-direction: row;
}

.image-container {
    flex: 0 0 400px;
    height: auto;
    max-height: 340px;
    min-height: 280px;
    overflow: hidden;
    border-right: 1px #f5f5f5 solid;
    /* border-radius: 12px 0 0 12px; */

}

.preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.content-container {
    flex: 1;
    padding: 20px;
    min-width: 0;  /* Prevents flex items from overflowing */
    display: flex;
    flex-direction: column;
}

.save-date, .url-text {
    margin: 0;
    padding: 0;
    border: 0;
    display: inline-block;
    font-weight: 500;
    font-size: 10px;
    line-height: 1.2;
    text-transform: uppercase;
    color: #999;
}

.title {
    color: #1a1a1a;
    font-weight: 500;
    font-size: 18px;
    line-height: 1.45;
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

a:hover .title {
    color: #007AFF;
}

.url {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}

.note {
    color: #666;
    font-size: 16px;
    line-height: 1.4;
    margin-top: 12px;
    padding-top: 24px;
    border-top: 1px #f5f5f5 solid;
}

.note span {
    display: block;
    font-weight: bold;
    font-size: 10px;
    line-height: 1.2;
    text-transform: uppercase;
    color: #999;
}

.url-container {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
}

.url, .bullet-wrap {
    color: #666;
    font-size: 14px;
}

.bullet {
    margin: 0 6px;
    font-size: 12px;
}

.pdf-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: color 0.3s ease;
    font-size: 10px;
    text-decoration: none;
}

.pdf-link:hover {
    color: #df0fff;
}

.bullet-wrap .bullet {
    margin: 0 6px;
    font-size: 12px;
}

.pdf-link svg {
    vertical-align: middle;
    margin: 0 2px;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .card-inner {
        flex-direction: column;
    }

    .image-container {
        flex: none;
        width: 100%;
        max-height: 400px;
        min-height: auto;
    }

    .content-container {
        padding: 16px;
    }

    .search-container {
        margin: calc(24 * var(--vh, 1vh)) auto 0;
        padding: 0 16px;
    }

    .search-container #search-button {
        padding: 15px 20px;
    }

    #results {
        padding: 0;
    }

    .search-controls {
        flex-direction: column;
        gap: 8px;
    }

    .user-select {
        width: 100%;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

.loading-message {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    margin-top: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    text-align: center;
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 500;
}

.logo {
    font-family: "Konkhmer Sleokchher", sans-serif;
    font-size: 28px;
    font-style: normal;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 110%;
    width: 100%;
    margin-bottom: 20px;
    text-align: center;
    color: #383838;
    text-decoration: none;
    text-transform: none;
    cursor: pointer;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.animated-word {
    display: inline-block;
}

.animated-word span {
    display: inline-block;
    background: linear-gradient(
        90deg,
        #4ECDC4,
        #45B7D1,
        #9B6BFF
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradient 3s linear infinite;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

@keyframes gradient {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 150% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.image-container.loading {
    position: relative;
    background: #f5f5f5;
}

.image-container.loading .preview-image {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-container:not(.loading) .preview-image {
    opacity: 1;
}

.image-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #df0fff;
    animation: spin 1s linear infinite;
}

.image-container:not(.loading) .image-spinner {
    display: none;
}

@media (hover: none) {
    /* Better touch feedback for mobile */
    #search-button:active {
        transform: scale(0.98);
        background-color: #cd27e7;
    }

    .result-card:active {
        transform: scale(0.99);
        background-color: #fafafa;
    }
}

/* Add these to improve form interaction on iOS */
input[type="text"],
button {
    -webkit-tap-highlight-color: transparent;
}

/* Prevent text selection on touch */
.logo, .title, .url-container {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Improve scrolling on iOS */
body {
    -webkit-overflow-scrolling: touch;
}

.search-controls {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

.user-select {
    min-width: 160px;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    background-color: white;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
}

.user-select:focus {
    outline: none;
    border-color: #df0fff;
}