/* ═══════════════════════════════════════════════════════════════════════
   Nocturnal AI — Web Edition Styles
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    --bg: #0a0a10;
    --bg-panel: rgba(16,16,24,0.85);
    --bg-sidebar: rgba(8,8,16,0.9);
    --bg-card: rgba(20,20,30,0.7);
    --bg-bubble-ai: rgba(25,25,40,0.8);
    --bg-bubble-user: rgba(40,25,60,0.5);
    --bg-input: rgba(15,15,25,0.8);
    --bg-btn: rgba(30,30,45,0.7);
    --bg-btn-hover: rgba(50,40,70,0.7);
    --fg: #cccccc;
    --fg-dim: #777788;
    --fg-bright: #e8e8f0;
    --accent: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-glow: rgba(108,60,224,0.4);
    --send-btn: #6c3ce0;
    --danger: #ff5555;
    --warn: #ffaa33;
    --narrator: #ccaa88;
    --border: rgba(200,170,255,0.35);
    --radius: 12px;
    --radius-sm: 8px;
}

/* ── Custom cursor (animated via JS in cursor.js) ──────────────────── */

* { margin: 0; padding: 0; box-sizing: border-box; cursor: none !important; }

#customCursor {
    position: fixed;
    top: 0; left: 0;
    width: 22px; height: 30px;
    z-index: 99999;
    pointer-events: none;
    transition: filter 0.08s;
    animation: cursorPulse 3s ease-in-out infinite;
}

#customCursor.pointer {
    width: 22px; height: 28px;
}

@keyframes cursorPulse {
    0%, 100% {
        filter: drop-shadow(0 0 2px rgba(139,92,246,0.2));
    }
    50% {
        filter: drop-shadow(0 0 8px rgba(139,92,246,0.7)) drop-shadow(0 0 16px rgba(108,60,224,0.4));
    }
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    overflow: hidden;
}

/* ── Top navigation bar ─────────────────────────────────────────────── */

.top-nav {
    height: 44px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
}
.top-nav .nav-logo {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}
.top-nav .nav-logo span { font-size: 18px; }
.top-nav .nav-links {
    display: flex;
    gap: 24px;
    align-items: center;
}
.top-nav .nav-links a {
    font-size: 13px;
    color: var(--fg-dim);
    text-decoration: none;
    transition: color 0.2s;
}
.top-nav .nav-links a:hover { color: #fff; }

.cookie-balance {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    background: rgba(255, 200, 50, 0.1);
    border: 1px solid rgba(255, 200, 50, 0.25);
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
    color: #f0c040;
}
.cookie-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
}

/* ── App layout ─────────────────────────────────────────────────────── */

.app {
    display: flex;
    height: calc(100vh - 44px);
}

/* ── Sidebar ────────────────────────────────────────────────────────── */

.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-sidebar);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding: 12px;
    display: flex;
    gap: 8px;
}

.btn-new-chat {
    flex: 1;
    padding: 8px 12px;
    background: linear-gradient(135deg, #6c3ce0, #9b59b6);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn-new-chat:hover { transform: translateY(-1px); box-shadow: 0 4px 15px var(--accent-glow); }

.btn-settings {
    padding: 8px 10px;
    background: var(--bg-btn);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    transition: background 0.15s, border-color 0.15s;
}
.btn-settings:hover { background: var(--bg-btn-hover); border-color: rgba(108,60,224,0.3); }

.sidebar-note {
    font-size: 11px;
    color: var(--fg-dim);
    padding: 0 12px 8px;
    line-height: 1.4;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.12s;
    border-radius: 0;
}
.chat-list-item:hover { background: rgba(108,60,224,0.08); }
.chat-list-item.active { background: rgba(108,60,224,0.15); border-right: 2px solid var(--accent); }

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}
.chat-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.chat-preview {
    font-size: 11px;
    color: var(--fg-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.sidebar-bottom {
    padding: 8px 12px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-sidebar {
    padding: 5px 10px;
    background: var(--bg-btn);
    color: var(--fg-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.btn-sidebar:hover { background: var(--bg-btn-hover); color: var(--fg); border-color: rgba(108,60,224,0.3); }

/* ── Main area ──────────────────────────────────────────────────────── */

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}

#sandCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ── Header ─────────────────────────────────────────────────────────── */

.chat-header {
    position: relative;
    z-index: 1;
    height: 52px;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
    gap: 8px;
    flex-shrink: 0;
}

.header-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--fg-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.btn-header {
    padding: 6px 12px;
    background: var(--bg-btn);
    color: var(--fg-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s;
}
.btn-header:hover { background: var(--bg-btn-hover); color: var(--fg); border-color: rgba(108,60,224,0.3); }
.btn-header.accent {
    background: linear-gradient(135deg, #6c3ce0, #9b59b6);
    color: #fff;
    border: none;
    font-weight: 600;
}
.btn-header.accent:hover { box-shadow: 0 4px 15px var(--accent-glow); }

.status-text {
    font-size: 11px;
    color: var(--fg-dim);
    white-space: nowrap;
}

/* ── Messages area ──────────────────────────────────────────────────── */

.messages-container {
    position: relative;
    z-index: 1;
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.message {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    max-width: 85%;
    animation: fadeIn 0.2s ease;
}
.message.ai { align-self: flex-start; }
.message.ai.main-char {
    align-self: flex-end;
    margin-left: auto;
    flex-direction: row-reverse;
}
.message.hint {
    align-self: flex-end;
    margin-left: auto;
    flex-direction: row-reverse;
    max-width: 70%;
}
.message.narrator {
    max-width: 100%;
    justify-content: center;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    margin-top: 4px;
}

.msg-content {
    max-width: calc(100% - 44px);
}

.msg-bubble {
    padding: 12px 16px;
    border-radius: var(--radius);
    line-height: 1.6;
    font-size: 18px;
    word-wrap: break-word;
    white-space: pre-wrap;
    border: 1px solid var(--border);
}
.msg-bubble.ai { background: var(--bg-bubble-ai); color: var(--fg-bright); }
.msg-bubble.hint { background: var(--bg-bubble-user); color: var(--fg-bright); border-color: rgba(108,60,224,0.15); }
.msg-bubble.narrator {
    background: transparent;
    color: var(--narrator);
    font-style: italic;
    text-align: center;
    font-size: 15px;
}

.msg-bubble .dialogue {
    font-style: italic;
}

.msg-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}
.message:hover .msg-actions { opacity: 1; }

.btn-msg-action {
    padding: 3px 8px;
    background: none;
    color: var(--fg-dim);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.12s, color 0.12s;
}
.btn-msg-action:hover { background: var(--bg-btn); color: var(--fg); }
.btn-msg-action.pinned { color: var(--warn); }

.msg-hint-line {
    font-size: 11px;
    color: var(--fg-dim);
    margin-top: 4px;
    font-style: italic;
}

.msg-image {
    max-width: 400px;
    border-radius: var(--radius);
    cursor: pointer;
    margin-top: 8px;
    transition: transform 0.15s;
}
.msg-image:hover { transform: scale(1.02); }

/* ── Typing indicator ───────────────────────────────────────────────── */

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 4px 2px;
    align-items: center;
}
.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #444;
    animation: typingPulse 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingPulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

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

/* ── Streaming bubble ───────────────────────────────────────────────── */

.streaming-bubble {
    padding: 4px 4px;
    background: var(--bg-bubble-ai);
    border-radius: var(--radius);
    color: var(--fg-bright);
    line-height: 1.55;
    font-size: 14px;
    white-space: pre-wrap;
    display: inline-block;
    max-width: fit-content;
}

/* ── Input area ─────────────────────────────────────────────────────── */

.input-area {
    position: relative;
    z-index: 1;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    padding: 8px 12px 12px;
    flex-shrink: 0;
}

.input-toolbar {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    justify-content: flex-end;
}

.char-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
}

.char-tab {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s;
    color: var(--fg-dim);
    background: var(--bg-btn);
}
.char-tab.active { color: white; border-color: rgba(108,60,224,0.4); box-shadow: 0 0 8px rgba(108,60,224,0.2); }
.char-tab:hover { filter: brightness(1.2); }

.btn-add-char {
    padding: 5px 10px;
    background: var(--bg-btn);
    color: var(--fg-dim);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
}

.char-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.char-badge {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    color: white;
    white-space: nowrap;
    min-width: 70px;
    text-align: center;
}

.char-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    color: var(--fg-bright);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 18px;
    outline: none;
    transition: border-color 0.2s;
}
.char-input:focus { border-color: rgba(108,60,224,0.4); }
.char-input::placeholder { color: var(--fg-dim); }

.btn-send {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: white;
    background: linear-gradient(135deg, #6c3ce0, #9b59b6);
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn-send:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }

.btn-icon {
    padding: 8px;
    background: none;
    border: none;
    color: var(--fg-dim);
    cursor: pointer;
    font-size: 16px;
    border-radius: var(--radius-sm);
    transition: background 0.12s;
}
.btn-icon:hover { background: var(--bg-btn); }

.narrator-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}
.narrator-label {
    font-size: 12px;
    font-style: italic;
    color: var(--fg-dim);
    min-width: 60px;
}
.narrator-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--narrator);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
}

/* ── Modal / Dialog overlay ─────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s;
}

.modal {
    background: rgba(16,16,24,0.9);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(108,60,224,0.15);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    animation: modalIn 0.2s ease;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

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

.modal h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--fg-bright);
    margin-bottom: 16px;
    text-align: center;
}

.modal p, .modal > div {
    text-align: center;
}

.modal-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 4px;
    display: block;
}

.modal-input {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--fg-bright);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.modal-input:focus { border-color: rgba(108,60,224,0.5); }

.modal-textarea {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--fg-bright);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
    resize: vertical;
    min-height: 60px;
    margin-bottom: 12px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.modal-textarea:focus { border-color: rgba(108,60,224,0.5); }

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    justify-content: center;
}

.btn-primary {
    padding: 8px 20px;
    background: linear-gradient(135deg, #6c3ce0, #9b59b6);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: transform 0.15s, box-shadow 0.15s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 15px var(--accent-glow); }

.btn-secondary {
    padding: 8px 20px;
    background: var(--bg-btn);
    color: var(--fg-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
}
.btn-secondary:hover { background: var(--bg-btn-hover); color: var(--fg); border-color: rgba(108,60,224,0.3); }

.btn-danger {
    padding: 8px 20px;
    background: #3a1515;
    color: var(--danger);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
}
.btn-danger:hover { background: #4a2020; }

.scene-starter {
    padding: 6px 10px;
    background: var(--bg-btn);
    color: var(--fg-dim);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    text-align: left;
    margin-bottom: 4px;
    width: 100%;
    transition: background 0.12s;
}
.scene-starter:hover { background: var(--bg-btn-hover); color: var(--fg); }

/* ── Phone simulator ────────────────────────────────────────────────── */

.phone-overlay {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 390px;
    background: var(--bg);
    z-index: 900;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.5), -1px 0 0 var(--border);
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.phone-status-bar {
    height: 44px;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
}
.phone-time { font-size: 14px; font-weight: 700; color: var(--fg-bright); }
.phone-icons { font-size: 12px; color: var(--fg-dim); }

.phone-nav {
    height: 50px;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}
.phone-back {
    font-size: 15px;
    color: var(--accent);
    cursor: pointer;
    background: none;
    border: none;
    transition: color 0.2s;
}
.phone-back:hover { color: var(--accent-hover); }
.phone-contact-name {
    flex: 1;
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--fg-bright);
}

.phone-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.phone-contact-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}
.phone-contact-row:hover { background: var(--bg-card); }

.phone-contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
}

.phone-contact-info { flex: 1; }
.phone-contact-info .name { font-size: 15px; font-weight: 600; color: var(--fg-bright); }
.phone-contact-info .preview { font-size: 13px; color: var(--fg-dim); }

.phone-bubble {
    max-width: 75%;
    padding: 8px 14px;
    border-radius: 18px;
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.phone-bubble.outgoing {
    background: linear-gradient(135deg, #6c3ce0, #9b59b6);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}
.phone-bubble.incoming {
    background: var(--bg-bubble-ai);
    border: 1px solid var(--border);
    color: var(--fg);
    border-bottom-left-radius: 4px;
}

.phone-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
}
.phone-input {
    flex: 1;
    padding: 8px 14px;
    background: var(--bg-input);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.phone-input:focus { border-color: var(--accent); }
.phone-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6c3ce0, #9b59b6);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: transform 0.2s, box-shadow 0.2s;
}
.phone-send:hover { transform: scale(1.05); box-shadow: 0 2px 12px var(--accent-glow); }

/* ── Image viewer overlay ───────────────────────────────────────────── */

.image-viewer {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    cursor: pointer;
}
.image-viewer img {
    max-width: 90%;
    max-height: 80vh;
    border-radius: var(--radius);
}
.image-viewer-meta {
    margin-top: 12px;
    font-size: 12px;
    color: var(--fg-dim);
    text-align: center;
    max-width: 600px;
}

/* ── Image generator tab ────────────────────────────────────────────── */

.image-gen-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 420px;
    background: rgba(12,12,20,0.95);
    backdrop-filter: blur(16px);
    z-index: 800;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.25s ease;
    box-shadow: -4px 0 20px rgba(0,0,0,0.5);
    border-left: 1px solid #222;
}

.image-gen-header {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.image-gen-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--fg-bright);
}

.image-gen-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.image-gen-preview {
    width: 100%;
    aspect-ratio: 1;
    background: var(--bg);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    overflow: hidden;
}
.image-gen-preview img {
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--radius);
}
.image-gen-preview .placeholder {
    color: var(--fg-dim);
    font-size: 13px;
}

/* ── Toast notifications ────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    background: #222;
    color: var(--fg-bright);
    border-radius: var(--radius-sm);
    font-size: 13px;
    z-index: 2000;
    animation: fadeIn 0.2s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* ── Scrollbar styling ──────────────────────────────────────────────── */

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ── Loading spinner ────────────────────────────────────────────────── */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--fg-dim);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Side panel dim overlays — containers act as backdrop when they have content */
#memoryPanel:not(:empty),
#imageGenContainer:not(:empty),
#phoneContainer:not(:empty) {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 799;
}

/* ── Memory notes panel ─────────────────────────────────────────────── */

.memory-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 440px;
    background: rgba(12,12,20,0.95);
    backdrop-filter: blur(16px);
    z-index: 800;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.25s ease;
    box-shadow: -4px 0 30px rgba(0,0,0,0.6), -1px 0 0 rgba(108,60,224,0.15);
    border-left: 1px solid var(--border);
}

.memory-panel h3 {
    padding: 16px;
    font-size: 15px;
    color: var(--fg-bright);
    border-bottom: 1px solid var(--border);
    text-shadow: 0 0 20px var(--accent-glow);
}

.memory-section {
    padding: 12px 16px;
}
.memory-section label {
    font-size: 12px;
    font-weight: 600;
    color: var(--fg-dim);
    margin-bottom: 6px;
    display: block;
}
.memory-section textarea {
    width: 100%;
    min-height: 120px;
    padding: 8px 12px;
    background: var(--bg-input);
    color: var(--fg-bright);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
    outline: none;
}
.memory-section textarea:focus { border-color: rgba(108,60,224,0.5); }
.memory-section textarea.readonly {
    background: rgba(20,15,30,0.6);
    color: #b088f0;
}

/* ── Empty state ────────────────────────────────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--fg-dim);
    font-size: 15px;
    gap: 12px;
}
.empty-state .title {
    font-size: 22px;
    font-weight: 700;
    text-shadow: 0 0 30px rgba(108,60,224,0.4);
    color: var(--fg);
}

/* ── Checkbox toggle ────────────────────────────────────────────────── */

.toggle-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.toggle-row input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}
.toggle-row label {
    font-size: 13px;
    color: var(--fg);
}
