:root {
    --primary-color: #4a90e2;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #333333;
    --border-radius: 12px;
    --spacing: 16px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'M PLUS Rounded 1c', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
}

/* Views */
.view {
    display: none;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
}

.view.active {
    display: block;
}

/* Login Screen */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
}

.login-container h1 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.login-container input {
    width: 100%;
    max-width: 300px;
    padding: 8px;
    /* Standardize padding */
    height: 40px;
    /* Explicit height */
    box-sizing: border-box;
    /* Include padding/border in height */
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    /* Standardize border-radius */
    font-size: 16px;
    /* Prevent zoom on iOS */
    vertical-align: middle;
    /* Align with buttons */
}

.login-container button {
    width: 100%;
    max-width: 300px;
    padding: 0 20px;
    /* Vertical padding handled by height */
    height: 40px;
    /* Match input height */
    box-sizing: border-box;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    /* Standardize border-radius */
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    vertical-align: middle;
    /* Align with inputs */
    display: inline-flex;
    /* Allow vertical-align to work and center content */
    align-items: center;
    justify-content: center;
}

.error-msg {
    color: red;
    margin-top: 10px;
    font-size: 0.9rem;
}

/* App Header */
header {
    height: var(--header-height);
    background-color: var(--card-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--spacing);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-left h2 {
    font-size: 1.2rem;
}

.header-right {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    padding: 8px;
    cursor: pointer;
    color: var(--text-color);
}

/* Gallery Grid */
.gallery {
    padding: var(--spacing);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding-bottom: 80px;
    /* Space for bottom interaction if needed */
}

.gallery-item {
    aspect-ratio: 1;
    background-color: #ddd;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.gallery-item img,
.gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.gallery-item:active img {
    transform: scale(0.98);
}

.media-badge {
    position: absolute;
    bottom: 5px;
    right: 5px;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Search Bar */
.search-bar {
    display: none;
    padding: 10px var(--spacing);
    background: #fff;
    border-bottom: 1px solid #eee;
}

.search-bar.active {
    display: flex;
    gap: 10px;
}

.search-bar input {
    flex: 1;
    padding: 8px;
    /* Standardize padding */
    height: 40px;
    /* Explicit height */
    box-sizing: border-box;
    /* Include padding/border in height */
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    /* Prevent zoom on iOS */
    min-width: 0;
}

.search-actions button {
    padding: 0 20px;
    /* Vertical padding handled by height */
    height: 40px;
    /* Match input height */
    box-sizing: border-box;
    background: var(--primary-color);
    color: white;
    font-size: 14px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.search-actions button.secondary {
    background: #999;
}

/* Modal System */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 10px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px;
    border-top: 1px solid #eee;
    text-align: right;
}

/* Upload UI */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
}

.upload-area i {
    font-size: 3rem;
    color: #ccc;
    margin-bottom: 10px;
}

.upload-area input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.preview-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.preview-item {
    aspect-ratio: 1;
    position: relative;
    border-radius: 6px;
    overflow: hidden;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#upload-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
}

#upload-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Slideshow */
.modal.fullscreen {
    background: black;
}

.modal.fullscreen .modal-content {
    background: transparent;
    width: 100%;
    height: 100%;
    border-radius: 0;
}

.slideshow-content {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    height: 100%;
}

.slide-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.slide-container img,
.slide-container video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 20px 10px;
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 10;
}

.nav-btn.prev {
    left: 10px;
}

.nav-btn.next {
    right: 10px;
}

.slideshow-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 20px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn.abs-top-right {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    z-index: 20;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.action-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 20px;
    border: none;
    font-size: 0.9rem;
    margin-left: 10px;
    cursor: pointer;
}

.action-btn.delete {
    background: rgba(255, 0, 0, 0.6);
}

/* Admin Bar */
.admin-bar {
    background: #ff5252;
    color: white;
    text-align: center;
    padding: 5px;
    font-size: 0.8rem;
    font-weight: bold;
}

/* Upload Progress Bar */
.progress-container {
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: #f0f0f0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    transition: width 0.2s ease;
}