:root {
    --bg-color: #f4f7f6;
    --container-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #666666;
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --secondary-bg: #e2e8f0;
    --secondary-hover: #cbd5e1;
    --border-color: #e2e8f0;
    --highlight-bg: #ffedd5;
    --highlight-color: #ea580c;
    --radius: 12px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --transition: all 0.2s ease-in-out;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --container-bg: #1e293b;
        --text-color: #f8fafc;
        --text-muted: #94a3b8;
        --primary-color: #3b82f6;
        --primary-hover: #60a5fa;
        --secondary-bg: #334155;
        --secondary-hover: #475569;
        --border-color: #334155;
        --highlight-bg: #7c2d12;
        --highlight-color: #ffedd5;
    }
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 2rem 1rem;
    display: flex;
    justify-content: center;
}

.container {
    max-width: 800px;
    width: 100%;
    background-color: var(--container-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

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

header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--primary-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
}

.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--container-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    cursor: pointer;
}

textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--container-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    outline: none;
    transition: var(--transition);
}

textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 1rem;
    font-family: inherit;
}

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

button.secondary {
    background-color: var(--secondary-bg);
    color: var(--text-color);
}

button.secondary:hover {
    background-color: var(--secondary-hover);
}

.hidden {
    display: none !important;
}

#text-display {
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background-color: var(--secondary-bg);
    min-height: 150px;
    font-size: 1.25rem; /* Größer für bessere Lesbarkeit */
    line-height: 2.0;   /* Mehr Abstand zwischen den Zeilen */
}

#text-display span.word {
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}

#text-display span.word:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

#text-display span.word.selected {
    background-color: var(--highlight-bg);
    color: var(--highlight-color);
    font-weight: 500;
}

.lists-section {
    margin-top: 2rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 600px) {
    .lists-section {
        grid-template-columns: 1fr;
    }
    
    #text-display {
        font-size: 1rem; /* Kleinere Schrift auf Mobile */
        padding: 1rem;
        line-height: 1.6;
    }
}

.list-container {
    display: flex;
    flex-direction: column;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.list-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.list-header button {
    margin-top: 0;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--text-color);
    color: var(--bg-color);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: var(--shadow);
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

.toast.fade-out {
    opacity: 0;
}

/* Modal & Language Manager */
.controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.icon-btn {
    margin-top: 0;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.sm-btn {
    margin-top: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    white-space: nowrap;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: var(--container-bg);
    color: var(--text-color);
    width: 100%;
    max-width: 580px;
    max-height: 90vh;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    margin: 0;
    padding: 0.2rem 0.5rem;
}

.close-btn:hover {
    color: var(--text-color);
    background: none;
    transform: none;
}

.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.modal-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.modal-actions-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.modal-actions-bar input[type="text"] {
    flex: 1;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--container-bg);
    color: var(--text-color);
    outline: none;
    font-size: 0.9rem;
}

.modal-actions-bar input[type="text"]:focus {
    border-color: var(--primary-color);
}

.lang-selection-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
    max-height: 220px;
    overflow-y: auto;
    padding: 0.5rem;
    background-color: var(--secondary-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.lang-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    user-select: none;
    transition: background-color 0.15s ease;
}

.lang-item:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

.lang-item input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--primary-color);
    width: 15px;
    height: 15px;
}

.lang-item .lang-code-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background-color: rgba(0, 0, 0, 0.06);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    margin-left: auto;
}

.custom-lang-section {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.custom-lang-section h4 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.custom-lang-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.custom-lang-form input {
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--container-bg);
    color: var(--text-color);
    outline: none;
    font-size: 0.85rem;
}

.custom-lang-form input:focus {
    border-color: var(--primary-color);
}

#custom-lang-name {
    flex: 2;
    min-width: 140px;
}

#custom-lang-code {
    flex: 1;
    min-width: 70px;
    text-transform: uppercase;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background-color: var(--container-bg);
}

.modal-footer button {
    margin-top: 0;
}
