body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #1a1a1a;
    color: #e0e0e0;
    font-size: 16px;
}
#header {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #333;
    gap: 20px;
    background-color: #2a2a2a;
    box-sizing: border-box;
}
#search-form {
    display: flex;
    flex: 1;
    gap: 10px;
    box-sizing: border-box;
}
#search-form input {
    flex: 1;
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #333;
    color: #e0e0e0;
    box-sizing: border-box;
    min-width: 0;
    height: 44px;
}
#search-form button {
    height: 44px;
    box-sizing: border-box;
}
#random-btn {
    background-color: #2a2a2a;
    border: 1px solid #444;
    padding: 8px;
    font-size: 20px;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    box-sizing: border-box;
}
#random-btn:hover {
    background-color: #3a3a3a;
    border-color: #555;
    text-decoration: none;
}
#user-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
#login-form {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
    margin: 0px;
}
a { color: #4a9eff; text-decoration: none; }
a:hover { text-decoration: underline; color: #6bb3ff; }
button {
    padding: 8px 16px;
    background-color: #0d6efd;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    min-height: 44px;
}
button:hover { background-color: #0b5ed7; }
button.btn-danger {
    background-color: #dc3545;
    color: white;
}
button.btn-danger:hover { background-color: #c82333; }
.search-results {
    display: flex;
    flex-wrap: wrap;
    padding: 20px;
    gap: 20px;
}
.search-results > div {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.search-results img {
    max-width: 45vw;
    max-height: 45vh;
    margin: 0;
    object-fit: contain;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #2a2a2a;
}
.main-image {
    max-width: 80vw;
    max-height: 80vh;
    object-fit: contain;
    border: 1px solid #444;
    border-radius: 4px;
    margin: 20px 0;
    background-color: #2a2a2a;
}
.similar-image {
    max-width: 30vw;
    max-height: 30vh;
    object-fit: contain;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #2a2a2a;
}
.similar-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px 0;
}
.similar-container > div {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.image-metadata {
    text-align: center;
    font-size: 0.9em;
    color: #999;
    margin: 5px 0 0 0;
}
.image-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
    align-items: center;
    position: relative;
}
.inline-details {
    display: block;
    width: 100%;
}
.inline-details summary {
    display: block;
    cursor: pointer;
    user-select: none;
    padding: 4px 10px;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    font-size: 0.9em;
    color: #4a9eff;
    transition: background-color 0.2s;
    text-align: center;
}
.inline-details summary:hover {
    background-color: #3a3a3a;
    border-color: #555;
}
.inline-details[open] summary {
    background-color: #3a3a3a;
}
.details-content {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #2a2a2a;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 15px;
    margin-top: 5px;
    min-width: 300px;
    max-width: 400px;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}
.details-content input[type="text"] {
    box-sizing: border-box;
}
.content-wrapper {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
}
th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #333;
}
th {
    background-color: #2a2a2a;
    font-weight: 600;
}
form {
    margin: 10px 0;
}
h1, h2 {
    margin: 20px 0 10px 0;
    color: #f0f0f0;
}
textarea {
    width: 100%;
    min-height: 80px;
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    font-family: inherit;
    margin: 10px 0;
    background-color: #333;
    color: #e0e0e0;
}
input[type="text"], input[type="password"], input[type="file"], input[type="search"] {
    padding: 8px;
    border: 1px solid #444;
    border-radius: 4px;
    background-color: #333;
    color: #e0e0e0;
    font-size: 16px;
    margin-right: 10px;
}
/* Style the search input clear button for dark theme */
input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    height: 16px;
    width: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23e0e0e0"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>');
    background-size: 16px 16px;
    cursor: pointer;
}
input[type="search"]::-webkit-search-cancel-button:hover {
    opacity: 0.7;
}
input[type="file"]::file-selector-button {
    background-color: #0d6efd;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 10px;
}
input[type="file"]::file-selector-button:hover {
    background-color: #0b5ed7;
}
pre {
    background-color: #2a2a2a;
    color: #e0e0e0;
}
.mod-description-input {
    width: 300px;
    margin-right: 10px;
}
.welcome-image {
    max-width: 400px;
    width: 100%;
    height: auto;
    object-fit: contain;
    border: 1px solid #444;
    border-radius: 4px;
    margin: 20px 0 10px 0;
    background-color: #2a2a2a;
}
.welcome-quote {
    font-style: italic;
    text-align: center;
    margin: 10px 0;
    color: #e0e0e0;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    * {
        box-sizing: border-box;
    }

    body {
        font-size: 18px;
        overflow-x: hidden;
    }

    #header {
        flex-direction: column;
        padding: 15px;
        gap: 0px;
        align-items: stretch;
        width: 100%;
        max-width: 100vw;
    }

    #header > a {
        text-align: center;
        padding: 8px;
    }

    #search-form {
        width: 100%;
        flex-direction: row;
        gap: 8px;
        margin: 5px 0px;
    }

    #search-form input {
        flex: 1;
        min-width: 0;
        padding: 12px;
        font-size: 16px;
        height: 50px;
    }

    #search-form button {
        flex-shrink: 0;
        width: auto;
        padding: 12px 20px;
        height: 50px;
    }

    #random-btn {
        padding: 10px;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    #user-controls {
        flex-direction: column;
        width: 100%;
        gap: 10px;
        align-items: stretch;
    }

    #user-controls > a,
    #user-controls > form {
        width: 100%;
    }

    #login-form {
        flex-direction: column;
        width: 100%;
        gap: 0;
        align-items: stretch;
        transition: gap 0.3s ease;
    }

    /* Add gap when form has focus or username has content */
    #login-form:focus-within,
    #login-form:has(input[type="text"]:not(:placeholder-shown)) {
        gap: 8px;
    }

    #login-form input[type="text"],
    #login-form input[type="password"] {
        width: 100%;
        margin-bottom: 0;
    }

    #login-form label {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        width: auto;
        flex-shrink: 0;
        white-space: nowrap;
        margin-bottom: 0;
        margin-top: 8px;
        transition: margin-top 0.3s ease;
    }

    /* Remove label top margin when password/button are shown */
    #login-form:focus-within label,
    #login-form:has(input[type="text"]:not(:placeholder-shown)) label {
        margin-top: 0;
    }

    #login-form label input[type="checkbox"] {
        width: auto;
        min-height: auto;
        margin: 0;
    }

    /* Hide password field and button when username is empty and unfocused */
    #login-form input[type="password"],
    #login-form button {
        max-height: 0;
        min-height: 0;
        opacity: 0;
        overflow: hidden;
        margin: 0 !important;
        padding: 0 !important;
        border: 0;
        transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease, border 0.3s ease, min-height 0.3s ease;
    }

    /* Show password and button when username has content OR when form has focus */
    #login-form:focus-within input[type="password"],
    #login-form:focus-within button,
    #login-form input[type="text"]:not(:placeholder-shown) ~ input[type="password"],
    #login-form input[type="text"]:not(:placeholder-shown) ~ button {
        max-height: 200px;
        min-height: 44px;
        opacity: 1;
        margin-bottom: 0 !important;
        padding: 12px !important;
        border: 1px solid #444;
        transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease, border 0.3s ease, min-height 0.3s ease;
    }

    /* Button needs no border */
    #login-form:focus-within button,
    #login-form input[type="text"]:not(:placeholder-shown) ~ button {
        border: none;
    }

    button {
        width: 100%;
        padding: 12px 16px;
        font-size: 16px;
    }

    .search-results {
        flex-direction: column;
        align-items: center;
        padding: 15px;
        gap: 20px;
    }

    .search-results > div {
        width: 100%;
    }

    .search-results img {
        max-width: 90vw;
        max-height: 60vh;
    }

    .main-image {
        max-width: 95vw;
        max-height: 70vh;
    }

    .similar-container {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .similar-container > div {
        width: 100%;
    }

    .similar-image {
        max-width: 90vw;
        max-height: 50vh;
    }

    .image-metadata {
        font-size: 1em;
    }

    .details-content {
        position: static;
        min-width: auto;
        max-width: 100%;
        width: 100%;
    }

    .content-wrapper {
        padding: 15px;
    }

    h1 {
        font-size: 1.75em;
    }

    h2 {
        font-size: 1.5em;
    }

    table {
        font-size: 14px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    th, td {
        padding: 8px 6px;
    }

    textarea {
        font-size: 16px;
        padding: 12px;
    }

    input[type="text"], input[type="password"], input[type="file"], input[type="search"] {
        padding: 12px;
        font-size: 16px;
        min-height: 44px;
        margin-bottom: 10px;
        width: 100%;
        box-sizing: border-box;
    }

    .mod-description-input {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }

    form {
        width: 100%;
    }

    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .welcome-image {
        max-width: 90vw;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 480px) {
    body {
        font-size: 16px;
    }

    #header {
        padding: 12px;
        gap: 12px;
    }

    .content-wrapper {
        padding: 12px;
    }

    h1 {
        font-size: 1.5em;
    }

    h2 {
        font-size: 1.3em;
    }

    table {
        font-size: 12px;
    }

    th, td {
        padding: 6px 4px;
    }
}
