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

/* Theme Variables */
:root {
    --bg-primary: #000000;
    --bg-secondary: #1c1c1e;
    --bg-tertiary: #2c2c2e;
    --text-primary: #ffffff;
    --text-secondary: #98989d;
    --text-tertiary: #3a3a3c;
    --bubble-left: #2c2c2e;
    --bubble-right: #0a84ff;
    --border-color: #2c2c2e;
    --input-bg: #1c1c1e;
}

/* Light Theme */
:root[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f2f2f7;
    --bg-tertiary: #e5e5ea;
    --text-primary: #000000;
    --text-secondary: #8e8e93;
    --text-tertiary: #c7c7cc;
    --bubble-left: #e5e5ea;
    --bubble-right: #0a84ff;
    --border-color: #d1d1d6;
    --input-bg: #ffffff;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    width: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Mobile touch optimizations */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    touch-action: manipulation;
}

/* Main Container - Full Screen */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    width: 100vw;
    background: var(--bg-primary);
    overflow: hidden;
}

/* Header - Fixed Top */
.header {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 6px 16px;
    text-align: center;
    position: relative;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 44px;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 2px;
}

.header .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.header-buttons {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
}

.header-buttons-left {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 8px;
}

.settings-icon {
    background: transparent;
    border: none;
    color: #0a84ff;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.settings-icon:active {
    opacity: 0.6;
}

/* Settings Modal - Full Screen */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    z-index: 2000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.settings-modal.show {
    transform: translateX(0);
}

.settings-header {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    padding: 16px;
    border-bottom: 1px solid #2c2c2e;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    min-height: 56px;
}

.close-settings {
    background: transparent;
    border: none;
    color: #0a84ff;
    font-size: 28px;
    cursor: pointer;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    transition: opacity 0.2s ease;
}

.close-settings:active {
    opacity: 0.6;
}

.done-settings {
    background: transparent;
    border: none;
    color: #0a84ff;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 16px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.done-settings:active {
    opacity: 0.6;
}

.settings-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: #ffffff;
    flex: 1;
    text-align: center;
}

.settings-content {
    padding: 0 0 40px 0;
}

.settings-section {
    margin-top: 32px;
}

.settings-section:first-child {
    margin-top: 16px;
}

.settings-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: #98989d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0 16px 8px 16px;
}

.settings-group {
    background: #2c2c2e;
    border-top: 1px solid #3a3a3c;
    border-bottom: 1px solid #3a3a3c;
}

.settings-item {
    padding: 12px 16px;
    border-bottom: 1px solid #3a3a3c;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item label {
    display: block;
    font-size: 14px;
    color: #98989d;
    margin-bottom: 8px;
    font-weight: 500;
}

.settings-item input[type="text"],
.settings-item input[type="number"],
.settings-item select,
.settings-item textarea {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
}

.settings-item input[type="text"]:focus,
.settings-item select:focus,
.settings-item textarea:focus {
    outline: 2px solid #0a84ff;
    outline-offset: 0;
}

.settings-item textarea {
    min-height: 100px;
    resize: vertical;
}

.name-input-group {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.name-input-group input {
    flex: 1;
}

.update-name-btn {
    padding: 12px 20px;
    background: #0a84ff;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 17px;
    min-width: 88px;
    min-height: 44px;
    transition: opacity 0.2s ease;
}

.update-name-btn:active {
    opacity: 0.6;
}

.identity-display {
    padding: 16px;
    background: #1c1c1e;
    border-radius: 10px;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    color: #0a84ff;
}

.room-info, .partner-status {
    padding: 12px 16px;
    background: #1c1c1e;
    border-radius: 10px;
    font-size: 15px;
    color: #98989d;
}

.partner-status {
    color: #0a84ff;
}

.checkbox-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    min-height: 44px;
}

.checkbox-container label {
    font-size: 17px;
    color: #ffffff;
    font-weight: 400;
    margin: 0;
}

.checkbox-container input[type="checkbox"] {
    width: 51px;
    height: 31px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background: #3a3a3c;
    border-radius: 16px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.checkbox-container input[type="checkbox"]:checked {
    background: #34c759;
}

.checkbox-container input[type="checkbox"]::before {
    content: '';
    position: absolute;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: #ffffff;
    top: 2px;
    left: 2px;
    transition: transform 0.3s ease;
}

.checkbox-container input[type="checkbox"]:checked::before {
    transform: translateX(20px);
}

.invite-buttons {
    display: flex;
    gap: 12px;
    padding: 16px;
}

.invite-btn {
    flex: 1;
    padding: 12px;
    background: #0a84ff;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 17px;
    min-height: 44px;
    transition: opacity 0.2s ease;
}

.invite-btn:active {
    opacity: 0.6;
}

.invite-btn.secondary {
    background: #2c2c2e;
}

/* Modal Styles (for invite/link modals) */
.modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: #1c1c1e;
    padding: 24px;
    border-radius: 14px;
    max-width: 90%;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

/* Centered modal for action menu */
.centered-modal {
    max-width: 320px;
    text-align: center;
}

.action-menu-btn {
    width: 100%;
    padding: 16px;
    margin-bottom: 8px;
    font-size: 16px;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.action-menu-btn:active {
    opacity: 0.6;
}

.action-menu-btn-primary {
    background: #0a84ff;
    color: #ffffff;
    border-color: #0a84ff;
    font-weight: 600;
}

.action-divider {
    height: 1px;
    background: var(--border-color);
    margin: 12px 0;
}

.action-menu-cancel-btn {
    width: 100%;
    padding: 16px;
    background: transparent;
    color: #ff453a;
    border: none;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.feeling-number-btn {
    width: calc(20% - 6.4px);
    aspect-ratio: 1;
    background: #1c1c1e;
    border: 2px solid #2c2c2e;
    color: white;
    font-size: 18px;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.feeling-number-btn.selected {
    background: #0a84ff;
    border-color: #0a84ff;
}

.modal-subtitle {
    color: #98989d;
    font-size: 14px;
    margin-bottom: 16px;
}

.form-label {
    display: block;
    color: var(--text-primary);
    font-size: 14px;
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
}

.form-textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    resize: vertical;
}

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

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    color: #ffffff;
    font-size: 20px;
    font-weight: 600;
}

.close-modal {
    font-size: 28px;
    color: #98989d;
    cursor: pointer;
    line-height: 20px;
    background: transparent;
    border: none;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:active {
    opacity: 0.6;
}

/* Welcome Screen Styles */
.welcome-screen {
    padding: 32px 20px;
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-screen h2 {
    color: #ffffff;
    margin-bottom: 16px;
    font-size: 28px;
    font-weight: 700;
}

.welcome-screen p {
    color: #98989d;
    margin-bottom: 32px;
    font-size: 17px;
    line-height: 1.5;
}

.room-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 32px;
}

.room-option {
    padding: 24px;
    background: #1c1c1e;
    border-radius: 14px;
    border: 1px solid #2c2c2e;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
    min-height: 88px;
}

.room-option:active {
    transform: scale(0.98);
    background: #2c2c2e;
}

.room-option h3 {
    color: #0a84ff;
    margin-bottom: 8px;
    font-size: 22px;
    font-weight: 600;
}

.room-option p {
    color: #98989d;
    font-size: 15px;
}

.room-code-display {
    background: #2c2c2e;
    padding: 20px;
    border-radius: 14px;
    margin: 20px 0;
    text-align: center;
    border: 1px solid #0a84ff;
}

.room-code {
    font-size: 32px;
    font-weight: 700;
    color: #0a84ff;
    letter-spacing: 4px;
    margin: 10px 0;
    font-family: 'Courier New', monospace;
}

.invite-link-section, .personal-link-section {
    background: #2c2c2e;
    padding: 20px;
    border-radius: 14px;
    margin: 20px 0;
    border: 1px solid #0a84ff;
}

.personal-link-section {
    border-color: #34c759;
}

.link-display {
    background: #1c1c1e;
    padding: 12px;
    border-radius: 10px;
    margin: 12px 0;
    word-break: break-all;
    font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #ffffff;
    border: 1px solid #3a3a3c;
}

.copy-button {
    background: #0a84ff;
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 600;
    transition: opacity 0.2s ease;
    margin: 8px 4px;
    min-height: 44px;
    min-width: 100px;
}

.copy-button:active {
    opacity: 0.6;
}

.copy-button.green {
    background: #34c759;
}

.copy-button.copied {
    background: #34c759;
}

.waiting-message {
    text-align: center;
    padding: 24px;
    background: #2c2c2e;
    border-radius: 14px;
    margin: 20px 0;
    border: 1px solid #ff9f0a;
}

.waiting-message h3 {
    color: #ff9f0a;
    margin-bottom: 12px;
    font-size: 20px;
    font-weight: 600;
}

.waiting-message p {
    color: #98989d;
    font-size: 15px;
}

.success-message {
    border-color: #34c759;
}

.success-message h3 {
    color: #34c759;
}

.spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #3a3a3c;
    border-top: 3px solid #0a84ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-top: 16px;
}

.info-tip {
    background: #2c2c2e;
    border: 1px solid #0a84ff;
    color: #0a84ff;
    padding: 12px;
    border-radius: 10px;
    margin: 12px 0;
    font-size: 14px;
}

/* Chat Container - Full Screen */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

/* Messages Area - Full Screen Scrollable */
.messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    background: var(--bg-primary);
}

.message-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
    animation: fadeInMessage 0.3s ease;
}

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

.message-group.align-left {
    align-items: flex-start;
}

.message-group.align-right {
    align-items: flex-end;
}

.message-author {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    margin-left: 14px;
    margin-right: 14px;
    font-weight: 500;
}

.message-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    word-wrap: break-word;
    position: relative;
}

.message-group.align-left .message-bubble {
    background: var(--bubble-left);
    color: var(--text-primary);
    border-radius: 18px 18px 18px 2px;
}

.message-group.align-left .message-bubble.has-tail::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 14px 8px;
    border-color: transparent transparent var(--bubble-left) transparent;
}

.message-group.align-right .message-bubble {
    background: var(--bubble-right);
    color: #ffffff;
    border-radius: 18px 18px 2px 18px;
}

.message-group.align-right .message-bubble.has-tail::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: -8px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 14px 0;
    border-color: transparent var(--bubble-right) transparent transparent;
}

.message-content {
    line-height: 1.4;
    font-size: 17px;
    font-weight: 400;
    white-space: pre-wrap;
}

.message-time {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    margin: 16px 0;
    font-weight: 500;
}

.message-model-info {
    font-size: 11px;
    margin-top: 6px;
    opacity: 0.7;
    font-weight: 500;
}

.message-group.align-left .message-model-info {
    color: rgba(255, 255, 255, 0.7);
}

.message-group.align-right .message-model-info {
    color: rgba(255, 255, 255, 0.8);
}

.message-label {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.6;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.original-bubble {
    opacity: 0.85;
    margin-bottom: 8px;
}

.empty-state {
    text-align: center;
    color: #98989d;
    padding: 60px 20px;
    font-size: 17px;
}

/* Coach Messages in Shared Chat */
.coach-message-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px 0;
    width: 100%;
}

.coach-author {
    font-size: 13px;
    font-weight: 600;
    color: #0a84ff;
    margin-bottom: 8px;
}

.coach-bubble {
    background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    max-width: 85%;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid #3a5a7a;
}

.coach-bubble .message-content {
    color: #ffffff;
}

.coach-bubble .message-model-info {
    color: rgba(255, 255, 255, 0.6);
    text-align: center;
    margin-top: 8px;
}

/* Input Area - Fixed Bottom */
.input-area {
    background: #1c1c1e;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid #2c2c2e;
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.coach-button {
    padding: 8px;
    background: #2c2c2e;
    color: #ffffff;
    border: none;
    border-radius: 18px;
    font-size: 20px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    min-width: 44px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coach-button:active {
    opacity: 0.6;
}

.input-area textarea {
    flex: 1;
    min-height: 36px;
    max-height: 120px;
    resize: none;
    font-size: 17px;
    padding: 8px 12px;
    border: 1px solid var(--text-tertiary);
    border-radius: 18px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
}

.input-area textarea:focus {
    outline: none;
    border-color: #0a84ff;
}

.input-area textarea::placeholder {
    color: var(--text-secondary);
}

.send-button {
    padding: 8px 20px;
    background: #0a84ff;
    color: #ffffff;
    border: none;
    border-radius: 18px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s ease;
    min-width: 70px;
    min-height: 36px;
    flex-shrink: 0;
}

.send-button:active {
    opacity: 0.6;
}

.send-button:disabled {
    background: #3a3a3c;
    color: #98989d;
    cursor: not-allowed;
    opacity: 0.5;
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #3a3a3c;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Coach Modal Styles */
.coach-modal {
    z-index: 2000;
    background: var(--bg-primary) !important;
    display: none;
}

.coach-modal.show {
    display: flex !important;
    align-items: stretch !important;
    justify-content: stretch !important;
}

.coach-content {
    width: 100% !important;
    height: 100% !important;
    display: flex;
    flex-direction: column;
    border-radius: 0 !important;
    overflow: hidden;
    max-width: 100% !important;
    max-height: 100% !important;
    background: var(--bg-primary);
    padding: 0 !important;
}

.coach-header {
    background: var(--bg-secondary);
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    min-height: 52px;
}

.coach-header-content {
    flex: 1;
    text-align: center;
}

.coach-header h2 {
    margin: 0;
    color: #ffffff;
    font-size: 17px;
    font-weight: 600;
}

.coach-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.coach-action-btn {
    background: transparent;
    border: none;
    color: #0a84ff;
    font-size: 15px;
    cursor: pointer;
    padding: 6px 10px;
    font-weight: 600;
    transition: opacity 0.2s;
    border-radius: 8px;
    white-space: nowrap;
}

.coach-action-btn:active {
    opacity: 0.6;
    background: rgba(10, 132, 255, 0.1);
}

.coach-clear-btn {
    color: #ff453a;
}

.coach-clear-btn:active {
    background: rgba(255, 69, 58, 0.1);
}

.coach-header .close-modal,
.coach-back-btn {
    background: transparent;
    border: none;
    color: #0a84ff;
    font-size: 17px;
    cursor: pointer;
    padding: 8px;
    font-weight: 600;
    transition: opacity 0.2s;
}

.coach-header .close-modal:active,
.coach-back-btn:active {
    opacity: 0.6;
}

.coach-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: calc(160px + env(safe-area-inset-bottom, 20px));
    background: var(--bg-primary);
    -webkit-overflow-scrolling: touch;
}

.coach-message-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 4px;
    animation: fadeInMessage 0.3s ease;
}

.coach-message-group.align-left {
    align-items: flex-start;
}

.coach-message-group.align-right {
    align-items: flex-end;
}

.coach-message-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    word-wrap: break-word;
    position: relative;
    line-height: 1.4;
    font-size: 17px;
    white-space: pre-wrap;
}

.coach-message-group.align-left .coach-message-bubble {
    background: var(--bubble-left);
    color: var(--text-primary);
    border-radius: 18px 18px 18px 4px;
}

.coach-message-group.align-right .coach-message-bubble {
    background: var(--bubble-right);
    color: #ffffff;
    border-radius: 18px 18px 4px 18px;
}

.coach-message-author {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    margin-left: 14px;
    margin-right: 14px;
    font-weight: 500;
}

.coach-input-area {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--input-bg);
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    z-index: 10;
}

.coach-input-area textarea {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    resize: none;
    font-size: 17px;
    padding: 10px 12px;
    border: 1px solid var(--text-tertiary);
    border-radius: 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: inherit;
}

.coach-input-area textarea:focus {
    outline: none;
    border-color: #0a84ff;
}

.coach-input-area textarea::placeholder {
    color: var(--text-secondary);
}

/* Context Editor Modal */
.context-editor-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 3000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.context-editor-modal.show {
    transform: translateY(0);
}

.context-editor-header {
    background: var(--bg-secondary);
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    min-height: 60px;
}

.context-editor-header h2 {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    text-align: center;
}

.context-editor-header button {
    background: transparent;
    border: none;
    color: #0a84ff;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 16px;
    min-width: 44px;
    min-height: 44px;
    transition: opacity 0.2s;
}

.context-editor-header button:active {
    opacity: 0.6;
}

.context-editor-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px;
}

.context-editor-content textarea {
    flex: 1;
    min-height: 300px;
    font-size: 17px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    resize: none;
    line-height: 1.5;
}

.context-editor-content textarea:focus {
    outline: none;
    border-color: #0a84ff;
}

.context-editor-content textarea::placeholder {
    color: var(--text-secondary);
}

.context-hint {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.4;
}

/* Intake UI */
.intake-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
    background: var(--bg-primary);
}

.intake-progress {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.intake-question {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.intake-question h3 {
    font-size: 20px;
    color: var(--text-primary);
    line-height: 1.4;
}

.intake-answer {
    flex: 1;
    min-height: 120px;
    font-size: 17px;
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    resize: none;
}

.intake-answer:focus {
    outline: none;
    border-color: #0a84ff;
}

.intake-actions {
    display: flex;
    gap: 12px;
}

.intake-actions button {
    flex: 1;
    padding: 16px;
    font-size: 17px;
    font-weight: 600;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
}

.intake-actions button:active {
    opacity: 0.7;
}

.intake-skip {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.intake-submit {
    background: #0a84ff;
    color: #ffffff;
}

.intake-complete {
    text-align: center;
    padding: 40px 20px;
}

.intake-complete h3 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.intake-complete p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Insights Dashboard */
/* Insights Modal - Full Screen Width */
.insights-modal-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
}

.insights-dashboard {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    max-height: calc(100vh - 140px);
}

.insights-loading {
    text-align: center;
    padding: 40px;
    color: #98989d;
    font-size: 16px;
}

.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.insight-card {
    background: #1c1c1e;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #2c2c2e;
}

.insight-card h3 {
    font-size: 14px;
    color: #98989d;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-value {
    font-size: 48px;
    font-weight: 700;
    margin: 8px 0;
    background: linear-gradient(135deg, #0a84ff 0%, #34c759 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.insight-label {
    font-size: 14px;
    color: #98989d;
    margin-top: 8px;
}

.insight-change {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
}

.insight-change.positive {
    background: rgba(52, 199, 89, 0.2);
    color: #34c759;
}

.insight-change.negative {
    background: rgba(255, 69, 58, 0.2);
    color: #ff453a;
}

.streak-value {
    position: relative;
    display: inline-block;
}

.streak-value::after {
    content: '🔥';
    position: absolute;
    right: -30px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 32px;
    animation: flicker 2s ease-in-out infinite;
}

@keyframes flicker {
    0%, 100% { opacity: 1; transform: translateY(-50%) scale(1); }
    50% { opacity: 0.8; transform: translateY(-50%) scale(1.1); }
}

.score-bar {
    width: 100%;
    height: 12px;
    background: #2c2c2e;
    border-radius: 6px;
    overflow: hidden;
    margin: 12px 0;
}

.score-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff453a 0%, #ff9500 25%, #ffcc00 50%, #34c759 100%);
    transition: width 0.8s ease-in-out;
    border-radius: 6px;
}

.mood-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.mood-emoji {
    font-size: 40px;
}

.mood-info {
    flex: 1;
}

.mood-info .label {
    font-size: 12px;
    color: #98989d;
    text-transform: uppercase;
}

.mood-info .value {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
}

.sentiment-graph {
    margin: 20px 0;
    padding: 20px;
    background: #1c1c1e;
    border-radius: 12px;
    border: 1px solid #2c2c2e;
}

.graph-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #ffffff;
}

.graph-container {
    position: relative;
    height: 180px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    padding: 10px 0;
}

.graph-bar {
    flex: 1;
    background: linear-gradient(180deg, #0a84ff 0%, #34c759 100%);
    border-radius: 4px 4px 0 0;
    transition: height 0.5s ease-in-out;
    min-width: 8px;
}

.graph-bar:hover {
    opacity: 0.8;
}

.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.achievement-item {
    background: linear-gradient(135deg, #2c2c2e 0%, #1c1c1e 100%);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid #2c2c2e;
}

.achievement-icon {
    font-size: 32px;
}

.achievement-info {
    flex: 1;
}

.achievement-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 4px;
}

.achievement-description {
    font-size: 13px;
    color: #98989d;
}

.weekly-summary {
    background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
    border-radius: 16px;
    padding: 24px;
    margin: 20px 0;
    border: 1px solid #2c2c2e;
}

.summary-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #ffffff;
}

.summary-stat {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #2c2c2e;
}

.summary-stat:last-child {
    border-bottom: none;
}

.summary-stat .label {
    color: #98989d;
    font-size: 14px;
}

.summary-stat .value {
    color: #ffffff;
    font-weight: 600;
    font-size: 16px;
}

/* Journal Button */
.journal-btn {
    width: 100%;
    background: linear-gradient(135deg, #0a84ff 0%, #0066cc 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 20px;
    transition: transform 0.2s;
}

.journal-btn:hover {
    transform: scale(1.02);
}

.journal-btn:active {
    transform: scale(0.98);
}

/* Journal Container */
.journal-container {
    padding: 20px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Journal Entry Card */
.journal-entry {
    background: linear-gradient(135deg, #1c1c1e 0%, #2c2c2e 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid #2c2c2e;
}

.journal-entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2c2c2e;
}

.journal-date {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.journal-happiness {
    font-size: 20px;
}

.journal-summary {
    color: #ffffff;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 12px;
}

.journal-coach-section {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #2c2c2e;
}

.journal-coach-label {
    font-size: 12px;
    color: #98989d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.journal-coach-topics {
    list-style: none;
    padding: 0;
    margin: 0;
}

.journal-coach-topics li {
    color: #98989d;
    font-size: 14px;
    padding: 4px 0 4px 16px;
    position: relative;
}

.journal-coach-topics li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #0a84ff;
}

.journal-empty {
    text-align: center;
    color: #98989d;
    padding: 40px 20px;
    font-size: 16px;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .header h1 {
        font-size: 18px;
    }

    .header .subtitle {
        font-size: 12px;
    }

    .message-bubble {
        max-width: 85%;
        padding: 8px 12px;
        font-size: 16px;
    }

    .room-options {
        gap: 12px;
    }

    .room-option {
        padding: 20px;
    }

    .modal-content {
        max-width: 95%;
        width: 95%;
        padding: 20px;
    }
}

/* Landscape optimizations for small devices */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding: 8px 16px;
        min-height: 44px;
    }

    .header h1 {
        font-size: 16px;
    }

    .header .subtitle {
        display: none;
    }

    .input-area {
        padding: 8px 12px;
    }

    .input-area textarea {
        max-height: 60px;
    }
}

/* Document Notification Animations */
@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(-100%);
        opacity: 0;
    }
}

/* Floating Coach Button */
.floating-coach-button {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 30px;
    background: linear-gradient(135deg, #0a84ff 0%, #0066cc 100%);
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(10, 132, 255, 0.4);
    z-index: 1000;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-coach-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(10, 132, 255, 0.6);
}

.floating-coach-button:active {
    transform: scale(0.95);
}

/* Pulse animation for when mood is low */
.floating-coach-button.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(10, 132, 255, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(10, 132, 255, 0.8), 0 0 0 10px rgba(10, 132, 255, 0.2);
    }
    100% {
        box-shadow: 0 4px 12px rgba(10, 132, 255, 0.4);
    }
}

/* Conversation Prompt Card */
.conversation-prompt-card {
    margin: 16px;
    padding: 16px;
    background: linear-gradient(135deg, #2c2c2e 0%, #1c1c1e 100%);
    border: 1px solid #3c3c3e;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.prompt-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.prompt-icon {
    font-size: 20px;
    margin-right: 8px;
}

.prompt-title {
    flex: 1;
    font-weight: 600;
    color: #ffffff;
}

.prompt-dismiss {
    background: none;
    border: none;
    color: #98989d;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prompt-dismiss:hover {
    color: #ffffff;
}

.prompt-message {
    font-size: 15px;
    color: #ffffff;
    margin-bottom: 12px;
    line-height: 1.4;
}

.prompt-actions {
    display: flex;
    gap: 8px;
}

.prompt-send-btn {
    flex: 1;
    padding: 10px;
    background: #0a84ff;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.prompt-send-btn:hover {
    background: #0066cc;
}

.prompt-edit-btn {
    flex: 1;
    padding: 10px;
    background: #2c2c2e;
    color: #ffffff;
    border: 1px solid #3c3c3e;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.prompt-edit-btn:hover {
    background: #3c3c3e;
}

/* Streak Warning Banner */
.streak-warning-banner {
    margin: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #ff9500 0%, #ff6b00 100%);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(255, 149, 0, 0.4);
    text-align: center;
    font-weight: 600;
    color: #ffffff;
    animation: slideInBanner 0.3s ease;
}

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

/* Smart Reply Chips */
.smart-reply-chips {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #1c1c1e;
    border-top: 1px solid #2c2c2e;
    align-items: center;
    animation: slideUpChips 0.3s ease;
}

.smart-reply-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.smart-reply-chip {
    padding: 8px 16px;
    background: #2c2c2e;
    color: #0a84ff;
    border: 1px solid #3c3c3e;
    border-radius: 18px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.smart-reply-chip:hover {
    background: #3c3c3e;
    border-color: #0a84ff;
    transform: scale(1.05);
}

.smart-reply-chip:active {
    transform: scale(0.95);
}

.smart-reply-dismiss {
    padding: 6px 12px;
    background: transparent;
    color: #98989d;
    border: none;
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.smart-reply-dismiss:hover {
    color: #ffffff;
}

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

/* Mobile responsive adjustments for smart replies */
@media (max-width: 600px) {
    .smart-reply-chip {
        font-size: 13px;
        padding: 6px 12px;
        max-width: 150px;
    }

    .smart-reply-chips {
        padding: 10px 12px;
    }
}
