:root {
    --bg: #FAF8F5;
    --sidebar-bg: #F5F0EB;
    --accent: #C8956C;
    --accent-hover: #B07D58;
    --accent-light: rgba(200,149,108,0.1);
    --text: #2C2C2C;
    --text-sub: #6B6B6B;
    --card: #FFFFFF;
    --border: #E8E2DC;
    --danger: #D4574E;
    --success: #5B8A5E;
    --radius: 12px;
    --sidebar-w: 240px;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
    background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh;
}

/* ===== Layout ===== */
.app-layout { display: flex; min-height: 100vh; }
.guest-layout { min-height: 100vh; display: flex; align-items: center; justify-content: center; }

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-w); background: var(--sidebar-bg); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100; overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px; padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo { font-size: 1.4em; }
.sidebar-title { font-size: 1em; font-weight: 600; color: var(--accent); }
.sidebar-nav {
    flex: 1; display: flex; flex-direction: column; gap: 1px; padding: 8px 10px;
}
.sidebar-section {
    font-size: 0.7em; font-weight: 600; color: var(--text-sub); text-transform: uppercase;
    letter-spacing: 0.05em; padding: 12px 12px 4px; margin-top: 4px;
}
.sidebar-divider {
    height: 1px; background: var(--border); margin: 8px 12px;
}
.sidebar-link {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px;
    color: var(--text-sub); text-decoration: none; font-size: 0.85em; transition: all 0.15s;
}
.sidebar-link:hover { background: var(--accent-light); color: var(--accent); }
.sidebar-link.active { background: var(--accent); color: #fff; }
.sidebar-link .icon { font-size: 1em; width: 20px; text-align: center; }
.sidebar-footer {
    padding: 10px; border-top: 1px solid var(--border); margin-top: auto;
}
.sidebar-user { padding: 6px 12px; font-size: 0.82em; font-weight: 500; color: var(--accent); }
.logout-link { color: var(--danger) !important; }
.logout-link:hover { background: rgba(212,87,78,0.08) !important; color: var(--danger) !important; }

/* ===== Mobile Nav ===== */
.mobile-nav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
    background: var(--card); border-top: 1px solid var(--border);
    padding: 6px 0; box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.mobile-nav { display: none; justify-content: space-around; align-items: center; }
.mobile-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    text-decoration: none; color: var(--text-sub); font-size: 1.2em;
    background: none; border: none; cursor: pointer; padding: 4px 8px;
}
.mobile-nav-item small { font-size: 0.55em; }
.mobile-nav-item.active { color: var(--accent); }

/* Mobile Filter Panel */
.mobile-filter-panel {
    display: none; position: fixed; bottom: 60px; left: 0; right: 0; z-index: 190;
    background: var(--card); border-top: 1px solid var(--border); border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.1); max-height: 60vh; overflow-y: auto;
}
.mobile-filter-panel.open { display: block; }
.mobile-filter-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.mobile-filter-header button {
    background: none; border: none; font-size: 1.2em; cursor: pointer; color: var(--text-sub);
}
.mobile-filter-body { padding: 12px 20px 20px; }
.mobile-filter-section {
    font-size: 0.75em; font-weight: 600; color: var(--text-sub); padding: 8px 0 4px;
}
.mobile-filter-link {
    display: block; padding: 10px 12px; color: var(--text); text-decoration: none;
    border-radius: 8px; font-size: 0.9em;
}
.mobile-filter-link:hover { background: var(--accent-light); }

/* ===== Main Content ===== */
.main-content { flex: 1; margin-left: var(--sidebar-w); padding: 24px 28px; min-height: 100vh; }

/* ===== Login ===== */
.login-container {
    width: 100%; max-width: 380px; padding: 36px 28px; background: var(--card);
    border-radius: var(--radius); box-shadow: 0 4px 20px rgba(0,0,0,0.06); text-align: center;
}
.login-title { color: var(--accent); font-size: 1.7em; margin-bottom: 4px; font-weight: 600; }
.login-subtitle { color: var(--text-sub); font-size: 0.9em; margin-bottom: 28px; }
.login-form { text-align: left; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.82em; color: var(--text-sub); margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select {
    width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 0.95em; background: var(--bg); transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }
.error { color: var(--danger); font-size: 0.85em; margin-bottom: 14px; padding: 10px; background: #fef2f2; border-radius: 6px; border-left: 3px solid var(--danger); }
.success { color: var(--success); font-size: 0.85em; margin-bottom: 14px; padding: 10px; background: #f0fdf0; border-radius: 6px; border-left: 3px solid var(--success); }

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 24px; border: none; border-radius: 8px; font-size: 0.9em;
    cursor: pointer; text-decoration: none; text-align: center; transition: all 0.15s;
    font-weight: 500; min-height: 42px;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c04a42; }
.btn-sm { padding: 7px 14px; font-size: 0.8em; min-height: 34px; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-sub); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-block { display: flex; width: 100%; }
.register-link { display: block; margin-top: 18px; color: var(--accent); font-size: 0.85em; text-decoration: none; }
.register-link:hover { text-decoration: underline; }

/* ===== Gallery ===== */
.gallery-top { margin-bottom: 16px; }
.page-title { font-size: 1.3em; font-weight: 600; margin-bottom: 2px; }
.page-subtitle { color: var(--text-sub); font-size: 0.82em; }
.active-filter {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px;
    background: var(--accent-light); border-radius: 20px; font-size: 0.82em;
    color: var(--accent); margin-bottom: 16px;
}
.filter-clear { color: var(--danger); text-decoration: none; font-weight: 600; }
.filter-clear:hover { text-decoration: underline; }

.gallery-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px;
}
.gallery-item {
    display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
    position: relative; background: var(--sidebar-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04); transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
}
.gallery-item:hover { transform: translateY(-3px); box-shadow: 0 6px 20px rgba(0,0,0,0.08); }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; }
.gallery-meta {
    position: absolute; bottom: 0; left: 0; right: 0; padding: 6px 10px;
    background: linear-gradient(transparent, rgba(0,0,0,0.55));
    display: flex; justify-content: space-between; align-items: flex-end;
}
.meta-user, .meta-date { color: #fff; font-size: 0.7em; }
.empty-state {
    grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-sub);
    background: var(--card); border-radius: var(--radius); border: 2px dashed var(--border);
}
.empty-state p { margin-bottom: 12px; }

/* ===== Video Thumbnail ===== */
.video-thumb { position: relative; width: 100%; height: 100%; overflow: hidden; background: #1a1a1a; }
.video-thumb video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.play-icon {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    font-size: 1.4em; color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    background: rgba(0,0,0,0.35); width: 44px; height: 44px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; padding-left: 3px;
}

/* ===== Upload ===== */
.upload-area {
    border: 2px dashed var(--border); border-radius: var(--radius); padding: 48px 20px;
    text-align: center; cursor: pointer; transition: all 0.2s; margin-bottom: 20px; background: var(--card);
}
.upload-area:hover, .upload-area.dragover { border-color: var(--accent); background: var(--accent-light); }
.upload-area input { display: none; }
.upload-area p { color: var(--text-sub); }
.preview-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px; margin-bottom: 20px;
}
.preview-item {
    aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--sidebar-bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 1px solid var(--border);
}
.preview-item img { width: 100%; height: 80%; object-fit: cover; }
.preview-item small { font-size: 0.6em; color: var(--text-sub); padding: 2px; }

/* ===== Detail ===== */
.detail-page { max-width: 640px; }
.back-link {
    color: var(--accent); text-decoration: none; font-size: 0.85em;
    display: inline-flex; align-items: center; gap: 4px; margin-bottom: 16px;
}
.back-link:hover { text-decoration: underline; }
.detail-media {
    border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
    background: #000; box-shadow: 0 4px 16px rgba(0,0,0,0.1); max-height: 480px;
}
.detail-media img { width: 100%; max-height: 480px; object-fit: contain; display: block; }
.detail-media video { width: 100%; max-height: 480px; object-fit: contain; display: block; }
.detail-info {
    background: var(--card); padding: 20px; border-radius: var(--radius); border: 1px solid var(--border);
}
.detail-info p { margin-bottom: 10px; font-size: 0.9em; color: var(--text-sub); }
.detail-info strong { color: var(--text); }
.detail-actions { display: flex; gap: 12px; margin-top: 20px; }
.detail-actions .btn { flex: 1; }
.detail-actions form { flex: 1; display: flex; }
.detail-actions form .btn { flex: 1; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .mobile-nav { display: flex; }
    .main-content { margin-left: 0; padding: 16px 14px 80px; }
    .gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 4px; }
    .gallery-item { border-radius: 6px; }
    .detail-media { max-height: 300px; }
    .detail-media img, .detail-media video { max-height: 300px; }
    .detail-actions { flex-direction: row; }
    .login-container { margin: 0 16px; }
    .guest-layout { padding: 20px; }
}


/* ===== Mobile Header ===== */
.mobile-header {
    display: none;
}
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 48px;
        background: #FAF8F5;
        border-bottom: 1px solid #E8E2DC;
        padding: 0 12px;
        z-index: 1000;
    }
    .mobile-header-title {
        font-weight: 700;
        color: #C8956C;
        font-size: 0.95em;
    }
    .mobile-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    .mobile-user-name {
        font-size: 0.8em;
        color: #6B6B6B;
    }
    .mobile-logout-btn {
        font-size: 0.75em;
        color: #D4574E;
        text-decoration: none;
        padding: 4px 10px;
        border: 1px solid #D4574E;
        border-radius: 4px;
    }
    .main-content {
        padding-top: 56px !important;
        padding-bottom: 72px !important;
    }
}


/* ===== User Card ===== */
.user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #E8E2DC;
    border-radius: var(--radius, 8px);
    margin-bottom: 8px;
}
.user-card-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.1em;
}
.user-card-name {
    font-weight: 600;
    color: #333;
}
.user-card-date {
    color: #999;
    font-size: 0.8em;
}
.user-card-actions {
    display: flex;
    gap: 6px;
}
