:root {
    --bg: #0f0f0f;
    --card-bg: #1a1a1a;
    --text: #e0e0e0;
    --text-dim: #888;
    --accent: #4a9eff;
    --border: #2a2a2a;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

#app {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-header {
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top));
    text-align: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
}

.app-header h1 {
    font-size: 18px;
    font-weight: 600;
}

.back-btn {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--accent);
    font-size: 16px;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: var(--text-dim);
    font-size: 14px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.album-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 12px;
}

@media (min-width: 480px) {
    .album-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 768px) {
    .album-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.album-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: opacity 0.2s;
    position: relative;
}

.album-card:active {
    opacity: 0.7;
}

.album-cover {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: var(--border);
}

.album-info {
    padding: 8px 10px;
}

.album-title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.album-count {
    font-size: 11px;
    color: var(--text-dim);
}

.lock-icon {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
}

.photo-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    cursor: pointer;
    background: var(--border);
}

.photo-item:active {
    opacity: 0.8;
}

.photo-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.video-play-overlay::after {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 8px 0 8px 14px;
    border-color: transparent transparent transparent #fff;
    margin-left: 4px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px 20px;
    width: 100%;
    max-width: 340px;
}

.modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.modal-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    min-height: 44px;
    outline: none;
}

.modal-input:focus {
    border-color: var(--accent);
}

.modal-error {
    color: #ff6b6b;
    font-size: 13px;
    margin-top: 8px;
    text-align: center;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.modal-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    min-height: 44px;
    cursor: pointer;
}

.modal-btn-cancel {
    background: var(--border);
    color: var(--text);
}

.modal-btn-submit {
    background: var(--accent);
    color: #fff;
}

.modal-btn:active {
    opacity: 0.7;
}

.viewer {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    touch-action: none;
    overscroll-behavior: none;
}

.viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    z-index: 10;
}

.viewer-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer-counter {
    font-size: 14px;
    color: #ccc;
}

.viewer-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
}

.viewer-slides {
    display: flex;
    height: 100%;
    transition: transform 0.3s ease;
    will-change: transform;
}

.viewer-slide {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.viewer-slide img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    -webkit-user-drag: none;
    user-select: none;
}

.viewer-slide video {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-dim);
    text-align: center;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.scroll-container {
    -webkit-overflow-scrolling: touch;
}
