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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
    line-height: 1.5;
    -webkit-user-select: none;
    /* Prevent text selection on iOS */
    -webkit-touch-callout: none;
    /* Disable callout on iOS */
    -webkit-tap-highlight-color: transparent;
    /* Remove tap highlight */
}

#app {
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile Safari */
    width: 100vw;
    width: 100dvw;
    /* Dynamic viewport width for mobile Safari */
    position: relative;
    overflow: hidden;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
    transform: translateX(100%);
    display: flex;
    flex-direction: column;
}

.view.active {
    transform: translateX(0);
}

.header {
    background: #1c1c1e;
    padding: 20px;
    border-bottom: 1px solid #38383a;
    position: relative;
}

.header h1,
.header h2 {
    color: #fff;
    font-size: 24px;
    font-weight: 600;
}

#back-btn {
    background: none;
    border: none;
    color: #007aff;
    font-size: 18px;
    cursor: pointer;
    margin-bottom: 10px;
}

#see-all-btn {
    background: none;
    border: 1px solid #007aff;
    color: #007aff;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    position: absolute;
    top: 20px;
    right: 20px;
    transition: all 0.2s ease;
}

#see-all-btn:hover {
    background: #007aff;
    color: white;
}

#translation-toggle {
    background: none;
    border: 1px solid #007aff;
    color: #007aff;
    font-size: 14px;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    position: absolute;
    top: 20px;
    right: 20px;
    transition: all 0.2s ease;
}

#translation-toggle:hover {
    background: #007aff;
    color: white;
}

#translation-toggle.active {
    background: #007aff;
    color: white;
}

.conversations {
    padding: 0;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
}

.conversation-item {
    padding: 15px 20px;
    border-bottom: 1px solid #38383a;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: #1c1c1e;
}

.conversation-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.conversation-item.disabled:hover {
    background: transparent;
}

.conversation-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 5px;
}

.conversation-preview {
    font-size: 14px;
    color: #8e8e93;
    opacity: 0.8;
}

.messages {
    padding: 20px 20px 30px 20px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scrolling on iOS */
}

.message {
    margin-bottom: 15px;
    display: flex;
    align-items: flex-end;
}

.message.socrates {
    justify-content: flex-end;
}

.message.socrates>div {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message.other {
    justify-content: flex-start;
    text-align: left;
}

.message.other>div {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.message-bubble {
    max-width: 70%;
    min-width: fit-content;
    padding: 12px 16px;
    border-radius: 20px;
    font-size: 16px;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    opacity: 0;
    transform: translateY(10px);
    animation: slideInMessage 0.3s ease-out forwards;
    -webkit-user-select: text;
    /* Allow text selection in bubbles */
    user-select: text;
}

@keyframes slideInMessage {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble.no-animation,
.speaker-name.no-animation {
    animation: none;
    opacity: 1;
    transform: none;
}

.message.socrates .message-bubble {
    background: #007aff;
    color: white;
    border-bottom-right-radius: 5px;
}

.message.other .message-bubble {
    background: #3a3a3c;
    color: white;
    border-bottom-left-radius: 5px;
}

.speaker-name {
    font-size: 12px;
    color: #8e8e93;
    margin-bottom: 5px;
    padding: 0 16px;
    font-weight: 500;
    opacity: 0;
    animation: fadeIn 0.3s ease-out 0.1s forwards;
}

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

.message.socrates .speaker-name {
    text-align: right;
}

.message.other .speaker-name {
    text-align: left;
}

.typing-indicator {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    margin-bottom: 15px;
}

.typing-bubble {
    background: #3a3a3c;
    border-radius: 20px;
    border-bottom-left-radius: 5px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    opacity: 0;
    transform: scale(0.8);
    animation: popIn 0.2s ease-out forwards;
}

@keyframes popIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #8e8e93;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        opacity: 0.3;
    }

    30% {
        opacity: 1;
    }
}

.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #38383a;
    border-top-color: #007aff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: #8e8e93;
    font-size: 14px;
}

.conversation-ended {
    text-align: center;
    color: #8e8e93;
    font-size: 13px;
    padding: 20px;
    margin-top: 10px;
    opacity: 0;
    animation: fadeIn 0.5s ease-out 0.3s forwards;
}

.conversation-ended.no-animation {
    animation: none;
    opacity: 1;
}

@media (min-width: 768px) {
    #app {
        max-width: 400px;
        margin: 0 auto;
        border: 1px solid #38383a;
        border-radius: 10px;
        overflow: hidden;
        margin-top: 50px;
        height: calc(100vh - 100px);
    }

}