/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0a0e1a;
    color: #e8eaf0;
    font-family: 'Segoe UI', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* ── Start overlay ────────────────────────────────────────────── */
#start-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #121829 0%, #0a0e1a 100%);
    transition: opacity 0.5s ease;
}

#start-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.start-content {
    text-align: center;
}

.start-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.1); opacity: 0.8; }
}

.start-content h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #5b9bf5, #c8a8f5);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.start-content p {
    font-size: 1.25rem;
    color: #8a92a8;
    margin-bottom: 2rem;
}

#start-btn {
    padding: 1rem 3rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #4a7ff5, #7b5ff5);
    border: none;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 24px rgba(74, 127, 245, 0.4);
}

#start-btn:hover, #start-btn:active {
    transform: scale(1.05);
    box-shadow: 0 6px 32px rgba(74, 127, 245, 0.6);
}

/* ── Kiosk layout ─────────────────────────────────────────────── */
#kiosk {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    background: radial-gradient(ellipse at center 30%, #121829 0%, #0a0e1a 70%);
}

#header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 2rem 0.5rem;
    width: 100%;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #5b9bf5, #c8a8f5);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.9rem;
    color: #5a6280;
}

/* ── Clear button ─────────────────────────────────────────────── */
.clear-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    color: #c0c5d8;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* touch target */
}

.clear-btn:hover {
    background: rgba(199, 0, 11, 0.15);
    border-color: rgba(199, 0, 11, 0.4);
    color: #f0a0a8;
}

.clear-btn:active {
    transform: scale(0.96);
    background: rgba(199, 0, 11, 0.25);
}

.clear-icon {
    flex-shrink: 0;
}

/* ── Avatar ───────────────────────────────────────────────────── */
#avatar-stage {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: min(38vh, 320px);
    min-height: 180px;
}

#avatar-canvas {
    width: min(35vh, 35vw, 280px);
    height: min(35vh, 35vw, 280px);
    display: block;
}

/* ── Chat panel ───────────────────────────────────────────────── */
#chat-panel {
    flex: 1 1 auto;
    width: 100%;
    max-width: 800px;
    min-height: 0;
    padding: 0.5rem 1.5rem 0.5rem;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

#chat-panel::-webkit-scrollbar {
    width: 5px;
}

#chat-panel::-webkit-scrollbar-track {
    background: transparent;
}

#chat-panel::-webkit-scrollbar-thumb {
    background: #2a3045;
    border-radius: 3px;
}

#messages {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-bottom: 1rem;
}

/* ── Chat bubbles ─────────────────────────────────────────────── */
.bubble {
    max-width: 80%;
    padding: 0.8rem 1.1rem;
    border-radius: 18px;
    font-size: 1.05rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: bubble-in 0.25s ease-out;
}

@keyframes bubble-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* User bubbles — right aligned, Huawei red accent */
.bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #C7000B, #a00009);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 12px rgba(199, 0, 11, 0.25);
}

/* Assistant bubbles — left aligned, dark surface */
.bubble.assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.07);
    color: #d8dce8;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom-left-radius: 6px;
}

/* Error bubbles — left aligned, red-tinted */
.bubble.error-bubble {
    background: rgba(245, 74, 74, 0.12);
    border-color: rgba(245, 74, 74, 0.3);
    color: #f0a0a8;
}

/* Markdown-lite elements inside bubbles */
.bubble strong {
    font-weight: 700;
    color: #fff;
}

.bubble.assistant strong {
    color: #e8eaf0;
}

.bubble ul, .bubble ol {
    margin: 0.4rem 0 0.2rem;
    padding-left: 1.4rem;
}

.bubble li {
    margin-bottom: 0.2rem;
}

.bubble p {
    margin: 0;
}

/* Streaming indicator on the active assistant bubble */
.bubble.streaming::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 14px;
    margin-left: 3px;
    background: #5b9bf5;
    border-radius: 2px;
    animation: cursor-blink 0.8s ease-in-out infinite;
    vertical-align: text-bottom;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.2; }
}

/* ── Footer / status ──────────────────────────────────────────── */
#footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    font-size: 0.85rem;
    color: #5a6280;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.dot.idle       { background: #4a5170; }
.dot.listening  { background: #4a7ff5; box-shadow: 0 0 12px rgba(74, 127, 245, 0.6); animation: blink 1s ease-in-out infinite; }
.dot.thinking   { background: #f5a84a; box-shadow: 0 0 12px rgba(245, 168, 74, 0.6); animation: blink 0.8s ease-in-out infinite; }
.dot.speaking   { background: #5af5a8; box-shadow: 0 0 12px rgba(90, 245, 168, 0.6); }
.dot.error      { background: #f54a4a; box-shadow: 0 0 12px rgba(245, 74, 74, 0.6); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
