/* Account Toggle Button */
.account-toggle {
    position: absolute;
    top: var(--space-6);
    right: calc(var(--space-6) + 56px);
    height: 40px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-full);
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    border: 1px solid var(--border);
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 10;
    transition: all var(--transition);
}

.account-toggle:has(.account-badge.pro) {
    padding-right: 10px; /* Align concentric rounding with inner pill */
}

.account-toggle:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.account-icon {
    width: 18px;
    height: 18px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.account-badge {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all var(--transition);
    white-space: nowrap;
    opacity: 0.5;
    cursor: pointer;
    user-select: none;
}

.account-badge.pro {
    color: var(--accent-primary);
    background-color: rgba(99, 102, 241, 0.15);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    opacity: 1;
    transform: translateX(-2px);
}

/* Account Modal Styles */
.account-modal-body {
    padding: var(--space-8) var(--space-8) var(--space-10) var(--space-8);
}

.account-info-section {
    margin-bottom: var(--space-6);
}

.account-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
}

.account-info-row:last-child {
    border-bottom: none;
}

.account-info-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.account-info-value {
    font-size: var(--text-sm);
    color: var(--text-primary);
    font-weight: 600;
}

.account-status-badge {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.account-status-badge.trial {
    background-color: rgba(156, 163, 175, 0.2);
    color: var(--text-secondary);
}

.account-status-badge.pro {
    background-color: var(--accent-primary);
    color: white;
}

.account-actions-section {
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--border);
}

.account-action-btn {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.account-action-btn:hover {
    background-color: var(--bg-primary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.account-action-btn.danger {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
}

.account-action-btn.danger:hover {
    background-color: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.account-action-btn.primary {
    background-color: var(--accent-primary);
    color: white;
    border-color: transparent;
}

.account-action-btn.primary:hover {
    filter: brightness(1.1);
    color: white;
}

/* License Modal Styles */
.license-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    overflow: auto;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.license-modal-content {
    position: relative;
    max-width: 500px;
    width: 90%;
    margin: 80px auto;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    animation: slideUp 0.3s ease;
}

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

.license-modal-header {
    padding: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.license-modal-header h2 {
    margin: 0;
    font-size: var(--text-2xl);
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.license-modal-close {
    position: absolute;
    top: var(--space-6);
    right: var(--space-6);
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.license-modal-close:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.license-modal-body {
    padding: var(--space-8);
}

.license-modal-body p {
    color: var(--text-secondary);
    margin-bottom: var(--space-6);
    line-height: 1.6;
}

.pro-features-list {
    list-style: none;
    padding: 0;
    margin: var(--space-6) 0;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: var(--space-4);
}

.pro-features-list li {
    padding: var(--space-2) var(--space-3);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.pro-features-list li::before {
    content: '✓';
    color: var(--accent-secondary);
    font-weight: bold;
    font-size: var(--text-lg);
}

.license-form {
    margin-top: var(--space-6);
}

.license-input-group {
    margin-bottom: var(--space-4);
}

.license-input-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.license-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--text-base);
    font-family: 'Courier New', monospace;
    transition: all var(--transition);
    user-select: text;
    cursor: text;
}

.license-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.license-input::placeholder {
    color: var(--text-tertiary);
    font-family: inherit;
}

.license-error {
    display: none;
    padding: var(--space-3) var(--space-4);
    background-color: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius);
    color: #ef4444;
    font-size: var(--text-sm);
    margin-top: var(--space-3);
}

.license-loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.license-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.license-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.license-btn {
    flex: 1;
    padding: var(--space-3) var(--space-5);
    border: none;
    border-radius: var(--radius);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.license-btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

.license-btn-primary:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.license-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.license-btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.license-btn-secondary:hover {
    background-color: var(--bg-primary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Success State */
.license-success {
    text-align: center;
    padding: var(--space-8) 0;
}

.success-icon {
    margin-bottom: var(--space-4);
    color: var(--accent-secondary);
    animation: scaleIn 0.4s ease;
}

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

.license-success h3 {
    font-size: var(--text-xl);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.license-success p {
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* Account Status Widget */
.account-widget {
    padding: var(--space-4);
    background-color: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
}

.account-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-3);
}

.account-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.account-status {
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.account-status.free {
    background-color: rgba(156, 163, 175, 0.2);
    color: var(--text-secondary);
}

.account-status.pro {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.account-email {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
    display: none;
}

.account-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.account-btn {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.account-btn:hover {
    background-color: var(--bg-primary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.account-btn.primary {
    background-color: var(--accent-primary);
    color: white;
    border-color: transparent;
}

.account-btn.primary:hover {
    filter: brightness(1.1);
    color: white;
}

/* Pro Feature Indicators */
.pro-locked {
    position: relative;
}

.pro-locked::after {
    content: '';
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 10px;
    background-color: var(--accent-primary);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='11' x='3' y='11' rx='2' ry='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
    background-size: 10px 10px;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    z-index: 10;
    border: 2px solid var(--bg-secondary);
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background-color: var(--text-primary);
    color: var(--bg-primary);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 90%;
    text-align: center;
}

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

/* Responsive adjustments */
@media (max-width: 1024px) {
    .account-toggle {
        position: fixed !important;
        top: 16px !important;
        right: calc(16px + 40px + 8px) !important;
        z-index: 200 !important;
    }
}

@media (max-width: 640px) {
    .license-modal-content {
        margin: 20px auto;
        width: 95%;
    }

    .license-modal-header,
    .license-modal-body {
        padding: var(--space-6);
    }

    .license-actions {
        flex-direction: column;
    }

    .license-btn {
        width: 100%;
    }

    .account-toggle {
        position: fixed !important;
        top: 14px !important;
        right: calc(12px + 36px + 8px) !important;
        z-index: 200 !important;
        height: 36px !important;
        padding: 0 12px !important;
    }

    .account-badge {
        font-size: 10px;
    }

    .account-icon {
        width: 16px;
        height: 16px;
    }
}

/* ESC key hint */
.modal-esc-hint {
    position: absolute;
    bottom: var(--space-4);
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    opacity: 0.6;
}

/* Premium activation uses the same centered shell as About / Help. */
#licenseModal { inset: 0; width: 100%; height: 100%; overflow: hidden; background: rgb(9 10 18 / 60%); backdrop-filter: blur(10px); }
#licenseModal .license-modal-content { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; width: min(560px, calc(100% - 32px)); max-width: 560px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden; border-radius: 22px; background: var(--bg-secondary); box-shadow: 0 24px 100px rgb(0 0 0 / 30%); animation: premiumModalIn 180ms ease; }
#licenseModal .license-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex: 0 0 auto; padding: 26px 28px 22px; border-bottom: 1px solid var(--border); }
#licenseModal .premium-heading { display: flex; align-items: center; gap: 14px; min-width: 0; }
#licenseModal .premium-emblem { display: grid; place-items: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: 13px; color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 12%, var(--bg-secondary)); border: 1px solid color-mix(in srgb, var(--accent-primary) 22%, var(--border)); }
#licenseModal .premium-emblem svg { width: 24px; height: 24px; }
#licenseModal .premium-eyebrow { display: block; margin-bottom: 6px; font-size: 10px; font-weight: 600; letter-spacing: .12em; color: var(--accent-primary); }
#licenseModal .license-modal-header h2 { color: var(--text-primary); background: none; font-size: 23px; font-weight: 600; letter-spacing: -.025em; line-height: 1.25; }
#licenseModal .license-modal-close { position: static; flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text-secondary); transition: background-color 160ms, border-color 160ms, color 160ms, transform 160ms; }
#licenseModal .license-modal-close svg { pointer-events: none; width: 20px; height: 20px; }
#licenseModal .license-modal-close:hover { background: color-mix(in srgb, var(--accent-primary) 14%, var(--bg-secondary)); border-color: color-mix(in srgb, var(--accent-primary) 55%, var(--border)); color: var(--accent-primary); transform: translateY(-1px); }
#licenseModal .license-modal-close:active { transform: scale(.94); }
#licenseModal .license-modal-body { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 22px 28px 28px; }
#licenseModal .license-modal-body p { font-size: 13px; line-height: 1.6; margin: 0 0 18px; }
#licenseModal .pro-features-list { display: grid; gap: 0; list-style: none; margin: 0 0 24px; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: transparent; overflow: hidden; }
#licenseModal .pro-features-list li { display: flex; align-items: center; gap: 12px; padding: 15px 16px; border-bottom: 1px solid var(--border); }
#licenseModal .pro-features-list li:last-child { border: 0; }
#licenseModal .pro-features-list li::before { content: none; }
#licenseModal .premium-feature-icon { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 8px; color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 8%, var(--bg-secondary)); }
#licenseModal .premium-feature-icon svg { width: 18px; height: 18px; }
#licenseModal .pro-features-list strong { display: block; color: var(--text-primary); font-size: 12px; font-weight: 600; line-height: 1.5; }
#licenseModal .pro-features-list li div > span { display: block; margin-top: 3px; color: var(--text-secondary); font-size: 11px; line-height: 1.6; }
#licenseModal .license-form { margin: 0; padding: 18px; background: var(--bg-tertiary); border: 1px solid var(--border); border-radius: 12px; }
#licenseModal .license-input-group { margin: 0; }
#licenseModal .license-input-group label { font-size: 12px; font-weight: 600; margin-bottom: 6px; }
#licenseModal .license-modal-body .premium-key-hint { font-size: 11px; color: var(--text-secondary); margin: 0 0 12px; }
#licenseModal .license-input { min-height: 44px; padding: 12px; font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-secondary); transition: border-color 160ms, box-shadow 160ms; }
#licenseModal .license-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-primary) 16%, transparent); }
#licenseModal .license-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
#licenseModal .license-btn { width: 100%; min-height: 42px; padding: 10px 8px; border-radius: 8px; font-size: 11px; font-weight: 500; gap: 7px; }
#licenseModal .license-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
#licenseModal .license-btn-secondary { background: var(--bg-secondary); }
#licenseModal :is(button, input):focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 3px; }
#licenseModal .license-error { font-size: 12px; padding: 10px 12px; }
#licenseModal .license-loading { font-size: 12px; }
@keyframes premiumModalIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.97); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@media (max-width: 600px) {
    #licenseModal .license-modal-content { width: calc(100% - 20px); max-height: calc(100dvh - 20px); border-radius: 16px; }
    #licenseModal .license-modal-header { padding: 20px 18px 18px; gap: 10px; }
    #licenseModal .premium-heading { gap: 10px; }
    #licenseModal .premium-emblem { width: 38px; height: 38px; }
    #licenseModal .license-modal-header h2 { font-size: 20px; }
    #licenseModal .license-modal-body { padding: 18px; }
    #licenseModal .pro-features-list li { padding: 13px 12px; }
    #licenseModal .license-form { padding: 14px; }
}
@media (max-width: 360px) { #licenseModal .license-actions { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) {
    #licenseModal, #licenseModal .license-modal-content { animation: none; }
    #licenseModal .license-modal-close { transition: none; }
    #licenseModal .license-modal-close:hover, #licenseModal .license-modal-close:active { transform: none; }
}
