:root {
    --bg-dark: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

.glow-bg {
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, rgba(15, 23, 42, 0) 70%);
    top: -200px;
    left: -200px;
    z-index: -1;
    filter: blur(40px);
}

.glow-bg.secondary {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, rgba(15, 23, 42, 0) 70%);
    bottom: -200px;
    right: -100px;
    top: auto;
    left: auto;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 8px;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

h1 span {
    color: var(--accent);
    font-weight: 400;
}

.api-key-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 99px;
    border: 1px solid var(--border-color);
}

.api-key-container input {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: monospace;
    outline: none;
    width: 250px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--success);
    box-shadow: 0 0 10px var(--success);
}

.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    flex-grow: 1;
    min-height: 0;
}

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.panel-header {
    min-height: 64px;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
}

.word-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

textarea {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 1.5rem;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.primary-btn {
    margin: 1.5rem;
    padding: 1rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.3);
}

.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

.hidden {
    display: none !important;
}

.tabs {
    display: flex;
    gap: 1.5rem;
    align-self: stretch;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0;
    position: relative;
    transition: color 0.2s;
    height: 100%;
    display: flex;
    align-items: center;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--text-primary);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 2px 2px 0 0;
}

.tab-content {
    display: none;
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.tab-content.active {
    display: block;
}

.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    gap: 1rem;
}

/* ========================
   PROGRESS PANEL (Copyleaks-style)
   ======================== */

.progress-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.progress-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar-container {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.1, 0.7, 0.1, 1);
}

.progress-percent {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: right;
}

.progress-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 1px solid transparent;
    animation: stepFadeIn 0.4s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

.progress-step.active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.progress-step.done {
    border-color: var(--success);
    opacity: 0.6;
}

@keyframes stepFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.step-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-icon.active {
    background: rgba(59, 130, 246, 0.2);
}

.step-icon.done {
    background: rgba(16, 185, 129, 0.2);
}

.step-icon .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.step-icon .check {
    color: var(--success);
    font-size: 14px;
}

.step-text {
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* Skeleton shimmer blocks */
.skeleton-results {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.skeleton-block {
    height: 20px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
    width: 100%;
}

.skeleton-block.short {
    width: 75%;
}

.skeleton-block.shorter {
    width: 55%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ========================
   SCORE + RESULTS
   ======================== */

.score-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.score-card {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.score-card h3 {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.score-value {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.score-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.score-bar .fill {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 1s cubic-bezier(0.1, 0.7, 0.1, 1);
}

.analysis-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 99px;
    font-size: 0.875rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
}

.badge.safe {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge.risk {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge.warn {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.truncate-link {
    color: var(--accent);
    text-decoration: none;
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.truncate-link:hover {
    text-decoration: underline;
}

.output-content {
    line-height: 1.8;
    color: #e2e8f0;
}

.output-content p {
    margin-bottom: 1rem;
}

.output-content h1,
.output-content h2 {
    margin: 1.5rem 0 1rem 0;
    color: white;
}

.output-content ul {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

/* ========================
   HISTORY
   ======================== */

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    background: rgba(0, 0, 0, 0.25);
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
    transform: translateY(-2px);
}

.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.history-score {
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
}

.history-score.low {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.history-score.mid {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.history-score.high {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.history-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 100;
}

.toast {
    background: #1e293b;
    border-left: 4px solid var(--accent);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    color: white;
    font-size: 0.9rem;
    animation: slideIn 0.3s forwards;
}

.toast.error {
    border-left-color: var(--danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

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

/* ========================
   REFERENCE LIST
   ======================== */

.refs-row {
    flex-direction: column !important;
    gap: 0.5rem !important;
}

.refs-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 180px;
    overflow-y: auto;
}

.ref-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.ref-link:hover {
    background: rgba(59, 130, 246, 0.15);
}

.ref-score {
    background: var(--accent);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.ref-url {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 350px;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ========================
   AUTH HEADER BUTTON
   ======================== */
.auth-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.secondary-btn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.secondary-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
}

.secondary-btn.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* ========================
   MODALS
   ======================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none !important;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 90%;
    max-width: 450px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--text-primary);
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-group input:focus {
    border-color: var(--accent);
}

.upgrade-actions {
    margin-top: 1.5rem;
}

.w-100 {
    width: 100%;
    margin: 0 !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}