:root {
    --app-height: 100dvh;
    --nav-height: 70px; 
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

body {
    background-color: #f8fafc;
    color: #1e293b;
    font-family: 'Sarabun', sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    height: var(--app-height);
    width: 100%;
    overflow: hidden;
    position: fixed;
}

.dark body { background-color: #0B1120; color: #f1f5f9; }
.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.physics-scroll {
    display: flex;
    gap: 1rem;
    cursor: grab;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}
.physics-scroll > * { scroll-snap-align: center; }

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#main-view {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 20px);
    opacity: 0;
    transition: opacity 0.2s ease;
    -webkit-overflow-scrolling: touch;
}
#main-view.loaded { opacity: 1; }

.glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
}
.dark .glass {
    background: rgba(11, 17, 32, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.header-bg { transition: all 0.3s ease; }
.header-scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.dark .header-scrolled {
    background: rgba(11, 17, 32, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.safe-bottom { padding-bottom: var(--safe-area-bottom); }
.prose p { margin-bottom: 0.8rem; }
.prose strong { color: #C5A059; font-weight: 700; }
.prose ul { list-style-type: disc; padding-left: 1.5rem; margin-top: 0.5rem; }

/* Styles for the thumbnail gallery */
.thumb-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.thumb-scroll::-webkit-scrollbar { display: none; }
.thumb-item {
    width: 60px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    opacity: 0.6;
    transition: all 0.2s;
    border: 2px solid transparent;
}
.thumb-item.active {
    opacity: 1;
    border-color: #C5A059;
}
.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gallery Swipe Styles */
.gallery-swipe {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; 
    width: 100%;
    height: 100%;
}
.gallery-swipe::-webkit-scrollbar { display: none; }
.gallery-swipe > * {
    scroll-snap-align: center;
    flex-shrink: 0;
    width: 100%;
    height: 100%;
}

/* Height Transition for Loan Modal */
.transition-height {
    transition: height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
:root {
    --app-height: 100dvh;
    --nav-height: 70px; 
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
}

body {
    background-color: #f8fafc;
    color: #1e293b;
    font-family: 'Sarabun', sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    height: var(--app-height);
    width: 100%;
    overflow: hidden;
    position: fixed;
}

.dark body { background-color: #0B1120; color: #f1f5f9; }

/* Hide Scrollbar but allow scrolling */
.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Physics Scroll for Horizontal Lists */
.physics-scroll {
    display: flex;
    gap: 1rem;
    cursor: grab;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}
.physics-scroll > * { scroll-snap-align: center; }

#app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#main-view {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    /* Adjusted padding to ensure content isn't hidden behind the floating buttons */
    padding-bottom: calc(var(--nav-height) + var(--safe-area-bottom) + 60px); 
    opacity: 0;
    transition: opacity 0.2s ease;
    -webkit-overflow-scrolling: touch;
}
#main-view.loaded { opacity: 1; }

/* Glassmorphism Effect */
.glass {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, 0.5);
}
.dark .glass {
    background: rgba(11, 17, 32, 0.85);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Header Transition */
.header-bg { transition: all 0.3s ease; }
.header-scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.dark .header-scrolled {
    background: rgba(11, 17, 32, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Text Truncation */
.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Typography & Helpers */
.safe-bottom { padding-bottom: var(--safe-area-bottom); }
.prose p { margin-bottom: 0.8rem; }
.prose strong { color: #C5A059; font-weight: 700; }
.prose ul { list-style-type: disc; padding-left: 1.5rem; margin-top: 0.5rem; }

/* Styles for the thumbnail gallery */
.thumb-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.thumb-scroll::-webkit-scrollbar { display: none; }
.thumb-item {
    width: 60px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    opacity: 0.6;
    transition: all 0.2s;
    border: 2px solid transparent;
}
.thumb-item.active {
    opacity: 1;
    border-color: #C5A059;
}
.thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
