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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* ===== Landing Page ===== */
.landing-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, #1a1a3e 0%, #0f0f1a 70%);
    position: relative;
    overflow: hidden;
}

.landing-content {
    text-align: center;
    z-index: 1;
    animation: floatIn 0.8s ease-out;
}

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

.landing-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: pulse 2s ease-in-out infinite;
}

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

.landing-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #a78bfa, #6366f1, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: 2px;
}

.landing-subtitle {
    color: #666;
    font-size: 1rem;
    margin-bottom: 40px;
}

.enter-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border: none;
    padding: 14px 36px;
    border-radius: 50px;
    font-size: 1.05rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 24px rgba(99, 102, 241, 0.3);
}

.enter-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.5);
}

.enter-btn:active {
    transform: translateY(0);
}

.landing-particles {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(2px 2px at 20% 30%, rgba(99, 102, 241, 0.3), transparent),
        radial-gradient(2px 2px at 70% 20%, rgba(167, 139, 250, 0.3), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(99, 102, 241, 0.2), transparent),
        radial-gradient(2px 2px at 80% 60%, rgba(167, 139, 250, 0.2), transparent),
        radial-gradient(1px 1px at 10% 80%, rgba(129, 140, 248, 0.3), transparent),
        radial-gradient(1px 1px at 60% 90%, rgba(129, 140, 248, 0.2), transparent);
    animation: drift 20s linear infinite;
}

@keyframes drift {
    from { transform: translateY(0); }
    to { transform: translateY(-20px); }
}

/* ===== Chat App Layout ===== */
.app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: #12121f;
    border-right: 1px solid #1e1e3a;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    border-bottom: 1px solid #1e1e3a;
}

.sidebar-header h2 {
    font-size: 0.9rem;
    font-weight: 500;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#new-chat-btn {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

#new-chat-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

.conversation-list::-webkit-scrollbar {
    width: 4px;
}

.conversation-list::-webkit-scrollbar-thumb {
    background: #2a2a4a;
    border-radius: 2px;
}

.conv-item {
    display: flex;
    align-items: center;
    padding: 11px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 2px;
    transition: all 0.15s;
    position: relative;
}

.conv-item:hover {
    background: #1e1e3a;
}

.conv-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(79, 70, 229, 0.1));
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.conv-item .conv-title {
    flex: 1;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #aaa;
}

.conv-item.active .conv-title {
    color: #e0e0e0;
}

.conv-item .conv-delete {
    display: none;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
    flex-shrink: 0;
    transition: color 0.2s;
}

.conv-item:hover .conv-delete {
    display: block;
}

.conv-item .conv-delete:hover {
    color: #ef4444;
}

/* Main content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #0f0f1a;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #1e1e3a;
    backdrop-filter: blur(8px);
}

header h1 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.skill-select {
    font-size: 0.75rem;
    background: #1a1a2e;
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
    padding: 4px 8px;
    border-radius: 8px;
    max-width: 220px;
    outline: none;
    cursor: pointer;
}

.skill-select:focus {
    border-color: #818cf8;
}

.model-select {
    max-width: 200px;
}

.conv-item .conv-skill {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.65rem;
    color: #818cf8;
    background: rgba(99, 102, 241, 0.12);
    padding: 1px 6px;
    border-radius: 6px;
    vertical-align: middle;
}

.model-badge {
    font-size: 0.7rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    color: #818cf8;
    flex-shrink: 0;
    font-weight: 500;
}

main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

main::-webkit-scrollbar {
    width: 6px;
}

main::-webkit-scrollbar-thumb {
    background: #2a2a4a;
    border-radius: 3px;
}

.welcome {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #555;
    font-size: 1.1rem;
}

/* Messages */
.message {
    margin-bottom: 24px;
    display: flex;
    gap: 14px;
    animation: fadeIn 0.3s ease;
    max-width: 800px;
}

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

.message .avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.message.user .avatar {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
}

.message.assistant .avatar {
    background: linear-gradient(135deg, #059669, #047857);
    color: #fff;
}

.message .content {
    flex: 1;
    line-height: 1.7;
    max-width: calc(100% - 48px);
    font-size: 0.92rem;
}

.message .content p {
    margin-bottom: 10px;
}

.message .content p:last-child {
    margin-bottom: 0;
}

.message .content pre {
    background: #0a0a14;
    border: 1px solid #1e1e3a;
    border-radius: 10px;
    padding: 16px;
    overflow-x: auto;
    margin: 10px 0;
}

.message .content code {
    font-family: "JetBrains Mono", "Fira Code", monospace;
    font-size: 0.82rem;
}

.message .content :not(pre) > code {
    background: #1e1e3a;
    padding: 2px 7px;
    border-radius: 5px;
    color: #a78bfa;
}

.message .content ul, .message .content ol {
    padding-left: 20px;
    margin: 8px 0;
}

.message .content blockquote {
    border-left: 3px solid #6366f1;
    padding-left: 12px;
    color: #888;
    margin: 10px 0;
}

.message .content table {
    border-collapse: collapse;
    margin: 10px 0;
    width: 100%;
}

.message .content th, .message .content td {
    border: 1px solid #1e1e3a;
    padding: 8px 12px;
    text-align: left;
}

.message .content th {
    background: #1e1e3a;
}

.msg-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 6px;
    padding: 4px 10px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: #a5b4fc;
    max-width: 100%;
}

.msg-file-chip span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-events {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
}

.tool-card {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 10px;
    padding: 10px 12px;
    color: #c7d2fe;
}

.tool-card.done {
    background: rgba(5, 150, 105, 0.08);
    border-color: rgba(5, 150, 105, 0.24);
    color: #a7f3d0;
}

.tool-card.error {
    background: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.28);
    color: #fecaca;
}

.tool-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
}

.tool-card-title em {
    margin-left: auto;
    color: #888;
    font-style: normal;
    font-size: 0.75rem;
}

.tool-card-args {
    margin: 8px 0 0 !important;
    padding: 8px 10px !important;
    max-height: 120px;
    font-size: 0.75rem !important;
}

.tool-card-output {
    margin-top: 8px;
    color: #b7b7c8;
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Processing indicator */
.processing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    color: #818cf8;
    font-size: 0.85rem;
    animation: fadeIn 0.3s ease;
}

.processing .dots {
    display: flex;
    gap: 4px;
}

.processing .dots span {
    width: 6px;
    height: 6px;
    background: #6366f1;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.processing .dots span:nth-child(1) { animation-delay: -0.32s; }
.processing .dots span:nth-child(2) { animation-delay: -0.16s; }
.processing .dots span:nth-child(3) { animation-delay: 0s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Footer */
footer {
    padding: 12px 24px 16px;
    border-top: 1px solid #1e1e3a;
    background: #0f0f1a;
}

#chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    max-width: 800px;
}

/* Attach button */
#attach-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    overflow: hidden;
}

#attach-btn {
    width: 44px;
    height: 44px;
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
    pointer-events: none;
}

#attach-wrapper:hover #attach-btn {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.1);
}

#pdf-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    font-size: 0;
}

/* Input area with file tag */
.file-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 6px;
    padding: 4px 10px;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: #a5b4fc;
    animation: fadeIn 0.2s ease;
    max-width: 800px;
}

.file-tag span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-tag-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(165, 180, 252, 0.3);
    border-top-color: #a5b4fc;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    flex-shrink: 0;
    margin-right: 6px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#file-tag-remove {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

#file-tag-remove:hover {
    color: #ef4444;
}

#user-input {
    flex: 1;
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 12px;
    padding: 12px 16px;
    color: #e0e0e0;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#user-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#send-btn {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

#send-btn:disabled {
    background: #1e1e3a;
    color: #555;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.typing-indicator::after {
    content: "█";
    animation: blink 1s infinite;
    color: #6366f1;
}

/* Toast notifications */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: #1e1e3a;
    border: 1px solid #2a2a4a;
    border-radius: 10px;
    padding: 12px 16px;
    min-width: 260px;
    max-width: 340px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    animation: toastIn 0.3s ease;
    pointer-events: auto;
}

.toast.success {
    border-left: 3px solid #22c55e;
}

.toast.error {
    border-left: 3px solid #ef4444;
}

.toast-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 4px;
}

.toast-body {
    font-size: 0.78rem;
    color: #888;
    line-height: 1.5;
}

.toast.hide {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(20px); }
}

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

.message .content .error-text {
    color: #ef4444;
    margin-top: 8px;
    word-break: break-word;
}

.retry-btn {
    margin-top: 10px;
    padding: 4px 12px;
    font-size: 0.8rem;
    color: #e5e7eb;
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.retry-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.usage-meta {
    margin-top: 8px;
    font-size: 0.72rem;
    color: #6b7280;
}

.cost-badge {
    margin-top: 6px;
    text-align: right;
    font-size: 0.72rem;
    color: #818cf8;
    font-variant-numeric: tabular-nums;
}

.context-info {
    margin-right: 12px;
    color: #9ca3af;
}

.context-info.warn {
    color: #f59e0b;
}

.web-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: #c7d2fe;
    background: #1a1a2e;
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 3px 8px;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.web-toggle input {
    accent-color: #818cf8;
    cursor: pointer;
    margin: 0;
}

.web-toggle.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.web-toggle.disabled input {
    cursor: not-allowed;
}
