:root {
    /* Warm Creme & Brown Palette */
    --bg-color: #F7F3F0; /* Soft Creme */
    --bg-accent: #EFE9E4; 
    --text-dark: #3E2F28; /* Dark Cocoa */
    --text-light: #6D5B52; /* Muted Umber */
    --accent-color: #A68A64; /* Antique Gold/Brown */
    
    /* Glassmorphism Variables */
    --glass-bg: rgba(255, 255, 255, 0.4);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-highlight: rgba(255, 255, 255, 0.8);
    --liquid-shadow: 0 30px 60px rgba(62, 47, 40, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background: radial-gradient(circle at top left, #FDFCFB 0%, #F7F3F0 100%);
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text-dark);
    line-height: 1.7;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Glass Header --- */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px) saturate(180%);
    -webkit-backdrop-filter: blur(12px) saturate(180%);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

.home-btn {
    background: rgba(255, 255, 255, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    border-radius: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.home-btn:hover {
    background: var(--glass-highlight);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    color: var(--accent-color);
}

header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.02em;
}

/* --- Glass Search Bar & Dropdown --- */
.search-container {
    flex: 0 1 400px;
    position: relative;
}

.search-bar {
    width: 100%;
    padding: 12px 24px;
    border-radius: 100px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.2);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-dark);
    outline: none;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    backdrop-filter: blur(4px);
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.05),
        0 1px 0 rgba(255, 255, 255, 0.6);
}

.search-bar:focus {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--accent-color);
    box-shadow: 
        0 0 0 4px rgba(166, 138, 100, 0.1),
        inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: 100%;
    background: var(--glass-highlight);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--liquid-shadow);
    overflow: hidden;
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.dropdown-item {
    padding: 12px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
    background: transparent;
    border-left: none; border-right: none; border-top: none;
    font-family: inherit;
    width: 100%;
}

.dropdown-item:hover {
    background: rgba(255, 255, 255, 0.9);
}

.see-more-btn {
    padding: 12px;
    background: rgba(166, 138, 100, 0.1);
    color: var(--accent-color);
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.see-more-btn:hover {
    background: var(--accent-color);
    color: #fff;
}

/* --- Search Result Elements --- */
.result-excerpt {
    font-size: 0.9rem;
    color: var(--text-dark);
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.result-docname {
    font-size: 0.75rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

mark {
    background-color: rgba(166, 138, 100, 0.3);
    color: var(--text-dark);
    border-radius: 2px;
    padding: 0 2px;
    font-weight: 600;
}

/* --- Main Content --- */
main {
    max-width: 1300px;
    margin: 0 auto;
    padding: 5rem 2rem;
}

.intro-section {
    text-align: center;
    margin-bottom: 5rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.intro-section h2, .results-header-section h2 {
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
    font-weight: 700;
    font-style: italic;
}

.intro-section p {
    font-size: 1.1rem;
    color: var(--text-light);
    margin-bottom: 1.5rem;
    font-weight: 400;
}

.divider {
    width: 60px;
    height: 3px;
    background: var(--accent-color);
    margin: 3rem auto;
    border-radius: 2px;
    opacity: 0.6;
}

/* --- The Liquid Glass Iframe --- */
.tree-viewer {
    perspective: 1000px;
}

.tree-container {
    width: 100%;
    height: 85vh;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 40px;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 
        var(--liquid-shadow), 
        inset 0 2px 15px rgba(255, 255, 255, 0.8),
        inset 0 -2px 10px rgba(0, 0, 0, 0.03);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

iframe {
    width: 100%;
    height: 100%;
    border: none;
    opacity: 1; 
    display: block;
}

/* --- Full Search Results View --- */
.results-header-section {
    text-align: center;
    margin-bottom: 2rem;
}
.page-search-bar {
    max-width: 600px;
    margin: 0 auto;
    display: block;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.result-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 1.25rem;
    border-radius: 16px;
    cursor: pointer;
    text-align: left;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
}

.result-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.05);
    background: var(--glass-highlight);
    border-color: var(--accent-color);
}

/* --- Split Screen Layout (Viewer) --- */
#app-container {
    display: none;
    height: calc(100vh - 75px); /* Minus header */
    width: 100vw;
}

/* Left Side: Images */
#left-panel {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-accent);
    padding: 2rem;
    border-right: 1px solid rgba(0,0,0,0.05);
    position: relative;
    box-shadow: inset -5px 0 15px rgba(0,0,0,0.02);
}

.back-btn {
    display: inline-block;
    margin-bottom: 2rem;
    padding: 0.6rem 1.2rem;
    background: var(--glass-bg);
    color: var(--text-dark);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s;
}
.back-btn:hover {
    background: var(--glass-highlight);
    border-color: var(--accent-color);
}

.image-container {
    margin-bottom: 3rem;
    text-align: center;
}
.image-container img {
    max-width: 100%;
    height: auto;
    border: 3px solid transparent;
    transition: border 0.3s, transform 0.3s;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.image-container.active img {
    border: 3px solid var(--accent-color);
    transform: scale(1.02);
}
.image-name {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.75rem;
    font-weight: 500;
}

/* Right Side: Transcription */
#right-panel {
    flex: 1;
    background: var(--bg-color);
    color: var(--text-dark);
    overflow: hidden;
    position: relative;
    scroll-behavior: smooth;
}

#transcription-content {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 3rem;
    font-family: 'Courier New', Courier, monospace; 
    font-size: 1.1rem;
    line-height: 1.6;
    white-space: pre; 
    overflow: auto;
    cursor: grab;
    scrollbar-width: none;
    -ms-overflow-style: none;
    color: var(--text-dark);
}
#transcription-content::-webkit-scrollbar {
    display: none;
}
#transcription-content:active {
    cursor: grabbing;
}

#loading-text {
    display: none;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    header { padding: 1rem 1.5rem; }
    .search-container { display: none; }
    .intro-section h2, .results-header-section h2 { font-size: 2.2rem; }
    .tree-container { height: 70vh; border-radius: 24px; }
    main { padding: 3rem 1.25rem; }
    #app-container { flex-direction: column; height: auto; }
    #left-panel, #right-panel { height: 50vh; flex: none; border-right: none; border-bottom: 1px solid rgba(0,0,0,0.05); }
}