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

:root {
    --bg: #050510;
    --bg-secondary: #0a0a20;
    --primary: #00d4ff;
    --primary-dim: #0088cc;
    --primary-glow: rgba(0, 212, 255, 0.3);
    --secondary: #4488ff;
    --accent: #00ff88;
    --text: #e0e8f0;
    --text-dim: #8090a0;
    --danger: #ff4466;
    --glass: rgba(10, 15, 30, 0.7);
    --glass-border: rgba(0, 212, 255, 0.15);
    --glass-border-hover: rgba(0, 212, 255, 0.3);
    --radius: 16px;
    --font: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

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

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

/* Background effects */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(0, 212, 255, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 212, 255, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.bg-vignette {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 30%, var(--bg) 80%);
    pointer-events: none;
    z-index: 0;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    position: relative;
    z-index: 10;
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    background: rgba(5, 5, 16, 0.8);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
    animation: pulse-dot 2s ease-in-out infinite;
}

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

.status-text {
    font-size: 12px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.header-center {
    text-align: center;
}

.logo {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 8px;
    color: var(--primary);
    text-shadow: 0 0 20px var(--primary-glow);
}

.clock {
    font-size: 11px;
    color: var(--text-dim);
    font-family: var(--font-mono);
    letter-spacing: 2px;
    margin-top: 2px;
}

.header-right {
    display: flex;
    gap: 8px;
    min-width: 140px;
    justify-content: flex-end;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: var(--glass-border-hover);
    color: var(--primary);
    background: rgba(0, 212, 255, 0.05);
}

.btn-icon.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 212, 255, 0.1);
}

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* Orb */
.orb-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 0 20px;
    transition: padding 0.5s ease;
}

.orb-container.minimized {
    padding: 15px 0 10px;
}

.orb-container.minimized .orb {
    width: 60px;
    height: 60px;
}

.orb-container.minimized .orb-ring {
    display: none;
}

.orb {
    width: 120px;
    height: 120px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.5s ease, height 0.5s ease;
}

.orb-core {
    width: 40%;
    height: 40%;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary), var(--primary-dim));
    box-shadow:
        0 0 20px var(--primary-glow),
        0 0 60px var(--primary-glow),
        inset 0 0 20px rgba(255, 255, 255, 0.2);
    animation: core-pulse 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
}

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

.orb-pulse {
    position: absolute;
    width: 50%;
    height: 50%;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0;
    animation: orb-pulse-wave 3s ease-in-out infinite;
    z-index: 1;
}

@keyframes orb-pulse-wave {
    0% { transform: scale(1); opacity: 0.3; }
    100% { transform: scale(2.5); opacity: 0; }
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid;
    animation: ring-rotate 8s linear infinite;
}

.orb-ring-1 {
    width: 75%;
    height: 75%;
    border-color: rgba(0, 212, 255, 0.3);
    animation-duration: 8s;
}

.orb-ring-2 {
    width: 90%;
    height: 90%;
    border-color: rgba(0, 212, 255, 0.15);
    animation-duration: 12s;
    animation-direction: reverse;
}

.orb-ring-3 {
    width: 100%;
    height: 100%;
    border-color: rgba(0, 212, 255, 0.08);
    animation-duration: 16s;
    border-style: dashed;
}

@keyframes ring-rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Orb states */
.orb.listening .orb-core {
    background: radial-gradient(circle, var(--danger), #cc2244);
    box-shadow: 0 0 20px rgba(255, 68, 102, 0.4), 0 0 60px rgba(255, 68, 102, 0.2);
    animation: core-pulse 0.8s ease-in-out infinite;
}

.orb.listening .orb-pulse {
    background: var(--danger);
    animation-duration: 1.2s;
}

.orb.listening .orb-ring-1 { border-color: rgba(255, 68, 102, 0.3); }
.orb.listening .orb-ring-2 { border-color: rgba(255, 68, 102, 0.15); }

.orb.thinking .orb-core {
    animation: core-pulse 0.5s ease-in-out infinite;
}

.orb.thinking .orb-ring-1 { animation-duration: 2s; }
.orb.thinking .orb-ring-2 { animation-duration: 3s; }
.orb.thinking .orb-ring-3 { animation-duration: 4s; }

.orb.speaking .orb-core {
    background: radial-gradient(circle, var(--accent), #00cc66);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.4), 0 0 60px rgba(0, 255, 136, 0.2);
    animation: core-pulse 1s ease-in-out infinite;
}

.orb.speaking .orb-pulse {
    background: var(--accent);
    animation-duration: 1.5s;
}

.orb.speaking .orb-ring-1 { border-color: rgba(0, 255, 136, 0.3); }
.orb.speaking .orb-ring-2 { border-color: rgba(0, 255, 136, 0.15); }

.orb-label {
    margin-top: 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--text-dim);
    transition: color 0.3s;
}

/* Chat */
.chat-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 24px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 2px;
}

.message {
    max-width: 85%;
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
    animation: message-in 0.3s ease-out;
    word-wrap: break-word;
}

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

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 136, 204, 0.3), rgba(0, 212, 255, 0.15));
    border: 1px solid rgba(0, 212, 255, 0.2);
    color: var(--text);
}

.message.assistant {
    align-self: flex-start;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text);
}

.message.assistant .message-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--primary);
    margin-bottom: 6px;
    font-weight: 600;
}

.message.error {
    align-self: center;
    background: rgba(255, 68, 102, 0.1);
    border: 1px solid rgba(255, 68, 102, 0.3);
    color: var(--danger);
    font-size: 13px;
    text-align: center;
}

.message p { margin-bottom: 8px; }
.message p:last-child { margin-bottom: 0; }
.message strong { color: var(--primary); font-weight: 600; }
.message em { color: var(--text-dim); }
.message code {
    background: rgba(0, 212, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 13px;
}
.message pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.message pre code {
    background: none;
    padding: 0;
}
.message ul, .message ol {
    padding-left: 20px;
    margin: 8px 0;
}
.message li { margin: 4px 0; }

.typing-indicator {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* Input area */
.input-area {
    padding: 16px 24px 24px;
    position: relative;
    z-index: 10;
    border-top: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    background: rgba(5, 5, 16, 0.8);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 8px 8px 8px 16px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--glass-border-hover);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.05);
}

#message-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    max-height: 120px;
    padding: 6px 0;
}

#message-input::placeholder {
    color: var(--text-dim);
}

.btn-voice, .btn-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-voice {
    background: transparent;
    color: var(--text-dim);
}

.btn-voice:hover {
    background: rgba(0, 212, 255, 0.1);
    color: var(--primary);
}

.btn-voice.recording {
    background: rgba(255, 68, 102, 0.2);
    color: var(--danger);
    animation: recording-pulse 1s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% { box-shadow: none; }
    50% { box-shadow: 0 0 15px rgba(255, 68, 102, 0.3); }
}

.btn-send {
    background: linear-gradient(135deg, var(--primary-dim), var(--primary));
    color: white;
}

.btn-send:hover {
    box-shadow: 0 0 15px var(--primary-glow);
    transform: scale(1.05);
}

.btn-send:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Welcome screen */
.welcome {
    text-align: center;
    padding: 20px;
    color: var(--text-dim);
}

.welcome h2 {
    font-size: 18px;
    color: var(--text);
    margin-bottom: 8px;
    font-weight: 500;
}

.welcome p {
    font-size: 13px;
    line-height: 1.6;
}

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

.suggestion {
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    background: var(--glass);
    color: var(--text-dim);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion:hover {
    border-color: var(--glass-border-hover);
    color: var(--primary);
    background: rgba(0, 212, 255, 0.05);
}

/* Responsive */
@media (max-width: 768px) {
    .header { padding: 12px 16px; }
    .header-left .status-text { display: none; }
    .header-right { min-width: auto; }
    .logo { font-size: 16px; letter-spacing: 6px; }
    .chat-container { padding: 0 16px; }
    .input-area { padding: 12px 16px 16px; }
    .orb-container { padding: 24px 0 12px; }
    .orb { width: 90px; height: 90px; }
    .orb-container.minimized .orb { width: 50px; height: 50px; }
    .message { max-width: 92%; font-size: 13px; padding: 12px 14px; }
}

@media (max-width: 480px) {
    .header-left { min-width: auto; }
    .orb-container { padding: 16px 0 8px; }
    .orb { width: 70px; height: 70px; }
}

/* Tool badges */
.message-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--glass-border);
}

.tool-badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(0, 212, 255, 0.08);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
}

/* Canvas orb */
#orb-canvas {
    width: 230px;
    height: 230px;
    transition: width 0.5s ease, height 0.5s ease;
}

.orb-container.minimized #orb-canvas {
    width: 100px;
    height: 100px;
}

/* Conversation mode button */
#btn-conv.active {
    background: rgba(0, 255, 136, 0.15);
    color: var(--accent);
    box-shadow: 0 0 12px rgba(0, 255, 136, 0.25);
}

@media (max-width: 768px) {
    #orb-canvas { width: 170px; height: 170px; }
    .orb-container.minimized #orb-canvas { width: 80px; height: 80px; }
}
