:root {
    --primary-color: #1a4731; --primary-dark: #2d6a4f; --secondary-color: #1b4332; 
    --accent-color: #40916c; --light-bg: #f8f9fa; --dark-bg: #e9ecef; 
    --border-color: #dee2e6; --shadow: 0 4px 6px rgba(0, 0, 0, 0.1); 
    --vowel-color: #e8f5e9; --consonant-color: #faf6f1; --diacritic-color: #d4a373; 
    --control-color: #f3f4f6; --hover-color: #f0f0f0; --active-color: #e0e0e0; 
    --spacing-xs: 4px; --spacing-sm: 8px;
}

* {
    box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, 'Helvetica Neue', sans-serif; 
    background-color: var(--light-bg); color: var(--secondary-color); 
    height: 100vh; width: 100vw; overflow: hidden; display: flex; flex-direction: column; 
    touch-action: manipulation;
}

header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white; padding: 6px 0; text-align: center; box-shadow: var(--shadow); 
    flex-shrink: 0; position: relative; z-index: 10;
}

h1 { font-size: 1rem; margin-bottom: 0; font-weight: 600; letter-spacing: 0.5px; }
h2 { font-size: 0.7rem; font-weight: 400; opacity: 0.9; }

.language-bar {
    display: flex; gap: 3px; padding: 3px 6px; background-color: var(--light-bg); 
    overflow-x: auto; justify-content: center; flex-wrap: wrap; flex-shrink: 0;
}

.language-btn {
    background-color: var(--light-bg); border: 1px solid var(--border-color); 
    border-radius: 6px; padding: 4px 8px; cursor: pointer; font-size: 0.75rem; 
    flex-grow: 1; text-align: center; max-width: 80px; transition: background-color .2s ease;
}

.language-btn:hover { background-color: var(--hover-color); }
.language-btn.active { background-color: var(--primary-color); color: white; border-color: var(--primary-dark); }

.main-content {
    display: flex; flex-direction: column; flex-grow: 1; overflow: hidden;
}

.output-container {
    padding: 6px; flex-shrink: 0; background-color: white; margin: 4px 6px;
    border-radius: 8px; box-shadow: var(--shadow); position: relative; 
     height: 7vh; min-height: 30px; max-height: 7vh;
}

#output {
    width: 100%; height: 100%; padding: 6px; border: 1px solid var(--border-color);
    border-radius: 6px; font-size: 1rem; line-height: 1.3; background-color: var(--light-bg);
    overflow-y: auto; white-space: pre-wrap; box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    font-family: 'Arial', sans-serif; outline: none; resize: none;
}

#output:focus {
    border-color: var(--primary-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05), 0 0 5px rgba(26, 71, 49, 0.3);
}

.copy-button {
    position: absolute; bottom: 10px; right: 10px; background-color: var(--accent-color); 
    color: white; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; 
    font-size: 0.75rem; transition: background-color .2s ease; box-shadow: var(--shadow); z-index: 5;
}

.copy-button:hover { background-color: #2d6a4f; }
.copy-button:active { background-color: #1a4731; }

.keyboard-container {
    flex-grow: 1; display: flex; flex-direction: column; justify-content: flex-end; 
     padding: 3px; background-color: var(--dark-bg); border-top: 1px solid var(--border-color);
}

.keyboard {
    display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; 
    background-color: var(--dark-bg); border-radius: 6px; padding: 2px;
}

.key {
    height: 32px; display: flex; align-items: center; justify-content: center;
    background-color: white; border: 1px solid var(--border-color); border-radius: 6px; 
    font-size: 0.95rem; cursor: pointer; user-select: none; 
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); transition: all 0.1s ease;
}

.key:active {
    background-color: var(--active-color); transform: translateY(1px); box-shadow: none;
}

.vowel { background-color: var(--vowel-color); border-color: #c8e6c9; }
.consonant { background-color: var(--consonant-color); border-color: #f5efe5; }
.diacritic { background-color: var(--diacritic-color); border-color: #c8956a; }
.control { background-color: var(--control-color); font-weight: 600; font-size: 0.75rem; border-color: #d1d5db; 
text-transform: uppercase; letter-spacing: 0.5px; }

.control-row {
    display: grid; grid-template-columns: 1fr 2fr 1fr 1fr; gap: 2px; margin-top: 2px; padding: 0 2px;
}

body.shifted .shift { background-color: var(--primary-color); color: white; }

.toast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); 
    background-color: rgba(0, 0, 0, 0.8); color: white; padding: 8px 12px; 
    border-radius: 4px; z-index: 1000; opacity: 0; transition: opacity .3s ease; 
    font-size: 0.9rem; pointer-events: none;
}

.toast.show { opacity: 1; }

@media (max-height: 600px) {
    .output-container { height: 12vh; min-height: 40px; }
    .key { height: 28px; font-size: 0.9rem; }
    h1 { font-size: 0.9rem; }
    h2 { font-size: 0.65rem; }
}

@media (max-height: 500px) {
    .output-container { height: 10vh; }
    .key { height: 24px; font-size: 0.8rem; }
    .control { font-size: 0.7rem; }
}

@media (prefers-color-scheme: dark) {
    :root {
        --light-bg: #1a1a1a; --dark-bg: #121212; --border-color: #333; 
        --vowel-color: #2d6a4f; --consonant-color: #40916c; 
        --diacritic-color: #d4a373; --control-color: #2a2a2a; 
        --hover-color: #2c2c2c; --active-color: #3c3c3c;
    }
    body { color: #faf6f1; }
    .key { background-color: #232323; color: #faf6f1; }
    #output { background-color: #232323; color: #faf6f1; }
    .language-btn { background-color: #232323; color: #faf6f1; }
    .output-container { background-color: #1e1e1e; }
}

.home-link {
    display: inline-flex; align-items: center; justify-content: center; 
    padding: 6px 12px; background-color: var(--primary-color); color: white; 
    font-weight: 500; font-size: 0.9rem; text-decoration: none; border-radius: 50px; 
    box-shadow: var(--shadow); transition: background-color .3s, transform .2s, box-shadow .3s;
    margin: 15px 0; letter-spacing: 1px;
}

.home-link:hover { background-color: var(--primary-dark); transform: scale(1.1); 
box-shadow: 0px 6px 18px rgba(0, 0, 0, 0.25); }

.home-link:active { transform: scale(1); box-shadow: var(--shadow); }

.home-icon { margin-right: 6px; font-size: 1.2rem; }

@media (max-width: 600px) {
    .home-link { font-size: 0.6rem; padding: 4px 10px; }
    .home-icon { font-size: 1rem; }
}

#faq-section {
    background-color: var(--light-bg);
    border-top: 2px solid var(--border-color);
}

.faq-main-title {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 12px;
    padding-top: 8px;
}

.faq-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
}

.faq-item {
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}
@media (prefers-color-scheme: dark) {
    .faq-item {
        background-color: #232323;
    }
}

.faq-question {
    padding: 10px 12px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--secondary-color);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.2s ease;
}

.faq-question::-webkit-details-marker {
    display: none;
}

.faq-question:hover {
    background-color: var(--hover-color);
}

.faq-item[open] > summary {
    background-color: var(--vowel-color);
    color: var(--primary-dark);
    font-weight: 600;
}

.faq-arrow {
    color: var(--primary-color);
    transition: transform 0.25s ease-in-out;
    flex-shrink: 0;
    margin-left: 10px;
}

.faq-item[open] .faq-arrow {
    transform: rotate(180deg);
}

.faq-answer {
    padding: 0px 12px 12px 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--secondary-color);
}

.faq-answer p, .faq-answer ol {
    margin-top: 8px;
    margin-bottom: 0;
}

.faq-answer ol {
    padding-left: 20px;
}