/* =========================================================
   Violet Chat — dark / gothic mobile-first theme
   ========================================================= */

:root {
    --bg:            #0a0a0c;
    --bg-surface:    #121215;
    --bg-input:      #1a1a1f;
    --violet:        #9b59b6;
    --violet-dark:   #6c3483;
    --violet-glow:   #b370cf;
    --violet-faint:  rgba(155, 89, 182, 0.12);
    --cali-bubble:   #2d1f3d;
    --violet-bubble: #1e1e24;
    --text:          #e8e0f0;
    --text-dim:      #8a8494;
    --text-faint:    #5a5564;
    --border:        #2a2a30;
    --danger:        #e74c3c;
    --radius:        14px;
    --radius-sm:     8px;
    --font:          'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--violet-dark); border-radius: 4px; }

/* ---- Login Page ---- */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    padding: 24px;
    background:
        radial-gradient(ellipse at 30% 20%, rgba(155, 89, 182, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(108, 52, 131, 0.06) 0%, transparent 60%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 340px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 28px 32px;
    text-align: center;
    box-shadow: 0 0 60px rgba(155, 89, 182, 0.06);
}

.login-card h1 {
    font-size: 28px;
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--violet-glow);
    margin-bottom: 6px;
}

.login-card .subtitle {
    font-size: 12px;
    color: var(--text-dim);
    letter-spacing: 1px;
    margin-bottom: 32px;
}

.login-card input {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.login-card input:focus {
    border-color: var(--violet);
}

.login-card input::placeholder {
    color: var(--text-faint);
}

.login-card button {
    width: 100%;
    padding: 14px;
    margin-top: 6px;
    background: linear-gradient(135deg, var(--violet-dark), var(--violet));
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.login-card button:active {
    transform: scale(0.97);
    opacity: 0.9;
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}

.login-error.show { display: block; }

/* ornamental line */
.login-card .ornament {
    margin: 24px auto 0;
    width: 40px;
    height: 1px;
    background: var(--violet-dark);
}

/* ---- Chat Layout ---- */
.chat-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* dynamic viewport for mobile */
    max-width: 600px;
    margin: 0 auto;
    background: var(--bg);
}

/* ---- Inbox View ---- */
#inboxView {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#chatView {
    flex-direction: column;
    height: 100%;
}

#chatView[style*="flex"] {
    display: flex;
}

.inbox-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.inbox-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.inbox-card:hover {
    background: var(--violet-faint);
}

.inbox-card:active {
    background: rgba(155, 89, 182, 0.2);
}

.inbox-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--violet-dark), var(--violet));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.inbox-avatar.online {
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px #2ecc71;
}

.inbox-info {
    flex: 1;
    min-width: 0;
}

.inbox-info .inbox-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.inbox-info .inbox-preview {
    font-size: 13px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-meta {
    flex-shrink: 0;
    text-align: right;
}

.inbox-meta .inbox-time {
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 4px;
}

.inbox-meta .inbox-badge {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--violet);
    color: #fff;
    border-radius: 9px;
    padding: 0 5px;
}

.inbox-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-faint);
    font-size: 14px;
}

/* ---- Back button ---- */
.back-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--violet-glow);
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
}

.back-btn:hover {
    background: var(--violet-faint);
}

/* ---- Header ---- */
.chat-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.chat-header .name {
    font-size: 18px;
    font-weight: 600;
    color: var(--violet-glow);
    letter-spacing: 2px;
}

.chat-header .status {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
}

.chat-header .logout-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.chat-header .logout-btn:hover {
    color: var(--violet);
    border-color: var(--violet-dark);
}

/* ---- Channel Tabs ---- */
.channel-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 8px;
    overflow: hidden;
}

.channel-tabs {
    display: flex;
    overflow-x: auto;
    flex: 1;
    gap: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 6px 0;
}
.channel-tabs::-webkit-scrollbar { display: none; }

.channel-tab {
    flex-shrink: 0;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
    position: relative;
    white-space: nowrap;
}

.channel-tab:hover {
    color: var(--violet-glow);
    background: var(--violet-faint);
}

.channel-tab.active {
    color: var(--violet-glow);
    background: rgba(155, 89, 182, 0.18);
    border-color: var(--violet-dark);
    font-weight: 600;
}

.channel-tab .unread-dot {
    width: 7px;
    height: 7px;
    background: var(--violet);
    border-radius: 50%;
    display: inline-block;
    margin-left: 5px;
    vertical-align: middle;
    animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.channel-tab .close-tab {
    display: none;
    margin-left: 6px;
    font-size: 14px;
    line-height: 1;
    color: var(--text-faint);
    cursor: pointer;
    vertical-align: middle;
}

.channel-tab:hover .close-tab {
    display: inline;
}

.channel-tab .close-tab:hover {
    color: var(--danger);
}

.channel-add-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 4px;
}

.channel-add-btn:hover {
    color: var(--violet-glow);
    border-color: var(--violet-dark);
    background: var(--violet-faint);
}

/* ---- Messages Area ---- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scroll-behavior: smooth;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(155, 89, 182, 0.03) 0%, transparent 70%),
        var(--bg);
}

/* load-more */
.load-more-btn {
    align-self: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12px;
    padding: 6px 18px;
    border-radius: 20px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: color 0.2s;
}
.load-more-btn:hover { color: var(--violet); }

/* ---- Message Bubble ---- */
.msg {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    animation: fadeIn 0.2s ease;
}

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

.msg.cali {
    align-self: flex-end;
    background: var(--cali-bubble);
    border-bottom-right-radius: 4px;
    color: var(--text);
}

.msg.violet {
    align-self: flex-start;
    background: var(--violet-bubble);
    border-bottom-left-radius: 4px;
    color: var(--text);
}

.msg .sender-label {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 3px;
    letter-spacing: 0.5px;
}

.msg.cali .sender-label { color: #c49bd9; }
.msg.violet .sender-label { color: var(--violet-glow); }

.msg .body { white-space: pre-wrap; }

.msg .timestamp {
    font-size: 10px;
    color: var(--text-faint);
    margin-top: 4px;
    text-align: right;
}

/* photo in bubble */
.msg .photo-thumb {
    max-width: 220px;
    max-height: 260px;
    border-radius: 10px;
    margin: 6px 0 2px;
    cursor: pointer;
    display: block;
    object-fit: cover;
}

/* TTS button */
.tts-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    cursor: pointer;
    margin-top: 6px;
    transition: color 0.2s, border-color 0.2s;
}

.tts-btn:hover {
    color: var(--violet-glow);
    border-color: var(--violet-dark);
}

.tts-btn.loading {
    opacity: 0.5;
    pointer-events: none;
}

.tts-btn svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
}

/* ---- Input Area ---- */
.chat-input-area {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 15px;
    font-family: var(--font);
    line-height: 1.4;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area textarea:focus {
    border-color: var(--violet);
}

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

.icon-btn {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-dim);
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.icon-btn:hover {
    color: var(--violet-glow);
    background: var(--violet-faint);
}

.icon-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.send-btn {
    color: var(--violet);
}

.send-btn:disabled {
    color: var(--text-faint);
    opacity: 0.4;
    pointer-events: none;
}

/* photo preview strip before sending */
.attach-preview {
    flex-shrink: 0;
    padding: 0 12px 0;
    background: var(--bg-surface);
    display: none;
}

.attach-preview.show { display: flex; gap: 8px; padding-top: 8px; }

.attach-preview .preview-thumb {
    position: relative;
}

.attach-preview img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.attach-preview .remove-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    font-size: 12px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---- Lightbox ---- */
.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox.show { display: flex; }

.lightbox img {
    max-width: 95vw;
    max-height: 90vh;
    border-radius: 8px;
    object-fit: contain;
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

/* ---- Date separator ---- */
.date-sep {
    align-self: center;
    font-size: 11px;
    color: var(--text-faint);
    padding: 4px 14px;
    background: var(--bg-surface);
    border-radius: 12px;
    margin: 10px 0;
    letter-spacing: 0.5px;
}

/* ---- Typing indicator ---- */
.typing-indicator .typing-dots {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.typing-indicator .typing-dots span {
    width: 7px;
    height: 7px;
    background: var(--violet-glow);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}
.typing-indicator .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

/* =========================================================
   Header actions + shared header button
   ========================================================= */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hdr-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    flex-shrink: 0;
}
.hdr-btn:hover {
    color: var(--violet-glow);
    border-color: var(--violet-dark);
    background: var(--violet-faint);
}
.hdr-btn svg { fill: currentColor; }

/* =========================================================
   Photo browser overlay
   ========================================================= */
.files-view {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 900;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(155, 89, 182, 0.05) 0%, transparent 60%),
        var(--bg);
    height: 100vh;
    height: 100dvh;
}
.files-view.open { display: flex; }

.files-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding-top: max(12px, env(safe-area-inset-top));
}

.files-title {
    flex: 1;
    min-width: 0;
}
.files-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--violet-glow);
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.files-crumbs {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    white-space: nowrap;
    margin-top: 2px;
    scrollbar-width: none;
}
.files-crumbs::-webkit-scrollbar { display: none; }
.files-crumbs .crumb {
    font-size: 11px;
    color: var(--text-dim);
    cursor: pointer;
    flex-shrink: 0;
}
.files-crumbs .crumb:active,
.files-crumbs .crumb:hover { color: var(--violet-glow); }
.files-crumbs .crumb-sep {
    font-size: 11px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.files-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 14px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.sort-group {
    display: flex;
    gap: 4px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2px;
}
.sort-group button {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 12px;
    padding: 5px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.15s;
}
.sort-group button.active {
    background: rgba(155, 89, 182, 0.22);
    color: var(--violet-glow);
    font-weight: 600;
}
.files-count {
    font-size: 11px;
    color: var(--text-faint);
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.files-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px 40px;
}

.files-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-faint);
    margin: 14px 4px 8px;
}
.files-section:first-child { margin-top: 4px; }

/* folders */
.folder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 8px;
}
.folder-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.folder-tile:active,
.folder-tile:hover {
    border-color: var(--violet-dark);
    background: var(--violet-faint);
}
.folder-ico { font-size: 26px; line-height: 1; }
.folder-name {
    font-size: 12px;
    color: var(--text);
    text-align: center;
    word-break: break-word;
    line-height: 1.25;
    max-height: 2.5em;
    overflow: hidden;
}

/* photo grid */
.img-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 5px;
}
.img-tile {
    position: relative;
    aspect-ratio: 1 / 1;
    background: var(--bg-input);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}
.img-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.img-tile:active { transform: scale(0.97); }
.img-tile.noprev::after {
    content: "no preview";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-faint);
    background: var(--bg-input);
}
.grid-sentinel { height: 1px; }

.files-empty {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-dim);
    font-size: 14px;
    line-height: 1.6;
}
.files-empty .dim { color: var(--text-faint); font-size: 12px; }

/* =========================================================
   Image detail / full-view overlay
   ========================================================= */
.img-detail {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1200;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.96);
}
.img-detail.open { display: flex; }

.img-detail-top {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    color: #fff;
}
.idt-btn {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.12);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.idt-name {
    flex: 1;
    text-align: center;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.idt-pos {
    font-size: 12px;
    color: var(--text-dim);
    min-width: 40px;
    text-align: right;
    flex-shrink: 0;
}

.img-detail-stage {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
}
.img-detail-stage img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.idt-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 64px;
    background: rgba(0,0,0,0.35);
    border: none;
    color: #fff;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
}
.idt-nav.prev { left: 0; border-radius: 0 10px 10px 0; }
.idt-nav.next { right: 0; border-radius: 10px 0 0 10px; }
.idt-nav:active { opacity: 1; }

.img-detail-actions {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    padding: 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    justify-content: center;
}
.idt-action {
    flex: 1;
    max-width: 160px;
    text-align: center;
    padding: 12px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}
.idt-action:active,
.idt-action:hover {
    border-color: var(--violet-dark);
    background: var(--violet-faint);
    color: var(--violet-glow);
}
#idtSave { color: var(--violet-glow); border-color: var(--violet-dark); }

/* =========================================================
   Bottom tab bar (Chats · Files)
   ========================================================= */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 600px;
    margin: 0 auto;
    z-index: 960;
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav.show { display: flex; }
.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 0 7px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 11px;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: color 0.15s;
}
.nav-tab svg { fill: currentColor; }
.nav-tab.active { color: var(--violet-glow); }
.nav-tab:active { opacity: 0.7; }

/* clear the fixed nav so last items aren't hidden behind it */
.inbox-list { padding-bottom: 70px; }
.files-body { padding-bottom: 74px; }

/* voice / auto-read toggle state */
.back-btn.voice-off { color: var(--text-faint); }
.back-btn.voice-on  { color: var(--violet-glow); }

/* ==== To-Do tab (backed by CALI_TODO.md) ==== */
.todo-view {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 900;
    flex-direction: column;
    max-width: 600px;
    margin: 0 auto;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(155, 89, 182, 0.05) 0%, transparent 60%),
        var(--bg);
    height: 100vh;
    height: 100dvh;
}
.todo-view.open { display: flex; }

.todo-add-row {
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}
.todo-add-row input[type="text"] {
    flex: 1;
    padding: 11px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 15px;
    outline: none;
}
.todo-add-row input[type="text"]:focus { border-color: var(--violet); }
.todo-add-row input::placeholder { color: var(--text-faint); }

.todo-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 84px;
}
.todo-section { margin-bottom: 18px; }
.todo-sec-title {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: var(--violet-glow);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 6px 2px;
    cursor: pointer;
}
.todo-sec-title:disabled { cursor: default; color: var(--violet-glow); opacity: 1; }
.todo-section.done-section .todo-sec-title { color: var(--text-dim); }
.todo-section.done-section .todo-sec-title::after { content: "  ▾"; }
.todo-section.done-section.collapsed .todo-sec-title::after { content: "  ▸"; }
.todo-section.done-section.collapsed .todo-items { display: none; }

.todo-items { display: flex; flex-direction: column; gap: 6px; }
.todo-item {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 11px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}
.todo-item input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 2px solid var(--violet-dark);
    border-radius: 6px;
    background: var(--bg-input);
    cursor: pointer;
    position: relative;
}
.todo-item input[type="checkbox"]:checked { background: var(--violet); border-color: var(--violet); }
.todo-item input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    left: 5px; top: 1px;
    width: 5px; height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.todo-text { flex: 1; font-size: 14.5px; line-height: 1.45; word-break: break-word; }
.todo-item.done .todo-text { color: var(--text-faint); text-decoration: line-through; }
.todo-phone-tag { flex-shrink: 0; font-size: 12px; opacity: 0.8; }
.todo-empty { color: var(--text-dim); padding: 28px 8px; text-align: center; font-size: 14px; }
