* {
    box-sizing: border-box;
    font-family: font-family-apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background-color: #fafafa;
    margin: 0;
    padding: 0;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(50px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    z-index: 1000;
}

h2 {
    color: #000;
    font-size: 24px;
    font-style: normal;
    font-weight: 510;
    line-height: normal;
    margin: 0;
}

header img {
    height: 48px;
}

header nav {
    display: flex;
    gap: 10px;
}

.container {
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: 100vh;
    padding-top: 68px;
}

.left-section {
    min-width: 240px;
    padding: 12px;
    background-color: #fff;
    bottom: 0;
}

#input-section {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-self: stretch;
    width: fit-content;
}

#input-section > div {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#word-input {
    min-height: 200px;
    resize: none;
}

#import-file-input {
    display: none;
}


.right-section {
    display: flex;
    flex-direction: column;
    justify-self: stretch;
    width: 100%;
    height: 100%;
    gap: 20px;
    padding: 20px;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    padding: 20px 20px;
    border-radius: 28px;
    gap: 20px;
}

.status-bar > p {
    color: #333;
    font-size: 18px;
    font-style: normal;
    font-weight: 510;
    line-height: normal;
    text-wrap: nowrap;
    margin: 0;
}

#progress-container {
    width: 100%;
    background-color: #f5f5f5;
    border-radius: 100px;
    overflow: hidden;
    max-width: 600px;
}

#progress-bar {
    height: 20px;
    background-color: #407CEA;
    text-align: center;
    line-height: 30px;
    color: white;
    width: 0;
    border-radius: 10px;
}

.centered {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.login-container {
    background: #fff;
    padding: 32px;
    border-radius: 28px;
    text-align: center;
    max-width: 400px;
}

.login-container > h2 {
    margin-bottom: 20px;
}

#login-section input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    border: 1px solid #ddd;
}

textarea, input[type="text"], input[type="password"] {
    width: 100%;
    padding: 13px 18px;
    border-radius: 16px;
    border: 1px solid #DDD;
    background: #FFF;
    color: #333;
    text-align: left;
    font-size: 18px;
    font-style: normal;
    font-weight: 310;
    line-height: normal;
}

textarea {
    height: 100px;
}

textarea:focus, input[type="text"]:focus, input[type="password"]:focus,
textarea:active, input[type="text"]:active, input[type="password"]:active {
    outline: 2px solid #407CEA;
}

textarea.valid, input[type="text"].valid, input[type="password"].valid {
    outline: 2px solid #8FC44C;
}

textarea.invalid, input[type="text"].invalid, input[type="password"].invalid {
    outline: 2px solid #CF1919;
}

button {
    font-size: 18px;
    height: 48px;
    font-style: normal;
    font-weight: 510;
    line-height: normal;
    border-radius: 16px;
    border: none;
    display: flex;
    padding: 13px 26px;
    justify-content: center;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all ease-in-out 150ms;
}

.nav-button, .play-button {
    color: #333;
    background-color: #ffffff00;
}

.play-button {
    border-radius: 24px;
    padding: 13px;
    width: 48px;
    height: 48px;
}

.nav-button:hover, .play-button:hover {
    color: #333;
    background: #F5F5F5;
}

.nav-button:active,
.nav-button:focus, .play-button:active,
.play-button:focus {
    color: #407CEA;
    background: #E3EBFC;
}

.nav-button.selected {
    color: #407CEA;
    background: #E3EBFC;
}

.primary-button {
    color: #FFF;
    background: #407CEA;
}

.primary-button:hover {
    color: #FFF;
    background: #333;
}

.primary-button:active,
.primary-button:focus {
    background: #407CEA;
}

.secondary-button {
    color: #333;
    border: 1px solid #DDD;
    background: #FFF;
}

.secondary-button:hover {
    background: #F5F5F5;
}

.secondary-button:active,
.secondary-button:focus {
    background: #ddd;
}

/* Flashcard */
#flashcard-section {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 40px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    align-self: stretch;
}

#flashcard-feedback-rail {
    width: 100%;
    max-width: 800px;
    display: none;
}

#flashcard-tools-rail {
    width: 100%;
    max-width: 800px;
    display: none;
}

#flashcard-recording-indicator {
    width: 100%;
    max-width: 800px;
    display: none;
}

#flashcard {
    display: flex;
    height: 480px;
    padding: 12px;
    min-width: 600px;
    max-width: 800px;
    width: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    border-radius: 32px;
    background: #FFF;
    box-shadow: 0px 4px 25px 0px rgba(0, 0, 0, 0.10);
}

#flashcard-upper-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    flex: 1;
    align-self: stretch;
    flex-grow: 1;
    background-color: #fafafa;
    border-radius: 20px 20px 12px 12px;
    gap: 12px;
    padding: 16px;
}

.flashcard-word-sentence {
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    align-self: stretch;
}

#word-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 24px;
    padding-right: 2px;
    gap: 6px;
    background: #fff;
    border-radius: 25px;
    height: 52px;
}

#word-container > p {
    color: #407CEA;
    font-size: 24px;
    font-style: normal;
    font-weight: 590;
    line-height: normal;
    margin: 0;
}

#sentence-container {
    display: flex;
    height: 100%;
    padding-bottom: 20px;
    justify-content: center;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 500;
    white-space: nowrap;
    align-self: stretch;
}

.memorize_special-characters {
    display: flex;
    /* padding-left: 12px; */
    justify-content: space-between;
    align-items: center;
    align-self: stretch;
}

.memorize-section, .word-item-info-action {
    display: flex; 
    gap: 12px;
    flex-wrap: nowrap;
    
}

.word-item-info-action {
    min-width: 350px;
}

.memorize-info {
    font-size: 18px;
    height: 48px;
    font-style: normal;
    font-weight: 510;
    line-height: normal;
    border-radius: 16px;
    display: flex;
    padding: 13px;
    justify-content: center;
    align-items: center;
    gap: 4px;
    background: #fff;
    color: #808080;
    border: #eee 1px solid;
}

.memorize-info > p {
    margin: 0;
}

/* for memorize progress feature in the future */
/* #memorize-progress {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 16px;
    height: 16px;
    background: #C6D8F9;
    border-radius: 8px;
}

.dot.filled {
    background: #407CEA;
} */

#special-characters {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

/* flashcard lower */
#flashcard-lower-container {
    display: flex;
    padding: 16px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    align-self: stretch;
}

#flashcard-en-cn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 6px;
}

#flashcard-en-cn > p {
    color: #555;
    font-size: 18px;
    font-style: normal;
    font-weight: 380;
    line-height: normal;
    margin: 0;
}

#flashcard-actions {
    display: flex;
    flex-direction: row-reverse;
    gap: 12px;
}

.flashcard-action-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.ai-actions {
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.flashcard-feedback {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    border-radius: 16px;
    background: #FAFAFA;
    border: 1px solid #EEE;
    padding: 12px 16px;
}

.flashcard-feedback > p {
    margin: 0;
    color: #555;
    font-size: 16px;
    font-style: normal;
    font-weight: 380;
    line-height: 1.45;
}

.flashcard-feedback > p > strong {
    color: #333;
    font-weight: 510;
}

.feedback-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.feedback-row > p {
    margin: 0;
    flex: 1;
}

.feedback-close {
    min-width: 32px;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 16px;
    border: 1px solid #DDD;
    background: #FFF;
    color: #555;
    font-size: 16px;
    line-height: 1;
}

.recording-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-radius: 16px;
    border: 1px solid #F2C8C8;
    background: #FFF4F4;
    padding: 10px 12px;
}

.recording-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #8A1C1C;
    font-size: 16px;
    font-weight: 510;
}

.recording-dot {
    width: 10px;
    height: 10px;
    border-radius: 5px;
    background: #CF1919;
}


#user-input {
    display: flex;
    width: fit-content;
    min-width: 200px;
    max-width: 340px;
    padding: 13px 18px;
    justify-content: center;
    align-items: center;
    gap: 12px;
    border-radius: 16px;
    border: 1px solid #DDD;
    background: #FFF;
    color: #333;
    font-size: 24px;
    font-style: normal;
    font-weight: 410;
    line-height: normal;
}

#user-input:focus,
#user-input:active {
    outline: 2px solid #407CEA;
    /* font-size: 24px;
    font-style: normal;
    font-weight: 410;
    line-height: normal; */
}

#user-input.correct, #user-input.correct:focus {
    color: #8FC44C;
    outline: 2px solid #8FC44C;
    /* font-size: 24px;
    font-style: normal;
    font-weight: 410;
    line-height: normal; */
}

#user-input.partial-correct, #user-input.partial-correct:focus {
    color: #E9B01D;
    outline: 2px solid #E9B01D;
    /* font-size: 24px;
    font-style: normal;
    font-weight: 410;
    line-height: normal; */
}

#user-input.incorrect, #user-input.incorrect:focus {
    color: #CF1919;
    outline: 2px solid #CF1919;
    /* font-size: 24px;
    font-style: normal;
    font-weight: 410;
    line-height: normal; */
}

.section-title {
    padding: 16px 32px;
    padding-top: 32px;
    width: 100%;
}

.section-title > h2 {
    margin: 0;
}

#word-list-section {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    height: 100%;
    border-radius: 32px;
    background: #FFF;
    overflow-y: scroll;
}

#word-list {
    display: flex;
    padding-left: 32px;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    width: 100%;
    height: 100%;
    border-radius: 32px;
    background: #FFF;
    overflow-y: scroll;
}

.word-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    align-self: stretch;
}

.word-item p {
    margin: 0;
    line-height: normal;
}

.word-item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-right: 32px;
    width: 100%;
}

.word-item-text-content {
    display: flex;
    padding-right: 32px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    align-self: stretch;
}

.word-item-row-1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    align-self: stretch;
}

.word-item-german {
    display: flex;
    align-items: baseline;
    gap: 20px;
}

.word-item-word {
    font-size: 20px;
    font-weight: 500;
}

.word-item-sentence {
    color: #808080;
    font-size: 18px;
    font-style: normal;
    font-weight: 400;
    line-height: normal;
}

.word-item-row-2 {
    display: flex;
    align-items: center;
    gap: 20px;
    align-self: stretch;
}

.word-item-meanings, .word-item-translations {
    color: #808080aa;
    font-size: 18px;
    font-style: normal;
    font-weight: 380;
    line-height: normal;
}

.divider {
    height: 1px;
    align-self: stretch;
    background-color: #ddd;
}

.divider.last {
    height: 1px;
    align-self: stretch;
    background-color: #dddddd00;
}



#sync-status {
    display: none;
    margin-top: 10px;
    text-align: center;
    color: #808080;
    margin-bottom: 0;
    transition: all ease-in-out 150ms;
}

@media screen and (max-width: 1024px) {
    .container {
        flex-direction: column-reverse;
        padding-top: 0;
        overflow-y: hidden
    }

    .nav-button {
        padding: 8px;
    }

    .left-section {
        width: 100%;
        min-width: unset;
        padding-bottom: 40px;
    }

    #input-section {
        width: 100%;
        padding: 12px;
        flex-direction: column;
        gap: 8px;
    }
    

    #input-section > div {
        width: 100%;
        flex-direction: row;
        gap: 8px;
        transition: all ease-in-out 150ms;
    }

    .left-section button {
        min-width: 44px;
        width: 100%;
        padding: 13px;
        justify-content: center;
    }

    #sync-status {
        margin-top: unset;
        max-height: 44px;
        width: 100%;
    }

    button {
        font-size: 16px;
        height: 44px;
        transition: all ease-in-out 150ms;
    }

    .button-text, .sync-status-text {
        display: none;
    }

    #add-new-word-section > button {
        width: 44px;
    }

    #word-input {
        min-height: unset;
        max-height: 44px;
        padding: 6px 12px;
        line-height: 180%;
    }

    .right-section {
        width: 100%;
        margin-top: 68px;
        padding: 0;
        gap: 0;
    }

    .status-bar{
        border-radius: 0;
        padding: 4px 20px 12px 20px;
        background-color: rgba(255, 255, 255, 0.5);
    }

    .status-bar > p {
        font-size: 16px;
    }

    #progress-bar {
        height: 12px;
    }

    #flashcard-section {
        padding: 16px 20px;
        justify-content: start;
    }

    #flashcard {
        min-width: 100%;
        max-width: 100%;
        min-height: 380px;
        max-height: 420px;
        padding: 8px;
        gap: 0;
    }

    #flashcard-upper-container {
        border-radius: 24px 24px 12px 12px;
        padding: 8px;
    }

    #sentence-container {
        font-size: 18px;
        gap: 6px;
        flex-wrap: wrap;
        max-height: 100px;
    }

    #user-input {
        width: 100%;
        min-width: unset;
        max-width: 300px;
        font-size: 18px;
        padding: 8px 8px;
        border-radius: 12px;
        min-width: 100px;
        max-width: 200px;
    }

    .memorize-info {
        height: 44px;
    }

    .memorize-info > p {
        font-size: 14px;
    }
    
    #special-characters {
        display: none;
    }

    #word-container {
        height: 44px;
    }

    .play-button {
        width: 40px;
        height: 40px;
        padding: 8px;
    }


    #flashcard-lower-container {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        padding: 8px 0 0 0;
    }

    .memorize_special-characters {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    #flashcard-en-cn {
        align-items: center;
        text-align: center;
    }

    #flashcard-en-cn > p {
        font-size: 16px;
    }

    #word-container > p {
        font-size: 16px;
    }

    #flashcard-actions {
        width: 100%;
    }

    .flashcard-action-stack {
        width: 100%;
        align-items: stretch;
    }

    .ai-actions {
        width: 100%;
    }

    #flashcard-actions > button,
    .ai-actions > button {
        width: 100%;
        border-radius: 24px;
    }

    #flashcard-feedback-rail {
        max-width: 100%;
    }

    #flashcard-tools-rail,
    #flashcard-recording-indicator,
    #flashcard-feedback-rail {
        max-width: 100%;
    }


    /* Wordlist */
    #word-list {
        padding-left: 0;
    }

    #word-list-section{
        border-radius: 0;
    }
    .word-item-content {
        justify-content: start;
        gap: 12px;
        flex-direction: column;
        padding-left: 20px;
        padding-right: 20px;
    }

    .word-item-row-1, .word-item-row-2, .word-item-german {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .word-item-row-2 {
        gap: 2px;
    }

    .word-item-info-action {
        justify-content: space-between;
        width: 100%;
        min-width: unset;
    }

    .word-item-word {
        font-size: 18px;
    }

    .word-item-sentence, .word-item-meanings, .word-item-translations {
        font-size: 16px;
    }

    /* Adjust layout for Word List view to size to content and avoid full-viewport scroller */
    body.view-wordlist .container {
        height: auto;
        min-height: calc(100vh - 68px); /* keep at least screen height below fixed header */
        overflow-y: visible;
    }

    

    body.view-wordlist #word-list-section,
    body.view-wordlist #word-list {
        height: auto;
        overflow: visible; /* let the page scroll naturally */
    }

    /* Word List: pin input bar to viewport bottom on small screens */
    body.view-wordlist .left-section {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1001;
        background: #fff;
        border-top: 1px solid #ddd;
        box-shadow: 0 -8px 24px rgba(0,0,0,0.06);
        /* safe area for iOS and spacing */
        padding: 12px env(safe-area-inset-right) calc(12px + env(safe-area-inset-bottom)) env(safe-area-inset-left);
    }

    /* Make room for the fixed footer */
    body.view-wordlist .right-section {
        height: auto;
        padding-bottom: calc(var(--wordlist-footer-height, 140px) + env(safe-area-inset-bottom));
        overflow-y: auto;
    }

    

}
