:root {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #dbeafe;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --success: #22c55e;
    --success-light: #dcfce7;
    --bg: linear-gradient(135deg, #f8fafc 0%, #eff6ff 50%, #eef2ff 100%);
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.1);
}

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

body {
    background: var(--bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    color: var(--text-main);
}

#container {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 720px;
    margin-top: 20px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    animation: slideUp 0.5s ease-out;
}

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

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

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

header {
    text-align: center;
    margin-bottom: 2rem;
}

#logo {
    width: 110px;
    height: auto;
    object-fit: contain;
}

#heading {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

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

.input-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

textarea {
    width: 100%;
    min-height: 180px;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 16px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: all 0.3s ease;
    background: rgba(248, 250, 252, 0.5);
    color: var(--text-main);
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

textarea::placeholder {
    color: #94a3b8;
}

.button-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 12px;
    margin-bottom: 1.5rem;
}

button {
    padding: 14px 20px;
    border-radius: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 1rem;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#checkBtn {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    box-shadow: 0 10px 20px -5px rgba(59, 130, 246, 0.4);
}

#checkBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px -5px rgba(59, 130, 246, 0.5);
}

#checkBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#checkBtn .spinner {
    animation: spin 1s linear infinite;
}

#resetBtn {
    background: transparent;
    color: var(--text-muted);
    border: 2px solid var(--border);
}

#resetBtn:hover {
    background: var(--border);
    color: var(--text-main);
}

.results-box {
    padding: 1.25rem;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    animation: slideUp 0.3s ease-out;
}

.results-box.success {
    background: var(--success-light);
    border: 1px solid #bbf7d0;
}

.results-box.danger {
    background: var(--danger-light);
    border: 1px solid #fecaca;
}

.results-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.results-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.results-content p {
    font-size: 0.875rem;
    opacity: 0.8;
}

.results-box.success .results-content h3,
.results-box.success .results-content p {
    color: #166534;
}

.results-box.danger .results-content h3,
.results-box.danger .results-content p {
    color: #991b1b;
}

.detected-words {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.word-badge {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

#highlightedText {
    padding: 1.25rem;
    background: white;
    border: 2px solid var(--border);
    border-radius: 16px;
    min-height: 120px;
    white-space: pre-wrap;
    line-height: 1.8;
    overflow-wrap: break-word;
    word-break: break-word;
    font-size: 0.95rem;
    color: var(--text-main);
}

.highlight {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #b91c1c;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    border-bottom: 2px solid #f87171;
    margin: 0 2px;
}

#fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 10px 30px -5px rgba(59, 130, 246, 0.5);
    transition: all 0.3s ease;
    z-index: 1000;
}

#fab:hover {
    transform: scale(1.1);
    box-shadow: 0 15px 40px -5px rgba(59, 130, 246, 0.6);
}

#symbolPanel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 320px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: none;
    flex-direction: column;
    z-index: 1000;
    border: 1px solid var(--border);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

#symbolPanel.show {
    display: flex;
}

.panel-header {
    padding: 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

.panel-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.close-btn:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

#symbolSearch {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.85rem;
    outline: none;
    transition: all 0.2s ease;
}

#symbolSearch:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.symbol-list {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.symbol-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.symbol-item:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

.panel-footer {
    padding: 12px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    text-align: center;
}

.panel-footer p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

#toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
    opacity: 0;
}

#toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

footer {
    margin-top: 2.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
}

.empty-state {
    grid-column: span 5;
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

@media (max-width: 640px) {
    body {
        padding: 12px;
    }

    #container {
        padding: 1.5rem;
        margin-top: 10px;
    }

    #heading {
        font-size: 1.5rem;
    }

    .button-row {
        grid-template-columns: 1fr;
    }

    #symbolPanel {
        width: 320px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    #fab {
        bottom: 16px;
        right: 16px;
    }
}
