* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #6e8efb, #a777e3);
    min-height: 100vh;
    padding: 20px;
    padding-top: 140px;
}

.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 12px 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.control-buttons {
    display: flex;
    gap: 8px;
}

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

.control-label {
    font-size: 14px;
    color: #555;
    white-space: nowrap;
}

.number-control {
    display: flex;
    align-items: center;
    gap: 4px;
}

.number-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background-color: #6e8efb;
    color: white;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-input {
    width: 50px;
    padding: 6px;
    border-radius: 20px;
    border: 2px solid #ddd;
    text-align: center;
    font-size: 14px;
}

.switch-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #4CAF50;
}

input:checked+.slider:before {
    transform: translateX(26px);
}

.main-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    flex-direction: column;
}

.content-area {
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.sidebar {
    background-color: #f9f9f9;
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    flex-direction: column;
    order: -1;
    /* Move phonetics output above input on mobile */
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 24px;
}

.input-section {
    margin-bottom: 20px;
    position: relative;
}

textarea {
    width: 100%;
    height: 100px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #6e8efb;
}

.text-controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.text-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 20px;
    background-color: #6e8efb;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

.text-btn:hover {
    background-color: #5a7de0;
}

.buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 15px;
    flex-wrap: wrap;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 50px;
    background-color: #6e8efb;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

button:hover {
    background-color: #5a7de0;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}
/* 🔥 Highlight Auto Correct button */
.autocorrect-btn {
    background-color: #ffaa00;  /* orange */
    font-weight: bold;
    transform: scale(1.1);
    transition: 0.2s;
}

.autocorrect-btn:hover {
    background-color: #e68900; /* darker orange */
    transform: scale(1.15);
}

.autocorrect-btn:disabled {
    background-color: #bdbdbd;
    transform: none;
    cursor: not-allowed;
}


#toggleSpeakBtn {
    background-color: #4CAF50;
    min-width: 80px;
}

#toggleSpeakBtn.speaking {
    background-color: #f44336;
}

#toggleSpeakBtn:hover {
    background-color: #3e8e41;
}

#toggleSpeakBtn.speaking:hover {
    background-color: #d32f2f;
}

#pauseBtn {
    background-color: #ff9800;
}

#pauseBtn:hover {
    background-color: #f57c00;
}

#pauseBtn.paused {
    background-color: #2196F3;
}

#pauseBtn.paused:hover {
    background-color: #0b7dda;
}

.controls {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.control-section {
    margin-bottom: 15px;
}

.control-section:last-child {
    margin-bottom: 0;
}

.section-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.value {
    color: #6e8efb;
    font-weight: 600;
}

input[type="range"] {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #6e8efb;
    cursor: pointer;
}

.jump-controls {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.jump-btn {
    text-align: center;
    padding: 6px 4px;
    background-color: #5a7de0;
    font-size: 12px;
    border-radius: 5px;
    min-width: 0;
}

.negative {
    background-color: #ff9800;
}

.negative:hover {
    background-color: #f57c00;
}

.word-nav-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.output-header h3 {
    color: #555;
    margin: 0;
    font-size: 18px;
}

.toggle-buttons {
    display: flex;
    gap: 8px;
}

.toggle-btn {
    padding: 5px 10px;
    background-color: #e0e0e0;
    color: #555;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.toggle-btn.active {
    background-color: #6e8efb;
    color: white;
}

#phoneticsOutput {
    font-size: 16px;
    line-height: 1.6;
    color: #333;
    height: 200px;
    /* Fixed height */
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    /* Vertical scrollbar */
}

.highlight {
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.3s;
}

.current {
    background-color: #4CAF50;
    color: white;
    font-weight: bold;
    padding: 2px 6px;
}

.word-count {
    text-align: center;
    margin-top: 8px;
    color: #777;
    font-size: 13px;
}

.ipa {
    font-family: 'Times New Roman', serif;
    font-size: 18px;
}

.arpabet {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.android-warning {
    display: none;
    background-color: #ffecb3;
    padding: 8px;
    border-radius: 5px;
    margin-top: 8px;
    font-size: 12px;
    color: #7d6608;
    text-align: center;
}

.voice-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

select {
    padding: 8px 12px;
    border-radius: 20px;
    border: 2px solid #ddd;
    background: white;
    font-size: 14px;
}

@media (min-width: 768px) {
    body {
        padding-top: 130px;
    }

    .main-container {
        flex-direction: row-reverse;
    }

    .content-area {
        flex: 7;
        padding: 30px;
        order: 0;
    }

    .sidebar {
        flex: 3;
        border-top: none;
        border-right: 1px solid #eee;
        padding: 25px;
        order: 0;
    }

    .sticky-header {
        padding: 15px 20px;
        justify-content: space-between;
    }

    h1 {
        font-size: 28px;
        margin-bottom: 20px;
    }

    textarea {
        height: 120px;
    }

    .jump-controls {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }

    .jump-btn {
        padding: 8px 5px;
        font-size: 14px;
    }

    #phoneticsOutput {
        height: 250px;
        /* Slightly taller on desktop */
    }
}

@media (max-width: 380px) {
    .jump-controls {
        grid-template-columns: repeat(3, 1fr);
    }

    .sticky-header {
        flex-direction: column;
        gap: 8px;
    }

    body {
        padding-top: 160px;
    }

    .control-buttons {
        flex-wrap: wrap;
        justify-content: center;
    }
}

.system-prompt-section {
    margin: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.system-prompt-section .section-label {
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.prompt-select {
    padding: 8px 12px;
    border-radius: 20px;
    border: 2px solid #ddd;
    background: white;
    font-size: 14px;
    width: 100%;
}


.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 15px 20px;
    background: #6e8efb;
    color: white;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.close {
    color: white;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #f1f1f1;
}

.modal-body {
    padding: 20px;
}

.modal-input, .modal-textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.modal-textarea {
    min-height: 100px;
    resize: vertical;
}

.custom-prompt-form {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.custom-prompts-list h3 {
    margin-bottom: 10px;
    color: #555;
}

#customPromptsList {
    list-style-type: none;
}

#customPromptsList li {
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 5px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.prompt-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.prompt-name {
    font-weight: bold;
}

.prompt-actions {
    display: flex;
    gap: 5px;
}

.delete-prompt {
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
}

.use-prompt {
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

@media (max-width: 380px) {
    .system-prompt-section .section-label {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .prompt-actions {
        flex-direction: column;
    }
}


.prompt-hint {
    font-size: 13px;
    color: #666;
    margin-top: -8px;
    margin-bottom: 10px;
}

.modal-input:focus, .modal-textarea:focus {
    border-color: #6e8efb;
    outline: none;
    box-shadow: 0 0 0 2px rgba(110, 142, 251, 0.2);
}

.confirmation-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #4CAF50;
    color: white;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s;
}

.confirmation-toast.show {
    opacity: 1;
}

/* Microphone button styles */
#microphoneBtn {
    background-color: #6e8efb;
    position: relative;
    overflow: hidden;
}

#microphoneBtn.listening {
    background-color: #f44336;
    animation: pulse 1.5s infinite;
}

#microphoneBtn:disabled {
    background-color: #ccc;
    animation: none;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Recognition status indicator */
.recognition-status {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 1000;
    display: none;
}

.recognition-status.active {
    display: block;
}

/* Highlight for recognized words */
.recognized {
    background-color: #ffeb3b;
    color: #333;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.5s ease-out;
}

/* highlighting */
.input-highlight {
    background-color: #ffeb3b;
    color: #333;
    padding: 2px 0;
    border-radius: 3px;
    animation: fadeHighlight 2s forwards;
}

@keyframes fadeHighlight {
    0% { background-color: #ffeb3b; }
    100% { background-color: transparent; }
}

/* ===== AUTHENTICATION STYLES ===== */
.auth-section {
    display: flex;
    align-items: center;
    margin-right: 15px;
}

.auth-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 20px;
    background-color: #4285f4;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

.auth-btn:hover {
    background-color: #357ae8;
    transform: translateY(-1px);
}

#userInfo {
    display: flex;
    align-items: center;
    gap: 8px;
}

#userPhoto {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#userName {
    font-size: 14px;
    font-weight: 500;
    color: #555;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive adjustments for auth section */
@media (max-width: 768px) {
    .auth-section {
        margin-right: 0;
        order: -1;
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }
    
    #userInfo {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    #userName {
        max-width: 100px;
    }
}

@media (max-width: 480px) {
    .auth-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    #userName {
        font-size: 12px;
        max-width: 80px;
    }
}

/* Loading animation for auth states */
.auth-loading {
    opacity: 0.7;
    pointer-events: none;
}

.auth-loading::after {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
    margin-left: 5px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Notification toast for auth messages */
.auth-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #323232;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 3000;
    opacity: 0;
    transition: opacity 0.3s;
}

.auth-toast.show {
    opacity: 1;
}

/* Error state for auth buttons */
.auth-error {
    background-color: #f44336 !important;
}

.auth-error:hover {
    background-color: #d32f2f !important;
}

/* Success state for auth buttons */
.auth-success {
    background-color: #4CAF50 !important;
}

.auth-success:hover {
    background-color: #45a049 !important;
}

/* ===== HISTORY SECTION STYLES ===== */
.history-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin: 20px auto;
    max-width: 1200px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.history-section h3 {
    color: #333;
    margin-bottom: 15px;
    border-bottom: 2px solid #6e8efb;
    padding-bottom: 8px;
}

#historyList {
    list-style: none;
    margin: 15px 0;
    max-height: 300px;
    overflow-y: auto;
    padding: 0;
}

#historyList li {
    background: #f9f9f9;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #6e8efb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#historyList li div:first-child {
    flex: 1;
    margin-right: 10px;
    word-break: break-word;
}

.history-controls {
    text-align: center;
    margin-top: 15px;
}

#clearHistoryBtn {
    background-color: #f44336;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    font-size: 14px;
}

#clearHistoryBtn:hover {
    background-color: #d32f2f;
}

#searchHistory {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

/* ===== COMMUNITY SECTION STYLES ===== */
.community-section {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin: 20px auto;
    max-width: 1200px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.community-section h3 {
    color: #333;
    margin-bottom: 15px;
    border-bottom: 2px solid #6e8efb;
    padding-bottom: 8px;
}

.community-filters {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.community-filters label {
    font-weight: bold;
    color: #555;
}

.community-filters select, 
.community-filters input {
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

#communityList {
    list-style: none;
    margin: 15px 0;
    max-height: 300px;
    overflow-y: auto;
    padding: 0;
}

#communityList li {
    background: #f9f9f9;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #a777e3;
}

/* Button styles for history items */
.text-btn {
    padding: 6px 10px;
    border: none;
    border-radius: 20px;
    background-color: #6e8efb;
    color: white;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
    margin-left: 5px;
}

.text-btn:hover {
    background-color: #5a7de0;
}

/* Error and empty state messages */
#historyList li, #communityList li {
    font-style: italic;
    color: #777;
    justify-content: center;
    border-left: 4px solid #ddd;
}

#historyList li, #communityList li {
    font-style: italic;
    color: #777;
    justify-content: center;
    border-left: 4px solid #ddd;
}
#historyList li:not(:has(div)) button, 
#communityList li:not(:has(div)) button {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .community-filters {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    #historyList li {
        flex-direction: column;
        align-items: flex-start;
    }
    
    #historyList li div:last-child {
        margin-top: 10px;
        align-self: flex-end;
    }
}

/* Remove duplicate and conflicting styles */
#historySection,
#publishSection,
#communitySection,
.history-item,
.filter-box,
.btn {
    display: none;
}
.loading {
    text-align: center;
    color: #666;
    font-style: italic;
}

.error {
    text-align: center;
    color: #f44336;
    font-weight: bold;
}
/* Pronunciation feedback highlights */
.pronunciation-match {
    background-color: #4CAF50 !important;  /* Green */
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    transition: background-color 0.3s;
}

.pronunciation-mismatch {
    background-color: #f44336 !important;  /* Red */
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    transition: background-color 0.3s;
}