* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    height: 100vh;
    overflow: hidden;
    transition: background 1.5s ease;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background: linear-gradient(135deg, #2A2D3A 0%, #3A3D4A 30%, #4A4D5A 60%, #5A5D6A 100%);
}

:root {
    --accent: #F4D17D;
    --accent-rgb: 244, 209, 125;
}

body.time-morning {
    background: linear-gradient(135deg, #C0C5CE 0%, #A8B0BC 30%, #8B95A5 60%, #6B7280 100%);
}

body.time-afternoon {
    background: linear-gradient(135deg, #D4C5B0 0%, #B5A690 30%, #968775 60%, #776850 100%);
}

body.time-evening {
    background: linear-gradient(135deg, #2A2D3A 0%, #3A3D4A 30%, #4A4D5A 60%, #5A5D6A 100%);
}

body.time-night {
    background: linear-gradient(135deg, #0F1419 0%, #1A1F2A 30%, #252A35 60%, #303540 100%);
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

body.time-morning::before {
    background: radial-gradient(circle at 15% 25%, rgba(255, 255, 255, 0.15) 0%, transparent 45%);
}

body.time-afternoon::before {
    background: radial-gradient(circle at 50% 50%, rgba(255, 200, 100, 0.12) 0%, transparent 50%);
}

body.time-evening::before {
    background: radial-gradient(circle at 80% 30%, rgba(255, 150, 100, 0.08) 0%, transparent 45%);
}

body.time-night::before {
    background: radial-gradient(circle at 70% 20%, rgba(80, 100, 180, 0.12) 0%, transparent 40%);
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    backdrop-filter: blur(8px);
    border-left: 1px solid rgba(244, 209, 125, 0.2);
    border-right: 1px solid rgba(244, 209, 125, 0.2);
    transition: all 1.5s ease;
}

body.time-morning .app {
    background: linear-gradient(135deg, rgba(57, 63, 78, 0.4) 0%, rgba(65, 74, 132, 0.3) 100%);
}

body.time-afternoon .app {
    background: linear-gradient(135deg, rgba(90, 75, 60, 0.3) 0%, rgba(120, 100, 80, 0.2) 100%);
}

body.time-evening .app {
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.5) 0%, rgba(50, 50, 65, 0.3) 100%);
}

body.time-night .app {
    background: linear-gradient(135deg, rgba(15, 20, 30, 0.6) 0%, rgba(30, 35, 50, 0.4) 100%);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 2px solid #F4D17D;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    flex-shrink: 0;
    transition: all 1.5s ease;
}

header::after {
    content: '';
    position: absolute;
    bottom: -2px; left: 0; width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent 0%, #F4D17D 50%, transparent 100%);
    box-shadow: 0 0 10px #F4D17D;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
}

.header-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 3px solid #F4D17D;
    object-fit: cover;
    box-shadow: 0 0 20px rgba(244, 209, 125, 0.6);
    cursor: pointer;
    transition: all 0.3s ease;
}

.header-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 0 24px rgba(var(--accent-rgb), 0.7);
}

header h1 {
    font-size: 24px;
    color: #FDE3BA;
    font-weight: 700;
    text-shadow: 0 0 15px rgba(244, 209, 125, 0.5), 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.subtitle {
    font-size: 11px;
    color: #74CAA4;
    font-style: italic;
    margin-top: -2px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    background: #82E0AA;
    box-shadow: 0 0 8px rgba(130, 224, 170, 0.6);
    transition: all 0.3s ease;
}

.status-dot.thinking {
    background: #F4D17D;
    box-shadow: 0 0 8px rgba(244, 209, 125, 0.7);
    animation: statusPulse 1.4s ease-in-out infinite;
}

.status-dot.error {
    background: #FF6B6B;
    box-shadow: 0 0 8px rgba(255, 107, 107, 0.7);
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status {
    font-size: 11px;
    padding: 5px 14px;
    background: linear-gradient(135deg, #74CAA4, #1F5E8D);
    color: #FDE3BA;
    border-radius: 14px;
    font-weight: 600;
    border: 1px solid #F4D17D;
    text-transform: uppercase;
    box-shadow: 0 2px 10px rgba(116, 202, 164, 0.4);
    transition: all 0.3s;
}

.status.error {
    background: linear-gradient(135deg, #c93838, #8b1f1f);
    border-color: #ff6b6b;
}

.status.thinking {
    background: linear-gradient(135deg, #F4D17D, #FDE3BA);
    color: #393F4E;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(0.98); }
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.message {
    display: flex;
    gap: 12px;
    animation: messageSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: 100%;
}

@keyframes messageSlideIn {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #F4D17D;
    box-shadow: 0 0 12px rgba(244, 209, 125, 0.5);
    flex-shrink: 0;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #414A84, #1F5E8D);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #FDE3BA;
    font-weight: bold;
    flex-shrink: 0;
    border: 2px solid #74CAA4;
}

.text {
    padding: 14px 18px;
    border-radius: 14px;
    max-width: 70%;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 14px;
    backdrop-filter: blur(10px);
}

body.time-morning .message.assistant .text {
    background: linear-gradient(135deg, rgba(57, 63, 78, 0.9) 0%, rgba(65, 74, 132, 0.9) 100%);
    color: #E4D9D5;
    border: 1px solid rgba(244, 209, 125, 0.3);
    border-left: 3px solid #F4D17D;
}

body.time-afternoon .message.assistant .text {
    background: linear-gradient(135deg, rgba(90, 75, 60, 0.85) 0%, rgba(120, 100, 80, 0.85) 100%);
    color: #F5E8D5;
    border: 1px solid rgba(255, 200, 130, 0.3);
    border-left: 3px solid #F4B17D;
}

body.time-evening .message.assistant .text {
    background: linear-gradient(135deg, rgba(40, 35, 50, 0.9) 0%, rgba(60, 50, 70, 0.9) 100%);
    color: #E0D4E8;
    border: 1px solid rgba(180, 150, 200, 0.3);
    border-left: 3px solid #B496C8;
}

body.time-night .message.assistant .text {
    background: linear-gradient(135deg, rgba(20, 22, 32, 0.95) 0%, rgba(35, 38, 50, 0.95) 100%);
    color: #C0C8E0;
    border: 1px solid rgba(120, 140, 180, 0.3);
    border-left: 3px solid #7B8AC8;
}

.message.user .text {
    background: linear-gradient(135deg, rgba(31, 94, 141, 0.9) 0%, rgba(65, 74, 132, 0.9) 100%);
    color: #FDE3BA;
    border: 1px solid rgba(116, 202, 164, 0.4);
}

.briefing-card {
    background: linear-gradient(135deg, rgba(244, 209, 125, 0.95) 0%, rgba(253, 227, 186, 0.95) 100%);
    border-radius: 16px;
    padding: 20px;
    margin: 10px 0;
    color: #393F4E;
    box-shadow: 0 4px 25px rgba(244, 209, 125, 0.4);
    animation: briefingSlide 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-left: 4px solid #F4D17D;
}

@keyframes briefingSlide {
    0% { opacity: 0; transform: translateY(-20px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.briefing-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-weight: bold;
    font-size: 16px;
    color: #1F5E8D;
}

.briefing-icon {
    font-size: 24px;
}

.briefing-section {
    margin: 10px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(57, 63, 78, 0.1);
}

.briefing-section:last-child {
    border-bottom: none;
}

.briefing-label {
    font-size: 11px;
    font-weight: bold;
    color: #1F5E8D;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.briefing-content {
    font-size: 14px;
    color: #2a2a3e;
    line-height: 1.5;
}

.briefing-item {
    padding: 3px 0;
}

.quick-actions {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(244, 209, 125, 0.3) transparent;
}

.quick-actions::-webkit-scrollbar {
    height: 4px;
    display: block;
}

.quick-actions::-webkit-scrollbar-track {
    background: transparent;
}

.quick-actions::-webkit-scrollbar-thumb {
    background: rgba(244, 209, 125, 0.3);
    border-radius: 2px;
}

.quick-actions button {
    padding: 9px 16px;
    background: linear-gradient(135deg, rgba(65, 74, 132, 0.6), rgba(31, 94, 141, 0.6));
    color: #FDE3BA;
    border: 1px solid rgba(244, 209, 125, 0.3);
    border-radius: 18px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.3s;
}

.quick-actions button:hover {
    background: linear-gradient(135deg, rgba(116, 202, 164, 0.3), rgba(244, 209, 125, 0.3));
    border-color: #F4D17D;
    transform: translateY(-2px);
}

/* ============================================ */
/* PATCH: header right 4-icon row              */
/* ============================================ */

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.header-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(65, 74, 132, 0.6), rgba(31, 94, 141, 0.6));
    border: 1px solid rgba(244, 209, 125, 0.4);
    color: var(--accent);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.25s ease;
    padding: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.header-icon-btn:hover {
    background: linear-gradient(135deg, rgba(244, 209, 125, 0.3), rgba(31, 94, 141, 0.6));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.header-icon-btn:active {
    transform: translateY(0);
}

.header-icon-btn.time-btn {
    color: #5DADE2;
    border-color: rgba(93, 173, 226, 0.4);
}
.header-icon-btn.time-btn:hover {
    background: linear-gradient(135deg, rgba(93, 173, 226, 0.3), rgba(31, 94, 141, 0.6));
    color: #5DADE2;
}

.header-icon-btn.end-day-btn {
    color: #BB8FCE;
    border-color: rgba(187, 143, 206, 0.4);
}
.header-icon-btn.end-day-btn:hover {
    background: linear-gradient(135deg, rgba(187, 143, 206, 0.3), rgba(31, 94, 141, 0.6));
    color: #BB8FCE;
}

.header-icon-btn.memory-icon-btn {
    color: #82E0AA;
    border-color: rgba(130, 224, 170, 0.4);
}
.header-icon-btn.memory-icon-btn:hover {
    background: linear-gradient(135deg, rgba(130, 224, 170, 0.3), rgba(31, 94, 141, 0.6));
    color: #82E0AA;
}

.header-icon-btn.push-btn {
    color: #F4D17D;
    border-color: rgba(244, 209, 125, 0.4);
    font-size: 18px;
}
.header-icon-btn.push-btn:hover {
    background: linear-gradient(135deg, rgba(244, 209, 125, 0.3), rgba(31, 94, 141, 0.6));
    color: #F4D17D;
}

@media (max-width: 480px) {
    .header-icon-btn { width: 32px; height: 32px; font-size: 14px; }
}

/* ============================================ */
/* PATCH: embedded attach icon + new input area  */
/* ============================================ */

.input-area {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 14px 16px;
    flex-shrink: 0;
}

.input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}

.input-wrap #userInput {
    flex: 1;
    width: 100%;
    padding: 12px 14px 12px 38px;
    background: rgba(65, 74, 132, 0.5);
    border: 1px solid rgba(244, 209, 125, 0.3);
    border-radius: 22px;
    color: #FDE3BA;
    font-size: 14px;
    outline: none;
    min-width: 0;
}

.input-wrap #userInput:focus {
    border-color: #F4D17D;
    box-shadow: 0 0 0 3px rgba(244, 209, 125, 0.1);
}

.input-wrap #userInput::placeholder {
    color: rgba(228, 217, 213, 0.5);
    font-style: italic;
}

.input-inline-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(244, 209, 125, 0.1);
    color: var(--accent);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
    padding: 0;
    z-index: 2;
}

.input-inline-icon:hover {
    background: rgba(244, 209, 125, 0.25);
}

.send-btn, .mic-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1F5E8D, #414A84);
    color: #FDE3BA;
    border: 2px solid #F4D17D;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    padding: 0;
}

.send-btn:hover, .mic-btn:hover {
    background: linear-gradient(135deg, #F4D17D, #FDE3BA);
    color: #393F4E;
    transform: scale(1.05);
}

.mic-btn.recording {
    background: linear-gradient(135deg, #c93838, #ff6b6b);
    animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.7); }
    50% { box-shadow: 0 0 0 15px rgba(255, 107, 107, 0); }
}

.send-btn svg, .mic-btn svg {
    display: block;
    fill: currentColor;
}

body.time-morning .input-area { background: linear-gradient(180deg, rgba(57, 63, 78, 0.8) 0%, rgba(57, 63, 78, 0.95) 100%); border-top: 2px solid rgba(244, 209, 125, 0.3); }
body.time-afternoon .input-area { background: linear-gradient(180deg, rgba(110, 90, 70, 0.7) 0%, rgba(110, 90, 70, 0.9) 100%); border-top: 2px solid rgba(255, 200, 130, 0.3); }
body.time-evening .input-area { background: linear-gradient(180deg, rgba(40, 35, 50, 0.9) 0%, rgba(40, 35, 50, 0.98) 100%); border-top: 2px solid rgba(180, 150, 200, 0.3); }
body.time-night .input-area { background: linear-gradient(180deg, rgba(20, 22, 32, 0.95) 0%, rgba(15, 18, 28, 0.98) 100%); border-top: 2px solid rgba(120, 140, 180, 0.3); }

#waveformContainer {
    display: none;
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(15,20,30,0.95) 0%, rgba(25,30,45,0.95) 100%);
    border-top: 1px solid #F4D17D;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    animation: slideInWave 0.3s ease;
}

@keyframes slideInWave {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

#waveformStatus {
    color: #FDE3BA;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#waveformStatusText {
    color: #FDE3BA;
}

.rec-dot {
    width: 10px;
    height: 10px;
    background: #ff4757;
    border-radius: 50%;
    animation: recPulse 1.2s infinite;
    box-shadow: 0 0 8px rgba(255, 71, 87, 0.6);
}

@keyframes recPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

#waveformBars {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
    width: 100%;
    max-width: 400px;
}

#waveformBars .bar {
    flex: 1;
    background: linear-gradient(180deg, #F4D17D, #FDE3BA);
    border-radius: 4px;
    height: 8px;
    transition: height 0.08s ease;
    box-shadow: 0 0 4px rgba(244, 209, 125, 0.4);
    min-width: 3px;
}

#waveformContainer.recording #waveformBars .bar {
    animation: waveReact 0.7s infinite ease-in-out;
}

#waveformContainer.recording #waveformBars .bar:nth-child(1) { animation-delay: 0s; }
#waveformContainer.recording #waveformBars .bar:nth-child(2) { animation-delay: 0.06s; }
#waveformContainer.recording #waveformBars .bar:nth-child(3) { animation-delay: 0.12s; }
#waveformContainer.recording #waveformBars .bar:nth-child(4) { animation-delay: 0.18s; }
#waveformContainer.recording #waveformBars .bar:nth-child(5) { animation-delay: 0.24s; }
#waveformContainer.recording #waveformBars .bar:nth-child(6) { animation-delay: 0.30s; }
#waveformContainer.recording #waveformBars .bar:nth-child(7) { animation-delay: 0.36s; }
#waveformContainer.recording #waveformBars .bar:nth-child(8) { animation-delay: 0.42s; }
#waveformContainer.recording #waveformBars .bar:nth-child(9) { animation-delay: 0.48s; }
#waveformContainer.recording #waveformBars .bar:nth-child(10) { animation-delay: 0.54s; }
#waveformContainer.recording #waveformBars .bar:nth-child(11) { animation-delay: 0.60s; }
#waveformContainer.recording #waveformBars .bar:nth-child(12) { animation-delay: 0.66s; }
#waveformContainer.recording #waveformBars .bar:nth-child(13) { animation-delay: 0.72s; }
#waveformContainer.recording #waveformBars .bar:nth-child(14) { animation-delay: 0.78s; }
#waveformContainer.recording #waveformBars .bar:nth-child(15) { animation-delay: 0.84s; }
#waveformContainer.recording #waveformBars .bar:nth-child(16) { animation-delay: 0.90s; }
#waveformContainer.recording #waveformBars .bar:nth-child(17) { animation-delay: 0.96s; }
#waveformContainer.recording #waveformBars .bar:nth-child(18) { animation-delay: 1.02s; }
#waveformContainer.recording #waveformBars .bar:nth-child(19) { animation-delay: 1.08s; }
#waveformContainer.recording #waveformBars .bar:nth-child(20) { animation-delay: 1.14s; }

@keyframes waveReact {
    0%, 100% { height: 8px; opacity: 0.5; }
    25% { height: 45px; opacity: 1; }
    50% { height: 18px; opacity: 0.8; }
    75% { height: 50px; opacity: 1; }
}

#waveformContainer.processing #waveformBars .bar {
    animation: processPulse 1.2s infinite ease-in-out;
}

#waveformContainer.processing #waveformBars .bar:nth-child(1) { animation-delay: 0s; }
#waveformContainer.processing #waveformBars .bar:nth-child(2) { animation-delay: 0.1s; }
#waveformContainer.processing #waveformBars .bar:nth-child(3) { animation-delay: 0.2s; }
#waveformContainer.processing #waveformBars .bar:nth-child(4) { animation-delay: 0.3s; }
#waveformContainer.processing #waveformBars .bar:nth-child(5) { animation-delay: 0.4s; }
#waveformContainer.processing #waveformBars .bar:nth-child(6) { animation-delay: 0.5s; }
#waveformContainer.processing #waveformBars .bar:nth-child(7) { animation-delay: 0.6s; }

@keyframes processPulse {
    0%, 100% { height: 8px; opacity: 0.3; }
    50% { height: 35px; opacity: 0.9; }
}

.reminder-notification {
    display: flex;
    gap: 12px;
    background: linear-gradient(135deg, rgba(244, 209, 125, 0.95), rgba(253, 227, 186, 0.95));
    padding: 16px;
    border-radius: 12px;
    color: #393F4E;
    border: 2px solid #F4D17D;
    width: 100%;
    box-sizing: border-box;
    font-weight: bold;
    flex-wrap: wrap;
}

.chat-container::-webkit-scrollbar { width: 8px; }
.chat-container::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #F4D17D, #FDE3BA);
    border-radius: 4px;
}

.typing-dots span {
    display: inline-block;
    animation: typing 1.4s infinite;
    font-weight: bold;
    font-size: 22px;
    color: #F4D17D;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, #F4D17D, #FDE3BA);
    color: #393F4E;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(244, 209, 125, 0.5);
    z-index: 9998;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

#installBtn {
    position: fixed;
    bottom: 90px;
    right: 20px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #F4D17D, #FDE3BA);
    color: #393F4E;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(244, 209, 125, 0.5);
    font-size: 14px;
}

.source-chips {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(244, 209, 125, 0.25);
    width: 100%;
}

.source-label {
    font-size: 10px;
    color: #74CAA4;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
    opacity: 0.85;
}

.source-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(15, 20, 30, 0.6);
    border: 1px solid rgba(116, 202, 164, 0.4);
    border-radius: 12px;
    text-decoration: none !important;
    transition: all 0.3s ease;
    width: 100%;
    overflow: hidden;
}

.source-chip:hover {
    background: rgba(116, 202, 164, 0.2);
    border-color: #F4D17D;
    transform: translateY(-1px);
}

.source-chip .site-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.source-chip .site-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.source-chip .site-icon .fallback {
    font-size: 14px;
}

.source-chip-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    min-width: 0;
}

.source-chip-title {
    font-size: 12px;
    font-weight: 600;
    color: #FDE3BA;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-chip-domain {
    font-size: 10px;
    color: #74CAA4;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rich-videos {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(244, 209, 125, 0.25);
    width: 100%;
}

.video-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: rgba(15, 20, 30, 0.7);
    border: 1px solid rgba(244, 209, 125, 0.4);
    border-radius: 12px;
    text-decoration: none !important;
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.video-card:hover {
    border-color: #F4D17D;
    background: rgba(244, 209, 125, 0.1);
}

.video-card img {
    width: 100px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
}

.video-card::after {
    content: '▶';
    position: absolute;
    left: 42px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 50%;
    color: #F4D17D;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 2px;
    pointer-events: none;
}

.video-title {
    flex: 1;
    color: #FDE3BA;
    font-size: 12px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.image-single {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(244, 209, 125, 0.25);
    width: 100%;
}

.image-single a {
    display: block;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(244, 209, 125, 0.4);
    background: rgba(15, 20, 30, 0.6);
    transition: all 0.3s ease;
    max-width: 320px;
    margin: 0 auto;
}

.image-single a:hover {
    border-color: #F4D17D;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(244, 209, 125, 0.3);
}

.image-single img {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: cover;
    display: block;
    border-radius: 12px;
    border: 2px solid rgba(244, 209, 125, 0.4);
}

@media (max-width: 600px) {
    .image-single a { max-width: 100%; }
    .image-single img { max-height: 260px; }
}

.message-time {
    display: block;
    text-align: right;
    font-size: 10px;
    color: rgba(253, 227, 186, 0.5);
    margin-top: 6px;
    font-weight: 500;
    letter-spacing: 0.3px;
    font-variant-numeric: tabular-nums;
    -webkit-font-variant-numeric: tabular-nums;
}

.reminder-notification .message-time {
    flex-basis: 100%;
    color: rgba(57, 63, 78, 0.6);
    margin-top: 4px;
    text-align: right;
}

/* ============================================ */
/* PATCH: mode popover                          */
/* ============================================ */

.mode-popover {
    position: absolute;
    top: 64px;
    left: 14px;
    width: 220px;
    background: linear-gradient(135deg, rgba(20, 25, 40, 0.98), rgba(30, 35, 55, 0.98));
    border: 1px solid rgba(244, 209, 125, 0.4);
    border-radius: 12px;
    padding: 8px;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.mode-popover:not([hidden]) {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.mode-popover[hidden] {
    display: none;
}

.mode-popover-title {
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 10px 8px;
    border-bottom: 1px solid rgba(244, 209, 125, 0.2);
    margin-bottom: 6px;
}

.mode-option {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    padding: 8px 10px;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #FDE3BA;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s ease;
    margin-bottom: 4px;
    font-family: inherit;
}

.mode-option:hover {
    background: rgba(244, 209, 125, 0.1);
    border-color: rgba(244, 209, 125, 0.3);
}

.mode-option.active {
    background: rgba(130, 224, 170, 0.15);
    border-color: rgba(130, 224, 170, 0.4);
}

.mode-option .mode-label {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
}

.mode-option .mode-desc {
    font-size: 10px;
    opacity: 0.7;
}

/* ============================================ */
/* LEGACY BUTTON STYLES (referenced by JS)      */
/* These are kept so older handlers don't break */
/* ============================================ */

.end-day-btn {
    background: rgba(244, 209, 125, 0.15);
    color: #F4D17D;
    border: 1px solid rgba(244, 209, 125, 0.4);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 6px;
}

.end-day-btn:hover:not(:disabled) {
    background: rgba(244, 209, 125, 0.25);
    border-color: rgba(244, 209, 125, 0.7);
    transform: translateY(-1px);
}

.end-day-btn:active:not(:disabled) {
    transform: translateY(0);
}

.end-day-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.end-day-btn.writing {
    background: rgba(116, 202, 164, 0.2);
    border-color: rgba(116, 202, 164, 0.6);
    color: #74CAA4;
}

.end-day-btn.success {
    background: rgba(116, 202, 164, 0.3);
    border-color: rgba(116, 202, 164, 0.8);
    color: #74CAA4;
}

.end-day-btn.error {
    background: rgba(255, 107, 107, 0.2);
    border-color: rgba(255, 107, 107, 0.6);
    color: #FF6B6B;
}

.memory-panel-btn {
    background: rgba(116, 202, 164, 0.15);
    color: #74CAA4;
    border: 1px solid rgba(116, 202, 164, 0.4);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 6px;
    padding: 0;
}

.memory-panel-btn:hover {
    background: rgba(116, 202, 164, 0.25);
    border-color: rgba(116, 202, 164, 0.7);
    transform: translateY(-1px);
}

.memory-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.memory-panel-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.memory-panel {
    background: linear-gradient(135deg, rgba(20, 25, 40, 0.98) 0%, rgba(30, 35, 55, 0.98) 100%);
    border: 1px solid rgba(244, 209, 125, 0.3);
    border-radius: 16px;
    width: 92%;
    max-width: 720px;
    max-height: 88vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 40px rgba(244, 209, 125, 0.1);
    overflow: hidden;
}

.memory-panel-header {
    padding: 18px 24px;
    border-bottom: 1px solid rgba(244, 209, 125, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.memory-panel-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.memory-panel-icon {
    font-size: 28px;
}

.memory-panel-title h2 {
    font-size: 20px;
    color: #FDE3BA;
    margin: 0;
    font-weight: 700;
}

.memory-panel-subtitle {
    font-size: 11px;
    color: #74CAA4;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.memory-panel-close {
    background: rgba(244, 209, 125, 0.1);
    color: #FDE3BA;
    border: 1px solid rgba(244, 209, 125, 0.3);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.memory-panel-close:hover {
    background: rgba(244, 209, 125, 0.2);
    transform: rotate(90deg);
}

.memory-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.memory-panel-loading,
.memory-panel-error,
.memory-panel-empty {
    text-align: center;
    color: rgba(253, 227, 186, 0.6);
    padding: 60px 20px;
    font-size: 14px;
}

.memory-panel-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.memory-panel-empty h3 {
    color: #FDE3BA;
    margin-bottom: 8px;
}

.memory-panel-empty p {
    font-size: 13px;
    line-height: 1.6;
    max-width: 360px;
    margin: 0 auto;
}

.memory-panel-footer {
    padding: 14px 24px;
    border-top: 1px solid rgba(244, 209, 125, 0.2);
    flex-shrink: 0;
}

.memory-panel-write-btn {
    width: 100%;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(244, 209, 125, 0.9), rgba(253, 227, 186, 0.9));
    color: #1a1a1a;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.memory-panel-write-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(244, 209, 125, 0.4);
}

.memory-panel-write-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.chapter-card {
    background: rgba(15, 20, 30, 0.6);
    border: 1px solid rgba(244, 209, 125, 0.2);
    border-radius: 12px;
    padding: 16px 18px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.chapter-card::before {
    content: '';
    position: absolute;
    left: -24px;
    top: 24px;
    width: 8px;
    height: 8px;
    background: #F4D17D;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(244, 209, 125, 0.5);
}

.chapter-card:hover {
    background: rgba(244, 209, 125, 0.08);
    border-color: rgba(244, 209, 125, 0.5);
    transform: translateX(4px);
}

.chapter-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
    flex-wrap: wrap;
    gap: 6px;
}

.chapter-card-date {
    font-size: 11px;
    color: #74CAA4;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.chapter-card-arc {
    font-size: 10px;
    color: rgba(180, 150, 200, 0.7);
    font-style: italic;
}

.chapter-card-title {
    font-size: 16px;
    color: #FDE3BA;
    font-weight: 700;
    margin: 4px 0 8px 0;
}

.chapter-card-preview {
    font-size: 13px;
    color: rgba(253, 227, 186, 0.7);
    line-height: 1.5;
    margin: 0 0 10px 0;
}

.chapter-card-themes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chapter-theme-chip {
    background: rgba(116, 202, 164, 0.15);
    color: #74CAA4;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    border: 1px solid rgba(116, 202, 164, 0.3);
    font-weight: 500;
}

.chapter-detail {
    padding: 0 4px;
}

.chapter-back-btn {
    background: rgba(244, 209, 125, 0.1);
    color: #FDE3BA;
    border: 1px solid rgba(244, 209, 125, 0.3);
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12px;
    cursor: pointer;
    margin-bottom: 18px;
    transition: all 0.2s;
}

.chapter-back-btn:hover {
    background: rgba(244, 209, 125, 0.2);
}

.chapter-detail-date {
    font-size: 12px;
    color: #74CAA4;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
    margin-bottom: 6px;
}

.chapter-detail-title {
    font-size: 24px;
    color: #FDE3BA;
    font-weight: 700;
    margin: 0 0 16px 0;
    line-height: 1.3;
}

.chapter-detail-arc {
    display: flex;
    gap: 8px;
    align-items: baseline;
    margin-bottom: 18px;
    padding: 10px 14px;
    background: rgba(180, 150, 200, 0.1);
    border-left: 3px solid #B496C8;
    border-radius: 6px;
}

.chapter-detail-arc-label {
    font-size: 11px;
    color: rgba(253, 227, 186, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.chapter-detail-arc-value {
    font-size: 13px;
    color: #E0D4E8;
    font-style: italic;
}

.chapter-detail-narrative {
    font-size: 15px;
    line-height: 1.75;
    color: rgba(253, 227, 186, 0.92);
    margin-bottom: 24px;
}

.chapter-detail-narrative p {
    margin: 0 0 16px 0;
}

.chapter-detail-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(244, 209, 125, 0.15);
}

.chapter-detail-section h4 {
    font-size: 12px;
    color: #74CAA4;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 12px 0;
    font-weight: 700;
}

.chapter-detail-themes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chapter-detail-moments {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-detail-moments li {
    padding: 10px 0;
    border-bottom: 1px solid rgba(244, 209, 125, 0.08);
    font-size: 13px;
    color: rgba(253, 227, 186, 0.85);
}

.chapter-detail-moments li:last-child {
    border-bottom: none;
}

.chapter-detail-moments strong {
    display: block;
    color: #FDE3BA;
    margin-bottom: 2px;
}

.moment-significance {
    font-size: 11px;
    color: rgba(116, 202, 164, 0.7);
    font-style: italic;
}

.memory-panel-body::-webkit-scrollbar {
    width: 6px;
}

.memory-panel-body::-webkit-scrollbar-thumb {
    background: rgba(244, 209, 125, 0.3);
    border-radius: 3px;
}

@media (max-width: 600px) {
    header { padding: 12px 14px; }
    header h1 { font-size: 20px; }
    .header-avatar { width: 44px; height: 44px; }
    .text { max-width: 75%; font-size: 13px; }
    .message-avatar-img, .user-avatar { width: 36px; height: 36px; }
    .input-area { padding: 12px 14px; }
    .send-btn, .mic-btn { width: 44px; height: 44px; }
    .briefing-card { padding: 14px; font-size: 13px; }
    .source-chip { padding: 6px 10px; }
    .source-chip-title { font-size: 11px; }
    .video-card img { width: 80px; height: 45px; }
    .video-title { font-size: 11px; }
    .video-card::after { left: 32px; width: 24px; height: 24px; font-size: 10px; }
    .memory-panel { width: 96%; max-height: 92vh; }
    .memory-panel-header { padding: 14px 16px; }
    .memory-panel-body { padding: 16px; }
    .chapter-detail-title { font-size: 20px; }
    .chapter-detail-narrative { font-size: 14px; }
}
