@import url('https://fonts.googleapis.com/css2?family=Onest:wght@600&display=swap');

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

:root {
    --bg-color: #e0e5ec;
    --text-color: #3a4558;
    --primary-blue: #6b9bd1;
    --light-blue: #a8c5e6;
    --shadow-light: #ffffff;
    --shadow-dark: #a3b1c6;
    --inlay-light: #d8e5f8;
    --inlay-dark: #a8b5c8;
    --success: #5cb85c;
    --error: #fc8181;
}

body.high-contrast {
    --bg-color: #ffffff;
    --text-color: #000000;
    --primary-blue: #0066cc;
    --light-blue: #0066cc;
    --shadow-light: #dddddd;
    --shadow-dark: #333333;
    --inlay-light: #eeeeee;
    --inlay-dark: #666666;
    --success: #008800;
    --error: #cc0000;
}

body.high-contrast *:not(.language-panel) {
    transition: none !important;
    animation: none !important;
}

body {
    font-family: 'Onest', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-weight: 600;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow: hidden;
}

*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

*::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 10px;
    box-shadow: inset 2px 2px 4px var(--inlay-dark),
                inset -2px -2px 4px var(--inlay-light);
}

*::-webkit-scrollbar-thumb {
    background: var(--bg-color);
    border-radius: 10px;
    box-shadow: 2px 2px 4px var(--shadow-dark),
                -2px -2px 4px var(--shadow-light);
}

*::-webkit-scrollbar-thumb:hover {
    box-shadow: 1px 1px 2px var(--shadow-dark),
                -1px -1px 2px var(--shadow-light);
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--bg-color) var(--bg-color);
}

#app {
    width: 100vw;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 2rem;
}

.title {
    font-size: 3.5rem;
    color: #4a7eb8;
    margin-bottom: 3rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8),
                 0 2px 3px rgba(0, 0, 0, 0.15),
                 0 -1px 1px rgba(0, 0, 0, 0.12),
                 inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.small-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    margin-top: 1rem;
    text-align: center;
    color: #4a7eb8;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8),
                 0 2px 3px rgba(0, 0, 0, 0.15),
                 0 -1px 1px rgba(0, 0, 0, 0.12),
                 inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

.neu-button {
    background: var(--bg-color);
    border: none;
    padding: 1.5rem 3rem;
    border-radius: 12px;
    color: var(--text-color);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 6px 6px 12px var(--shadow-dark),
                -6px -6px 12px var(--shadow-light),
                inset 0 0 0 2px transparent;
    transition: all 0.2s ease;
    position: relative;
    pointer-events: auto;
    z-index: 1;
}

.neu-button::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border-radius: 8px;
    border: 3px solid;
    border-color: var(--primary-blue) var(--light-blue) var(--light-blue) var(--primary-blue);
    pointer-events: none;
    z-index: -1;
}

.neu-button:hover {
    box-shadow: 4px 4px 8px var(--shadow-dark),
                -4px -4px 8px var(--shadow-light);
}

.neu-button:active {
    box-shadow: inset 3px 3px 6px var(--shadow-dark),
                inset -3px -3px 6px var(--shadow-light);
    transform: scale(0.98);
}

.neu-button.primary {
    background: var(--bg-color);
    color: var(--text-color);
    box-shadow: 6px 6px 12px var(--shadow-dark),
                -6px -6px 12px var(--shadow-light),
                inset 0 0 0 2px transparent;
}

.neu-button.primary::before {
    border-color: var(--success) #a8c5e6 #a8c5e6 var(--success);
}

.neu-button.small {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.button-group {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.neu-input {
    background: var(--bg-color);
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: var(--text-color);
    font-size: 1rem;
    box-shadow: inset 3px 3px 6px var(--inlay-dark),
                inset -3px -3px 6px var(--inlay-light);
    transition: box-shadow 0.3s ease, transform 0.2s ease;
    outline: none;
    position: relative;
    z-index: 1;
}

.neu-input:focus {
    box-shadow: inset 4px 4px 8px var(--inlay-dark),
                inset -4px -4px 8px var(--inlay-light),
                0 0 0 2px var(--primary-blue);
}

.input-row.success {
    animation: wiggle-success 0.3s ease;
}

.input-row.error {
    animation: wiggle 0.3s ease;
}

.input-row.success .neu-input {
    box-shadow: inset 3px 3px 6px var(--inlay-dark),
                inset -3px -3px 6px var(--inlay-light),
                0 0 20px var(--success);
    transition: box-shadow 0.5s ease;
}

.input-row.error .neu-input {
    box-shadow: inset 3px 3px 6px var(--inlay-dark),
                inset -3px -3px 6px var(--inlay-light),
                0 0 20px var(--error);
    transition: box-shadow 0.5s ease;
}

@keyframes glow-success {
    0%, 100% { box-shadow: inset 3px 3px 6px var(--inlay-dark), inset -3px -3px 6px var(--inlay-light); }
    50% { box-shadow: inset 3px 3px 6px var(--inlay-dark), inset -3px -3px 6px var(--inlay-light), 0 0 20px var(--success); }
}

@keyframes glow-error {
    0%, 100% { box-shadow: inset 3px 3px 6px var(--inlay-dark), inset -3px -3px 6px var(--inlay-light); }
    50% { box-shadow: inset 3px 3px 6px var(--inlay-dark), inset -3px -3px 6px var(--inlay-light), 0 0 20px var(--error); }
}

@keyframes wiggle {
    0%, 100% { transform: translateY(-50%) translateX(0); }
    25% { transform: translateY(-50%) translateX(-10px); }
    75% { transform: translateY(-50%) translateX(10px); }
}

@keyframes wiggle-success {
    0%, 100% { transform: translateY(-50%); }
    25% { transform: translateY(calc(-50% - 10px)); }
    75% { transform: translateY(calc(-50% + 10px)); }
}

.hidden {
    display: none !important;
}

#passphrase-input-container {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.entry-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
    height: 100%;
    position: relative;
}


#animation-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 10;
}

.word-traveler {
    position: absolute;
    background: var(--bg-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--primary-blue);
    box-shadow: 3px 3px 6px var(--shadow-dark),
                -3px -3px 6px var(--shadow-light);
    visibility: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.autocomplete-container {
    width: 100%;
    max-width: 600px;
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--bg-color);
    border-radius: 12px;
    box-shadow: inset 2px 2px 4px var(--inlay-dark),
                inset -2px -2px 4px var(--inlay-light);
    display: none;
    position: absolute;
    bottom: calc(50% + 80px);
    left: 0;
    right: 0;
    z-index: 15;
}

.autocomplete-container.active {
    display: block;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s ease;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: rgba(107, 155, 209, 0.1);
}

.input-row {
    display: flex;
    gap: 1rem;
    width: 100%;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

.word-input {
    flex: 1;
}

.word-list {
    width: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem;
    padding-right: 1rem;
    position: absolute;
    top: calc(50% + 80px);
    left: 0;
    right: 0;
    bottom: 2rem;
    z-index: 1;
}

.word-item {
    background: var(--bg-color);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--primary-blue);
    box-shadow: 3px 3px 6px var(--shadow-dark),
                -3px -3px 6px var(--shadow-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.remove-word-btn {
    background: transparent;
    border: none;
    color: var(--inlay-dark);
    font-size: 1.5rem;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 2px 2px 4px var(--inlay-dark),
                inset -2px -2px 4px var(--inlay-light);
    transition: all 0.2s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.remove-word-btn:hover {
    color: var(--error);
    box-shadow: inset 3px 3px 6px var(--inlay-dark),
                inset -3px -3px 6px var(--inlay-light);
}

#list-view-screen {
    display: flex;
    flex-direction: row;
}

.sidebar {
    width: 320px;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 8px rgba(163, 177, 198, 0.3);
    transition: all 0.3s ease;
}

.sidebar.slide-in {
    animation: slideFromCenter 0.5s ease;
}

@keyframes slideFromCenter {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 320px;
        opacity: 1;
    }
}

.saved-word-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.saved-word-item {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-color);
    font-weight: 500;
    box-shadow: 4px 4px 8px var(--shadow-dark),
                -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
}

.saved-word-item:hover {
    box-shadow: 2px 2px 4px var(--shadow-dark),
                -2px -2px 4px var(--shadow-light);
    transform: translateY(-2px);
}

.saved-word-item.active {
    background: linear-gradient(145deg, var(--primary-blue), var(--light-blue));
    color: white;
}

.control-tray {
    padding: 1.5rem;
    display: flex;
    gap: 0.75rem;
    flex-direction: column;
    border-top: 1px solid rgba(163, 177, 198, 0.3);
}

.iframe-container {
    flex: 1;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

#sign-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 16px;
    background: white;
}

.hamburger-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 100;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-color);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 4px 4px 8px var(--shadow-dark),
                -4px -4px 8px var(--shadow-light);
    color: var(--text-color);
    display: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-color);
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 8px 8px 16px var(--shadow-dark),
                -8px -8px 16px var(--shadow-light),
                inset 0 0 0 3px transparent;
    max-width: 500px;
    width: 90%;
    position: relative;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    bottom: 8px;
    border-radius: 16px;
    border: 3px solid;
    border-color: var(--primary-blue) var(--light-blue) var(--light-blue) var(--primary-blue);
    pointer-events: none;
    z-index: -1;
}

.modal-content h2 {
    color: var(--primary-blue);
    margin-bottom: 1.5rem;
    text-align: center;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-color);
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 3px 3px 6px var(--shadow-dark),
                -3px -3px 6px var(--shadow-light);
    transition: all 0.2s ease;
    z-index: 10;
}

.modal-close:hover {
    box-shadow: 2px 2px 4px var(--shadow-dark),
                -2px -2px 4px var(--shadow-light);
    color: var(--error);
}

.modal-close:active {
    box-shadow: inset 2px 2px 4px var(--shadow-dark),
                inset -2px -2px 4px var(--shadow-light);
}

.passphrase-display {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: inset 3px 3px 6px var(--inlay-dark),
                inset -3px -3px 6px var(--inlay-light);
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    word-break: break-word;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.utility-tray {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    gap: 1rem;
    z-index: 50;
}

.utility-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-color);
    border: none;
    cursor: pointer;
    color: var(--text-color);
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 2px 2px 5px var(--shadow-dark),
                inset -2px -2px 5px var(--shadow-light);
    transition: all 0.2s ease;
}

.utility-btn svg {
    width: 100%;
    height: 100%;
}

#logo-btn svg path {
    fill: currentColor;
    stroke: none;
}

#localization-btn svg path,
#localization-btn svg line,
#localization-btn svg circle,
#vision-btn svg path,
#vision-btn svg circle {
    fill: none;
    stroke: currentColor;
}

.utility-btn:hover {
    color: var(--primary-blue);
}

.utility-btn:active {
    box-shadow: inset 4px 4px 8px var(--shadow-dark),
                inset -4px -4px 8px var(--shadow-light);
}

.language-panel {
    position: fixed;
    top: 0;
    right: -320px;
    width: 320px;
    height: 100vh;
    background: var(--bg-color);
    box-shadow: -4px 0 8px rgba(163, 177, 198, 0.3);
    transition: right 0.3s ease !important;
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

.language-panel.hidden {
    display: flex;
}

.language-panel.open {
    right: 0;
}

.language-panel-header {
    padding: 2rem 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--shadow-dark);
}

.language-panel-header h3 {
    color: var(--primary-blue);
    font-size: 1.5rem;
    margin: 0;
}

.language-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.language-item {
    background: var(--bg-color);
    padding: 1rem 1.25rem;
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-color);
    font-weight: 500;
    box-shadow: 4px 4px 8px var(--shadow-dark),
                -4px -4px 8px var(--shadow-light);
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.language-item:hover {
    box-shadow: 2px 2px 4px var(--shadow-dark),
                -2px -2px 4px var(--shadow-light);
    transform: translateY(-2px);
}

.language-item.active {
    background: linear-gradient(145deg, var(--primary-blue), var(--light-blue));
    color: white;
    border-color: var(--primary-blue);
}

.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
    pointer-events: none;
}

.toast {
    background: var(--bg-color);
    color: var(--text-color);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 6px 6px 12px var(--shadow-dark),
                -6px -6px 12px var(--shadow-light);
    font-weight: 600;
    font-size: 0.95rem;
    min-width: 200px;
    text-align: center;
    pointer-events: auto;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--error);
}

.toast-info {
    border-left: 4px solid var(--primary-blue);
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.3s ease;
    opacity: 0;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--bg-color);
    box-shadow: 6px 6px 12px var(--shadow-dark),
                -6px -6px 12px var(--shadow-light);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 6px 6px 12px var(--shadow-dark),
                    -6px -6px 12px var(--shadow-light);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 8px 8px 16px var(--shadow-dark),
                    -8px -8px 16px var(--shadow-light);
    }
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 1rem;
    padding: 2rem;
    pointer-events: none;
}

.empty-state.hidden {
    display: none;
}

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

    .utility-tray {
        top: 1rem;
        right: 1rem;
        gap: 0.75rem;
    }

    .utility-btn {
        width: 40px;
        height: 40px;
    }

    .hamburger-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .hidden-desktop {
        display: flex !important;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        width: 80%;
        max-width: 320px;
        z-index: 99;
        transition: left 0.3s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .iframe-container {
        width: 100%;
        padding: 1rem;
        padding-top: 4rem;
    }

    .title {
        font-size: 2.75rem;
        margin-bottom: 2rem;
    }

    .small-title {
        font-size: 2rem;
    }
    
    #start-screen .title {
        font-size: 3rem;
    }

    .button-group {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }

    .neu-button {
        padding: 1rem 2rem;
        font-size: 1rem;
    }

    .input-row {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 0.5rem;
        align-items: center;
    }
    
    .word-input {
        flex: 1;
        min-width: 0;
    }
    
    #enter-btn,
    #save-btn {
        flex: 0 0 auto;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
        white-space: nowrap;
    }
    
    .entry-area {
        padding: 0 1rem;
    }

    .modal-content {
        padding: 1.5rem;
        width: 95%;
    }

    .modal-actions {
        flex-direction: column;
        width: 100%;
    }

    .modal-actions .neu-button {
        width: 100%;
    }

    .passphrase-display {
        font-size: 1rem;
        padding: 1rem;
    }

    .language-panel {
        width: 280px;
        right: -280px;
    }

    .toast-container {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        transform: none;
    }

    .toast {
        width: 100%;
    }

    .autocomplete-container {
        max-height: 150px;
    }

    .empty-state {
        font-size: 0.9rem;
        padding: 1rem;
    }

    #passphrase-input-container {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
        padding: 0 1rem;
    }

    #passphrase-input-container .neu-input,
    #passphrase-input-container .neu-button {
        width: 100%;
    }

    .autocomplete-container {
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
        bottom: calc(50% + 180px);
    }

    .word-list {
        left: 0;
        right: 0;
        padding: 0.5rem 1rem;
        padding-right: 1rem;
        top: calc(50% + 180px);
    }
}
