:root {
    --bg-page: #0f0f12; --bg-header: #16161a; --bg-card: #1c1c21; --bg-subcard: #25252b;
    --accent: #4fa3e0; --success: #2ecc71; --text: #e0e0e0; --gold: #f1c40f; --tab-inactive: #2a2a30;
}

body { font-family: 'Segoe UI', sans-serif; background: var(--bg-page); color: var(--text); margin: 0; padding-bottom: 60px; }

/* Header Layout */
.header-container { 
    position: sticky; top: 0; z-index: 1000;
    background: var(--bg-header); 
    padding: 10px 40px 0 40px; 
    border-bottom: 2px solid #2d2d35; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.top-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding-bottom: 10px; }

.title-side h1 { margin: 0 0 5px 0; font-size: 1.4rem; color: var(--gold); }
.tabs { display: flex; gap: 3px; }
.tab-btn { 
    padding: 8px 15px; border: none; background: var(--tab-inactive); color: #888; 
    cursor: pointer; border-radius: 6px 6px 0 0; font-weight: bold; transition: 0.2s;
    border-bottom: 2px solid transparent;
}
.tab-btn.active { background: var(--bg-page); color: var(--accent); border-bottom: 2px solid var(--accent); }

.search-wrapper { position: relative; flex-grow: 1; max-width: 500px; margin-bottom: 5px; }
#searchBar { 
    width: 100%; padding: 10px 40px 10px 15px; border-radius: 20px; 
    border: 1px solid #444; background: #121212; color: white; outline: none; box-sizing: border-box;
}
.clear-search { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: #333; color: #888; border: none; border-radius: 50%; width: 22px; height: 22px; cursor: pointer; display: none; align-items: center; justify-content: center; z-index: 2; }

/* Utilities & Buttons */
.nav-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.btn { padding: 8px 12px; border-radius: 6px; border: 1px solid #444; background: #2a2a30; color: white; cursor: pointer; font-size: 0.8rem; }
.btn.active-filter { background: var(--accent); border-color: white; }

/* NEW: Wider Uncollected Button */
#filterBtn {
    min-width: 180px;
    font-weight: bold;
}

.group-sep { width: 1px; height: 25px; background: #444; margin: 0 5px; }

#global-container { text-align: right; margin-right: 15px; width: 250px; }
#global-container > div:last-child {
    width: 100%; height: 12px; background: #222; border-radius: 6px;
    overflow: hidden; border: 1px solid #444; margin-top: 4px;
}

/* Grid & Card Layout */
#main-content { padding: 20px 40px; }
.grandparent-section { margin-top: 20px; background: var(--bg-card); padding: 20px; border-radius: 12px; border: 1px solid #2d2d35; }
.grandparent-header { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding-bottom: 10px; }
.grandparent-section.collapsed .grid { display: none !important; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 20px; margin-top: 15px; }
.category-card { background: var(--bg-subcard); padding: 18px; border-radius: 10px; border: 1px solid #333; }
.category-card.completed { border-color: var(--success); }

/* Card Spans for Royal Archivist etc. */
.category-card.span-2 { grid-column: span 2; }
.category-card.span-3 { grid-column: span 3; }
.category-card.span-4 { grid-column: span 4; }

h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 15px 0; font-size: 1.1rem; color: var(--gold); }
.p-title-box { display: flex; align-items: center; gap: 12px; }

/* Multi-Column Logic */
.item-list-compact { display: block !important; column-gap: 20px; width: 100%; }
.category-card.span-2 .item-list-compact { column-count: 2; }
.category-card.span-3 .item-list-compact { column-count: 3; }
.category-card.span-4 .item-list-compact { column-count: 4; }

/* Items - RESTORED SIZES from Old Code */
.item { position: relative; display: flex; align-items: center; padding: 8px; margin: 5px 0; border-radius: 6px; break-inside: avoid; }
.item:hover { background: rgba(255, 255, 255, 0.05); }
.item-content { display: flex; align-items: center; gap: 15px; pointer-events: none; font-size: 1rem; }
.item-content span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.click-target { position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: pointer; z-index: 1; }

/* Icons - RESTORED SIZES from Old Code */
.framed-icon { border: 1px solid #444; background: #000; border-radius: 5px; object-fit: cover; }
.bold-frame { border: 2px solid #555; width: 48px; height: 48px; box-shadow: 0 0 5px rgba(0,0,0,0.5); }
.p-icon-large { width: 42px; height: 42px; }
.item-icon { width: 40px; height: 40px; }

/* Progress Bars */
.sec-progress-container { width: 180px; height: 8px; background: #222; border-radius: 4px; overflow: hidden; margin-top: 5px; border: 1px solid #444; }
.sec-bar { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s; }

.reset-btn { font-size: 0.7rem; color: #ff6b6b; cursor: pointer; background: none; border: 1px solid #ff6b6b; padding: 2px 6px; border-radius: 4px; margin-top: 5px; }
.reset-btn:hover { background: #ff6b6b; color: white; }

footer { text-align: center; padding: 60px 40px; color: #444; font-size: 0.9rem; border-top: 1px solid #1a1a1e; margin-top: 40px; }
#backToTop { position: fixed; bottom: 25px; right: 25px; display: none; width: 45px; height: 45px; background: var(--accent); color: white; border-radius: 50%; cursor: pointer; border: none; z-index: 2000; font-weight: bold; }

/* When the whole Grandparent section is 100% complete */
.grandparent-section.all-complete {
    background: #1e2a24; /* Subtle dark green tint */
    border-color: var(--success);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.1);
    transition: all 0.4s ease;
}

/* Optional: Make the header text gold or green when finished */
.grandparent-section.all-complete h2 {
    color: var(--success);
}