/* ==========================================================================
   Baker Street concierge — bottom-right chat widget (theme-aware)
   ========================================================================== */

/* The hidden attribute must always win, even over display rules */
[hidden] { display: none !important; }


#sc-launcher {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--accent);
    color: #001018;
    border: none;
    border-radius: 28px;
    padding: 0.7rem 1.1rem;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    transition: transform 0.15s ease, filter 0.2s ease;
}
#sc-launcher:hover { filter: brightness(1.12); transform: translateY(-2px); }
#sc-launcher.open .sc-launcher-label { display: none; }
.sc-launcher-label { font-size: 0.9rem; }
:root[data-theme="parchment"] #sc-launcher { color: #fdf6e3; }

#sc-panel {
    position: fixed;
    bottom: 84px;
    right: 18px;
    z-index: 900;
    width: min(370px, calc(100vw - 36px));
    height: min(540px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    animation: sc-in 0.22s ease;
}
@keyframes sc-in {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

.sc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.sc-tabs { display: flex; gap: 0.35rem; }
.sc-tab {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 16px;
    padding: 0.3rem 0.75rem;
    font-family: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.sc-tab:hover { color: var(--text); border-color: var(--accent); }
.sc-tab.active { background: var(--accent); color: #001018; border-color: var(--accent); font-weight: bold; }
:root[data-theme="parchment"] .sc-tab.active { color: #fdf6e3; }
.sc-header-actions { display: flex; gap: 0.35rem; }
.sc-header-actions button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    border-radius: 8px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.sc-header-actions button:hover { border-color: var(--accent); color: var(--accent); }

#sc-keybar { padding: 0 0.6rem; }
#sc-keybar .gemini-key-bar { margin: 0.6rem 0 0; padding: 0.6rem 0.7rem; }

.sc-log {
    flex: 1;
    overflow-y: auto;
    padding: 0.8rem 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.sc-bubble {
    max-width: 86%;
    padding: 0.55rem 0.8rem;
    border-radius: 12px;
    font-size: 0.92rem;
    line-height: 1.5;
    animation: sc-bubble-in 0.18s ease;
}
@keyframes sc-bubble-in {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: none; }
}
.sc-user {
    align-self: flex-end;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    color: var(--text);
}
.sc-char {
    align-self: flex-start;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
}
.sc-greeting { color: var(--text-dim); font-style: italic; }
.sc-typing { color: var(--text-dim); letter-spacing: 3px; }
.sc-error { border-color: #ffb454; color: #ffb454; }

/* Live voice caption: the bubble fills as the words are spoken */
.sc-bubble.sc-live::after {
    content: '▍';
    margin-left: 2px;
    color: var(--accent);
    animation: sc-caret 0.9s steps(2, start) infinite;
}
@keyframes sc-caret { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .sc-bubble.sc-live::after { animation: none; }
}

.sc-voicebar {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.8rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.sc-voice-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 2px solid var(--border);
    transition: border-color 0.2s ease;
}
.sc-voice-avatar.speaking {
    border-color: var(--accent);
    animation: sc-pulse 1.1s ease-in-out infinite;
}
@keyframes sc-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--accent-soft); }
    50% { box-shadow: 0 0 0 10px transparent; }
}
.sc-voice-status { flex: 1; color: var(--text-dim); font-size: 0.82rem; }
.sc-voicebar button {
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 50%;
    width: 34px;
    height: 34px;
    cursor: pointer;
}
.sc-voicebar button:hover { border-color: var(--accent); }
#sc-hangup:hover { border-color: #ff6b6b; }

.sc-form {
    display: flex;
    gap: 0.45rem;
    padding: 0.6rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.sc-form input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 20px;
    padding: 0.5rem 0.9rem;
    font-family: inherit;
    font-size: 0.92rem;
}
.sc-form input:focus { outline: none; border-color: var(--accent); }
.sc-send {
    background: var(--accent);
    color: #001018;
    border: none;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    font-size: 1rem;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.12s ease;
}
.sc-send:hover { filter: brightness(1.12); }
.sc-send:active { transform: scale(0.92); }
:root[data-theme="parchment"] .sc-send { color: #fdf6e3; }

@media (prefers-reduced-motion: reduce) {
    #sc-panel, .sc-bubble, .sc-voice-avatar.speaking { animation: none; }
}
@media print {
    #sc-launcher, #sc-panel { display: none !important; }
}
