
/* ── Chat Panel ─────────────────────────────────────────────────────────── */
.assistant-panel {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 340px;
    min-width: 260px;
    max-width: 700px;
    max-height: 85vh;
    min-height: 220px;
    border-radius: 14px;
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    box-shadow: 0 8px 32px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    z-index: 1500;
    overflow: hidden;
}

/* Resize handle — bottom-right corner */
.assistant-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    cursor: nwse-resize;
    z-index: 10;
    border-radius: 0 0 14px 0;
    background: transparent;
    flex-shrink: 0;
}
/* Diagonal grip lines (bottom-right resize indicator) */
.assistant-resize-handle::before,
.assistant-resize-handle::after {
    content: '';
    position: absolute;
    background: var(--bs-border-color, #dee2e6);
    border-radius: 1px;
}
/* Two diagonal lines like a standard resize grip */
.assistant-resize-handle::before {
    width: 2px;
    height: 10px;
    bottom: 3px;
    right: 7px;
    transform: rotate(45deg);
    transform-origin: bottom right;
}
.assistant-resize-handle::after {
    width: 2px;
    height: 6px;
    bottom: 3px;
    right: 3px;
    transform: rotate(45deg);
    transform-origin: bottom right;
}
.assistant-resize-handle:hover::before,
.assistant-resize-handle:hover::after {
    background: #0d6efd;
}

/* Header — acts as drag handle */
.assistant-header {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem .75rem;
    background: #0d6efd;
    cursor: grab;
    color: #fff;
}
.assistant-icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: .1rem .35rem;
    border-radius: 6px;
    font-size: .95rem;
    color: inherit;
    line-height: 1;
    transition: background .1s;
}
.assistant-icon-btn:hover   { background: rgba(255,255,255,.15); }
.assistant-icon-btn:disabled { opacity: .35; cursor: default; }
.assistant-icon-btn.active  { background: rgba(255,255,255,.3); }
.send-btn { color: #0d6efd; }

/* Mic wrapper — stacks icon + local/cloud label */
.mic-wrap {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}
.mic-label {
    font-size: .58rem;
    line-height: 1;
    opacity: .65;
    letter-spacing: .02em;
    pointer-events: none;
    margin-top: -2px;
}
.mic-live {
    color: #f66;
    font-weight: 600;
    font-size: .58rem;
    animation: micPulse 1s ease-in-out infinite;
}
@keyframes micPulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .35; }
}
.assistant-icon-btn.mic-listening {
    color: #f66;
    background: rgba(255, 80, 80, .15);
}
.mic-error {
    font-size: .72rem;
    color: #f66;
    cursor: pointer;
    white-space: normal;
    line-height: 1.3;
    max-width: 160px;
}
.assistant-header .send-btn { color: #fff; }

/* Messages area */
.assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .6rem;
    display: flex;
    flex-direction: column;
    gap: .45rem;
}
.assistant-empty {
    text-align: center;
    color: var(--bs-secondary-color, #6c757d);
    padding: 1.5rem .5rem;
    font-size: .9rem;
}

/* Bubbles */
.assistant-msg { display: flex; }
.assistant-msg.user  { justify-content: flex-end; }
.assistant-msg.bot   { justify-content: flex-start; }
.assistant-bubble {
    max-width: 80%;
    padding: .45rem .7rem;
    border-radius: 12px;
    font-size: .85rem;
    line-height: 1.45;
    word-break: break-word;
}
.assistant-msg.user .assistant-bubble {
    background: #0d6efd;
    color: #fff;
    border-bottom-right-radius: 3px;
}
.assistant-msg.bot .assistant-bubble {
    background: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-body-color, #212529);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-bottom-left-radius: 3px;
}

/* Thinking dots */
.assistant-bubble.thinking {
    display: flex;
    gap: .3rem;
    align-items: center;
    padding: .55rem .9rem;
}
.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--bs-secondary-color, #888);
    animation: dotBounce 1.2s infinite ease-in-out;
}
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes dotBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%           { transform: translateY(-6px); }
}

/* Input row */
.assistant-input-row {
    display: flex;
    align-items: center;
    gap: .25rem;
    padding: .5rem .6rem;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
}
.assistant-input-row .form-control { flex: 1; font-size: .85rem; }

/* ── Clippy character (CSS art) ─────────────────────────────────────────── */
.clippy-panel { border-top: 4px solid #ffe066; }
.clippy-panel .assistant-header { background: #ffe066; color: #333; }
.clippy-panel .send-btn { color: #333; }

/* Full clippy character on FAB — sized to fill the larger button */
.clippy-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    animation: clippyBob 2.5s ease-in-out infinite;
}
.clippy-body {
    width: 38px;
    height: 30px;
    background: #fff;
    border: 2.5px solid #333;
    border-radius: 8px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.clippy-body.sm {
    width: 20px;
    height: 16px;
    border-radius: 4px;
    gap: 3px;
}
.clippy-eye {
    width: 7px;
    height: 7px;
    background: #333;
    border-radius: 50%;
    animation: clippyBlink 3.5s infinite;
    margin-bottom: 4px;
}
.clippy-body.sm .clippy-eye { width: 4px; height: 4px; margin-bottom: 2px; }
.clippy-mouth {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 6px;
    border: 2.5px solid #333;
    border-top: none;
    border-radius: 0 0 8px 8px;
}
.clippy-legs {
    display: flex;
    gap: 7px;
}
.clippy-leg {
    width: 8px;
    height: 9px;
    background: #333;
    border-radius: 0 0 4px 4px;
}

/* Mini clippy in header */
.clippy-mini {
    display: flex;
    align-items: center;
}

@keyframes clippyBob {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-3px); }
}
@keyframes clippyBlink {
    0%, 90%, 100% { transform: scaleY(1); }
    95%           { transform: scaleY(0.1); }
}

/* ── Phase 31: Onboarding Wizard ─────────────────────────────────────────── */
.wizard-panel {
    border-bottom: 1px solid rgba(0,0,0,.08);
    background: linear-gradient(135deg, #f0f4ff 0%, #fafbff 100%);
    padding: .75rem;
}
.wizard-step-header {
    display: flex;
    align-items: center;
    margin-bottom: .4rem;
}
.wizard-step-num {
    font-size: .7rem;
    color: #6c757d;
    background: rgba(13,110,253,.08);
    border-radius: 20px;
    padding: .1rem .5rem;
}
.wizard-step-title {
    font-weight: 600;
    font-size: .85rem;
    margin-bottom: .35rem;
    color: #1a1a2e;
}
.wizard-step-body {
    font-size: .8rem;
    color: #444;
    line-height: 1.5;
    margin-bottom: .6rem;
}
.wizard-step-body ul {
    padding-left: 1.2rem;
    margin-bottom: .3rem;
}
.wizard-step-buttons {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}
.wizard-choice-btn {
    text-align: left;
    font-size: .78rem;
    padding: .25rem .5rem;
}

/* ── Personality Badge + Picker ──────────────────────────────────────────── */
.assistant-personality-badge {
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 20px;
    color: #fff;
    font-size: .7rem;
    padding: .1rem .5rem;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.assistant-personality-badge:hover,
.assistant-personality-badge.active {
    background: rgba(255,255,255,.32);
}
.personality-picker-panel {
    border-bottom: 1px solid rgba(0,0,0,.08);
    background: var(--bs-body-bg, #fff);
    padding: .6rem .75rem;
    max-height: 260px;
    overflow-y: auto;
}
.personality-pill {
    background: var(--bs-tertiary-bg, #f8f9fa);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 20px;
    font-size: .72rem;
    padding: .15rem .55rem;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.personality-pill:hover {
    background: #e9ecef;
}
.personality-pill.active {
    background: #0d6efd;
    border-color: #0d6efd;
    color: #fff;
}

/* ── Focus Mode ──────────────────────────────────────────────────────────── */
.assistant-panel.focus-mode {
    width: 420px;
    max-height: 680px;
    box-shadow: 0 12px 48px rgba(0,0,0,.35);
    border-color: #0d6efd;
}
.assistant-panel.focus-mode .assistant-messages {
    background: #0d1117;
    color: #e6edf3;
}
.assistant-panel.focus-mode .assistant-bubble {
    background: #161b22;
    color: #e6edf3;
    border-color: #30363d;
}
.assistant-panel.focus-mode .assistant-bubble.user {
    background: #1f6feb;
    color: #fff;
}

/* ── Chain Bar ───────────────────────────────────────────────────────────── */
.chain-bar {
    display: flex;
    justify-content: flex-end;
    padding: .15rem 0 0;
}
.chain-continue-btn {
    font-size: .68rem;
    padding: .1rem .4rem;
    opacity: .7;
    transition: opacity .15s;
}
.chain-continue-btn:hover { opacity: 1; }
.chain-status-bar {
    font-size: .72rem;
    color: #6c757d;
    padding: .3rem .75rem;
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    display: flex;
    align-items: center;
}
.btn-xs {
    font-size: .65rem;
    padding: .1rem .35rem;
}

/* ── Simple Mode Banner ──────────────────────────────────────────────────── */
.simple-mode-banner {
    display: flex;
    align-items: center;
    padding: .25rem .75rem;
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    font-size: .75rem;
    color: #92400e;
    font-weight: 500;
}

/* ── Workflow Progress Banner ────────────────────────────────────────────── */
.workflow-banner {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .75rem;
    background: linear-gradient(135deg, #ede9fe 0%, #ddd6fe 100%);
    border-bottom: 1px solid #8b5cf6;
    font-size: .75rem;
    color: #4c1d95;
    font-weight: 500;
}
.workflow-banner-icon { font-size: .85rem; }
.workflow-banner-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── TTS Control Bar ─────────────────────────────────────────────────────── */
.tts-control-bar {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .75rem;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 100%);
    border-top: 1px solid #34d399;
    border-bottom: 1px solid rgba(0,0,0,.06);
    font-size: .78rem;
    animation: slideDown .15s ease-out;
}
.tts-control-label {
    font-weight: 500;
    color: #065f46;
    flex: 1;
}
.tts-progress {
    font-weight: 400;
    opacity: .75;
    font-size: .72rem;
}

/* ── Action Confirmation Bar ─────────────────────────────────────────────── */
.action-confirm-bar {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .75rem;
    background: linear-gradient(135deg, #fff8e1 0%, #fffde7 100%);
    border-top: 1px solid #f59e0b;
    border-bottom: 1px solid rgba(0,0,0,.06);
    font-size: .78rem;
    animation: slideDown .15s ease-out;
}
.action-confirm-label {
    font-weight: 500;
    color: #92400e;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Browser Agent Status Strip ─────────────────────────────────────────── */
.browser-agent-strip {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .4rem .75rem;
    background: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%);
    border-bottom: 1px solid #0ea5e9;
    font-size: .75rem;
    color: #0c4a6e;
    animation: slideDown .15s ease-out;
}
.browser-agent-strip.paused {
    background: linear-gradient(135deg, #fef3c7 0%, #fffde7 100%);
    border-bottom-color: #f59e0b;
    color: #78350f;
}
.ba-status-row {
    display: flex;
    align-items: center;
    gap: .4rem;
    min-width: 0;
}
.ba-icon { font-size: .95rem; flex-shrink: 0; }
.ba-url  { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .72rem; opacity: .8; }
.ba-steps { font-size: .7rem; opacity: .65; white-space: nowrap; }
.ba-human-prompt { font-size: .78rem; font-weight: 500; line-height: 1.4; }
.ba-resume-btn { font-size: .72rem; padding: .2rem .6rem; align-self: flex-start; }
.ba-stop-btn { font-size: .65rem; padding: .1rem .35rem; align-self: flex-end; }

/* ── TTS narrator voice list ───────────────────────────────────────────── */
.tts-voice-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 6px;
}
.tts-voice-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    cursor: pointer;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    transition: background .1s;
    font-size: .78rem;
}
.tts-voice-row:last-child  { border-bottom: none; }
.tts-voice-row:hover       { background: var(--bs-light, #f8f9fa); }
.tts-voice-selected        { background: rgba(13,110,253,.08); font-weight: 600; }
.tts-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 8px;
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    background: var(--bs-light, #f8f9fa);
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 6px 6px 0 0;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ── Anime skin ────────────────────────────────────────────────────────── */
.anime-panel-female { border-top: 4px solid #f472b6; }
.anime-panel-female .assistant-header { background: linear-gradient(135deg,#2d1b33,#4a1942); color: #fce7f3; }
.anime-panel-male   { border-top: 4px solid #60a5fa; }
.anime-panel-male   .assistant-header { background: linear-gradient(135deg,#1a2433,#1e3a5f); color: #dbeafe; }

.anime-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    animation: clippyBob 2.5s ease-in-out infinite;
}

/* Ahoge (anime hair spike) */
.anime-ahoge {
    width: 4px;
    height: 10px;
    border-radius: 2px 2px 0 0;
    margin-bottom: -2px;
    position: relative;
    z-index: 1;
}
.anime-female .anime-ahoge { background: #c084fc; transform: rotate(-8deg); }
.anime-male   .anime-ahoge { background: #60a5fa; width: 5px; height: 8px; transform: rotate(5deg); }

/* Face */
.anime-face {
    width: 34px;
    height: 30px;
    border-radius: 50% 50% 45% 45%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.anime-female .anime-face { background: #fde8f0; border: 1.5px solid #f9a8d4; }
.anime-male   .anime-face { background: #e0eeff; border: 1.5px solid #93c5fd; }

.anime-face.sm {
    width: 24px;
    height: 20px;
    gap: 3px;
}

/* Eyes — big anime ovals */
.anime-eye {
    width: 8px;
    height: 11px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    animation: clippyBlink 3.5s infinite;
    flex-shrink: 0;
}
.anime-female .anime-eye { background: #7c3aed; border: 1.5px solid #5b21b6; }
.anime-male   .anime-eye { background: #1d4ed8; border: 1.5px solid #1e3a8a; }

.anime-eye.sm { width: 5px; height: 7px; }

.anime-pupil {
    position: absolute;
    width: 4px;
    height: 5px;
    background: #000;
    border-radius: 50%;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}
.anime-eye.sm .anime-pupil { width: 3px; height: 3px; bottom: 1px; }

.anime-shine {
    position: absolute;
    width: 3px;
    height: 3px;
    background: rgba(255,255,255,.9);
    border-radius: 50%;
    top: 2px;
    right: 1px;
}

/* Nose — tiny dot */
.anime-nose {
    position: absolute;
    bottom: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 2px;
    border-radius: 50%;
    background: rgba(0,0,0,.25);
}

/* Mouth — small curved smile */
.anime-mouth {
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 5px;
    border: 1.5px solid rgba(0,0,0,.4);
    border-top: none;
    border-radius: 0 0 8px 8px;
}
.anime-female .anime-mouth { border-color: #f472b6; }
.anime-male   .anime-mouth { border-color: #60a5fa; }

/* Blush (female only) */
.anime-blush {
    position: absolute;
    bottom: 9px;
    width: 7px;
    height: 4px;
    background: rgba(251,113,133,.5);
    border-radius: 50%;
}
.anime-blush.left  { left: 2px; }
.anime-blush.right { right: 2px; }

/* Mini header avatar */
.anime-mini { display: flex; align-items: center; }

/* Small mouth for mini header avatar */
.anime-mouth.sm {
    width: 6px;
    height: 3px;
    bottom: 1px;
    border-radius: 0 0 4px 4px;
}

/* ── Talking animation ─────────────────────────────────────────────────────── */

@keyframes animeSpeak {
    0%,100% { height: 5px; border-radius: 0 0 8px 8px; }
    25%      { height: 9px; border-radius: 0 0 5px 5px; border-top: none; }
    50%      { height: 3px; border-radius: 0 0 8px 8px; }
    75%      { height: 8px; border-radius: 0 0 4px 4px; }
}
.anime-speaking .anime-mouth {
    animation: animeSpeak 180ms steps(1, end) infinite;
}
.anime-speaking .anime-mouth.sm {
    animation: animeSpeak 180ms steps(1, end) infinite;
}

@keyframes clippySpeak {
    0%,100% { height: 4px; border-radius: 0 0 5px 5px; }
    33%      { height: 8px; border-radius: 0 0 3px 3px; }
    66%      { height: 2px; border-radius: 0 0 5px 5px; }
}
.clippy-speaking .clippy-mouth {
    animation: clippySpeak 170ms steps(1, end) infinite;
}

/* Custom AI-generated avatar image */
.anime-custom-mini {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
}

/* ── Tutorial progress bar ──────────────────────────────────────────────── */
.tutorial-bar {
    display: flex;
    align-items: center;
    gap: .4rem;
    background: rgba(162,155,254,.1);
    border: 1px solid rgba(162,155,254,.25);
    border-radius: 8px;
    padding: .3rem .6rem;
    margin: .2rem .5rem .1rem;
    font-size: .72rem;
}
.tutorial-bar-icon { flex-shrink: 0; }
.tutorial-bar-text { flex: 1; color: rgba(255,255,255,.8); }
.tutorial-bar-link {
    color: #a29bfe;
    text-decoration: none;
    font-size: .68rem;
    flex-shrink: 0;
}
.tutorial-bar-link:hover { text-decoration: underline; }
.tutorial-bar-exit {
    background: none;
    border: none;
    color: rgba(255,255,255,.4);
    font-size: .75rem;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
}
.tutorial-bar-exit:hover { color: #fff; }
