:root {
    --primary-color: #0084ff;
    --pi-gold: #FFB300;
    --bg-primary: #ffffff;
    --bg-secondary: #f0f2f5;
    --bg-tertiary: #e4e6eb;
    --text-primary: #050505;
    --text-secondary: #65676b;
    --border-color: #ced0d4;
    --hover-overlay: rgba(0, 0, 0, 0.05);
    --message-bg-sent: #0084ff;
    --message-bg-received: #e4e6eb;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-3: 0 4px 16px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    overflow: hidden;
}

body.settings-open {
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* ===== LOGIN SCREEN ===== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 3rem 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-3);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.login-logo {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.login-container h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.login-container p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.95rem;
}

.login-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--pi-gold);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-2);
}

.login-btn:hover {
    background: #ffa000;
    transform: translateY(-2px);
    box-shadow: var(--shadow-3);
}

.login-btn:active {
    transform: translateY(0);
}

/* ===== MAIN APP LAYOUT ===== */
.main-app {
    display: flex;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 360px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.sidebar-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--bg-tertiary);
}

.icon-btn:active {
    transform: scale(0.95);
}

/* ===== SEARCH BOX ===== */
.search-box {
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-primary);
}

.search-box svg {
    color: var(--text-secondary);
}

.search-box input {
    flex: 1;
    border: none;
    background: var(--bg-secondary);
    padding: 0.625rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-secondary);
}

/* ===== CHAT LIST ===== */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    transition: background 0.15s ease;
    position: relative;
}

.chat-item:hover {
    background: var(--bg-secondary);
}

.chat-item.active {
    background: var(--bg-secondary);
}

.avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--pi-gold));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar.small {
    width: 40px;
    height: 40px;
}

.avatar-initials {
    color: white;
    font-weight: 600;
    font-size: 1.25rem;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #31a24c;
    border: 2px solid white;
    border-radius: 50%;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.chat-item-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.chat-item-time {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.chat-item-preview {
    font-size: 0.875rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-list-skeleton .chat-item {
    pointer-events: none;
}

.skeleton-placeholder .avatar {
    background: var(--bg-tertiary);
}

.skeleton-line {
    display: inline-block;
    height: 14px;
    border-radius: 999px;
    width: 70%;
}

.skeleton-line.short {
    width: 48px;
    height: 12px;
}

.skeleton-line.wide {
    width: 95%;
    height: 12px;
    margin-top: 6px;
}

.unread-badge {
    background: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

/* ===== CHAT AREA ===== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
}

.empty-state-icon {
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    max-width: 300px;
}

/* ===== ACTIVE CHAT ===== */
.active-chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    background: var(--bg-primary);
    box-shadow: var(--shadow-1);
    z-index: 10;
    gap: 0.75rem;
    position: sticky;
    top: 0;
}

.back-btn {
    display: none;
    background: var(--bg-secondary);
    box-shadow: none;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.chat-header-text h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-status {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

/* ===== MESSAGES CONTAINER ===== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg-primary);
}

.message {
    display: flex;
    gap: 0.5rem;
    max-width: 60%;
    animation: messageIn 0.2s ease;
}

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

.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

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

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message-bubble {
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
}

.message.sent .message-bubble {
    background: var(--message-bg-sent);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.received .message-bubble {
    background: var(--message-bg-received);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

.message-time {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    padding: 0 0.5rem;
}

.message.sent .message-time {
    text-align: right;
}

.message-reactions {
    display: flex;
    gap: 0.25rem;
    position: absolute;
    bottom: -12px;
    right: 8px;
    background: white;
    padding: 0.125rem 0.375rem;
    border-radius: 12px;
    box-shadow: var(--shadow-2);
    font-size: 0.875rem;
}

/* Payment message styles */
.message.payment .message-bubble {
    background: linear-gradient(135deg, var(--pi-gold), #ffa000);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.payment-icon {
    display: inline-block;
    margin-right: 0.25rem;
}

/* ===== MESSAGE INPUT ===== */
.message-input-container {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-primary);
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.message-input-wrapper {
    flex: 1;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 40px;
}

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.9375rem;
    max-height: 120px;
    overflow-y: auto;
    line-height: 1.4;
    color: var(--text-primary);
}

.message-input:empty:before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #0073e6;
    transform: scale(1.05);
}

.send-btn:active {
    transform: scale(0.95);
}

/* ===== MODALS ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-3);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.close-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
}

/* ===== SETTINGS PAGE ===== */
.settings-page {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    z-index: 950;
    overflow-y: auto;
}

.settings-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.settings-subtitle {
    margin-top: 0.25rem;
    color: var(--text-secondary);
}

.settings-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.settings-action-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.settings-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1rem;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    height: fit-content;
}

.settings-tab {
    border: none;
    background: transparent;
    padding: 0.65rem 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
}

.settings-tab:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.settings-tab.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-panel {
    display: none;
}

.settings-panel.active {
    display: block;
}

.settings-content {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-2);
    padding: 1.25rem 1.5rem;
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-row {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    flex: 1;
}

.setting-label label {
    font-weight: 700;
    display: block;
}

.setting-help {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.setting-row select {
    min-width: 140px;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.setting-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
}

.settings-status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.settings-status[data-status-type="success"] {
    background: #e6f4ea;
    color: #1f7a3d;
}

.settings-status[data-status-type="warning"] {
    background: #fff4e5;
    color: #a05a00;
}

.settings-status[data-status-type="info"] {
    background: #e8f0fe;
    color: #0b57d0;
}

.settings-meta {
    margin-top: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.settings-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Modal Tabs */
.modal-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-tab-btn:hover {
    color: var(--text-primary);
}

.modal-tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.modal-tab-content {
    display: none;
}

.modal-tab-content.active {
    display: block;
}

/* Form Groups */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 132, 255, 0.1);
}

/* Member Chips */
.member-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-color);
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
}

.member-chip-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.member-chip-remove:hover {
    opacity: 1;
}

/* Member List in Manage Modal */
.member-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.member-item-info {
    flex: 1;
}

.member-item-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.member-item-role {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.member-item-actions {
    display: flex;
    gap: 0.5rem;
}

.member-remove-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.member-remove-btn:hover {
    background: #dc2626;
}

/* User List */
.user-list {
    margin-top: 1rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-item:hover {
    background: var(--bg-secondary);
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 0.9375rem;
}

.user-username {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* Pi Send Form */
.pi-send-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.875rem;
}

.form-group input,
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
}

.wallet-balance {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.wallet-balance strong {
    color: var(--pi-gold);
    font-size: 1rem;
}

.btn-primary {
    padding: 0.875rem 1.5rem;
    background: var(--pi-gold);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #ffa000;
    transform: translateY(-1px);
    box-shadow: var(--shadow-2);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 0.85rem 1.25rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-secondary.ghost {
    background: transparent;
    border-style: dashed;
}

/* ===== EMOJI PICKER ===== */
.emoji-picker {
    position: absolute;
    bottom: 80px;
    right: 20px;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-3);
    padding: 1rem;
    width: 320px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    animation: emojiPickerIn 0.2s ease;
}

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

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 0.5rem;
    font-size: 1.5rem;
}

.emoji-grid span {
    cursor: pointer;
    text-align: center;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.emoji-grid span:hover {
    background: var(--bg-secondary);
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    body {
        background: var(--bg-secondary);
        overflow: hidden;
    }

    .main-app {
        flex-direction: column;
        height: 100vh;
        background: var(--bg-secondary);
    }

    .sidebar {
        width: 100%;
        position: relative;
        z-index: 10;
        height: 100vh;
        border-right: none;
        box-shadow: var(--shadow-2);
        transform: translateX(0);
        transition: transform 0.25s ease, opacity 0.25s ease;
    }

    .sidebar-header {
        position: sticky;
        top: 0;
        background: var(--bg-primary);
        z-index: 20;
        border-bottom: 1px solid var(--border-color);
    }

    .search-box {
        position: sticky;
        top: 64px;
        padding: 0.75rem 1rem;
        background: var(--bg-primary);
        border-bottom: 1px solid var(--border-color);
        z-index: 19;
    }

    .search-box input {
        background: var(--bg-secondary);
    }

    .chat-list {
        background: var(--bg-primary);
    }

    .chat-item {
        padding: 0.85rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .chat-area {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        background: var(--bg-primary);
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-3);
    }

    .main-app.mobile-chat-active .chat-area {
        transform: translateX(0);
    }

    .main-app.mobile-chat-active .sidebar {
        opacity: 0;
        pointer-events: none;
    }

    .back-btn {
        display: inline-flex;
    }

    .chat-header {
        padding: 0.75rem 1rem;
    }

    .messages-container {
        padding: 0.75rem 1rem;
    }

    .message {
        max-width: 86%;
    }

    .message-input-container {
        padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom));
    }

    .message-input-wrapper {
        padding: 0.45rem 0.65rem;
    }

    .emoji-picker {
        width: 280px;
        right: 10px;
        bottom: calc(70px + env(safe-area-inset-bottom));
    }

    .dev-console-toggle {
        left: 0.5rem;
        top: 0.5rem;
        font-size: 0.7rem;
        padding: 0.4rem 0.5rem;
    }

    .dev-console {
        left: 0.5rem;
        right: 0.5rem;
        top: 3rem;
        width: auto;
        max-width: calc(100vw - 1rem);
    }

    .settings-page {
        padding: 0.5rem;
    }

    .settings-layout {
        grid-template-columns: 1fr;
    }

    .settings-nav {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .settings-tab {
        flex: 1 1 45%;
        text-align: center;
    }
}

/* ===== LOADING STATES ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    to {
        background-position: -200% 0;
    }
}

/* ===== DEVELOPER CONSOLE ===== */
.dev-console-toggle {
    position: fixed;
    left: 1rem;
    top: 1rem;
    background: #1f2937;
    color: white;
    border: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    z-index: 50;
    opacity: 0.7;
    transition: transform 0.2s ease, opacity 0.2s ease;
    font-size: 0.75rem;
    font-weight: 500;
}

.dev-console-toggle .status-dot {
    width: 10px;
    height: 10px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.15);
    display: inline-block;
}

.dev-console-toggle .status-dot.off {
    background: #9ca3af;
    box-shadow: 0 0 0 6px rgba(156, 163, 175, 0.15);
}

.dev-console-toggle.muted {
    opacity: 0.6;
}

.dev-console-toggle:hover {
    transform: translateY(-2px);
    opacity: 1;
}

.dev-console-toggle.active {
    background: #111827;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.dev-console {
    position: fixed;
    left: 1rem;
    top: 3.5rem;
    width: 420px;
    max-height: 65vh;
    background: #0b1220;
    color: #e5e7eb;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 50;
}

.dev-console-tabs {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.35rem 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dev-console-tab {
    flex: 1;
    background: transparent;
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    font-weight: 600;
}

.dev-console-tab.active {
    background: rgba(255, 255, 255, 0.08);
    color: #f9fafb;
    border-color: rgba(255, 255, 255, 0.16);
}

.dev-console-body {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.dev-console-panel.hidden {
    display: none;
}

.dev-console-info-grid {
    padding: 0.75rem 1rem 0.25rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.dev-console-info-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.75rem;
}

.dev-console-info-card.full-width {
    grid-column: 1 / -1;
}

.dev-console-info-label {
    font-size: 0.75rem;
    color: #9ca3af;
    letter-spacing: 0.01em;
    margin-bottom: 0.25rem;
}

.dev-console-info-value {
    font-weight: 700;
    color: #f9fafb;
    font-size: 1rem;
}

.dev-console-info-meta {
    color: #cbd5e1;
    font-size: 0.85rem;
}

.dev-console-actions.info-actions {
    justify-content: flex-end;
    padding: 0.4rem 1rem 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.dev-console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dev-console-title {
    font-weight: 700;
    font-size: 0.95rem;
}

.dev-console-subtitle {
    font-size: 0.8125rem;
    color: #9ca3af;
}

.dev-console-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dev-console-capture-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.5rem;
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
}

.dev-console-capture-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.dev-console-btn {
    background: #111827;
    color: #e5e7eb;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.dev-console-btn.secondary {
    background: rgba(255, 255, 255, 0.08);
}

.dev-console-btn:hover {
    background: #0b1220;
    border-color: rgba(255, 255, 255, 0.15);
}

.dev-console-logs {
    padding: 0.75rem 1rem;
    overflow-y: auto;
    max-height: 55vh;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dev-console-entry {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.6rem;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.8125rem;
    line-height: 1.45;
}

.dev-console-entry pre {
    white-space: pre-wrap;
    word-break: break-word;
    color: #e5e7eb;
}

.dev-console-entry .dev-console-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
    color: #9ca3af;
}

.dev-console-level {
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #f9fafb;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

.dev-console-entry.warn .dev-console-level {
    background: rgba(234, 179, 8, 0.15);
    color: #f59e0b;
}

.dev-console-entry.error .dev-console-level {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.dev-console-entry.network .dev-console-level {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.dev-console-time {
    font-size: 0.75rem;
}

/* ===== UTILITIES ===== */
.text-muted {
    color: var(--text-secondary);
}

.text-small {
    font-size: 0.875rem;
}

.text-bold {
    font-weight: 600;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
