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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    width: 100%;
}

/* Header */
header {
    background: #ffffff !important;
    padding: 0.6rem 0 !important;
    border-bottom: 1px solid #eee !important;
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100% !important;
    box-sizing: border-box !important;
}

.header-content {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 1.5rem !important;
}

.logo-area {
    flex-shrink: 0 !important;
}

.logo-link {
    text-decoration: none !important;
    color: inherit !important;
    border: none !important;
    outline: none !important;
}

.logo-link:hover {
    text-decoration: none !important;
}

header h1 {
    font-size: 1.2rem !important;
    color: #333 !important;
    margin: 0 !important;
    line-height: 1 !important;
    font-weight: 700 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
    border-bottom: none !important;
}

.tagline {
    color: #999 !important;
    font-size: 0.7rem !important;
    margin-top: 2px !important;
    margin-bottom: 0 !important;
    font-weight: 400 !important;
}

.header-search-form {
    flex: 1;
    max-width: 400px;
}

.header-input-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Language switch styles */
.lang-switch {
    display: flex;
    background: #f1f3f5;
    padding: 2px;
    border-radius: 6px;
    gap: 2px;
    flex-shrink: 0;
}

.lang-switch label {
    padding: 4px 8px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    color: #999;
    transition: all 0.2s;
    user-select: none;
    line-height: 1;
}

.lang-switch input[type="radio"] {
    display: none;
}

.lang-switch input[type="radio"]:checked + label {
    background: #fff;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.header-search-input {
    flex: 1;
    padding: 6px 10px;
    font-size: 0.85rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: border-color 0.3s;
}

.header-search-input:focus {
    outline: none;
    border-color: #333;
}

.header-search-button {
    padding: 6px 12px;
    font-size: 0.85rem;
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: 600;
}

.header-search-button:hover {
    background: #000;
}

/* Main Content */
main {
    flex: 1;
    padding: 1.5rem 0;
}

/* Search Container (Home page) */
.search-container {
    padding: 2rem;
    max-width: 1000px;
    margin: 2rem auto;
    text-align: center;
}

.search-container h2 {
    color: #333;
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
}

.search-intro {
    max-width: 600px;
    margin: 0 auto;
}

.search-container .search-form {
    display: none; /* Hide on home page if we have header search, or keep it? */
}
/* Re-showing search form on home page but styling it like header */
.home-search-form {
    margin-bottom: 2rem;
}

/* Info Box */
.info-box {
    background: #f8f9fa;
    padding: 1.2rem;
    border-radius: 6px;
    border: 1px solid #eee;
    text-align: left;
}

.info-box h3 {
    color: #333;
    margin-bottom: 0.8rem;
    font-size: 1rem;
}

.info-box ul {
    list-style-position: inside;
    color: #666;
    font-size: 0.9rem;
}

.info-box li {
    margin-bottom: 0.4rem;
}

/* History Section */
.history-section {
    margin-top: 2rem;
    text-align: left;
}

.history-section h3 {
    color: #333;
    margin-bottom: 1.2rem;
    font-size: 1.1rem;
    font-weight: 700;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.history-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.history-card:hover {
    border-color: #ccc;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid #f5f5f5;
    padding-bottom: 0.5rem;
}

.card-word {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    text-decoration: none;
}

.card-word:hover {
    color: #000;
}

.card-pronunciation {
    font-size: 0.8rem;
    color: #999;
    font-family: 'Consolas', monospace;
}

.card-pos-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.card-pos-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.card-pos-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.card-pos-type {
    font-size: 0.8rem;
    font-weight: 700;
    color: #555;
    text-transform: lowercase;
    font-style: italic;
}

.card-gender {
    font-size: 0.7rem;
    color: #888;
    font-style: italic;
}

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

.card-definitions li {
    font-size: 0.85rem;
    color: #444;
    line-height: 1.3;
    margin-bottom: 0.2rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Result Container */
.result-container {
    background: #ffffff;
    padding: 0;
    max-width: 100%;
    margin: 0 auto;
}

.back-link {
    display: none; /* Removed as requested */
}

.result-header {
    display: none; /* Removed as requested */
}

/* Word Information Section */
.word-info-section {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin: 0 auto 1.5rem auto;
    border: 1px solid #eee;
    max-width: 600px;
    margin-top: 1rem;
}

.summary-word {
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 0.8rem;
    font-weight: 700;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.4rem;
}

.parts-of-speech {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pos-block {
    background: white;
    padding: 0.6rem 0.8rem;
    border-radius: 4px;
    border: 1px solid #eee;
}

.pos-line {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
}

.pos-title {
    color: #333;
    font-size: 0.9rem;
    font-weight: 700;
}

.gender-badge {
    background: #f1f3f5;
    color: #666;
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 500;
    font-style: italic;
}

.pronunciation {
    font-size: 0.85rem;
    color: #999;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    margin-left: auto; /* Push to right on desktop */
}

.definitions-list {
    margin-left: 1.1rem;
    color: #333;
}

.definitions-list li {
    margin-bottom: 0.1rem;
    line-height: 1.3;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

/* Full HTML Section */
.full-html-section {
    margin-top: 1.5rem;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    padding: 1.5rem;
}

.html-content-display {
    background: white;
    padding: 1.5rem;
    overflow-x: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.html-content-display * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ancient Greek collapsing */
.ancient-greek-section {
    margin: 1rem auto;
    border: 1px solid #eee;
    border-radius: 8px;
    max-width: 800px;
}

.ancient-greek-section summary {
    padding: 0.8rem 1rem;
    background: #f8f9fa;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
}

.ancient-greek-content {
    padding: 1.5rem;
}

/* Debug Page Styles */
.debug-container {
    background: #ffffff;
    padding: 0;
    max-width: 100%;
    margin: 0 auto;
}

.debug-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.debug-header h2 {
    color: #333;
    margin-bottom: 0.3rem;
    font-size: 1.6rem;
}

.debug-subtitle {
    color: #888;
    font-size: 0.9rem;
}

.debug-form-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid #eee;
}

.debug-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-weight: 600;
    color: #333;
    font-size: 0.9rem;
}

.debug-input,
.debug-select {
    padding: 10px 12px;
    font-size: 0.95rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.3s;
}

.debug-input:focus,
.debug-select:focus {
    outline: none;
    border-color: #333;
}

.debug-button {
    padding: 10px 25px;
    font-size: 1rem;
    background: #333;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: 600;
    align-self: flex-start;
}

.debug-results {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.results-header {
    background: #f8f9fa;
    color: #333;
    padding: 0.8rem 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

.results-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.clear-button {
    padding: 0.4rem 0.8rem;
    background: #fff;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    font-size: 0.8rem;
}

.clear-button:hover {
    background: #f8f9fa;
    color: #333;
}

.result-metadata {
    background: #fff;
    padding: 1.2rem;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.result-metadata p {
    margin: 0.3rem 0;
    color: #555;
}

.result-metadata code {
    background: #f8f9fa;
    padding: 0.1rem 0.3rem;
    border: 1px solid #eee;
    border-radius: 3px;
    font-size: 0.8rem;
    word-break: break-all;
}

.parsed-section,
.raw-section,
.error-section {
    padding: 1.2rem;
    border-bottom: 1px solid #eee;
}

.parsed-section h4,
.raw-section h4,
.error-section h4 {
    margin: 0 0 0.8rem 0;
    color: #333;
    font-size: 1rem;
}

.raw-section pre,
.error-section pre {
    background: #f8f9fa;
    color: #333;
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 4px;
    font-size: 0.85rem;
}

.error-section {
    background: #fff5f5;
}

.error-section h4 {
    color: #c53030;
}

.error-section pre {
    background: #fff;
    color: #c53030;
    border-color: #feb2b2;
}

/* Footer */
footer {
    background: #ffffff;
    padding: 1.5rem 0;
    margin-top: 3rem;
    text-align: center;
    color: #888;
    border-top: 1px solid #eee;
    font-size: 0.9rem;
}

footer a {
    color: #666;
    text-decoration: none;
}

footer a:hover {
    color: #000;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }

    header {
        padding: 0.8rem 0 !important;
    }

    .header-content {
        flex-direction: column !important;
        gap: 0.8rem !important;
        text-align: center !important;
    }

    .logo-area {
        text-align: center !important;
    }

    header h1 {
        font-size: 1.3rem !important;
    }

    .header-search-form {
        width: 100% !important;
        max-width: 100% !important;
    }

    .header-input-group {
        width: 100% !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
    }

    .header-search-input {
        flex: 1 1 150px !important; /* Allow growing and shrinking, with a reasonable base */
        min-width: 0 !important;
    }

    .header-search-button {
        flex: 0 0 auto !important;
    }

    .lang-switch {
        margin-bottom: 4px !important;
    }

    .search-container {
        padding: 1.5rem;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .search-button {
        width: 100%;
    }
    
    .word-title {
        font-size: 1.6rem;
    }
    
    .pronunciation {
        font-size: 1.1rem;
    }
    
    .results-header {
        flex-direction: row; /* Keep it side by side if possible */
        align-items: center;
    }
}

/* Tags styling */
.tags-container {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #eee;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-badge {
    background: #e9ecef;
    color: #495057;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}

.tag-badge.small {
    padding: 2px 8px;
    font-size: 0.65rem;
}

.remove-tag {
    cursor: pointer;
    color: #adb5bd;
    font-size: 1rem;
    line-height: 1;
    margin-left: 2px;
}

.remove-tag:hover {
    color: #fa5252;
}

.add-tag-form {
    display: flex;
    gap: 4px;
}

.add-tag-form input {
    padding: 4px 8px;
    font-size: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    flex: 1;
    max-width: 150px;
}

.add-tag-form button {
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-weight: 700;
}

.card-add-tag {
    margin-top: 0.2rem;
}

.small-tag-input {
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 0.7rem;
    width: 60px;
    transition: width 0.3s, border-color 0.3s;
}

.small-tag-input:focus {
    width: 100px;
    outline: none;
    border-color: #ccc;
}

/* Tags Page styling */
.tags-page-container {
    padding: 1rem 0;
}

.tags-header {
    margin-bottom: 2rem;
}

.tags-header h2 {
    font-size: 1.6rem;
    margin-bottom: 0.4rem;
}

.tags-header p {
    color: #888;
}

.filters-section {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #eee;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-group label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #555;
}

.filter-group select {
    padding: 6px 12px;
    font-size: 0.9rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
}

.clear-filters {
    font-size: 0.85rem;
    color: #888;
    text-decoration: none;
    margin-bottom: 8px;
}

.clear-filters:hover {
    color: #333;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 0.4rem;
}

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    background: #f8f9fa;
    border-radius: 8px;
    color: #888;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .filter-form {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
}

/* Wiktionary Content Styling */
.html-content-display {
    font-size: 0.95rem;
    color: #333;
    
    /* Wiktionary Palette Variables */
    --wikt-palette-paleblue: #f8f9ff;
    --wikt-palette-grey: #cccccc;
    --wikt-palette-grey-6: #eeeeee;
    --wikt-palette-white: #ffffff;
    --wikt-palette-lightergrey: #f9f9f9;
}

.html-content-display h2, 
.html-content-display h3, 
.html-content-display h4,
.html-content-display h5 {
    border-bottom: 1px solid #eee;
    margin: 1.5rem 0 1rem 0;
    padding-bottom: 0.3rem;
    color: #000;
    font-weight: 700;
}

.html-content-display h2 { font-size: 1.5rem; margin-top: 2rem; }
.html-content-display h3 { font-size: 1.3rem; }
.html-content-display h4 { font-size: 1.15rem; }
.html-content-display h5 { font-size: 1.05rem; }

.html-content-display a {
    color: #0056b3;
    text-decoration: none;
}

.html-content-display a:hover {
    text-decoration: underline;
}

/* Tables - primarily for declension/conjugation */
.html-content-display table {
    border-collapse: collapse;
    margin: 1.2rem 0;
    width: auto;
    max-width: 100%;
    background: #fff;
    border: 1px solid #ccc;
    line-height: 1.4;
}

.html-content-display th, 
.html-content-display td {
    border: 1px solid #ccc;
    padding: 8px 12px;
    text-align: left;
}

.html-content-display th {
    background: #f1f3f5;
    font-weight: 600;
    color: #333;
}

/* Lists and text content */
.html-content-display ul, 
.html-content-display ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.html-content-display li {
    margin-bottom: 0.4rem;
}

.html-content-display p {
    margin-bottom: 1rem;
}

.html-content-display dl {
    margin: 1rem 0;
}

.html-content-display dt {
    font-weight: 700;
    margin-top: 0.8rem;
}

.html-content-display dd {
    margin-left: 1.5rem;
    margin-bottom: 0.3rem;
}

/* IPA and pronunciation */
.html-content-display .IPA {
    font-family: 'Charis SIL', 'DejaVu Sans', 'Arial Unicode MS', sans-serif;
}

/* Wiktionary specific structures */
.html-content-display .NavFrame {
    border: 1px solid #ddd;
    margin: 1.5rem 0;
    border-radius: 4px;
    background: #fff;
}

.html-content-display .NavHead {
    background: #f8f9fa;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
    font-size: 1rem;
}

.html-content-display .NavContent {
    padding: 12px;
}

/* Hide Wiktionary internal/clutter elements */
.html-content-display .mw-editsection,
.html-content-display .noprint,
.html-content-display .metadata,
.html-content-display .stub,
.html-content-display .sister-project,
.html-content-display .phrasebook,
.html-content-display .disambig-see-also,
.html-content-display .k-player .k-attribution {
    display: none !important;
}

/* Language specific styling */
.html-content-display [lang="el"],
.html-content-display [lang="grc"] {
    font-family: 'Gentium Plus', 'Palatino Linotype', 'FreeSerif', serif;
}

