* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

body {
    background: linear-gradient(135deg, #e6f0ff 0%, #f0f7ff 100%);
    color: #1a1a1a;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    transition: background 0.3s ease;
}

.light-theme {
    background: linear-gradient(135deg, #e6f0ff 0%, #f0f7ff 100%);
    color: #1a1a1a;
}

.dark-theme {
    background: linear-gradient(135deg, #1e2a44 0%, #2a3a5a 100%);
    color: #e6e6e6;
}

.container {
    max-width: 700px;
    width: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-top: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    overflow: hidden;
}

.dark-theme .container {
    background: rgba(30, 40, 60, 0.95);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.container:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
}

h2 {
    font-size: 1.8rem;
    color: #1a73e8;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.dark-theme h2 {
    color: #64b5f6;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.auth-form input {
    padding: 14px;
    border: 1px solid #d1d9e6;
    border-radius: 12px;
    font-size: 1rem;
    background: #f8fafc;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    outline: none;
}

.dark-theme .auth-form input {
    background: #2c3e50;
    border-color: #546e7a;
    color: #e6e6e6;
}

.auth-form input:focus {
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.btn {
    padding: 14px;
    background: linear-gradient(90deg, #1a73e8, #4285f4);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn:hover {
    background: linear-gradient(90deg, #1557b0, #3578e5);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(26, 115, 232, 0.3);
}

.btn:disabled {
    background: #b0bec5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn svg {
    fill: #fff;
    width: 20px;
    height: 20px;
}

.copy-btn {
    background: linear-gradient(90deg, #4caf50, #66bb6a);
}

.copy-btn:hover {
    background: linear-gradient(90deg, #388e3c, #4caf50);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.3);
}

.delete-btn {
    background: linear-gradient(90deg, #d32f2f, #f44336);
}

.delete-btn:hover {
    background: linear-gradient(90deg, #b71c1c, #d32f2f);
    box-shadow: 0 5px 15px rgba(211, 47, 47, 0.3);
}

.exit-btn {
    background: linear-gradient(90deg, #f57c00, #ff9800);
}

.exit-btn:hover {
    background: linear-gradient(90deg, #e65100, #f57c00);
    box-shadow: 0 5px 15px rgba(245, 124, 0, 0.3);
}

.confirm-key-btn {
    background: linear-gradient(90deg, #0288d1, #03a9f4);
}

.confirm-key-btn:hover {
    background: linear-gradient(90deg, #01579b, #0288d1);
    box-shadow: 0 5px 15px rgba(2, 136, 209, 0.3);
}

.link {
    color: #1a73e8;
    text-decoration: none;
    font-size: 0.95rem;
    margin-top: 15px;
    display: inline-block;
    transition: color 0.3s ease;
}

.link:hover {
    color: #1557b0;
    text-decoration: underline;
}

.dark-theme .link {
    color: #64b5f6;
}

.dark-theme .link:hover {
    color: #42a5f5;
}

.error {
    background: rgba(255, 235, 238, 0.9);
    color: #d32f2f;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    margin-bottom: 15px;
    text-align: center;
    animation: slideIn 0.3s ease;
}

.success {
    background: rgba(200, 230, 201, 0.9);
    color: #2e7d32;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.95rem;
    margin-bottom: 15px;
    text-align: center;
    animation: slideIn 0.3s ease;
}

.key-display {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.key-display input {
    padding: 14px;
    border: 1px solid #d1d9e6;
    border-radius: 12px;
    font-size: 1rem;
    background: #f8fafc;
    text-align: center;
    flex: 1;
    min-width: 200px;
    outline: none;
}

.dark-theme .key-display input {
    background: #2c3e50;
    border-color: #546e7a;
    color: #e6e6e6;
}

.key-display .copy-btn {
    padding: 14px 20px;
    font-size: 0.95rem;
}

.warning {
    color: #d32f2f;
    font-size: 0.9rem;
    margin: 10px 0;
    text-align: center;
    font-weight: 500;
}

#key-form {
    display: none;
    margin: 20px 0;
    animation: slideIn 0.3s ease;
}

.key-form-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    max-width: 400px;
    margin: 0 auto;
}

.dark-theme .key-form-container {
    background: rgba(40, 50, 70, 0.9);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

#key-form input {
    padding: 14px;
    border: 1px solid #d1d9e6;
    border-radius: 12px;
    font-size: 1rem;
    background: #f8fafc;
    text-align: center;
    outline: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.dark-theme #key-form input {
    background: #2c3e50;
    border-color: #546e7a;
    color: #e6e6e6;
}

#key-form input:focus {
    border-color: #0288d1;
    box-shadow: 0 0 0 3px rgba(2, 136, 209, 0.1);
}

#messages {
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: background 0.3s ease;
}

.dark-theme #messages {
    background: rgba(30, 40, 60, 0.8);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

.message {
    margin: 10px 0;
    padding: 12px 18px;
    border-radius: 15px;
    max-width: 70%;
    position: relative;
    animation: slideIn 0.3s ease;
    transition: transform 0.2s ease;
}

.message:hover {
    transform: scale(1.02);
}

.message.sent {
    background: linear-gradient(90deg, #1a73e8, #4285f4);
    color: #fff;
    margin-left: auto;
    margin-right: 10px;
    border-top-right-radius: 5px;
}

.message.received {
    background: #fff;
    color: #1a1a1a;
    margin-right: auto;
    margin-left: 10px;
    border: 1px solid #e0e0e0;
    border-top-left-radius: 5px;
}

.dark-theme .message.received {
    background: #37474f;
    color: #e6e6e6;
    border-color: #546e7a;
}

.message.system {
    background: rgba(200, 230, 201, 0.9);
    color: #2e7d32;
    margin: 10px auto;
    text-align: center;
    max-width: 80%;
    border-radius: 10px;
}

.message .username {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 5px;
    display: block;
}

.message .content {
    display: block;
    font-size: 1rem;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.message .timestamp {
    font-size: 0.8rem;
    color: #757575;
    margin-top: 5px;
    display: block;
    text-align: right;
}

.message.sent .timestamp {
    color: #bbdefb;
}

.dark-theme .message.received .timestamp {
    color: #b0bec5;
}

#message-form {
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.dark-theme #message-form {
    background: rgba(30, 40, 60, 0.9);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#message-input {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    background: #f8fafc;
    outline: none;
    transition: box-shadow 0.3s ease;
}

.dark-theme #message-input {
    background: #2c3e50;
    color: #e6e6e6;
}

#message-input:focus {
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(90deg, #1a73e8, #4285f4);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle:hover {
    transform: rotate(360deg);
    box-shadow: 0 5px 15px rgba(26, 115, 232, 0.3);
}

.chat-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.chat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: slideIn 0.3s ease;
}

.dark-theme .chat-item {
    background: rgba(40, 50, 70, 0.9);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.chat-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.chat-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a73e8;
    text-decoration: none;
    flex: 1;
    transition: color 0.3s ease;
}

.dark-theme .chat-name {
    color: #64b5f6;
}

.chat-name:hover {
    color: #1557b0;
}

.dark-theme .chat-name:hover {
    color: #42a5f5;
}

.chat-actions {
    display: flex;
    gap: 10px;
}

.home-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        padding: 15px;
        margin: 10px;
        border-radius: 15px;
    }

    h2 {
        font-size: 1.5rem;
    }

    .auth-form input,
    .key-display input,
    #key-form input,
    #message-input {
        padding: 12px;
        font-size: 0.95rem;
    }

    .btn,
    .key-display .copy-btn,
    .copy-btn,
    .delete-btn,
    .exit-btn,
    .confirm-key-btn {
        padding: 12px;
        font-size: 0.95rem;
    }

    .message {
        max-width: 85%;
        padding: 8px 10px;
        margin-left: 5px;
        margin-right: 5px;
        font-size: 0.85rem;
    }

    .message.sent {
        margin-left: auto;
        margin-right: 5px;
    }

    .message.received {
        margin-right: auto;
        margin-left: 5px;
    }

    .message .username {
        font-size: 0.75rem;
    }

    .message .content {
        font-size: 0.85rem;
    }

    .message .timestamp {
        font-size: 0.65rem;
    }

    #messages {
        max-height: 400px;
        padding: 10px;
    }

    .theme-toggle {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .chat-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .chat-name {
        font-size: 1rem;
    }

    .chat-actions {
        width: 100%;
        justify-content: space-between;
    }

    .home-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .key-form-container {
        padding: 15px;
        max-width: 100%;
    }
}

@media (max-width: 400px) {
    .key-display,
    .key-form-container {
        flex-direction: column;
        align-items: stretch;
    }

    .key-display input,
    #key-form input {
        min-width: auto;
    }

    #message-form,
    .key-form-container {
        flex-direction: column;
        gap: 8px;
    }

    #message-input,
    #key-form input {
        border-radius: 10px;
    }

    #message-form .btn,
    .confirm-key-btn {
        border-radius: 10px;
        padding: 12px;
    }

    .chat-actions {
        flex-direction: column;
        gap: 8px;
    }

    .copy-btn,
    .delete-btn,
    .exit-btn {
        width: 100%;
    }
}