:root {
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --secondary-color: #ec4899;
    /* Pink 500 */
    --secondary-hover: #db2777;
    /* Pink 600 */
    --bg-color: #0f172a;
    /* Slate 900 */
    --card-bg: #1e293b;
    /* Slate 800 */
    --text-main: #f8fafc;
    /* Slate 50 */
    --text-muted: #94a3b8;
    /* Slate 400 */
    --border-color: #334155;
    /* Slate 700 */
    --accent-glow: rgba(99, 102, 241, 0.3);
    --font-family: 'Outfit', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.hidden {
    display: none !important;
}

.no-transition {
    transition: none !important;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    /* For pseudo-element positioning */
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: var(--bg-custom-dark);
    /* Fallback if JS hasn't run yet */
    background-color: var(--bg-color);
    pointer-events: none;
    transition: background 0.0s ease;
}

body.light-mode::before {
    background: var(--bg-custom-light);
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

header {
    text-align: center;
    margin-bottom: 0.1rem;
}

h1 {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -1px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* Search Section */
.search-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    margin-bottom: 1.0rem;
}

input[type="text"] {
    width: 100%;
    padding: 1rem 1.5rem;
    font-size: 1.2rem;
    background-color: var(--bg-color);
    border: 3px solid var(--border-color);
    border-radius: 0.75rem;
    color: var(--text-main);
    font-family: var(--font-family);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* Suggestions Dropdown */
.input-wrapper {
    position: relative;
    width: 100%;
}

.suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0 0 0.75rem 0.75rem;
    border-top: none;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 50;
    margin-top: 0;
    overflow: hidden;
}

.suggestions-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.suggestion-item {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    color: var(--text-main);
}

.suggestion-item:hover,
.suggestion-item.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.search-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

button {
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    border: none;
    border-radius: 0.75rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    transition: all 0.1s ease;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.secondary-btn {
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-muted);
}

.secondary-btn:hover {
    border-color: var(--text-muted);
    color: var(--text-main);
}

/* Search Actions Toggle Behavior - Matching Tabs */
.search-actions button {
    /* Base style (inactive) - looks like tab-btn */
    background-color: transparent !important;
    border: none !important;
    color: var(--text-muted) !important;
    box-shadow: none !important;
    border-radius: 0.5rem !important;
    padding: 0.5rem 1rem !important;
}

.search-actions button:hover {
    background-color: #ffffca !important;
    color: black !important;
    transform: none !important;
    border: none !important;
}

.search-actions button.active {
    /* Active style - looks like tab-btn.active */
    background-color: #fef08a !important;
    /* Pastel Yellow */
    color: #1e293b !important;
    /* Dark text */
    font-weight: 700 !important;
    border: none !important;
    box-shadow: none !important;
}

.search-actions button.active:hover {
    background-color: #fef08a !important;
}

.sort-btn:hover {
    background-color: #bfdbfe;
}

/* Results Section */
#results-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 60vh;
}

#results-container.hidden {
    display: none;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tabs {
    display: flex;
    gap: 0.5rem;
}

.tab-btn {
    background: none;
    color: var(--text-muted);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
}

.tab-btn.active {
    background-color: #fef08a;
    /* Pastel Yellow */
    color: #1e293b;
    /* Dark text */
    font-weight: 700;
}

.tab-btn:hover:not(.active) {
    color: black;
    background-color: #ffffca;
}

/* Theme Variables */
.light-mode {
    --bg-color: #f8fafc;
    /* Slate 50 */
    --card-bg: #ffffff;
    /* White */
    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --border-color: #e2e8f0;
    /* Slate 200 */
    --accent-glow: rgba(99, 102, 241, 0.15);
}

/* Header & Theme Toggle */
.header-top {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
    margin-bottom: -2rem;
    position: relative;
    z-index: 10;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.1s;
}

.icon-btn:hover {
    background-color: var(--card-bg);
    color: var(--primary-color);
}


.sun-icon {
    display: block;
}

.moon-icon {
    display: none;
}

body.light-mode .sun-icon {
    display: none;
}

body.light-mode .moon-icon {
    display: block;
}

/* Controls Bar */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--card-bg);
    padding: 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.sort-controls::-webkit-scrollbar {
    display: none;
}

.sort-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

.sort-btn {
    background-color: var(--card-bg);
    color: var(--text-muted);
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
}

.sort-btn.active {
    background-color: #bfdbfe;
    /* Pastel Blue */
    color: #1e293b;
    /* Dark text */
    font-weight: 700;
    border-color: #bfdbfe;
}

/* Definitions Content */
#definitions-content {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#definitions-content.hidden {
    display: none;
}

#lyrics-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.def-list {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.def-item {
    padding-left: 1rem;
    border-left: 3px solid var(--primary-color);
    color: var(--text-main);
}

.wiktionary-link {
    display: inline-block;
    margin-top: 1rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.wiktionary-link:hover {
    text-decoration: underline;
}

/* Results List */
.results-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.result-item {
    background-color: var(--card-bg);
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    /* Higher contrast border for results */
    border-color: rgba(148, 163, 184, 0.4);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: transform 0.2s;
    cursor: pointer;
}

.result-item:hover {
    border-color: var(--primary-color);
}

.result-item.has-definition:hover {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.result-item.has-definition:active {
    outline: 2px solid var(--primary-hover);
    outline-offset: 1px;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.4);
    transform: scale(0.98);
}

.result-item.strength-100 {
    background-color: rgba(16, 185, 129, 0.35);
    border-color: rgba(16, 185, 129, 0.5);
}

.result-item.strength-96 {
    background-color: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.4);
}

.result-item.strength-92 {
    background-color: rgba(16, 185, 129, 0.18);
    border-color: rgba(16, 185, 129, 0.3);
}

.result-item.strength-86 {
    background-color: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.25);
}

.result-item.strength-80 {
    background-color: rgba(16, 185, 129, 0.07);
    border-color: rgba(16, 185, 129, 0.2);
}

body.light-mode .result-item.strength-100 {
    background-color: rgba(16, 185, 129, 0.4);
}

body.light-mode .result-item.strength-96 {
    background-color: rgba(16, 185, 129, 0.3);
}

body.light-mode .result-item.strength-92 {
    background-color: rgba(16, 185, 129, 0.22);
}

body.light-mode .result-item.strength-86 {
    background-color: rgba(16, 185, 129, 0.17);
}

body.light-mode .result-item.strength-80 {
    background-color: rgba(16, 185, 129, 0.12);
}

.word-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.word {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Allow wrapping for lyrics titles */
#lyrics-content .word {
    white-space: normal;
    overflow: visible;
}

.syllables {
    font-size: 0.85rem;
    color: var(--text-muted);
    background-color: var(--bg-color);
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
}

.definition {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-style: italic;
}

#loading-indicator {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

#error-message {
    color: #ef4444;
    text-align: center;
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 0.5rem;
}

/* Mobile Responsiveness Updates */
@media (max-width: 600px) {
    .results-list {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    .sort-btn {
        flex-shrink: 0;
    }

    .view-controls {
        padding-left: 0.5rem;
    }

    /* Mobile Search Actions */
    .search-actions {
        flex-wrap: wrap;
    }

    .search-actions button {
        padding: 0.5rem 0.1rem !important;
        /* So that all the options fit on one line */
        font-size: 0.9rem;
        flex: 1 1 auto;
        /* Allow buttons to shrink/grow */
    }

    /* Mobile Tabs */
    .tabs {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
        /* Smooth scrolling on iOS */
    }

    /* Hide scrollbar for tabs but keep functionality */
    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tabs {
        -ms-overflow-style: none;
        /* IE and Edge */
        scrollbar-width: none;
        /* Firefox */
    }
}

.syllable-section {
    grid-column: 1 / -1;
    /* Span all columns in grid layout */
    margin-top: 1rem;
}

.syllable-header {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border-color);
}

.syllable-header-clickable {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: color 0.2s ease;
}

.syllable-header-clickable:hover {
    color: var(--primary-hover);
}

.accordion-icon {
    transition: transform 0.3s ease;
}

.syllable-section.expanded .accordion-icon {
    transform: rotate(180deg);
}

.syllable-section-content {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.syllable-section-content.collapsed {
    display: none;
}

.word-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: color 0.1s;
}

.word-link:hover .word {
    color: var(--primary-color);
    text-decoration: underline;
}

.logo-link {
    display: inline-block;
    cursor: pointer;
}

.logo-link:hover {
    transform: scale(1.02);
}

/* Lyrics Match Highlighting */
.lyric-match {
    font-weight: bold;
    color: #60a5fa;
    /* Blue 400 */
}

body.light-mode .lyric-match {
    color: #2563eb;
    /* Blue 600 */
}

/* Footer Links */
#main-footer {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-muted);
}

.footer-links {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    margin: 0 0.5rem;
    transition: color 0.1s;
}

.footer-links a:hover {
    color: var(--primary-color);
}

.lyricfind-ack {
    margin-top: 10px;
    color: grey;
}

/* Lyrics Cards - Minimal Version */
.lyrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.lyrics-section {
    margin-bottom: 2rem;
}

.lyrics-section-header {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.lyric-card {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    overflow: hidden;
}

.lyric-card:hover {
    border-color: var(--primary-color);
}

.lyric-artist-section {
    flex-shrink: 0;
    width: 120px;
    padding: 1rem 1rem 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--border-color);
    background: rgba(99, 102, 241, 0.05);
}

.artist-avatar,
.artist-avatar-fallback {
    width: 90px;
    height: 90px;
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.artist-avatar {
    object-fit: cover;
}

.artist-avatar-fallback {
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
}

.artist-name {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    word-wrap: break-word;
    margin-top: 0.5rem;
}

.artist-metadata {
    display: flex;
    gap: 0.3rem;
    font-size: 0.75rem;
    margin-top: auto;
}

.metadata-badge {
    padding: 0.1rem 0.3rem;
    background: var(--bg-color);
    border-radius: 0.25rem;
}

.lyric-content-link,
.lyric-content-section {
    flex: 1;
    padding: 1rem;
    text-decoration: none;
    color: inherit;
}

.lyric-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    word-wrap: break-word;
}

.lyric-excerpt {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Related Words Card - Below results */
.related-words-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.5rem;
    margin: 3rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .related-words-card {
        padding: 1rem;
        margin: 2rem 0;
    }
}

.related-words-header {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.related-words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.related-word-chip {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    color: var(--text-main);
    text-decoration: none;
    transition: all 0.1s ease;
    cursor: pointer;
}

.related-word-chip:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

/* Drawer Overlay */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.15);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    overscroll-behavior: contain;
}

.drawer-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

/* Definition Drawer */
.definition-drawer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border-radius: 1rem 1rem 0 0;
    box-shadow: 0 -10px 25px -5px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    height: 35vh;
    display: flex;
    flex-direction: column;
    overscroll-behavior: contain;
}

@media (min-width: 769px) {
    .definition-drawer {
        height: 50vh;
    }
}

.definition-drawer:not(.hidden) {
    transform: translateY(0);
}

.drawer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.drawer-word {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.drawer-word-clickable {
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s ease;
}

.drawer-word-clickable:hover {
    color: var(--primary-color);
}

.drawer-potencia {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 600;
    color: #000;
    background: var(--primary-color);
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    margin-left: 0.5rem;
    text-decoration: none;
    cursor: default;
}

.drawer-word:active {
    color: var(--primary-hover);
}

.drawer-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drawer-close-btn:hover {
    color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
}

.drawer-body {
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1 1 auto;
    position: relative;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

#drawer-definitions {
    min-height: 100%;
}

#drawer-definitions ul {
    list-style-type: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
    padding: 0;
}

#drawer-definitions li {
    padding-left: 1rem;
    border-left: 3px solid var(--primary-color);
    color: var(--text-main);
    line-height: 1.6;
}


/* Drawer Tabs */
.drawer-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.drawer-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.drawer-tabs {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
    overflow-x: auto;
    padding: 0.25rem 0;
    scrollbar-width: thin;
    max-width: 400px;
}

/* Mobile: Force two rows */
@media (max-width: 768px) {
    .drawer-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .drawer-header-top {
        justify-content: space-between;
        width: 100%;
    }

    .drawer-tabs {
        width: 100%;
        max-width: none;
        justify-content: space-around;
    }

    .drawer-tab-btn {
        flex: 1;
        min-width: 60px;
    }
}

/* Desktop: One row */
@media (min-width: 769px) {
    .drawer-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .drawer-header-top {
        display: contents;
    }

    .drawer-word {
        order: 1;
        flex-shrink: 0;
    }

    .drawer-tabs {
        order: 2;
        flex-shrink: 0;
        margin-left: auto;
        margin-right: 1rem;
    }

    .drawer-close-btn {
        order: 3;
        flex-shrink: 0;
    }
}

.drawer-tabs::-webkit-scrollbar {
    height: 4px;
}

.drawer-tabs::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

.drawer-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.25rem 0.75rem;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
    min-width: 70px;
}

.drawer-tab-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.drawer-tab-btn span {
    margin-top: 0.15rem;
}

.drawer-tab-btn:hover {
    color: #666;
}

.drawer-tab-btn.active {
    color: #8b5cf6;
}

.drawer-tab-link span {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.drawer-tab-link:hover {
    color: var(--primary-color, #8b5cf6) !important;
    opacity: 0.85;
}

.drawer-tab-divider {
    width: 1px;
    height: 32px;
    background: var(--border-color);
    flex-shrink: 0;
}

/* Drawer Accordion */
.drawer-accordion-section {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.drawer-accordion-section:last-child {
    border-bottom: none;
}

.drawer-accordion-section.expanded {
    background: var(--bg-secondary);
    border-left: 3px solid #8b5cf6;
}

.drawer-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.drawer-accordion-header:hover {
    background: rgba(139, 92, 246, 0.05);
}

.drawer-accordion-section.expanded .drawer-accordion-header {
    background: rgba(139, 92, 246, 0.08);
}

.drawer-accordion-section.expanded .section-title {
    color: #8b5cf6;
    font-weight: 700;
}

.section-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.section-title {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
}

.section-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: opacity 0.2s ease, max-height 0.2s ease;
    display: flex;
    align-items: center;
}

.drawer-accordion-section.expanded .section-preview {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
}

/* Letras Preview - Avatar circles with count + text */
.letras-preview-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.letras-preview-avatars {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.letras-preview-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: normal;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

/* Mobile: Allow text to wrap to 2 lines */
@media (max-width: 768px) {
    .letras-preview-text {
        font-size: 0.8rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}

.accordion-icon {
    flex-shrink: 0;
    transition: transform 0.3s ease;
    color: var(--text-muted);
}

.drawer-accordion-section.expanded .accordion-icon {
    transform: rotate(180deg);
}

.drawer-accordion-content {
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, background 0.2s ease;
    padding: 0 1rem 1rem 1rem;
    max-height: 2000px;
    -webkit-overflow-scrolling: touch;
}

.drawer-accordion-content.collapsed {
    max-height: 0;
    padding: 0 1rem;
    overflow: hidden;
}

.drawer-accordion-section.expanded .drawer-accordion-content {
    background: rgba(139, 92, 246, 0.05);
}

/* Drawer Section Content */
.related-words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Drawer Lyrics Grid - Responsive Columns */
.drawer-lyrics-grid {
    display: grid;
    gap: 0;
}

.drawer-lyric-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    height: 100%;
    min-height: 150px;
}

/* Mobile: 1 column - no right border */
@media (max-width: 768px) {
    .drawer-lyrics-grid {
        grid-template-columns: 1fr;
    }

    .drawer-lyric-card {
        border-right: none;
    }
}

/* Tablet: 2 columns - remove right border on even items */
@media (min-width: 769px) and (max-width: 1200px) {
    .drawer-lyrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .drawer-lyric-card:nth-child(2n) {
        border-right: none;
    }
}

/* Desktop: 3 columns - remove right border on every 3rd item */
@media (min-width: 1201px) {
    .drawer-lyrics-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .drawer-lyric-card:nth-child(3n) {
        border-right: none;
    }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .definition-drawer {
        height: 60vh;
    }

    .drawer-header {
        padding: 1rem;
    }

    .drawer-body {
        padding: 0;
    }

    .drawer-word {
        font-size: 1.25rem;
    }
}

@media (min-width: 769px) {
    .definition-drawer {
        height: 55vh;
    }
}

/* Sticky Header - All Screen Sizes */
.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    background-color: var(--bg-color);
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: none;
}

body.has-results .sticky-header:not(.hidden) {
    display: block;
}

.sticky-header-content {
    width: 100%;
}

.sticky-header-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0.75rem 1rem;
    gap: 1rem;
}

.sticky-left {
    display: flex;
    justify-content: flex-start;
    align-items: center;
}

.sticky-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.search-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-icon-btn:hover {
    color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
}

.sticky-logo {
    display: flex;
    justify-content: center;
    align-items: center;
}

.sticky-logo-link {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.sticky-logo img {
    height: 40px;
    max-height: 40px;
    width: auto;
}

.sticky-search-wrapper {
    padding: 0 1rem 0.5rem 1rem;
}

.sticky-input-wrapper {
    position: relative;
    width: 100%;
}

#sticky-search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    color: var(--text-main);
    font-family: var(--font-family);
}

#sticky-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.sticky-tabs {
    display: flex;
    gap: 0.5rem;
    padding: 0 1rem 0.75rem 1rem;
    border-bottom: 2px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.sticky-tabs::-webkit-scrollbar {
    display: none;
}

.sticky-tab-btn {
    background: none;
    color: var(--text-muted);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.sticky-tab-btn.active {
    background-color: #fef08a;
    color: #1e293b;
    font-weight: 700;
}

.sticky-tab-btn:hover:not(.active) {
    color: black;
    background-color: #ffffca;
}

.search-trends {
    margin: auto;
}

.trend-section-title {
    text-align: center;
    font-size: 1.0rem;
    color: var(--text-muted);
}

.trend-section-content {
    font-size: 0.9rem;
    text-align: center;
    word-spacing: 10px;
    margin-bottom: 10px;
}

.trend-section-content a {
    text-decoration: none;
    color: var(--text-main);
}

.usage-hint {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.1rem;
    padding: 0 1rem;
}

/* Drawer UI Refinements */
.lyric-highlight-blue {
    font-weight: bold;
    color: #3b82f6;
    /* Blue 500 */
}

body.light-mode .lyric-highlight-blue {
    color: #2563eb;
    /* Blue 600 */
}

.drawer-potency-badge {
    display: inline-block;
    background-color: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 0.4rem;
    margin-left: 1rem;
    vertical-align: middle;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.drawer-body-flex {
    display: flex;
    gap: 2rem;
    height: 100%;
}

.drawer-column {
    flex: 1;
    min-width: 0;
    /* Fix flex child overflow */
    display: flex;
    flex-direction: column;
}

.drawer-column-header {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 700;
}

/* Scroll definitions independently in 2-col layout */
.drawer-definitions-scroll {
    overflow-y: auto;
    flex: 1;
    padding-right: 0.5rem;
}

/* Mobile Layout for Drawer */
@media (max-width: 768px) {
    .drawer-body-flex {
        flex-direction: column;
        gap: 1.5rem;
    }

    .drawer-column {
        flex: none;
        /* Let them stack naturally */
    }

    .drawer-potency-badge {
        font-size: 0.8rem;
        margin-left: 0.5rem;
    }
}

/* View Controls */
.view-controls {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.view-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.4rem;
    border-radius: 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-btn:hover {
    color: var(--primary-color);
    background-color: var(--bg-color);
}

.view-btn.active {
    color: var(--primary-color);
    background-color: rgba(99, 102, 241, 0.1);
}

/* Table Header - Match Grid */
.results-table-header {
    display: grid;
    padding: 0.75rem 0;
    background-color: var(--bg-color);
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
    color: var(--text-muted);
    align-items: center;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    gap: 1rem;
}

/* Three column layout (Rhymes) */
.three-columns .results-table-header {
    grid-template-columns: minmax(150px, 1fr) 80px 140px !important;
}

/* Two column layout (Relacionadas, Adjetivos) */
.two-columns .results-table-header {
    grid-template-columns: minmax(150px, 1fr) 140px !important;
}

.results-table-header > *:first-child {
    padding-left: 1.5rem;
}

.results-table-header > *:last-child {
    padding-right: 1.5rem;
}

.results-table-row {
    display: grid;
    border-bottom: 1px solid var(--border-color);
    align-items: stretch;
    gap: 1rem;
    padding: 0;
}

/* Three column layout (Rhymes) */
.three-columns .results-table-row {
    grid-template-columns: minmax(150px, 1fr) 80px 140px !important;
}

/* Two column layout (Relacionadas, Adjetivos) */
.two-columns .results-table-row {
    grid-template-columns: minmax(150px, 1fr) 140px !important;
}

.results-table-row > *:first-child {
    padding-left: 1.5rem;
}

.results-table-row > *:last-child {
    padding-right: 1.5rem;
}

/* Mobile adjustments for table columns */
@media (max-width: 600px) {
    /* Three column layout (Rhymes) */
    .three-columns .results-table-header,
    .three-columns .results-table-row {
        grid-template-columns: minmax(100px, 1fr) 60px 80px !important;
        gap: 0.5rem;
    }

    /* Two column layout (Relacionadas, Adjetivos) */
    .two-columns .results-table-header,
    .two-columns .results-table-row {
        grid-template-columns: minmax(100px, 1fr) 80px !important;
        gap: 0.5rem;
    }

    .results-table-header {
        font-size: 0.6rem;
        padding: 0.75rem 0;
    }

    .results-table-row {
        padding: 0;
    }

    .results-table-header > *:first-child,
    .results-table-row > *:first-child {
        padding-left: 0.75rem;
    }

    .results-table-header > *:last-child,
    .results-table-row > *:last-child {
        padding-right: 0.75rem;
    }

    .word-cell {
        font-size: 1rem;
    }
}

/* Cap content width and add vertical lines on large screens */
@media (min-width: 800px) {
    .results-table-header,
    .results-table-row {
        max-width: 750px;
        margin-left: auto;
        margin-right: auto;
        border-left: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
    }
}

.results-table-row:last-child {
    border-bottom: none;
}

.table-cell {
    padding: 0.75rem 0;
    /* Vertical padding only, horizontal handled by grid gap/columns */
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}



.word-cell {
    /* Padding handled by row > *:first-child */
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    cursor: pointer;
    /* Background color will be applied here via .strength class */
}

.word-cell:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Reuse strength colors for word-cell background */
.word-cell.strength-100 {
    background-color: rgba(16, 185, 129, 0.35);
}

.word-cell.strength-96 {
    background-color: rgba(16, 185, 129, 0.25);
}

.word-cell.strength-92 {
    background-color: rgba(16, 185, 129, 0.18);
}

.word-cell.strength-86 {
    background-color: rgba(16, 185, 129, 0.12);
}

.word-cell.strength-80 {
    background-color: rgba(16, 185, 129, 0.07);
}

.center-text {
    justify-content: center;
    text-align: center;
}

.pop-bar-container {
    width: 100%;
    height: 6px;
    background-color: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.pop-bar-fill {
    height: 100%;
    background-color: #3b82f6;
    /* Blue 500 */
    border-radius: 3px;
}

/* List View Override for results-list */
.results-list.list-view {
    display: block !important;
    gap: 0;
}


/* Tabular Layout */
.results-table-container {
    width: 100%;
    overflow-x: auto;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
}

body.light-mode .word-cell.strength-100 {
    background-color: rgba(16, 185, 129, 0.4);
}

body.light-mode .word-cell.strength-96 {
    background-color: rgba(16, 185, 129, 0.3);
}

body.light-mode .word-cell.strength-92 {
    background-color: rgba(16, 185, 129, 0.22);
}

body.light-mode .word-cell.strength-86 {
    background-color: rgba(16, 185, 129, 0.17);
}

body.light-mode .word-cell.strength-80 {
    background-color: rgba(16, 185, 129, 0.12);
}
