* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #1a1030;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Segoe UI", Meiryo, sans-serif;
    color: #262626;
}

/* 背景（動くメッシュグラデーション＋粒子） */

.bg-mesh {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    z-index: -2;
}

.bg-grain {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: -1;
    opacity: 0.22;
    mix-blend-mode: overlay;
    background-image: url("grain.svg");
    animation: grainShift 1.2s steps(6) infinite;
}

@keyframes grainShift {
    0% { transform: translate(0, 0); }
    33% { transform: translate(-3%, 2%); }
    66% { transform: translate(2%, -3%); }
    100% { transform: translate(0, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .bg-grain {
        animation: none;
    }
}

.app-header {
    position: sticky;
    top: 0;
    background: rgba(20, 14, 34, 0.38);
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    -webkit-backdrop-filter: blur(18px) saturate(1.3);
    backdrop-filter: blur(18px) saturate(1.3);
    color: #f6f2ff;
    z-index: 10;
}

.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 935px;
    margin: 0 auto;
    padding: 12px 20px;
}

.logo {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.photo-count {
    font-size: 13px;
    color: rgba(246, 242, 255, 0.68);
}

.empty {
    grid-column: 1 / -1;
    text-align: center;
    color: rgba(246, 242, 255, 0.68);
    margin-top: 60px;
}

.time {
    font-size: 13px;
    color: #8e8e8e;
}

/* 写真グリッド（iPhone写真アプリ風） */

.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 935px;
    margin: 0 auto;
    padding: 2px;
}

.grid-item {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #000;
    cursor: pointer;
    border: 0;
    padding: 0;
    animation: fadeIn 0.3s ease;
}

.grid-item:focus-visible {
    outline: 3px solid #0095f6;
    outline-offset: -3px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.loading-indicator {
    text-align: center;
    color: rgba(246, 242, 255, 0.68);
    font-size: 13px;
    padding: 16px 0 32px;
}

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

/* 拡大表示モーダル */

.modal-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.modal-overlay.open .modal-content {
    transform: scale(1);
}

.modal-close,
.modal-nav {
    position: absolute;
    background: none;
    border: none;
    line-height: 1;
    color: #fff;
    cursor: pointer;
    z-index: 1;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

.modal-close {
    top: 8px;
    right: 12px;
    font-size: 28px;
}

.modal-nav {
    top: 50%;
    transform: translateY(-50%);
    font-size: 44px;
    padding: 8px 14px;
}

.modal-prev {
    left: 0;
}

.modal-next {
    right: 0;
}

.modal-media {
    width: 100%;
    background: #000;
    display: flex;
}

.modal-media img {
    width: 100%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.modal-info {
    padding: 10px 14px 12px;
}

/* スマホはスワイプで移動できるので矢印ボタンは隠す */
@media (hover: none) {
    .modal-nav {
        display: none;
    }
}

/* 管理画面（並べ替え） */

.logo a {
    color: inherit;
    text-decoration: none;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.admin-actions form {
    margin: 0;
}

.admin-button {
    font: inherit;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #f6f2ff;
    cursor: pointer;
}

.admin-button.primary {
    background: #0095f6;
    border-color: #0095f6;
}

.admin-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.admin-message {
    max-width: 935px;
    margin: 16px auto;
    padding: 0 20px;
    font-size: 13px;
    color: rgba(246, 242, 255, 0.8);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 320px;
    margin: 80px auto;
    padding: 0 20px;
    color: #f6f2ff;
}

.login-form input {
    font: inherit;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.3);
    color: #f6f2ff;
}

.login-error {
    margin: 0;
    font-size: 13px;
    color: #ff8fa3;
}

.sort-item {
    cursor: grab;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.sort-placeholder {
    opacity: 0.25;
}

.sort-ghost {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    pointer-events: none;
    cursor: grabbing;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    animation: none;
}

.sort-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 18px;
    line-height: 28px;
    padding: 0;
    cursor: pointer;
}

.sort-delete:hover {
    background: #ed4956;
}

.sort-ghost .sort-delete {
    display: none;
}
