:root {
    --text-light: #1f2937;
    --text-dark: #f8fafc;
    --box-light: rgba(255, 255, 255, 0.20);
    --box-dark: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.28);
    --border-dark: rgba(255, 255, 255, 0.14);
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    width: 100%;
}

body {
    height: auto;
    overflow-x: hidden;
    min-height: 100vh;
    margin: 0;
    flex: 1;
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    color: var(--text-light);
    background:
        linear-gradient(135deg, #fff1eb, #ace0f9, #fad0c4, #ffd1ff, #f6d365, #fda085, #c2e9fb);
    transition: background 0.3s ease, color 0.3s ease;
    position: relative;
}

html.dark-mode body {
    color: var(--text-dark);
    background:
        linear-gradient(135deg, #0f172a, #111827, #1e1b4b, #312e81, #1f2937, #0f1a2b, #111111);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    mix-blend-mode: soft-light;
    opacity: 0.9;
}

html.dark-mode body::before {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
}

.theme-toggle {
    position: absolute;
    top: 5px;
    right: 16px;
    width: 54px;
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    appearance: none;
    padding: 0;
}

html.dark-mode .theme-toggle {
    background: rgba(10, 15, 25, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.14);
}

label, input {
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.theme-icon {
    display: block;
    width: 30px;
    height: 30px;
    background: url("/static/images/sun.png") center / contain no-repeat;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.45)) brightness(1.15) contrast(1.15);
    transition: background-image 0.2s ease, transform 0.2s ease, filter 0.2s ease;
}

html.dark-mode .theme-icon {
    background-image: url("/static/images/moon.png");
}

.theme-toggle:active .theme-icon {
    transform: scale(0.94);
}

.box {
    display: flex;
    flex-direction: column;
    max-width: 270px;
    max-height: 60px;
    margin: 17px;
    padding: 1px;
    text-align: center;
    gap: 8px;
    border-radius: 18px;
    justify-content: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
    border: 1px solid var(--border-light);
    background: var(--box-light);
    color: var(--text-light);
}

html.dark-mode .box {
    background: var(--box-dark);
    border: 1px solid var(--border-dark);
    color: var(--text-dark);
}

.menu-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
}

.bot-card {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 14px;
    align-items: start;
    padding: 16px;
    border-radius: 18px;
    text-decoration: none;
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.16);
    transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

html.dark-mode .bot-card {
    background: rgba(10, 15, 25, 0.28);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-dark);
}

.bot-card:hover {
    transform: translateY(-2px);
}

.bot-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.bot-content {
    min-width: 0;
    text-align: left;
}

.bot-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: inherit;
}

.bot-description {
    margin: 6px 0 0;
    font-size: 0.92rem;
    line-height: 1.4;
    opacity: 0.82;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

.bot-arrow {
    margin-top: 20px;
    font-size: 1.3rem;
    opacity: 0.75;
}

html.dark-mode .content {
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    color: #f8fafc;
}

html.dark-mode .panel {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #f8fafc;
}

.wiki-main {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.wiki-search-box {
    padding: 20px;
    border-radius: 18px;
    background: var(--box-light);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
    margin-bottom: 20px;
    transition: background 0.3s ease, border 0.3s ease;
}

html.dark-mode .wiki-search-box {
    background: var(--box-dark);
    border: 1px solid var(--border-dark);
}

.wiki-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.wiki-input-icon {
    position: absolute;
    left: 14px;
    font-size: 18px;
    opacity: 0.6;
}

.wiki-input {
    width: 100%;
    padding: 14px 40px 14px 42px;
    border-radius: 14px;
    border: 1px solid var(--border-light);
    background: rgba(255, 255, 255, 0.3);
    color: var(--text-light);
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

html.dark-mode .wiki-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-dark);
    color: var(--text-dark);
}

.wiki-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: rgba(255, 255, 255, 0.5);
}

html.dark-mode .wiki-input:focus {
    background: rgba(0, 0, 0, 0.4);
}

.wiki-clear-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    color: var(--text-light);
}

html.dark-mode .wiki-clear-btn {
    color: var(--text-dark);
}

.wiki-char-counter {
    text-align: right;
    font-size: 12px;
    color: var(--text-light);
    opacity: 0.6;
    margin-top: 6px;
    margin-bottom: 16px;
}

html.dark-mode .wiki-char-counter {
    color: var(--text-dark);
}

.wiki-char-counter.warning { color: #f59e0b; opacity: 1; }
.wiki-char-counter.error { color: #ef4444; opacity: 1; }

.wiki-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wiki-btn {
    width: 100%;
    padding: 14px;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    border: none;
}

.wiki-btn-secondary {
    background: rgba(255, 255, 255, 0.15);
    border: 1px dashed rgba(255, 255, 255, 0.4);
    color: var(--text-light);
}

html.dark-mode .wiki-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    color: var(--text-dark);
}

.wiki-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.wiki-btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.3);
}

.wiki-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.wiki-btn-primary:active {
    transform: scale(0.98);
}

.wiki-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 30px;
    color: var(--text-light);
    opacity: 0.8;
}

html.dark-mode .wiki-loader {
    color: var(--text-dark);
}

.wiki-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.wiki-error {
    padding: 16px;
    border-radius: 14px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

.wiki-result-card {
    border-radius: 18px;
    background: var(--box-light);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

html.dark-mode .wiki-result-card {
    background: var(--box-dark);
    border: 1px solid var(--border-dark);
}

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

.wiki-image-wrap {
    position: relative;
    height: 220px;
    overflow: hidden;
}

.wiki-image {
    width: 100%;
    height: 120%;
    object-fit: cover;
    transition: transform 0.1s linear;
}

.wiki-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60%;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
}

.wiki-title {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    color: white;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.2;
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.wiki-title-mobile {
    display: none;
    padding: 20px 20px 0;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-light);
}

html.dark-mode .wiki-title-mobile {
    color: var(--text-dark);
}

.wiki-content-wrap {
    padding: 20px;
}

.wiki-summary {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-light);
    margin-bottom: 20px;
}

html.dark-mode .wiki-summary {
    color: var(--text-dark);
}

.wiki-related {
    margin-bottom: 20px;
}

.wiki-related-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    opacity: 0.7;
    margin-bottom: 10px;
}

html.dark-mode .wiki-related-label {
    color: var(--text-dark);
}

.wiki-related-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wiki-related-tag {
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: #2563eb;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

html.dark-mode .wiki-related-tag {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.wiki-related-tag:hover {
    background: #2563eb;
    color: white;
    transform: translateY(-1px);
}

.wiki-read-more {
    display: block;
    text-align: center;
    padding: 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-light);
    color: var(--text-light);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
}

html.dark-mode .wiki-read-more {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-dark);
    color: var(--text-dark);
}

.wiki-read-more:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
    color: #2563eb;
}

@media (max-width: 480px) {
    .wiki-image-wrap { height: 180px; }
    .wiki-title { font-size: 18px; }
}