:root {
    --bg-color: #ffffff;
    --text-color: #202124;
    --secondary-text: #4d5156;
    --link-color: #1a0dab;
    --url-color: #006621;
    --search-bg: #ffffff;
    --search-border: #dfe1e5;
    --search-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
    --btn-bg: #f8f9fa;
    --btn-hover: #e8eaed;
    --card-bg: #ffffff;
    --card-border: #ebebeb;
    --g-blue: #1f74fc;
    --g-red: #fd1904;
    --g-yellow: hsl(48, 100%, 1%);
    --g-green: hsl(66, 96%, 50%);
}

body.dark-mode {
    --bg-color: #202124;
    --text-color: #e8eaed;
    --secondary-text: #9aa0a6;
    --link-color: #8ab4f8;
    --url-color: #81c995;
    --search-bg: #303134;
    --search-border: #5f6368;
    --search-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    --btn-bg: #303134;
    --btn-hover: #3c4043;
    --card-bg: #292a2d;
    --card-border: #3c4043;
}

* { box-sizing: border-box; font-family: 'Roboto', Arial, sans-serif; margin: 0; padding: 0; }
body { background-color: var(--bg-color); color: var(--text-color); transition: 0.3s; display: flex; flex-direction: column; min-height: 100vh; }
.c-blue { color: var(--g-blue); } .c-red { color: var(--g-red); } .c-yellow { color: var(--g-yellow); } .c-green { color: var(--g-green); }

header {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    background-color: var(--bg-color);
    border-bottom: 1px solid transparent;
    transition: transform 0.3s ease;
}
.header-scrolled { box-shadow: 0 1px 5px rgba(0,0,0,0.05); border-bottom: 1px solid var(--search-border); }

.navbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 30px; height: 70px; }
.logo-small { font-size: 26px; font-weight: 700; text-decoration: none; letter-spacing: -1px; }
.nav-links { list-style: none; display: flex; gap: 25px; align-items: center; margin-right: 20px;}
.nav-links a { color: var(--text-color); text-decoration: none; font-size: 14px; font-weight: 500;}
.nav-links a:hover { text-decoration: underline; }
.nav-right-controls { display: flex; align-items: center; gap: 15px; }
.icon-btn { background: none; border: none; cursor: pointer; font-size: 20px; padding: 8px; border-radius: 50%; transition: 0.2s;}
.icon-btn:hover { background: var(--btn-hover); }
.ts1-btn svg { transition: transform 0.2s; }
.ts1-btn:hover svg { transform: scale(1.1); }
.hamburger { display: none; background: none; border: none; font-size: 24px; color: var(--text-color); cursor: pointer; }

main { flex-grow: 1; display: flex; flex-direction: column; align-items: center; width: 100%; padding-top: 70px; }
.hidden { display: none !important; }

.search-engine-layout { display: flex; flex-direction: column; align-items: center; width: 100%; margin-top: 15vh; transition: 0.4s ease-out; }
.search-engine-layout.results-active { margin-top: 0; align-items: flex-start; padding: 0; max-width: 100%; }
.results-active #main-logo { display: none; }

.search-container { width: 100%; max-width: 650px; display: flex; flex-direction: column; align-items: center; z-index: 999; }
.results-active .search-container { position: sticky; top: 70px; max-width: 100%; padding: 15px 5%; background-color: var(--bg-color); border-bottom: 1px solid var(--search-border); transition: top 0.3s ease; }

.logo-large { font-size: 85px; font-weight: 700; letter-spacing: -3px; margin-bottom: 30px; position: relative;}
.badge-ai { position: absolute; bottom: 10px; right: -35px; font-size: 16px; color: var(--g-blue); font-weight: bold; }

.search-bar-wrapper { display: flex; align-items: center; width: 100%; max-width: 800px; margin: 0 auto; background: var(--search-bg); border: 1px solid var(--search-border); border-radius: 24px; padding: 6px 15px 6px 20px; height: 52px; transition: 0.2s; }
.search-bar-wrapper:hover, .search-bar-wrapper:focus-within { box-shadow: var(--search-shadow); background-color: var(--bg-color); border-color: transparent;}
.search-icon { width: 22px; height: 22px; fill: #9aa0a6; margin-right: 12px; cursor: pointer; transition: 0.2s; }
.search-icon:hover { fill: var(--g-blue); }
#main-search-query { flex-grow: 1; border: none; background: transparent; outline: none; font-size: 16px; color: var(--text-color); }

.search-tabs { display: flex; gap: 20px; width: 100%; max-width: 800px; margin: 15px auto 0; border-bottom: 1px solid transparent; }
.tab-btn { background: none; border: none; padding: 10px 5px; color: var(--secondary-text); font-size: 14px; font-weight: 500; cursor: pointer; border-bottom: 3px solid transparent; transition: 0.2s; }
.tab-btn:hover { color: var(--g-blue); }
.tab-btn.active { color: var(--g-blue); border-bottom: 3px solid var(--g-blue); }
.tab-content { width: 100%; display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }

.profile-select { border: none; background: var(--btn-bg); color: var(--text-color); padding: 8px 12px; border-radius: 20px; font-size: 13px; font-weight: 500; cursor: pointer; outline: none; margin-right: 10px; transition: 0.2s; }
.profile-select:hover { background: var(--search-border); }
.voice-btn svg { transition: transform 0.2s; }
.voice-btn:hover svg { transform: scale(1.1); }
.listening { animation: pulseRed 1.5s infinite; background: rgba(234, 67, 53, 0.1) !important;}
@keyframes pulseRed { 0% { box-shadow: 0 0 0 0 rgba(234, 67, 53, 0.4); } 70% { box-shadow: 0 0 0 15px rgba(234, 67, 53, 0); } 100% { box-shadow: 0 0 0 0 rgba(234, 67, 53, 0); } }

.skeleton-box { width: 100%; height: 20px; background: linear-gradient(90deg, var(--btn-bg) 25%, var(--search-border) 50%, var(--btn-bg) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 4px; margin-bottom: 10px; }
.skeleton-title { width: 60%; height: 24px; margin-bottom: 15px; }
.skeleton-img { width: 120px; height: 120px; border-radius: 8px; flex-shrink: 0; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

#search-results-container { width: 100%; max-width: 900px; margin: 0 auto; padding: 20px 5%; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.autocomplete-items { position: absolute; top: 100%; left: 0; right: 0; z-index: 1001; background-color: var(--bg-color); border-radius: 0 0 16px 16px; box-shadow: 0 4px 6px rgba(32, 33, 36, 0.28); overflow: hidden; margin-top: 5px; border: 1px solid var(--search-border); border-top: none;}
.autocomplete-items div { padding: 12px 20px; cursor: pointer; display: flex; align-items: center; gap: 10px; color: var(--text-color); font-size: 15px; border-bottom: 1px solid var(--card-border);}
.autocomplete-items div:hover { background-color: var(--btn-hover); }

.ai-summary-card { background: linear-gradient(135deg, rgba(31, 116, 252, 0.05), rgba(52, 168, 83, 0.05)); border: 1px solid rgba(31, 116, 252, 0.3); border-radius: 12px; padding: 20px; margin-bottom: 30px; box-shadow: var(--shadow-sm); }
.ai-badge { font-weight: bold; color: var(--g-blue); margin-bottom: 12px; display: flex; align-items: center; font-size: 16px; }
.typing-text { font-size: 15px; line-height: 1.6; color: var(--text-color); }
.typing-text::after { content: '▋'; animation: blink 1s step-end infinite; color: var(--g-blue); }
@keyframes blink { 50% { opacity: 0; } }

.images-hub { display: flex; gap: 15px; margin-bottom: 30px; overflow-x: auto; padding-bottom: 15px; scroll-snap-type: x mandatory;}
.images-hub::-webkit-scrollbar { height: 6px; }
.images-hub::-webkit-scrollbar-thumb { background: var(--search-border); border-radius: 10px; }
.images-hub img { height: 160px; min-width: 160px; border-radius: 12px; object-fit: cover; box-shadow: 0 2px 6px rgba(0,0,0,0.1); scroll-snap-align: start; transition: 0.3s; cursor: pointer;}
.images-hub img:hover { transform: translateY(-4px); box-shadow: 0 6px 12px rgba(0,0,0,0.15);}

.full-images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; }
.full-images-grid img { width: 100%; height: 180px; object-fit: cover; border-radius: 10px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); cursor: pointer; transition: 0.2s;}
.full-images-grid img:hover { transform: scale(1.03); }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.video-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; overflow: hidden; box-shadow: 0 2px 4px rgba(0,0,0,0.05); transition: 0.2s; cursor: pointer; text-decoration: none;}
.video-card:hover { transform: translateY(-4px); box-shadow: var(--search-shadow); }
.video-thumbnail { width: 100%; height: 160px; object-fit: cover; position: relative;}
.video-info { padding: 15px; }
.video-title { font-size: 15px; font-weight: bold; color: var(--text-color); margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;}
.video-channel { font-size: 12px; color: var(--secondary-text); }

.search-result { margin-bottom: 35px; }
.search-result .source { color: var(--text-color); font-size: 13px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px;}
.search-result h3 { margin: 0 0 8px 0; font-size: 20px; font-weight: 400; line-height: 1.3;}
.search-result h3 a { color: var(--link-color); text-decoration: none; }
.search-result h3 a:hover { text-decoration: underline; }
.snippet-container { display: flex; gap: 20px; align-items: flex-start;}
.search-result p { color: var(--secondary-text); font-size: 14px; line-height: 1.6; flex-grow: 1; margin: 0;}
.search-result .thumbnail { width: 110px; height: 110px; border-radius: 8px; object-fit: cover; border: 1px solid var(--search-border); }

.result-actions { margin-top: 12px; display: flex; gap: 10px; }
.result-actions button { background: var(--btn-bg); border: 1px solid var(--search-border); color: var(--text-color); cursor: pointer; font-size: 13px; padding: 6px 12px; border-radius: 16px; transition: 0.2s;}
.result-actions button:hover { background: var(--btn-hover); }

.pagination { display: flex; justify-content: center; gap: 10px; margin-top: 40px; margin-bottom: 20px; border-top: 1px solid var(--card-border); padding-top: 20px;}
.page-btn { background: var(--bg-color); border: 1px solid var(--search-border); color: var(--text-color); width: 40px; height: 40px; border-radius: 50%; font-size: 15px; cursor: pointer; transition: 0.2s; display: flex; justify-content: center; align-items: center;}
.page-btn:hover { background: var(--btn-hover); }
.page-btn.active { background: var(--g-blue); color: white; border-color: var(--g-blue); font-weight: bold;}

.dashboard-section { width: 100%; max-width: 850px; margin: 30px auto; padding: 0 20px; animation: fadeIn 0.4s ease; }
.back-btn { background: none; border: none; color: var(--secondary-text); font-size: 15px; cursor: pointer; margin-bottom: 20px; font-weight: 500; transition: 0.2s; }
.back-btn:hover { color: var(--link-color); }
.profile-card { background: var(--card-bg); border-radius: 16px; border: 1px solid var(--card-border); overflow: hidden; box-shadow: var(--search-shadow); text-align: center; padding-bottom: 30px; }
.profile-banner { height: 120px; background: linear-gradient(135deg, var(--g-blue), var(--g-green)); }
.profile-avatar-large { font-size: 60px; background: var(--bg-color); width: 100px; height: 100px; margin: -50px auto 10px; border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 6px rgba(0,0,0,0.1); border: 4px solid var(--card-bg); }
.profile-card h2 { margin: 0; font-size: 24px; color: var(--text-color); }
.profile-subtitle { color: var(--secondary-text); margin-bottom: 25px; font-size: 14px; margin-top: 5px; }

.profile-form { max-width: 400px; margin: 0 auto; text-align: left; padding: 0 20px;}
.input-group { margin-bottom: 20px; }
.input-group label { display: block; font-size: 13px; font-weight: bold; color: var(--secondary-text); margin-bottom: 8px; }
.input-group input, .input-group select { width: 100%; padding: 12px; border: 1px solid var(--search-border); border-radius: 8px; background: var(--bg-color); color: var(--text-color); font-size: 15px; transition: 0.2s;}
.input-group input:focus, .input-group select:focus { border-color: var(--g-blue); outline: none; }
.cta-button-large { width: 100%; background: var(--g-blue); color: white; padding: 14px; border: none; border-radius: 8px; font-weight: bold; font-size: 15px; cursor: pointer; transition: 0.2s; }

.dashboard-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 30px; border-bottom: 1px solid var(--search-border); padding-bottom: 15px; }
.clear-btn { background: var(--btn-bg); color: var(--g-red); border: 1px solid var(--search-border); padding: 8px 15px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: bold; transition: 0.2s; }

.favorites-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.favorite-card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; transition: 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.favorite-card:hover { transform: translateY(-4px); box-shadow: var(--search-shadow); }
.fav-title { font-size: 16px; font-weight: bold; color: var(--g-blue); text-decoration: none; margin-bottom: 10px; display: block; line-height: 1.4; }
.fav-snippet { font-size: 13px; color: var(--secondary-text); margin-bottom: 15px; line-height: 1.5; flex-grow: 1; }
.fav-actions { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--search-border); padding-top: 10px; }

.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px; padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; transition: 0.2s; }
.timeline-item:hover { background: var(--btn-hover); }
.timeline-content strong { font-size: 16px; display: block; margin-bottom: 4px; color: var(--text-color);}
.timeline-content small { color: var(--secondary-text); font-size: 12px; font-weight: 500;}

.delete-item-btn { background: none; border: none; font-size: 16px; cursor: pointer; opacity: 0.6; transition: 0.2s; }
.delete-item-btn:hover { opacity: 1; transform: scale(1.2); }

.ts1-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 3000; display: flex; justify-content: center; align-items: center; }
.ts1-modal-content { background: var(--bg-color); width: 90%; max-width: 500px; padding: 20px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); border: 1px solid var(--search-border); }
.ts1-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.ts1-header h3 { margin: 0; color: var(--g-blue); font-size: 18px; }
.close-btn { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-color); }
#ts1-input { width: 100%; height: 120px; padding: 12px; border: 1px solid var(--search-border); border-radius: 8px; background: var(--btn-bg); color: var(--text-color); margin-bottom: 15px; resize: none; font-size: 15px; }
.ts1-controls { display: flex; gap: 10px; margin-bottom: 15px; }
.ts1-controls select { flex-grow: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--search-border); background: var(--bg-color); color: var(--text-color); }
.ts1-submit-btn { padding: 10px 20px; border-radius: 8px; border: none; background: var(--g-blue); color: white; cursor: pointer; font-weight: bold; }
.ts1-result { min-height: 80px; padding: 15px; background: var(--btn-bg); border-radius: 8px; border: 1px solid var(--search-border); font-size: 15px; color: var(--text-color); white-space: pre-wrap; line-height: 1.5; }

footer { background: var(--bg-color); color: var(--secondary-text); padding: 20px; text-align: center; font-size: 13px; margin-top: auto;}

@media (max-width: 768px) {
    .nav-links { display: none; flex-direction: column; position: absolute; top: 70px; right: 20px; background: var(--card-bg); width: 220px; border: 1px solid var(--card-border); border-radius: 12px; box-shadow: var(--search-shadow); padding: 20px; z-index: 100;}
    .nav-links.show { display: flex; }
    .hamburger { display: block; }
    .logo-large { font-size: 60px; }
    .search-bar-wrapper { flex-wrap: wrap; height: auto; padding: 10px 15px; border-radius: 18px; }
    #main-search-query { width: 100%; margin-bottom: 10px; }
    .profile-select { width: 100%; margin-bottom: 10px; margin-right: 0;}
    .snippet-container { flex-direction: column; }
    .search-result .thumbnail { width: 100%; height: 180px; }
    .results-active .search-container { top: 60px; }
}