/* ============================================
   Visual Match — 画像マッチング検証プラットフォーム
   Design System (based on Pointcloud Lab theme)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* --- CSS Custom Properties --- */
:root {
    /* Color Palette - Dark Cyberpunk Theme */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: #1a2035;
    --bg-card-hover: #1f2847;
    --bg-glass: rgba(26, 32, 53, 0.85);
    --bg-overlay: rgba(10, 14, 26, 0.9);

    --text-primary: #e8ecf4;
    --text-secondary: #8b95a8;
    --text-muted: #5a6478;
    --text-accent: #64d2ff;

    --accent-blue: #3b82f6;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --accent-pink: #ec4899;

    --gradient-blue: linear-gradient(135deg, #3b82f6, #06b6d4);
    --gradient-green: linear-gradient(135deg, #10b981, #06b6d4);
    --gradient-purple: linear-gradient(135deg, #8b5cf6, #ec4899);
    --gradient-orange: linear-gradient(135deg, #f97316, #f59e0b);
    --gradient-hero: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);

    /* Borders */
    --border-color: rgba(59, 130, 246, 0.15);
    --border-glow: rgba(59, 130, 246, 0.3);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-blue: 0 0 20px rgba(59, 130, 246, 0.2);
    --shadow-glow-cyan: 0 0 20px rgba(6, 182, 212, 0.2);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(245, 158, 11, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(6, 182, 212, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-yellow);
    border-radius: 3px;
}

/* --- Typography --- */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 1.75rem;
}

h3 {
    font-size: 1.25rem;
}

a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-blue);
}

code,
.mono {
    font-family: var(--font-mono);
    font-size: 0.85em;
}

/* --- Layout --- */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    position: relative;
    z-index: 1;
}

.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* --- Header --- */
.site-header {
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 1100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 800;
    font-size: 1.3rem;
    color: var(--text-primary);
    text-decoration: none;
}

/* --- Header Ping Animation --- */
.header-ping {
    position: relative;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.header-ping .orbit {
    position: absolute;
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.header-ping .orbit:nth-child(1) {
    width: 16px;
    height: 16px;
}

.header-ping .orbit:nth-child(2) {
    width: 26px;
    height: 26px;
    border-color: rgba(6, 182, 212, 0.12);
}

.header-ping .orbit:nth-child(3) {
    width: 36px;
    height: 36px;
    border-color: rgba(245, 158, 11, 0.1);
}

.header-ping .center-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    background: var(--gradient-orange);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.header-ping .ping-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border: 1px solid rgba(245, 158, 11, 0.6);
    border-radius: 50%;
    animation: ping 2s ease-out infinite;
}

.header-ping .ping-ring:nth-of-type(2) {
    animation-delay: 0.7s;
}

.header-ping .ping-ring:nth-of-type(3) {
    animation-delay: 1.4s;
}

@keyframes ping {
    0% {
        width: 6px;
        height: 6px;
        opacity: 1;
    }

    100% {
        width: 36px;
        height: 36px;
        opacity: 0;
    }
}

.header-title {
    font-size: 1.1rem;
    font-weight: 800;
    background: linear-gradient(135deg, #e8ecf4, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.nav-link {
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
    background: rgba(245, 158, 11, 0.1);
}

/* --- Hamburger Menu --- */
.hamburger-btn {
    display: block;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: var(--space-xs);
    line-height: 1;
    z-index: 1001;
    transition: transform var(--transition-fast);
}

.hamburger-btn:hover {
    transform: scale(1.1);
}

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    z-index: 999;
    transition: opacity var(--transition-base);
}

.nav-backdrop.open {
    display: block;
    opacity: 1;
}

/* Drawer */
.header-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: rgb(35, 32, 55);
    border-right: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
    padding: 70px var(--space-md) var(--space-lg);
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    z-index: 1000;
    overflow-y: auto;
}

.header-nav.open {
    transform: translateX(0);
}

.header-nav .nav-link {
    padding: var(--space-sm) var(--space-md);
    font-size: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- Footer --- */
.site-footer {
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: auto;
}

/* --- Hero Section --- */
.hero {
    text-align: center;
    padding: var(--space-2xl) 0 var(--space-lg);
}

.hero h1 {
    margin-bottom: var(--space-md);
}

.hero-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.8;
}

/* --- Stats Bar --- */
.stats-bar {
    display: flex;
    justify-content: center;
    gap: var(--space-2xl);
    padding: var(--space-lg) 0;
    margin-bottom: var(--space-xl);
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 1.8rem;
    font-weight: 800;
    background: var(--gradient-orange);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* --- Section --- */
.section {
    padding: var(--space-2xl) 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.section-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0;
}

.mt-sm {
    margin-top: var(--space-sm);
}

/* --- Cards --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.tech-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: all var(--transition-slow);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.tech-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.tech-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.tech-card[data-tech="register"]::before {
    background: var(--gradient-blue);
}

.tech-card[data-tech="search"]::before {
    background: var(--gradient-orange);
}

.tech-card[data-tech="api"]::before {
    background: var(--gradient-green);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
    margin-bottom: var(--space-md);
}

.card-meta {
    display: flex;
    gap: var(--space-md);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.card-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-blue);
    color: white;
    border: none;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    border-color: var(--accent-cyan);
    background: var(--bg-card-hover);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border-color: rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-lg {
    padding: var(--space-md) var(--space-xl);
    font-size: 1rem;
}

/* --- File Upload Area --- */
.file-upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-xl);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background: rgba(26, 32, 53, 0.5);
    transition: all var(--transition-base);
    cursor: pointer;
}

.file-upload-area:hover,
.file-upload-area.drag-over {
    border-color: var(--accent-yellow);
    background: rgba(245, 158, 11, 0.05);
}

.upload-icon {
    font-size: 2.5rem;
}

.upload-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Image Grid --- */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-md);
}

.image-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all var(--transition-base);
}

.image-card:hover {
    border-color: var(--border-glow);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.image-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    display: block;
}

.image-card-info {
    padding: var(--space-sm) var(--space-md);
}

.image-card-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-card-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 var(--space-sm) var(--space-sm);
}

.image-card-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.image-card-btn:hover {
    color: var(--accent-red);
    background: rgba(239, 68, 68, 0.1);
}

/* --- Search Results --- */
.results-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.result-item {
    display: flex;
    gap: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    transition: all var(--transition-base);
}

.result-item:hover {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-md);
}

.result-item.result-best {
    border-color: var(--accent-yellow);
    box-shadow: var(--shadow-md), 0 0 16px rgba(245, 158, 11, 0.15);
}

.result-item img {
    width: 160px;
    height: 120px;
    object-fit: cover;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: var(--space-sm);
}

.result-name {
    font-weight: 600;
    font-size: 1rem;
}

.result-score {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.score-bar {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}

.score-high {
    background: var(--accent-green);
}

.score-mid {
    background: var(--accent-yellow);
}

.score-low {
    background: var(--accent-red);
}

/* --- Camera Section --- */
.camera-container {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    max-width: 640px;
}

.camera-container video,
.camera-container canvas {
    width: 100%;
    display: block;
    border-radius: var(--radius-lg);
}

.camera-controls {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    justify-content: center;
}

/* --- Loading / Progress --- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 14, 26, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(245, 158, 11, 0.2);
    border-top-color: var(--accent-yellow);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-label {
    font-size: 0.9rem;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
}

.progress-bar {
    width: 300px;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-orange);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    z-index: 3000;
    transition: bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    white-space: nowrap;
}

.toast.show {
    bottom: var(--space-xl);
}

.toast-success {
    background: rgba(16, 185, 129, 0.9);
    color: white;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
}

.toast-error {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
}

.toast-info {
    background: rgba(59, 130, 246, 0.9);
    color: white;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.3);
}

/* --- Model Status Badge --- */
.model-status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 2px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.model-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.model-status.ready .dot {
    background: var(--accent-green);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.model-status.loading .dot {
    background: var(--accent-yellow);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-text {
    font-size: 0.95rem;
}

/* --- Roadmap --- */
.roadmap {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    padding-left: var(--space-lg);
    border-left: 2px solid var(--border-color);
}

.roadmap-item {
    position: relative;
    padding-left: var(--space-lg);
}

.roadmap-item::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--space-lg) - 5px);
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
}

.roadmap-item.done::before {
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.roadmap-item.current::before {
    background: var(--accent-yellow);
    border-color: var(--accent-yellow);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.roadmap-title {
    font-size: 1rem;
    margin-bottom: var(--space-xs);
}

.roadmap-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.roadmap-tag {
    display: inline-block;
    margin-top: var(--space-sm);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: var(--radius-sm);
}

.tag-now {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-yellow);
}

.tag-done {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.tag-future {
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
}

/* --- User Menu --- */
.user-menu {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-left: auto;
    margin-right: var(--space-md);
}

.user-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.user-logout-btn {
    font-size: 0.75rem !important;
    padding: 2px 10px !important;
}

/* --- Gallery --- */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-lg);
}

.gallery-grid.gallery-list {
    grid-template-columns: 1fr;
}

.gallery-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-base);
    cursor: pointer;
}

.gallery-card:hover {
    border-color: var(--accent-yellow);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), 0 0 20px rgba(245, 158, 11, 0.1);
}

.gallery-card-image {
    position: relative;
    overflow: hidden;
}

.gallery-card-image img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-slow);
}

.gallery-grid.gallery-list .gallery-card-image img {
    height: 160px;
}

.gallery-card:hover .gallery-card-image img {
    transform: scale(1.05);
}

.gallery-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 26, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-base);
}

.gallery-card:hover .gallery-card-overlay {
    opacity: 1;
}

.gallery-card-zoom {
    background: rgba(245, 158, 11, 0.9);
    color: #0a0e1a;
    padding: var(--space-xs) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
}

.gallery-card-footer {
    padding: var(--space-sm) var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
}

.gallery-card-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.gallery-card-size {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    white-space: nowrap;
}

.gallery-grid.gallery-list .gallery-card {
    display: grid;
    grid-template-columns: 200px 1fr;
}

.gallery-grid.gallery-list .gallery-card-footer {
    align-self: center;
    flex-direction: column;
    align-items: flex-start;
}

/* Gallery View Toggle */
.gallery-view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 2px;
}

.btn-view {
    padding: 4px 10px !important;
    font-size: 1rem !important;
    border: none !important;
    min-width: 36px;
    justify-content: center;
}

.btn-view.active {
    background: var(--accent-blue) !important;
    color: white !important;
}

/* Gallery Modal */
.gallery-modal {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.gallery-modal.open {
    opacity: 1;
    pointer-events: auto;
}

.gallery-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 26, 0.92);
    backdrop-filter: blur(8px);
}

.gallery-modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(59, 130, 246, 0.1);
    transform: scale(0.95);
    transition: transform var(--transition-slow);
}

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

.gallery-modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    transition: all var(--transition-fast);
}

.gallery-modal-close:hover {
    background: rgba(239, 68, 68, 0.5);
    transform: scale(1.1);
}

.gallery-modal-image-wrap {
    width: 100%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow: hidden;
}

.gallery-modal-image-wrap img {
    max-width: 100%;
    max-height: 60vh;
    object-fit: contain;
    display: block;
}

.gallery-modal-info {
    padding: var(--space-xl);
}

.gallery-modal-name {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--space-md);
    word-break: break-all;
}

.gallery-modal-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.gallery-modal-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.gallery-modal-actions {
    display: flex;
    justify-content: flex-end;
}

/* --- Query Preview (Search) --- */
.query-preview {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
}

.query-preview img {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 2px solid var(--accent-yellow);
}

.query-preview-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.query-preview-label strong {
    color: var(--accent-yellow);
}

/* --- No-match suggestion --- */
.no-match-suggestion {
    margin-top: var(--space-md);
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .stats-bar {
        gap: var(--space-lg);
        flex-wrap: wrap;
    }

    .result-item {
        flex-direction: column;
    }

    .result-item img {
        width: 100%;
        height: 200px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .gallery-grid.gallery-list .gallery-card {
        grid-template-columns: 1fr;
    }

    .gallery-modal-content {
        width: 95%;
    }

    .query-preview {
        flex-direction: column;
        text-align: center;
    }
}