:root {
    --ios-blue: #007AFF;
    --ios-gray: #E9E9EB;
    --ios-dark-gray: #8E8E93;
    --bg-color: #FFFFFF;
    --header-bg: rgba(249, 249, 249, 0.8);
    --input-bg: #FFFFFF;
    --text-color: #000000;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    overflow: hidden;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
    background: #fff;
}

.chat-header {
    padding: 10px 16px;
    padding-top: env(safe-area-inset-top, 10px);
    background-color: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.avatar-container {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0,0,0,0.05);
}

.header-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.25);
    transition: transform 0.2s ease;
}

.contact-info {
    text-align: center;
    width: 100%;
}

.name-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.contact-name {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
}

.verified-badge {
    width: 14px;
    height: 14px;
    color: var(--ios-blue);
    flex-shrink: 0;
}

.persona-selector {
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.persona-label {
    font-size: 11px;
    color: var(--ios-dark-gray);
    font-weight: 500;
}

#persona-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: rgba(0,0,0,0.05);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    border: none;
    border-radius: 8px;
    font-size: 11px;
    padding: 4px 24px 4px 10px;
    color: var(--ios-dark-gray);
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    outline: none;
    transition: background-color 0.2s;
}

#persona-select:active {
    background-color: rgba(0,0,0,0.1);
}

.contact-status {
    display: block;
    font-size: 10px;
    color: var(--ios-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #fff;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: none;
}

.chat-messages::-webkit-scrollbar {
    display: none;
}

.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
    animation: messageSlide 0.2s ease-out;
}

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

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-bubble {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 16px;
    line-height: 1.35;
    position: relative;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background-color: var(--ios-blue);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.user .message-bubble::after {
    content: "";
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 15px;
    height: 18px;
    background-color: var(--ios-blue);
    border-bottom-left-radius: 15px;
    clip-path: polygon(0 0, 0% 100%, 100% 100%);
}

.message.assistant .message-bubble {
    background-color: var(--ios-gray);
    color: black;
    border-bottom-left-radius: 4px;
}

.message.assistant .message-bubble::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 15px;
    height: 18px;
    background-color: var(--ios-gray);
    border-bottom-right-radius: 15px;
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.message-content p { margin: 8px 0; }
.message-content p:first-child { margin-top: 0; }
.message-content p:last-child { margin-bottom: 0; }

.message-content pre {
    background: rgba(0,0,0,0.05);
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 14px;
    margin: 8px 0;
    position: relative;
}

.copy-button {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 255, 255, 0.8);
    border: 0.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    font-weight: 600;
    text-transform: uppercase;
}

.message-content pre:hover .copy-button {
    opacity: 1;
}

.copy-button.copied {
    color: var(--ios-blue);
}

.message-content code {
    font-family: "SF Mono", "Menlo", monospace;
    background: rgba(0,0,0,0.05);
    padding: 2px 4px;
    border-radius: 4px;
}

.message-content ul, .message-content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.read-receipt {
    font-size: 10px;
    color: var(--ios-dark-gray);
    margin-top: 2px;
    margin-right: 4px;
    align-self: flex-end;
    font-weight: 500;
}

.chat-input-area {
    padding: 8px 12px;
    padding-bottom: calc(env(safe-area-inset-bottom, 10px) + 20px);
    background-color: #fff;
    border-top: 0.5px solid rgba(0, 0, 0, 0.1);
}

.chat-input-container {
    display: flex;
    align-items: flex-end;
    background-color: #fff;
    border: 1px solid #d1d1d6;
    border-radius: 22px;
    padding: 4px 4px 4px 12px;
}

#message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 20px;
    line-height: 20px;
}

#send-button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--ios-blue);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 8px;
}

#send-button:disabled {
    opacity: 0.3;
}

#send-button svg {
    width: 20px;
    height: 20px;
}

.loading-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.loading-dots span {
    width: 7px;
    height: 7px;
    background-color: #8E8E93;
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-4px); opacity: 1; }
}

/* Footer Styling */
.site-footer {
    text-align: center;
    font-size: 10px;
    color: var(--ios-dark-gray);
    margin-top: 12px;
    letter-spacing: 0.3px;
    font-weight: 500;
    opacity: 0.7;
    text-transform: uppercase;
}

.site-footer .heart {
    color: #ff3b30; /* iOS Red */
    display: inline-block;
    animation: pulse 2s infinite;
}

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