:root {
    --bg: #0b0d12;
    --bg-muted: #10141c;
    --surface: #11161f;
    --surface-2: #151c27;
    --border: #273142;
    --text: #f5f7fa;
    --text-muted: #a8b3c2;
    --accent: #4b83ff;
    --accent-soft: #2d4f91;
    --positive: #22a06b;
    --negative: #d64545;
    --neutral: #8896a8;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
    --radius-lg: 16px;
    --radius-md: 12px;
}

[data-theme="light"] {
    --bg: #f5f7fb;
    --bg-muted: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #dde4ef;
    --text: #111827;
    --text-muted: #5f6d7e;
    --accent: #2f6df3;
    --accent-soft: #dce7ff;
    --positive: #16784e;
    --negative: #b62f2f;
    --neutral: #6b7280;
    --shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

py-script,
py-config,
script[type="py"],
.py-terminal,
.pyscript-error,
#pyscript_loading_splash {
    display: none !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

body {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 56px 20px 32px;
    background: linear-gradient(180deg, var(--bg-muted) 0%, var(--bg) 65%);
    color: var(--text);
    font-family: "Outfit", "Segoe UI", sans-serif;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.text-input {
    user-select: text;
}

.background-radial {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(700px circle at 10% 0%, rgba(75, 131, 255, 0.08), transparent 55%),
        radial-gradient(600px circle at 90% 100%, rgba(75, 131, 255, 0.06), transparent 55%);
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2.5rem;
}

.theme-switch-wrapper {
    position: fixed;
    top: 22px;
    right: 22px;
    z-index: 1000;
}

.theme-switch {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.theme-switch:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

header {
    width: 100%;
    text-align: center;
}

.logo-text {
    font-family: "Outfit", "Segoe UI", sans-serif;
    font-size: clamp(2rem, 5vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: 0.8rem;
}

.subtitle {
    max-width: 680px;
    margin: 0 auto 1.4rem;
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.65;
}

.authors-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    font-weight: 600;
    text-transform: uppercase;
}

.analysis-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-card,
.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.input-card {
    padding: 1.1rem;
}

.text-input {
    width: 100%;
    min-height: 180px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    color: var(--text);
    padding: 1rem;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.55;
    resize: vertical;
    margin-bottom: 0.9rem;
    transition: border-color 0.2s ease;
}

.text-input::placeholder {
    color: var(--text-muted);
}

.text-input:focus {
    outline: none;
    border-color: var(--accent);
}

.pro-button {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.pro-button:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.pro-button:active {
    transform: translateY(0);
}

.result-card {
    padding: 1.2rem;
    text-align: center;
}

.result-header .label {
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sentiment-badge {
    margin: 0.7rem 0;
    font-size: clamp(2rem, 6vw, 2.8rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.result-footer {
    color: var(--text-muted);
    font-size: 0.92rem;
}

.positive-text {
    color: var(--positive);
}

.negative-text {
    color: var(--negative);
}

.neutral-text {
    color: var(--neutral);
}

.spinner {
    text-align: center;
    padding: 0.8rem;
    color: var(--text-muted);
}

.spinner div {
    position: relative;
    width: 42px;
    height: 42px;
    margin: 0 auto 0.7rem;
}

.double-bounce1,
.double-bounce2 {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--accent);
    opacity: 0.25;
    animation: pulseRing 1.4s ease-out infinite;
}

.double-bounce2 {
    animation-delay: -0.7s;
}

#loader-wrapper {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    background: var(--bg);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

#loader-wrapper.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    width: min(340px, 84vw);
    text-align: center;
}

.loader-logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 1.2rem;
}

.progress-container {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-2);
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}

.progress-bar {
    height: 100%;
    width: 0;
    background: var(--accent);
    transition: width 0.1s linear;
}

.loader-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

footer {
    width: 100%;
    text-align: center;
    padding-bottom: 0.5rem;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
}

.authorship,
.copyright {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.authorship a {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: border-color 0.2s ease;
}

.authorship a:hover {
    border-bottom-color: var(--accent);
}

.footer-links {
    display: flex;
    align-items: center;
}

.repo-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.48rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.86rem;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.repo-link:hover {
    border-color: var(--accent);
    color: var(--text);
}

.github-icon {
    opacity: 0.85;
}

@keyframes pulseRing {
    from {
        transform: scale(0.65);
        opacity: 0.45;
    }

    to {
        transform: scale(1);
        opacity: 0;
    }
}

.fade-in,
.pop-in {
    animation: none;
}

.hidden {
    display: none !important;
}

@media (max-width: 640px) {
    body {
        padding: 44px 14px 24px;
    }

    .theme-switch-wrapper {
        top: 14px;
        right: 14px;
    }

    .container {
        gap: 2rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .input-card,
    .result-card {
        border-radius: 14px;
    }

    .text-input {
        min-height: 160px;
    }
}